@promptctl/cc-candybar 1.155.2 → 1.156.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +54 -49
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i,pathToFileURL as a}from"node:url";import{json as o}from"node:stream/consumers";import s,{basename as c,dirname as l,isAbsolute as u,join as d,sep as f}from"node:path";import p,{closeSync as m,constants as h,existsSync as g,fstatSync as _,openSync as v,readSync as y,realpathSync as b,statSync as ee,watch as x}from"node:fs";import S,{createHash as te,randomUUID as ne}from"node:crypto";import C,{homedir as re}from"node:os";import{spawn as ie,spawnSync as ae}from"node:child_process";import{inspect as w,parseArgs as T,types as oe}from"node:util";import E from"node:net";import se from"node:v8";import{open as ce,readFile as le,readdir as ue,stat as de}from"node:fs/promises";import{clearInterval as fe,setImmediate as pe,setInterval as me}from"node:timers";import{get as he}from"node:https";import{setTimeout as ge}from"node:timers/promises";import{WriteStream as _e}from"node:tty";import{createInterface as ve}from"node:readline";var ye=Object.create,be=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyNames,Ce=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty,Te=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Se(t),a=0,o=i.length,s;a<o;a++)s=i[a],!we.call(e,s)&&s!==n&&be(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=xe(t,s))||r.enumerable});return e},De=(e,t,n)=>(n=e==null?{}:ye(Ce(e)),Ee(t||!e||!e.__esModule?be(n,`default`,{value:e,enumerable:!0}):n,e));function D(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}const Oe=(e,t)=>D(t),ke=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Ae(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function je(e){return ke.test(e)?e:Ae(e)}function Me(e){return`${e.dir===void 0?``:`cd ${je(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${je(t)} `).join(``)}${[e.program,...e.args].map(je).join(` `)}`}const Ne=`cc-extra`;function Pe(e){return s.join(s.dirname(e),Ne,`src`,`bun-attach.js`)}function Fe(e){return s.join(s.dirname(e),`bun-graph.js`)}const Ie=`attach-preload.cjs`;function Le(e){return s.join(s.dirname(e),Ie)}function Re(e,t){return Me({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const ze=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Be(e,t){return t.isSymbolicLink()?Buffer.from(p.readlinkSync(e)):p.readFileSync(e)}function Ve(e,t,n=ze){return p.readdirSync(t).filter(n).sort().flatMap(n=>{let r=s.join(t,n),i=p.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Ve(e,r):[[s.relative(e,r).split(s.sep).join(`/`),Be(r,i)]]})}function He(e){let t=S.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Ue(e){return He(Ve(e,e))}const We=[`Cargo.toml`,`Cargo.lock`,`src`];function Ge(e){return He(Ve(e,e,e=>We.includes(e)))}const Ke=e=>e.slice(0,7),qe=`1.155.2`;function Je(e){let t=s.dirname(s.dirname(e));return p.existsSync(s.join(t,`src`))?t:null}function Ye(){let e=Xe();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:qe,digest:e}}function Xe(){return`10532d8ba03382a96c64bc6cc44cb3c8752f8e03051207351fe9557b26b4fda7`}function Ze(e){let t=JSON.parse(p.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 Qe(e,t){try{let n=Je(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Ue(s.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:Ze(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function $e(e,t){return oe.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!g(t)?`working directory does not exist: ${t}`:e.message:String(e)}const et={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3},tt=new Map;function nt(e){let t=et[e];if(t===void 0)return{allowed:!0};let n=tt.get(e);if(n===void 0)return{allowed:!0};let r=Date.now()-n;return r>=t?{allowed:!0}:{allowed:!1,minIntervalMs:t,sinceLastMs:r}}function rt(e){tt.set(e,Date.now())}function it(e){return e.env??process.env}function at(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 ${n}ms ago`}}let ot=null;function st(e){ot=e}function ct(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function lt(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=nt(e.category);if(!t.allowed)return at(e.category,t.minIntervalMs,t.sinceLastMs);rt(e.category);let n=Date.now();return ot?.onStart(e.category),new Promise(t=>{let r;try{r=ie(e.bin,e.args??[],{cwd:e.cwd,env:it(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){ot?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:$e(r,e.cwd)});return}let i=``,a=``,o=!1,s=null,c=null,l=null,u=()=>m(`aborted`),d=t=>{o||(o=!0,s&&clearTimeout(s),c&&clearTimeout(c),e.signal?.removeEventListener(`abort`,u),ot?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{ct(e,t)}catch(e){f({ok:!1,reason:`signal-refused`,stdout:i,stderr:a,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)})}},m=t=>{l=t,s&&clearTimeout(s),e.signal?.removeEventListener(`abort`,u);let n=r.pid;n!==void 0&&(c=setTimeout(()=>p(n,`SIGKILL`),250),p(n,`SIGTERM`))};r.stdout?.on(`data`,e=>{i+=e.toString(`utf8`)}),r.stderr?.on(`data`,e=>{a+=e.toString(`utf8`)}),r.on(`error`,t=>{f({ok:!1,reason:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:null,error:$e(t,e.cwd)})}),r.on(`close`,(e,t)=>{if(l!==null){f({ok:!1,reason:l,stdout:i,stderr:a,exitCode:e,signal:t});return}if(e===0){f({ok:!0,stdout:i,stderr:a,exitCode:e});return}f({ok:!1,reason:t?`signal`:`non-zero`,stdout:i,stderr:a,exitCode:e,signal:t})}),e.timeoutMs&&e.timeoutMs>0&&(s=setTimeout(()=>m(`timeout`),e.timeoutMs)),e.signal?.addEventListener(`abort`,u,{once:!0}),e.stdinInput!==void 0&&r.stdin?r.stdin.end(e.stdinInput):r.stdin&&r.stdin.end()})}function ut(e){let t=nt(e.category);if(!t.allowed)return at(e.category,t.minIntervalMs,t.sinceLastMs);rt(e.category);let n=Date.now();ot?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=ae(e.bin,e.args??[],{cwd:e.cwd,env:it(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});ot?.onEnd(e.category,Date.now()-n);let i=typeof t.stdout==`string`?t.stdout:``,a=typeof t.stderr==`string`?t.stderr:``;if(t.error)return{ok:!1,reason:t.error.code===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:t.signal??null,error:$e(t.error,e.cwd)};if(t.status===0)return{ok:!0,stdout:i,stderr:a,exitCode:t.status};let o=e.timeoutMs!==void 0&&e.timeoutMs>0;return{ok:!1,reason:t.signal?o&&t.signal===`SIGTERM`?`timeout`:`signal`:`non-zero`,stdout:i,stderr:a,exitCode:t.status,signal:t.signal??null}}catch(t){return ot?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:$e(t,e.cwd)}}}function dt(e){let t=nt(e.category);if(!t.allowed)return at(e.category,t.minIntervalMs,t.sinceLastMs);rt(e.category);let n=Date.now();ot?.onStart(e.category);let r=ft(e);return ot?.onEnd(e.category,Date.now()-n),r}function ft(e){let t;try{t=ie(e.bin,e.args??[],{cwd:e.cwd,env:it(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:$e(t,e.cwd)}}return t.once(`error`,()=>{}),t.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${e.bin}): no pid (binary not found or unexecutable)`}:(t.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}function O(e,t,n){let r=pt(e);p.mkdirSync(s.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??p.statSync(r,{throwIfNoEntry:!1})?.mode;try{p.writeFileSync(i,t,a===void 0?{}:{mode:a}),p.renameSync(i,r)}catch(e){throw p.rmSync(i,{force:!0}),e}}function pt(e){let t=e;for(let e=0;e<mt;e++){let e;try{e=p.lstatSync(t)}catch(e){if(e.code===`ENOENT`)return t;throw e}if(!e.isSymbolicLink())return t;t=s.resolve(p.realpathSync(s.dirname(t)),p.readlinkSync(t))}throw Error(`${e}: more than ${mt} symbolic links`)}const mt=40;function ht(e,t){let n=e[t];return n&&n.length>0?n:void 0}function gt(e=process.env){let t=ht(e,`XDG_STATE_HOME`)??s.join(C.homedir(),`.local`,`state`);return s.join(t,`cc-candybar`)}function k(){let e=ht(process.env,`XDG_CACHE_HOME`)??s.join(C.homedir(),`.cache`);return s.join(e,`cc-candybar`)}function _t(){return gt()}function vt(){return process.env.CC_CANDYBAR_SOCKET||yt()}function yt(){let e=C.userInfo().uid;return s.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function bt(e){p.mkdirSync(e,{recursive:!0,mode:448});let t=p.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=C.userInfo().uid;if(typeof n==`number`&&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 xt(e){bt(s.dirname(e));for(let t of[e,St(e)])try{if(p.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function St(e){return`${e}.lease`}function Ct(){return St(vt())}function wt(){return s.join(gt(),`session-state.json`)}function Tt(){return s.join(gt(),`settings-history.json`)}function Et(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=C.userInfo().uid;return s.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function Dt(){return s.join(gt(),`spawn.lock`)}function Ot(){return s.join(gt(),`spawn.cooldown`)}function kt(){return s.join(gt(),`spawn.backoff`)}function At(){return s.join(gt(),`diagnostics`)}function jt(e=process.env){return s.join(gt(e),`daemon.log`)}const Mt=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function Nt(e,t){return Object.fromEntries(Mt.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,s.resolve(t,r)]]}))}const Pt=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function Ft(e){return Object.fromEntries(Pt.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const It=[`native`,`node`,`frames`];function Lt(e,t){return{kind:e,bundle:t,source:null}}const Rt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,mementoEnv:!0,terminalEnv:!0,client:!0});function zt(e){let t=Jt(e.termCols),n=Jt(e.termRows),r=Yt(e.ssh),i=Kt(e.tmux),a=Gt(e.configEnv),o=Gt(e.claudeConfigDir),s=Wt(e.mementoEnv),c=A(e.terminalEnv),l=tn(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&&{mementoEnv:s},...c!==void 0&&{terminalEnv:c},...l!==void 0&&{client:l}}}function Bt(e,t){return Rt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function Vt(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 Ht={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Ut(e){let t=Object.keys(Ht).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[Ht[t](n.join(`, `))]});return t.length===0?null:t.join(`
2
+ import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i,pathToFileURL as a}from"node:url";import{json as o}from"node:stream/consumers";import s,{basename as c,dirname as l,isAbsolute as u,join as d,sep as f}from"node:path";import p,{closeSync as m,constants as h,existsSync as g,fstatSync as _,openSync as v,readSync as y,realpathSync as b,statSync as ee,watch as x}from"node:fs";import S,{createHash as te,randomUUID as ne}from"node:crypto";import C,{homedir as re}from"node:os";import{spawn as ie,spawnSync as ae}from"node:child_process";import{inspect as w,parseArgs as T,types as oe}from"node:util";import E from"node:net";import se from"node:v8";import{open as ce,readFile as le,readdir as ue,stat as de}from"node:fs/promises";import{clearInterval as fe,setImmediate as pe,setInterval as me}from"node:timers";import{get as he}from"node:https";import{setTimeout as ge}from"node:timers/promises";import{WriteStream as _e}from"node:tty";import{createInterface as ve}from"node:readline";var ye=Object.create,be=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyNames,Ce=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty,Te=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Se(t),a=0,o=i.length,s;a<o;a++)s=i[a],!we.call(e,s)&&s!==n&&be(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=xe(t,s))||r.enumerable});return e},De=(e,t,n)=>(n=e==null?{}:ye(Ce(e)),Ee(t||!e||!e.__esModule?be(n,`default`,{value:e,enumerable:!0}):n,e));function D(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}const Oe=(e,t)=>D(t),ke=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Ae(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function je(e){return ke.test(e)?e:Ae(e)}function Me(e){return`${e.dir===void 0?``:`cd ${je(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${je(t)} `).join(``)}${[e.program,...e.args].map(je).join(` `)}`}const Ne=`cc-extra`;function Pe(e){return s.join(s.dirname(e),Ne,`src`,`bun-attach.js`)}function Fe(e){return s.join(s.dirname(e),`bun-graph.js`)}const Ie=`attach-preload.cjs`;function Le(e){return s.join(s.dirname(e),Ie)}function Re(e,t){return Me({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const ze=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Be(e,t){return t.isSymbolicLink()?Buffer.from(p.readlinkSync(e)):p.readFileSync(e)}function Ve(e,t,n=ze){return p.readdirSync(t).filter(n).sort().flatMap(n=>{let r=s.join(t,n),i=p.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Ve(e,r):[[s.relative(e,r).split(s.sep).join(`/`),Be(r,i)]]})}function He(e){let t=S.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Ue(e){return He(Ve(e,e))}const We=[`Cargo.toml`,`Cargo.lock`,`src`];function Ge(e){return He(Ve(e,e,e=>We.includes(e)))}const Ke=e=>e.slice(0,7),qe=`1.156.1`;function Je(e){let t=s.dirname(s.dirname(e));return p.existsSync(s.join(t,`src`))?t:null}function Ye(){let e=Xe();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:qe,digest:e}}function Xe(){return`4bdc3df37f8c755cdaf7bd87d774300df81f89e6861db8f723f956f1593c458c`}function Ze(e){let t=JSON.parse(p.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 Qe(e,t){try{let n=Je(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Ue(s.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:Ze(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function $e(e,t){return oe.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!g(t)?`working directory does not exist: ${t}`:e.message:String(e)}const et={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3},tt=new Map;function nt(e){let t=et[e];if(t===void 0)return{allowed:!0};let n=tt.get(e);if(n===void 0)return{allowed:!0};let r=Date.now()-n;return r>=t?{allowed:!0}:{allowed:!1,minIntervalMs:t,sinceLastMs:r}}function rt(e){tt.set(e,Date.now())}function it(e){return e.env??process.env}function at(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 ${n}ms ago`}}let ot=null;function st(e){ot=e}function ct(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function lt(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=nt(e.category);if(!t.allowed)return at(e.category,t.minIntervalMs,t.sinceLastMs);rt(e.category);let n=Date.now();return ot?.onStart(e.category),new Promise(t=>{let r;try{r=ie(e.bin,e.args??[],{cwd:e.cwd,env:it(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){ot?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:$e(r,e.cwd)});return}let i=``,a=``,o=!1,s=null,c=null,l=null,u=()=>m(`aborted`),d=t=>{o||(o=!0,s&&clearTimeout(s),c&&clearTimeout(c),e.signal?.removeEventListener(`abort`,u),ot?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{ct(e,t)}catch(e){f({ok:!1,reason:`signal-refused`,stdout:i,stderr:a,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)})}},m=t=>{l=t,s&&clearTimeout(s),e.signal?.removeEventListener(`abort`,u);let n=r.pid;n!==void 0&&(c=setTimeout(()=>p(n,`SIGKILL`),250),p(n,`SIGTERM`))};r.stdout?.on(`data`,e=>{i+=e.toString(`utf8`)}),r.stderr?.on(`data`,e=>{a+=e.toString(`utf8`)}),r.on(`error`,t=>{f({ok:!1,reason:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:null,error:$e(t,e.cwd)})}),r.on(`close`,(e,t)=>{if(l!==null){f({ok:!1,reason:l,stdout:i,stderr:a,exitCode:e,signal:t});return}if(e===0){f({ok:!0,stdout:i,stderr:a,exitCode:e});return}f({ok:!1,reason:t?`signal`:`non-zero`,stdout:i,stderr:a,exitCode:e,signal:t})}),e.timeoutMs&&e.timeoutMs>0&&(s=setTimeout(()=>m(`timeout`),e.timeoutMs)),e.signal?.addEventListener(`abort`,u,{once:!0}),e.stdinInput!==void 0&&r.stdin?r.stdin.end(e.stdinInput):r.stdin&&r.stdin.end()})}function ut(e){let t=nt(e.category);if(!t.allowed)return at(e.category,t.minIntervalMs,t.sinceLastMs);rt(e.category);let n=Date.now();ot?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=ae(e.bin,e.args??[],{cwd:e.cwd,env:it(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});ot?.onEnd(e.category,Date.now()-n);let i=typeof t.stdout==`string`?t.stdout:``,a=typeof t.stderr==`string`?t.stderr:``;if(t.error)return{ok:!1,reason:t.error.code===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:t.signal??null,error:$e(t.error,e.cwd)};if(t.status===0)return{ok:!0,stdout:i,stderr:a,exitCode:t.status};let o=e.timeoutMs!==void 0&&e.timeoutMs>0;return{ok:!1,reason:t.signal?o&&t.signal===`SIGTERM`?`timeout`:`signal`:`non-zero`,stdout:i,stderr:a,exitCode:t.status,signal:t.signal??null}}catch(t){return ot?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:$e(t,e.cwd)}}}function dt(e){let t=nt(e.category);if(!t.allowed)return at(e.category,t.minIntervalMs,t.sinceLastMs);rt(e.category);let n=Date.now();ot?.onStart(e.category);let r=ft(e);return ot?.onEnd(e.category,Date.now()-n),r}function ft(e){let t;try{t=ie(e.bin,e.args??[],{cwd:e.cwd,env:it(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:$e(t,e.cwd)}}return t.once(`error`,()=>{}),t.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${e.bin}): no pid (binary not found or unexecutable)`}:(t.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}function O(e,t,n){let r=pt(e);p.mkdirSync(s.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??p.statSync(r,{throwIfNoEntry:!1})?.mode;try{p.writeFileSync(i,t,a===void 0?{}:{mode:a}),p.renameSync(i,r)}catch(e){throw p.rmSync(i,{force:!0}),e}}function pt(e){let t=e;for(let e=0;e<mt;e++){let e;try{e=p.lstatSync(t)}catch(e){if(e.code===`ENOENT`)return t;throw e}if(!e.isSymbolicLink())return t;t=s.resolve(p.realpathSync(s.dirname(t)),p.readlinkSync(t))}throw Error(`${e}: more than ${mt} symbolic links`)}const mt=40;function ht(e,t){let n=e[t];return n&&n.length>0?n:void 0}function gt(e=process.env){let t=ht(e,`XDG_STATE_HOME`)??s.join(C.homedir(),`.local`,`state`);return s.join(t,`cc-candybar`)}function k(){let e=ht(process.env,`XDG_CACHE_HOME`)??s.join(C.homedir(),`.cache`);return s.join(e,`cc-candybar`)}function _t(){return gt()}function vt(){return process.env.CC_CANDYBAR_SOCKET||yt()}function yt(){let e=C.userInfo().uid;return s.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function bt(e){p.mkdirSync(e,{recursive:!0,mode:448});let t=p.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=C.userInfo().uid;if(typeof n==`number`&&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 xt(e){bt(s.dirname(e));for(let t of[e,St(e)])try{if(p.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function St(e){return`${e}.lease`}function Ct(){return St(vt())}function wt(){return s.join(gt(),`session-state.json`)}function Tt(){return s.join(gt(),`settings-history.json`)}function Et(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=C.userInfo().uid;return s.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function Dt(){return s.join(gt(),`spawn.lock`)}function Ot(){return s.join(gt(),`spawn.cooldown`)}function kt(){return s.join(gt(),`spawn.backoff`)}function At(){return s.join(gt(),`diagnostics`)}function jt(e=process.env){return s.join(gt(e),`daemon.log`)}const Mt=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function Nt(e,t){return Object.fromEntries(Mt.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,s.resolve(t,r)]]}))}const Pt=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function Ft(e){return Object.fromEntries(Pt.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const It=[`native`,`node`,`frames`];function Lt(e,t){return{kind:e,bundle:t,source:null}}const Rt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,mementoEnv:!0,terminalEnv:!0,client:!0});function zt(e){let t=Jt(e.termCols),n=Jt(e.termRows),r=Yt(e.ssh),i=Kt(e.tmux),a=Gt(e.configEnv),o=Gt(e.claudeConfigDir),s=Wt(e.mementoEnv),c=A(e.terminalEnv),l=tn(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&&{mementoEnv:s},...c!==void 0&&{terminalEnv:c},...l!==void 0&&{client:l}}}function Bt(e,t){return Rt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function Vt(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 Ht={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Ut(e){let t=Object.keys(Ht).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[Ht[t](n.join(`, `))]});return t.length===0?null:t.join(`
3
3
  `)}function Wt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=Mt.filter(e=>t[e]!==void 0);return n.every(e=>Gt(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function A(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=Pt.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 Gt(e){return typeof e==`string`&&s.isAbsolute(e)?e:void 0}function Kt(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 qt=1e4;function Jt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>qt?qt:t}function Yt(e){return typeof e==`boolean`?e:void 0}function Xt(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var j=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Zt(e){return Qt(JSON.stringify(e))}function Qt(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function $t(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 j(`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 j(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function en(e,t,n){return new Promise((r,i)=>{let a=!1,o=t=>{if(!a){a=!0,clearTimeout(s),e.removeAllListeners();try{t()}catch{}}},s=setTimeout(()=>{o(()=>{e.destroy(),i(Error(`TIMEOUT`))})},n),c=$t(e=>o(()=>r(e)),e=>o(()=>i(e)));e.on(`data`,c),e.on(`error`,e=>o(()=>i(e))),e.on(`close`,()=>o(()=>i(Error(`socket closed before response`)))),e.write(Zt(t))})}function tn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=Gt(n);return It.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function nn(e,t,n){let r=null;try{r=await cn(vt(),t.connectMs);let i=await en(r,{v:3,...e},t.budgetMs);return on(e.kind,i,n)}catch(e){return sn(e)}finally{r&&r.destroy()}}function rn(e,t){return typeof e==`string`?e:t}function an(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function on(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=rn(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:an(r.daemonV)};case`TIMEOUT`:return{kind:`transient`,cause:`timeout`,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 sn(e){if(e instanceof j||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 t===`CONNECT_TIMEOUT`||t===`TIMEOUT`?{kind:`transient`,cause:`timeout`,message:t}:t.includes(`ECONNREFUSED`)||t.includes(`ENOENT`)||t.includes(`ENOTSOCK`)?{kind:`transient`,cause:`unreachable`,message:t}:{kind:`transient`,cause:`io_error`,message:t}}function cn(e,t){return new Promise((n,r)=>{let i=E.createConnection({path:e}),a=setTimeout(()=>{i.destroy(),r(Error(`CONNECT_TIMEOUT`))},t);i.once(`connect`,()=>{clearTimeout(a),n(i)}),i.once(`error`,e=>{clearTimeout(a),r(e)})})}function ln(e){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}`}}const un={connectMs:50,budgetMs:150},dn={connectMs:50,budgetMs:200};function fn(e){let t=e.output;return typeof t==`string`?t:void 0}function pn(e){return on(`render`,e,fn)}function mn(e,t,n,r){return nn({kind:`render`,hookData:e,args:t,cwd:n,...r},un,fn)}function hn(e,t){return nn({kind:`pane-session`,socket:e,pane:t},dn,e=>`paneSession`in e?e.paneSession:void 0)}function gn(e,t){return nn({kind:`click`,verb:e,value:t,clientVersion:qe},dn,fn)}let _n=null;function vn(e){if(_n!==null)return _n;p.mkdirSync(s.dirname(e),{recursive:!0});try{_n=p.statSync(e).size}catch{_n=0}return _n}function yn(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,r=`${e}.${t+1}`;try{p.renameSync(n,r)}catch{}}try{p.renameSync(e,`${e}.1`)}catch{}_n=0}function M(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=jt(),t=vn(e);p.appendFileSync(e,n),_n=t+Buffer.byteLength(n,`utf8`),_n>=5242880&&yn(e)}catch(e){_n=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}const bn=5e3;function xn(e){let t=[];for(let n of e){let e=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(`
4
4
  `)}const Sn=`/usr/bin/footprint`;function Cn(e,t){return e===`darwin`?[En(Sn,[`-p`,String(t)]),En(`/usr/bin/vmmap`,[`--summary`,String(t)])]:e===`linux`?[Dn(`/proc/self/smaps_rollup`),Dn(`/proc/self/status`)]:[]}function wn(e,t){return e===`darwin`?Tn(t,e=>lt({bin:Sn,args:e,timeoutMs:bn,category:`limits.charge`})):async e=>({kind:`charged`,measure:`rss`,bytes:e})}function Tn(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 ${r.reason}${r.error===void 0?``:`: ${r.error}`}${On(r.stderr)}`};let i=N(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 N(e){let t=/^\s*phys_footprint:\s+(\d+) B\s*$/m.exec(e);return t===null?null:Number(t[1])}function En(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=ut({bin:e,args:[...t],timeoutMs:bn,category:`limits.memory-report`});return n.ok?n.stdout.trim().length>0?{kind:`text`,text:n.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:`${n.reason}${n.error===void 0?``:`: ${n.error}`}${On(n.stderr)}`}}}}function Dn(e){return{name:e,read:()=>{try{let t=p.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}}}}}function On(e){let t=e.split(`
5
5
  `).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const kn=`CC_CANDYBAR_RSS_LIMIT_MB`;function An(e){let t=e[kn];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${kn} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function jn(e){return An(e)*2}const Mn=1024*1024,Nn=e=>Math.round(e/Mn);function Pn(e){return An(e)*Mn}const Fn={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function In(e,t){return e>t}function Ln(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}}function Rn(e,t){return e>t*.75}function zn(e,t,n){let{prefix:r,suffix:i}=Fn[t];return s.join(e,`${r}${n}${i}`)}function Bn(e){for(let t of Object.keys(Fn)){let{prefix:n,suffix:r}=Fn[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function Vn(e){let t=e.limitBytes??512*Mn,n=e.snapshotsKeep??3,r=!1,i={kind:`unmeasured`},a=null;function o(){return a??=s().finally(()=>{a=null}),a}async function s(){if(r)return!0;let{rss:a,heapTotal:o}=e.memoryBytes(),s=Ln(await e.memoryCharge(a),i),c={kind:`measured`,charge:s,rss:a,heapTotal:o};if(i=c,e.log(`info`,`memory ${Wn(c,t)}`),s.bytes<=t)return!1;r=!0,e.log(`warn`,`${Hn(s)} > limit ${Nn(t)} MB (rss ${Nn(a)} MB, v8 heap ${Nn(o)} MB); recording memory then shutting down`);let l=`${new Date(e.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return Gn(e.log,`memory report`,()=>{let t=zn(e.snapshotDir,`memoryReport`,l);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),Gn(e.log,`heap snapshot`,()=>{let t=zn(e.snapshotDir,`heapSnapshot`,l);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),Gn(e.log,`artifact rotation`,()=>{for(let{artifacts:t}of Kn(e.listArtifacts()).slice(n))for(let n of Object.values(t))Gn(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0}function c(){return i.kind===`measured`&&Rn(i.charge.bytes,t)?`${Hn(i.charge)} approaching limit ${Nn(t)} MB (v8 heap ${Nn(i.heapTotal)} MB)`:null}function l(){let n;try{n={kind:`ok`,value:Kn(e.listArtifacts())}}catch(e){n={kind:`failed`,reason:e.message}}return{pid:e.pid,memory:i,limit:t,postMortems:n}}function u(t=6e4){let n,r=!0,i=async()=>{try{if(await o())return}catch(t){e.log(`warn`,`memory check failed: ${t.message}`)}r&&(n=setTimeout(()=>void i(),t),n.unref())};return i(),{disarm:()=>{r=!1,clearTimeout(n)}}}return{check:o,describeNextRestart:c,serving:l,arm:u}}function Hn(e){return e.kind===`charged`?`${e.measure} ${Nn(e.bytes)} MB`:`rss ${Nn(e.bytes+e.gap)} MB${e.gap===0?``:` less its last ${Nn(e.gap)} MB gap`} (standing in: ${e.unread})`}function Un(e){return e.kind===`charged`?e.measure:`rss-stand-in`}function Wn({charge:e,rss:t,heapTotal:n},r){let i=e.kind===`stand-in`?` unread=${JSON.stringify(e.unread)} gap=${Nn(e.gap)}MB`:``;return`measure=${Un(e)} charge=${Nn(e.bytes)}MB rss=${Nn(t)}MB heap=${Nn(n)}MB limit=${Nn(r)}MB${i}`}function Gn(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function Kn(e){let t=new Map;for(let n of e){let e=s.basename(n),r=Bn(e);if(r===null)continue;let{prefix:i,suffix:a}=Fn[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(Fn);return[...t].sort(([e],[t])=>In(e,t)?-1:1).map(([e,t])=>({identity:e,artifacts:Object.fromEntries(n.flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}))}function qn(e,t,n={}){let r=_t();return{now:()=>Date.now(),pid:process.pid,snapshotDir:r,log:M,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},memoryCharge:wn(process.platform,process.pid),captureMemoryReport:()=>xn(Cn(process.platform,process.pid)),writeMemoryReport:(e,t)=>p.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>se.writeHeapSnapshot(e),listArtifacts:()=>{let e;try{e=p.readdirSync(r)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>Bn(e)!==null).map(e=>s.join(r,e))},removeFile:e=>p.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function Jn(e={}){if(ur()!==null)return;let n=e.spawn??dr,r=sr();if(r.kind===`contended`){let e=Xn();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),Yn(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),Yn(n);return}try{Yn(n)}finally{lr()}}function Yn(e){rr()&&Zn(e)}function Xn(){try{let e=p.statSync(Dt());return Date.now()-e.mtimeMs}catch{return null}}function Zn(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
@@ -38,25 +38,25 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
38
38
  `),process.exit(1)}function mo(e){switch(e.cause){case`version_mismatch`:return`url-handle: daemon rejected click (version mismatch: client v${e.clientV} ≠ daemon v${e.daemonV})`;case`bad_request`:return`url-handle: daemon rejected click (bad request: ${e.message})`;case`render_failed`:return`url-handle: daemon rejected click (handler failed: ${e.message})`;case`switched_off`:return`url-handle: daemon rejected click (switched off: ${e.message})`;case`malformed_response`:return`url-handle: daemon rejected click (malformed response: ${e.message})`}}function ho(){return`✓ install complete.
39
39
  Restart Claude Code to pick up the new statusline.
40
40
  Tip: every bar carries a settings menu — click it (${Jr} by\n default) for quick actions, preset switching, edit mode, and clickable\n theme/style/variation/shade/endcaps/wrap/padding controls.\n`}async function go(e,t){let n=e.includes(`--force`),r=e.filter(e=>e!==`--force`),i=r.length>0?r:[...Ka],a=so(t);process.platform===`darwin`?lo(a.distPath):process.stdout.write(`Skipping URL handler (cmd-click verbs are macOS-only).
41
- `),_o(a.binPath,i,n),process.stdout.write(ho());let o=Ha(za,Va(qe,await Ba(za,fetch,`https://registry.npmjs.org`)));process[o.stream].write(o.text)}function _o(e,t,n,r){let i=r??Sa(xa(ba(process.env,process.cwd())));p.mkdirSync(s.dirname(i),{recursive:!0});let a=Da(i).statusLine,o=Na(a)?a.command:void 0,c=[e,je(e),Ae(e)],l=typeof o==`string`&&(o.startsWith(`pnpm dlx @promptctl/cc-candybar@`)||c.some(e=>o===e||o.startsWith(`${e} `)));if(o&&!l&&!n){process.stderr.write(`Skipping settings.json update: existing statusLine.command appears customized.\n Current: ${o}\n To overwrite, re-run with --force.\n`);return}let u=qa(e,t);O(i,(Na(a)?[[[`statusLine`,`type`],`command`],[[`statusLine`,`command`],u]]:[[[`statusLine`],{type:`command`,command:u}]]).reduce((e,[t,n])=>Vi(e,t,JSON.stringify(n,null,2),Ei),Ea(i))),process.stdout.write(`Updated ${i}\n`)}function vo(e,t){return e.kind===`owned`?t(e.pid,e.startTime)?{kind:`attach-and-exit`,reason:`live owner pid=${e.pid} holds the socket`}:{kind:`reclaim`,reason:`owner pid=${e.pid} is gone or recycled`}:e.kind===`absent`?{kind:`reclaim`,reason:`no lease — stale socket, no live owner`}:{kind:`reclaim`,reason:`unreadable lease (${e.detail}) — cannot prove a live owner`}}function yo(e){let t;try{t=p.readFileSync(e,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:`read failed: ${e.message}`}}let n;try{n=JSON.parse(t)}catch(e){return{kind:`unreadable`,detail:`bad JSON: ${e.message}`}}let r=n,i=r?.pid;if(typeof i!=`number`||!Number.isInteger(i)||i<=0)return{kind:`unreadable`,detail:`no valid pid (got ${JSON.stringify(i)})`};let a=r?.startTime;return a!=null&&typeof a!=`string`?{kind:`unreadable`,detail:`invalid startTime (got ${JSON.stringify(a)})`}:{kind:`owned`,pid:i,startTime:a??null}}function bo(e,n){let r=`${e}.${t.pid}.tmp`;try{return p.writeFileSync(r,JSON.stringify(n),{mode:384}),p.renameSync(r,e),null}catch(e){let t=e.message;try{p.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`)return`${t}; also failed to remove temp ${r}: ${e.message}`}return t}}function xo(e,t){let n=yo(e);if(n.kind===`owned`&&n.pid===t)try{p.unlinkSync(e)}catch{}}function So(e){try{let t=p.statSync(e);return{kind:`present`,identity:{dev:t.dev,ino:t.ino}}}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:e.message}}}function Co(e,t,n,r){let i=wo(e,t);return i===null?r.kind===`owned`?r.pid===n?{kind:`owned`}:{kind:`displaced`,reason:`lease reassigned (names pid=${r.pid}, we are pid=${n}) — a reclaimer overwrote it`}:{kind:`displaced`,reason:`lease not held (${r.kind}) — no longer the socket owner`}:{kind:`displaced`,reason:i}}function wo(e,t){return t.kind===`present`?t.identity.dev===e.dev&&t.identity.ino===e.ino?null:`socket replaced (bound dev=${e.dev} ino=${e.ino}, now dev=${t.identity.dev} ino=${t.identity.ino})`:t.kind===`absent`?`socket path gone (ENOENT) — unlinked by a reclaimer`:`socket path unreadable (${t.detail}) — cannot prove ownership`}function To(e){let t=!1;function n(){let n=Co(e.bound,e.readIdentity(),e.myPid,e.readLease());return n.kind===`displaced`&&!t&&(t=!0,e.log(`warn`,`ownership self-check: ${n.reason}; shutting down`),e.shutdown(0)),n}function r(t=e.intervalMs??5e3){let r=setInterval(()=>{n().kind===`displaced`&&clearInterval(r)},t);return r.unref(),{disarm:()=>clearInterval(r)}}return{check:n,arm:r}}function Eo(e,t=ut){let n=t({bin:`ps`,args:[`-o`,`lstart=`,`-p`,String(e)],category:`process-fingerprint`,timeoutMs:2e3,env:{...process.env,LC_ALL:`C`,TZ:`UTC`}});if(n.ok){let e=n.stdout.trim();return e.length>0?{kind:`start`,token:e}:{kind:`unavailable`,detail:`ps produced no start-time`}}return{kind:`unavailable`,detail:n.reason===`spawn-error`?n.error??`ps spawn failed`:`ps ${n.reason} (exit ${n.exitCode})`}}function Do(e,t,n){if(t===null)return n.pidAlive(e);let r=n.readStartTime(e);switch(r.kind){case`start`:return r.token===t;case`unavailable`:return n.pidAlive(e)}}function Oo(e,t=Eo){let n=t(e);return n.kind===`start`?n.token:null}const ko=`CC_CANDYBAR_PARENT_PID`;function Ao(e){let t=e[ko];if(t===void 0)return{kind:`outlives-nobody`};let n=Number.parseInt(t,10);if(!Number.isInteger(n)||n<=0)throw Error(`${ko} must be a positive integer pid, got ${JSON.stringify(t)}`);return{kind:`anchored`,pid:n}}function jo(e){if(e.anchor.kind===`outlives-nobody`)return{disarm:()=>{}};let{pid:t}=e.anchor,n=setInterval(()=>{e.isAlive(t)||e.onOrphaned(`spawner pid ${t} gone`)},e.intervalMs??250);return n.unref(),{disarm:()=>clearInterval(n)}}function Mo(e){try{return t.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function No(){let e=Number(process.env.CC_CANDYBAR_DAEMON_CEILING??``);return Number.isInteger(e)&&e>0?e:16}function Po(e,t,n){return e?t>=n?{allow:!1,reason:`${t} live isolated daemons registered >= ceiling ${n}`}:{allow:!0,reason:`${t} live isolated daemons registered < ceiling ${n}`}:{allow:!0,reason:`canonical production socket — exempt (bind() already caps it to one)`}}function Fo(e){try{return p.readdirSync(e).filter(e=>e.endsWith(`.json`)).map(t=>s.join(e,t))}catch{return[]}}function Io(e){let t;try{t=p.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(t),n=e?.pid;return typeof n!=`number`||!Number.isInteger(n)||n<=0?null:{pid:n,startTime:typeof e?.startTime==`string`?e.startTime:null}}catch{return null}}function Lo(e,t,n){let r=0;for(let i of e)t(i.identity.pid,i.identity.startTime)?r++:n(i.path);return r}function Ro(e){if(!e.isolated)return{decision:Po(!1,0,e.ceiling),registryPath:null};e.ensureDirSafe(e.registryDir);let t=[];for(let n of e.listFiles(e.registryDir)){let r=e.readEntry(n);r!==null&&r.pid!==e.pid&&t.push({path:n,identity:r})}let n=Po(!0,Lo(t,e.isSameLiveProcess,e.removeFile),e.ceiling);if(!n.allow)return{decision:n,registryPath:null};let r=s.join(e.registryDir,`pid-${e.pid}.json`);return e.writeEntry(r,{pid:e.pid,startTime:e.startTime}),{decision:n,registryPath:r}}function zo(e,t,n,r){let i=n(e);if(i!==null&&i.pid===t)try{r(e)}catch{}}function Bo(e,t={}){return{isolated:!!process.env.CC_CANDYBAR_SOCKET,registryDir:Et(),ceiling:No(),pid:process.pid,startTime:e,isSameLiveProcess:(e,t)=>Do(e,t,{readStartTime:Eo,pidAlive:Mo}),listFiles:Fo,readEntry:Io,removeFile:e=>{try{p.unlinkSync(e)}catch{}},writeEntry:(e,t)=>{let n=`${e}.${t.pid}.tmp`;try{p.writeFileSync(n,JSON.stringify(t),{mode:384}),p.renameSync(n,e)}catch(e){try{p.unlinkSync(n)}catch(e){e.code}throw e}},ensureDirSafe:process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR?bt:e=>{bt(s.dirname(e)),bt(e)},...t}}const Vo=[[0,0,0],[768,879,0],[1155,1161,0],[1425,1469,0],[1471,1471,0],[1473,1474,0],[1476,1477,0],[1479,1479,0],[1552,1562,0],[1564,1564,0],[1611,1631,0],[1648,1648,0],[1750,1756,0],[1759,1764,0],[1767,1768,0],[1770,1773,0],[1809,1809,0],[1840,1866,0],[1958,1968,0],[2027,2035,0],[2045,2045,0],[2070,2073,0],[2075,2083,0],[2085,2087,0],[2089,2093,0],[2137,2139,0],[2199,2207,0],[2250,2273,0],[2275,2307,0],[2362,2364,0],[2366,2383,0],[2385,2391,0],[2402,2403,0],[2433,2435,0],[2492,2492,0],[2494,2500,0],[2503,2504,0],[2507,2509,0],[2519,2519,0],[2530,2531,0],[2558,2558,0],[2561,2563,0],[2620,2620,0],[2622,2626,0],[2631,2632,0],[2635,2637,0],[2641,2641,0],[2672,2673,0],[2677,2677,0],[2689,2691,0],[2748,2748,0],[2750,2757,0],[2759,2761,0],[2763,2765,0],[2786,2787,0],[2810,2815,0],[2817,2819,0],[2876,2876,0],[2878,2884,0],[2887,2888,0],[2891,2893,0],[2901,2903,0],[2914,2915,0],[2946,2946,0],[3006,3010,0],[3014,3016,0],[3018,3021,0],[3031,3031,0],[3072,3076,0],[3132,3132,0],[3134,3140,0],[3142,3144,0],[3146,3149,0],[3157,3158,0],[3170,3171,0],[3201,3203,0],[3260,3260,0],[3262,3268,0],[3270,3272,0],[3274,3277,0],[3285,3286,0],[3298,3299,0],[3315,3315,0],[3328,3331,0],[3387,3388,0],[3390,3396,0],[3398,3400,0],[3402,3405,0],[3415,3415,0],[3426,3427,0],[3457,3459,0],[3530,3530,0],[3535,3540,0],[3542,3542,0],[3544,3551,0],[3570,3571,0],[3633,3633,0],[3636,3642,0],[3655,3662,0],[3761,3761,0],[3764,3772,0],[3784,3790,0],[3864,3865,0],[3893,3893,0],[3895,3895,0],[3897,3897,0],[3902,3903,0],[3953,3972,0],[3974,3975,0],[3981,3991,0],[3993,4028,0],[4038,4038,0],[4139,4158,0],[4182,4185,0],[4190,4192,0],[4194,4196,0],[4199,4205,0],[4209,4212,0],[4226,4237,0],[4239,4239,0],[4250,4253,0],[4352,4447,2],[4448,4607,0],[4957,4959,0],[5906,5909,0],[5938,5940,0],[5970,5971,0],[6002,6003,0],[6068,6099,0],[6109,6109,0],[6155,6159,0],[6277,6278,0],[6313,6313,0],[6432,6443,0],[6448,6459,0],[6679,6683,0],[6741,6750,0],[6752,6780,0],[6783,6783,0],[6832,6877,0],[6880,6891,0],[6912,6916,0],[6964,6980,0],[7019,7027,0],[7040,7042,0],[7073,7085,0],[7142,7155,0],[7204,7223,0],[7376,7378,0],[7380,7400,0],[7405,7405,0],[7412,7412,0],[7415,7417,0],[7616,7679,0],[8203,8207,0],[8232,8238,0],[8288,8303,0],[8400,8432,0],[8986,8987,2],[9001,9002,2],[9193,9196,2],[9200,9200,2],[9203,9203,2],[9725,9726,2],[9748,9749,2],[9776,9783,2],[9800,9811,2],[9855,9855,2],[9866,9871,2],[9875,9875,2],[9889,9889,2],[9898,9899,2],[9917,9918,2],[9924,9925,2],[9934,9934,2],[9940,9940,2],[9962,9962,2],[9970,9971,2],[9973,9973,2],[9978,9978,2],[9981,9981,2],[9989,9989,2],[9994,9995,2],[10024,10024,2],[10060,10060,2],[10062,10062,2],[10067,10069,2],[10071,10071,2],[10133,10135,2],[10160,10160,2],[10175,10175,2],[11035,11036,2],[11088,11088,2],[11093,11093,2],[11503,11505,0],[11647,11647,0],[11744,11775,0],[11904,11929,2],[11931,12019,2],[12032,12245,2],[12272,12329,2],[12330,12335,0],[12336,12350,2],[12353,12438,2],[12441,12442,0],[12443,12543,2],[12549,12591,2],[12593,12643,2],[12644,12644,0],[12645,12686,2],[12688,12773,2],[12783,12830,2],[12832,12871,2],[12880,42124,2],[42128,42182,2],[42607,42610,0],[42612,42621,0],[42654,42655,0],[42736,42737,0],[43010,43010,0],[43014,43014,0],[43019,43019,0],[43043,43047,0],[43052,43052,0],[43136,43137,0],[43188,43205,0],[43232,43249,0],[43263,43263,0],[43302,43309,0],[43335,43347,0],[43360,43388,2],[43392,43395,0],[43443,43456,0],[43493,43493,0],[43561,43574,0],[43587,43587,0],[43596,43597,0],[43643,43645,0],[43696,43696,0],[43698,43700,0],[43703,43704,0],[43710,43711,0],[43713,43713,0],[43755,43759,0],[43765,43766,0],[44003,44010,0],[44012,44013,0],[44032,55203,2],[55216,55295,0],[63744,64255,2],[64286,64286,0],[65024,65039,0],[65040,65049,2],[65056,65071,0],[65072,65106,2],[65108,65126,2],[65128,65131,2],[65279,65279,0],[65281,65376,2],[65440,65440,0],[65504,65510,2],[65520,65531,0],[66045,66045,0],[66272,66272,0],[66422,66426,0],[68097,68099,0],[68101,68102,0],[68108,68111,0],[68152,68154,0],[68159,68159,0],[68325,68326,0],[68900,68903,0],[68969,68973,0],[69291,69292,0],[69370,69375,0],[69446,69456,0],[69506,69509,0],[69632,69634,0],[69688,69702,0],[69744,69744,0],[69747,69748,0],[69759,69762,0],[69808,69818,0],[69826,69826,0],[69888,69890,0],[69927,69940,0],[69957,69958,0],[70003,70003,0],[70016,70018,0],[70067,70080,0],[70089,70092,0],[70094,70095,0],[70188,70199,0],[70206,70206,0],[70209,70209,0],[70367,70378,0],[70400,70403,0],[70459,70460,0],[70462,70468,0],[70471,70472,0],[70475,70477,0],[70487,70487,0],[70498,70499,0],[70502,70508,0],[70512,70516,0],[70584,70592,0],[70594,70594,0],[70597,70597,0],[70599,70602,0],[70604,70608,0],[70610,70610,0],[70625,70626,0],[70709,70726,0],[70750,70750,0],[70832,70851,0],[71087,71093,0],[71096,71104,0],[71132,71133,0],[71216,71232,0],[71339,71351,0],[71453,71467,0],[71724,71738,0],[71984,71989,0],[71991,71992,0],[71995,71998,0],[72e3,72e3,0],[72002,72003,0],[72145,72151,0],[72154,72160,0],[72164,72164,0],[72193,72202,0],[72243,72249,0],[72251,72254,0],[72263,72263,0],[72273,72283,0],[72330,72345,0],[72544,72551,0],[72751,72758,0],[72760,72767,0],[72850,72871,0],[72873,72886,0],[73009,73014,0],[73018,73018,0],[73020,73021,0],[73023,73029,0],[73031,73031,0],[73098,73102,0],[73104,73105,0],[73107,73111,0],[73459,73462,0],[73472,73473,0],[73475,73475,0],[73524,73530,0],[73534,73538,0],[73562,73562,0],[78896,78912,0],[78919,78933,0],[90398,90415,0],[92912,92916,0],[92976,92982,0],[94031,94031,0],[94033,94087,0],[94095,94098,0],[94176,94179,2],[94180,94180,0],[94192,94193,0],[94194,94198,2],[94208,101589,2],[101631,101662,2],[101760,101874,2],[110576,110579,2],[110581,110587,2],[110589,110590,2],[110592,110882,2],[110898,110898,2],[110928,110930,2],[110933,110933,2],[110948,110951,2],[110960,111355,2],[113821,113822,0],[113824,113827,0],[118528,118573,0],[118576,118598,0],[119141,119145,0],[119149,119170,0],[119173,119179,0],[119210,119213,0],[119362,119364,0],[119552,119638,2],[119648,119670,2],[121344,121398,0],[121403,121452,0],[121461,121461,0],[121476,121476,0],[121499,121503,0],[121505,121519,0],[122880,122886,0],[122888,122904,0],[122907,122913,0],[122915,122916,0],[122918,122922,0],[123023,123023,0],[123184,123190,0],[123566,123566,0],[123628,123631,0],[124140,124143,0],[124398,124399,0],[124643,124643,0],[124646,124646,0],[124654,124655,0],[124661,124661,0],[125136,125142,0],[125252,125258,0],[126980,126980,2],[127183,127183,2],[127374,127374,2],[127377,127386,2],[127488,127490,2],[127504,127547,2],[127552,127560,2],[127568,127569,2],[127584,127589,2],[127744,127776,2],[127789,127797,2],[127799,127868,2],[127870,127891,2],[127904,127946,2],[127951,127955,2],[127968,127984,2],[127988,127988,2],[127992,127994,2],[127995,127999,0],[128e3,128062,2],[128064,128064,2],[128066,128252,2],[128255,128317,2],[128331,128334,2],[128336,128359,2],[128378,128378,2],[128405,128406,2],[128420,128420,2],[128507,128591,2],[128640,128709,2],[128716,128716,2],[128720,128722,2],[128725,128728,2],[128732,128735,2],[128747,128748,2],[128756,128764,2],[128992,129003,2],[129008,129008,2],[129292,129338,2],[129340,129349,2],[129351,129535,2],[129648,129660,2],[129664,129674,2],[129678,129734,2],[129736,129736,2],[129741,129756,2],[129759,129770,2],[129775,129784,2],[131072,196605,2],[196608,262141,2],[917504,921599,0]],Ho=new Set([35,42,48,49,50,51,52,53,54,55,56,57,169,174,8252,8265,8482,8505,8596,8597,8598,8599,8600,8601,8617,8618,9e3,9167,9197,9198,9199,9201,9202,9208,9209,9210,9410,9642,9643,9654,9664,9723,9724,9728,9729,9730,9731,9732,9742,9745,9752,9757,9760,9762,9763,9766,9770,9774,9775,9784,9785,9786,9792,9794,9823,9824,9827,9829,9830,9832,9851,9854,9874,9876,9877,9878,9879,9881,9883,9884,9888,9895,9904,9905,9928,9935,9937,9939,9961,9968,9969,9972,9975,9976,9977,9986,9992,9993,9996,9997,9999,10002,10004,10006,10013,10017,10035,10036,10052,10055,10083,10084,10145,10548,10549,11013,11014,11015,127344,127345,127358,127359,127777,127780,127781,127782,127783,127784,127785,127786,127787,127788,127798,127869,127894,127895,127897,127898,127899,127902,127903,127947,127948,127949,127950,127956,127957,127958,127959,127960,127961,127962,127963,127964,127965,127966,127967,127987,127989,127991,128063,128065,128253,128329,128330,128367,128368,128371,128372,128373,128374,128375,128376,128377,128391,128394,128395,128396,128397,128400,128421,128424,128433,128434,128444,128450,128451,128452,128465,128466,128467,128476,128477,128478,128481,128483,128488,128495,128499,128506,128715,128717,128718,128719,128736,128737,128738,128739,128740,128741,128745,128752,128755]);function Uo(e){if(e<32||e>=127&&e<160)return 0;let t=0,n=Vo.length-1;for(;t<=n;){let r=t+n>>1,[i,a,o]=Vo[r];if(e<i)n=r-1;else if(e>a)t=r+1;else return o}return 1}function Wo(e){return Ho.has(e)}var Go=class{entries=new Map;get size(){return this.entries.size}get(e,t){let n=this.entries.get(e);if(n!==void 0)return n;let r=t(e);return this.entries.size>=4096&&this.entries.clear(),this.entries.set(e,r),r}};const Ko=new Go,qo=/[\u200d\ufe0f]/,Jo=/^[ -~]*$/;function Yo(e){let t=0,n=!1,r=!1;for(let i of e){let e=i.codePointAt(0);if(r)r=!1;else if(e===8205)r=!0;else if(e===65039)t+=+!!n,n=!1;else{let r=Uo(e);t+=r,n=r>0?Wo(e):n}}return t}function Xo(e){if(Jo.test(e))return e.length;if(!qo.test(e))return Yo(e);let t=0;for(let{segment:n}of as().segment(e))t+=Yo(n);return t}function R(e){return e.length===0?0:e.length<=64?Ko.get(e,Xo):Xo(e)}function Zo(e){return e}function Qo(e){return e}function $o(e){return e>0?Math.floor(e):0}function es(e,t){if(t<=0)return[``,e];if(t>=R(e))return[e,``];let n=ls(e,t);return[n+` `.repeat(t-R(n)),e.slice(n.length)]}function ts(e,t){let n=[],r=0,i=0,a=0,o=0,s=0;for(let c of cs(e,Qo(0))){if(s===t.length)break;let l=o+R(c),u=o;for(;s<t.length&&t[s]<l;s++){let l=t[s];n.push(` `.repeat(i)+e.slice(r,a)+` `.repeat(l-u)),i=0,r=l===o?a:a+c.length,u=l}u>o&&(i=l-u),a+=c.length,o=l}return n.push(` `.repeat(i)+e.slice(r)),n}function ns(e,t){if(t<=0||e.length===0)return[e];let n=[],r=Qo(0);for(;r<e.length;){let i=ps(e,r,t);n.push(e.slice(r,i)),r=i}return n}let rs,is;function as(){return rs??=new Intl.Segmenter(void 0,{granularity:`grapheme`})}function os(e){return is?.text!==e&&(is={text:e,segments:as().segment(e)}),is.segments}function ss(e){return Array.from(cs(e,Qo(0)))}function*cs(e,t){let n=os(e);for(let r=t,i=n.containing(r);i;i=n.containing(r)){let t=i.index+i.segment.length;yield e.slice(r,t),r=Qo(t)}}function ls(e,t){return e.slice(0,ds(cs(e,Qo(0)),t))}function us(e,t){return e.slice(e.length-ds(ss(e).reverse(),t))}function ds(e,t){let n=0,r=0;for(let i of e){let e=R(i);if(n+e>t)break;n+=e,r+=i.length}return r}function fs(e,t,n){return Qo(t+ds(cs(e,t),n))}function ps(e,t,n){let[r=``]=cs(e,t);return Qo(Math.max(fs(e,t,n),t+r.length))}function ms(e){if(!Number.isInteger(e)||e<1)throw RangeError(`tabSize must be a positive integer, got ${e}`);return e}function hs(e,t){let[n,...r]=e.split(` `),i=[],a=[],o=(e,t)=>{let n=e.lastIndexOf(`
42
- `);return(n<0?t:0)+R(e.slice(n+1))},s=n,c=n,l=0,u=n.length,d=0;for(let e of r){l=o(c,l);let n=t-l%t;d+=n-1,i.push(u),a.push(d),s+=` `.repeat(n)+e,l+=n,c=e,u+=1+e.length}return{text:s,offsetOf:e=>{let t=0,n=i.length;for(;t<n;){let r=t+n>>1;i[r]<e?t=r+1:n=r}return e+(t===0?0:a[t-1])}}}var gs=class{name;dark;vars;constructor(e,t,n){this.name=e,this.dark=t;let r=n.get(`background`),i=r===void 0?vs(e):_s(e,r);this.vars=new Map([...n].map(([e,t])=>[e,i(t,e)]))}get(e){return this.vars.get(e)}};function _s(e,t){if(t.alpha!==1)throw RangeError(`palette ${JSON.stringify(e)}: background is the surface its translucent colours are drawn on, so it must be opaque; got ${t.hex}`);return e=>e.alpha===0?e:e.compositeOver(t)}function vs(e){return(t,n)=>{if(t.alpha!==1&&t.alpha!==0)throw RangeError(`palette ${JSON.stringify(e)}: ${n} is translucent (${t.hex}) but the palette has no "background" to draw it on`);return t}}function ys(e){return e.toString(16).padStart(2,`0`)}function bs(e){return Number.isInteger(e)&&e>=0&&e<=255}function xs(e,t){if(!bs(t))throw RangeError(`ColorRgba.${e} must be an integer in [0, 255]; got ${t}`)}var z=class e{red;green;blue;alpha;constructor(e,t,n,r=1){if(this.red=e,this.green=t,this.blue=n,this.alpha=r,xs(`red`,e),xs(`green`,t),xs(`blue`,n),!Number.isFinite(r)||r<0||r>1)throw RangeError(`ColorRgba.alpha must be a finite number in [0, 1]; got ${r}`)}get hex(){let e=`#`+ys(this.red)+ys(this.green)+ys(this.blue);return this.alpha===1?e:e+ys(Math.round(this.alpha*255))}get rgb(){return this.alpha===1?`rgb(${this.red},${this.green},${this.blue})`:`rgba(${this.red},${this.green},${this.blue},${this.alpha})`}get normalized(){return[this.red/255,this.green/255,this.blue/255,this.alpha]}compositeOver(t){if(this.alpha===1)return this;let n=this.alpha;return new e(Math.round(t.red+(this.red-t.red)*n),Math.round(t.green+(this.green-t.green)*n),Math.round(t.blue+(this.blue-t.blue)*n),1)}};const Ss=new z(0,0,0);function Cs(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.red)+.7152*t(e.green)+.0722*t(e.blue)}function ws(e,t){return Ts(Cs(e),Cs(t))}function Ts(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Es(e,t){let n=e.red-t.red,r=e.green-t.green,i=e.blue-t.blue;return n*n+r*r+i*i}var Ds=class{colors;firstIndex;matchMemo=new Go;readableMemo=new Go;constructor(e,t=0){this.colors=e,this.firstIndex=t}get(e){return this.colors[e-this.firstIndex]}luminanceCache;luminances(){return this.luminanceCache??=this.colors.map(Cs),this.luminanceCache}get size(){return this.colors.length}match(e){let t=`${e.red},${e.green},${e.blue},${e.alpha}`;return this.matchMemo.get(t,()=>this.nearest(e))}nearest(e){let t=0,n=1/0;for(let r=0;r<this.colors.length;r++){let i=this.colors[r],a=Es(i,e);a<n&&(n=a,t=r)}return this.firstIndex+t}matchReadable(e,t,n){let r=`${e.red},${e.green},${e.blue}|${t.red},${t.green},${t.blue}|${n}`;return this.readableMemo.get(r,()=>this.nearestReadable(e,t,n))}nearestReadable(e,t,n){let r=Cs(t),i=0,a=!1,o=-1/0;for(let t=0;t<this.colors.length;t++){let s=this.colors[t],c=this.luminances()[t],l=Ts(c,r),u=l>=n,d=u?-Es(s,e):l;(u&&!a||u===a&&d>o)&&(i=t,a=u,o=d)}return this.firstIndex+i}matchWhere(e,t){let n=this.colors.map(t=>Es(t,e)),r=[...n.keys()].sort((e,t)=>n[e]-n[t]).find(e=>t(this.colors[e],this.firstIndex+e));return r===void 0?void 0:this.firstIndex+r}},B;(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.STANDARD=1]=`STANDARD`,e[e.EIGHT_BIT=2]=`EIGHT_BIT`,e[e.TRUECOLOR=3]=`TRUECOLOR`,e[e.WINDOWS=4]=`WINDOWS`})(B||={});function Os(e){switch(e){case B.DEFAULT:return 0;case B.STANDARD:case B.WINDOWS:return 1;case B.EIGHT_BIT:return 2;case B.TRUECOLOR:return 3}}const ks={truecolor:B.TRUECOLOR,256:B.EIGHT_BIT,ansi:B.STANDARD,none:null},As=new Map([[`0`,null],[`false`,null],[`1`,B.STANDARD],[`true`,B.STANDARD],[`2`,B.EIGHT_BIT],[`3`,B.TRUECOLOR],[`iTerm.app`,B.TRUECOLOR],[`Apple_Terminal`,B.EIGHT_BIT],[`vscode`,B.TRUECOLOR],[`Tabby`,B.TRUECOLOR],[`xterm-kitty`,B.TRUECOLOR],[`xterm-ghostty`,B.TRUECOLOR],[`wezterm`,B.TRUECOLOR],[`alacritty`,B.TRUECOLOR],[`foot`,B.TRUECOLOR],[`contour`,B.TRUECOLOR]]);function js(e={}){let t=Ns(e).NO_COLOR;if(t!==void 0&&t!==``)return null;let n=Ms(Ns(e));return n===void 0?Fs(e):n}function Ms(e){let t=e.FORCE_COLOR;if(t===void 0||t===``)return;let n=As.get(t);return n===void 0?B.STANDARD:n}function Ns(e){return e.env??(typeof process<`u`?process.env:{})}function Ps(e){let t=e.TERM;return t===`dumb`||t===`unknown`}function Fs(e){let t=Ns(e);if(!(e.isTTY??(typeof process<`u`?process.stdout?.isTTY??!1:!1))||Ps(t))return null;let n=t.TERM??``,r=t.COLORTERM;if(r===`truecolor`||r===`24bit`)return B.TRUECOLOR;let i=As.get(n);if(i!==void 0)return i;let a=t.TERM_PROGRAM;if(a!==void 0){let e=As.get(a);if(e!==void 0)return e}return/-256(color)?$/i.test(n)?B.EIGHT_BIT:/-truecolor$/i.test(n)?B.TRUECOLOR:(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n),B.STANDARD)}function Is(e,t){return e===`auto`?{colorSystem:js(t),hyperlinks:(Ms(Ns(t??{}))??null)!==null||Fs(t??{})!==null}:{colorSystem:typeof e==`string`?Ls(e):e,hyperlinks:!0}}function Ls(e,t){if(e===`auto`)return js(t);if(Object.hasOwn(ks,e))return ks[e];throw new Rs(`Unknown color system name: ${JSON.stringify(e)} (expected "auto", "truecolor", "256", "ansi", or "none")`)}var Rs=class extends Error{constructor(e){super(e),this.name=`ColorParseError`}};const zs=new Go;var V=class e{name;type;number;value;downgradeCache=new Map;constructor(e,t,n,r){this.name=e,this.type=t,this.number=n,this.value=r}get isDefault(){return this.type===B.DEFAULT}get fixedValue(){switch(this.type){case B.TRUECOLOR:return this.value;case B.EIGHT_BIT:return this.number<16?void 0:lc.get(this.number);case B.DEFAULT:case B.STANDARD:case B.WINDOWS:return}}get isSystemDefined(){return this.type===B.STANDARD||this.type===B.WINDOWS}getAnsiCodes(e=!0){switch(this.type){case B.DEFAULT:return[e?`39`:`49`];case B.STANDARD:{let t=this.number;return e?t<8?[`${30+t}`]:[`${90+t-8}`]:t<8?[`${40+t}`]:[`${100+t-8}`]}case B.EIGHT_BIT:return[e?`38`:`48`,`5`,`${this.number}`];case B.TRUECOLOR:{let t=this.value;return[e?`38`:`48`,`2`,`${t.red}`,`${t.green}`,`${t.blue}`]}case B.WINDOWS:{let t=this.number;return e?t<8?[`${30+t}`]:[`${90+t-8}`]:t<8?[`${40+t}`]:[`${100+t-8}`]}}}flattenAlpha(t){if(this.type!==B.TRUECOLOR||!this.value)return this;let n=this.value.compositeOver(t);return n===this.value?this:e.fromRgba(n)}downgrade(e){if(this.type===B.DEFAULT||this.type===e||Os(this.type)<Os(e))return this;let t=this.downgradeCache.get(e);if(t)return t;let n=this.performDowngrade(e);return this.downgradeCache.set(e,n),n}getTruecolor(e,t=!0){switch(this.type){case B.TRUECOLOR:return this.value;case B.EIGHT_BIT:return this.number<16?mc(e,this.type).ansiColors.get(this.number):lc.get(this.number);case B.STANDARD:case B.WINDOWS:return mc(e,this.type).ansiColors.get(this.number);case B.DEFAULT:{let n=mc(e,this.type);return t?n.foregroundColor:n.backgroundColor}}}static default(){return new e(`default`,B.DEFAULT)}static fromAnsi(t){let n=t<16?B.STANDARD:B.EIGHT_BIT;return new e(`color(${t})`,n,t)}static fromRgba(t){return new e(t.hex,B.TRUECOLOR,void 0,t)}static fromRgb(t,n,r){return e.fromRgba(new z(t,n,r))}static blend(t,n,r){for(let e of[t,n]){if(e.isDefault)throw new Rs(`A blend cannot mix "default", which is no colour`);if(e.value!==void 0&&e.value.alpha<1)throw new Rs(`A blend's ends are opaque; "${e.name}" is translucent`)}if(!(r>=0&&r<=1))throw new Rs(`A blend's fraction is in [0, 1]; got ${r}`);let i=t.fixedValue,a=n.fixedValue;return i!==void 0&&a!==void 0?e.fromRgba(rc(i,a,r)):r===0?t:r===1?n:t.type===n.type&&(t.number===void 0?t.name===n.name:t.number===n.number)?t:new Gs(t,n,r)}static matchOn(t,n,r,i){if(t.alpha<1)throw RangeError(`matchOn rounds an opaque colour; got alpha ${t.alpha}`);if(n===B.TRUECOLOR)return e.fromRgba(t);if(n===B.DEFAULT)return e.default();let a=r.ansiColors.match(t);return[[e.default(),i?r.foregroundColor:r.backgroundColor],[new e(`color(${a})`,n===B.WINDOWS?n:B.STANDARD,a),r.ansiColors.get(a)],...n===B.EIGHT_BIT?[Bs(t)]:[]].reduce((e,n)=>Es(n[1],t)<Es(e[1],t)?n:e)[0]}static indexed(e,t){let n=Vs.get(t)??new Map;Vs.set(t,n);let r=n.get(e)??Hs(e,t);return n.set(e,r),r}static matchMove(t,n,r,i,a){let o=e.matchOn(n,r,i,a);return Es(t,n)<=Es(o.getTruecolor(i,a),n)?void 0:o}static parse(e){return zs.get(e.toLowerCase().trim(),Xs)}performDowngrade(t){let n=this.getTruecolor(mc(void 0,t));switch(t){case B.EIGHT_BIT:return e.fromAnsi(hc(t).match(n));case B.STANDARD:case B.WINDOWS:{let r=this.number!==void 0&&this.number<16?this.number:hc(t).match(n);return new e(`color(${r})`,t,r)}case B.TRUECOLOR:return this;case B.DEFAULT:return e.default()}}};function Bs(e){let t=uc.match(e);return[V.fromAnsi(t),uc.get(t)]}const Vs=new WeakMap;function Hs(e,t){let n=()=>Array.from({length:16},(n,r)=>[new V(`color(${r})`,e===B.WINDOWS?e:B.STANDARD,r),t.ansiColors.get(r)]);switch(e){case B.TRUECOLOR:case B.DEFAULT:return[];case B.STANDARD:case B.WINDOWS:return n();case B.EIGHT_BIT:{let{firstIndex:e,size:t}=uc;return[...n(),...Array.from({length:t},(t,n)=>[V.fromAnsi(e+n),uc.get(e+n)])]}}}function Us(e,t,n,r){return rc(e.getTruecolor(r),t.getTruecolor(r),n)}function Ws(e){return e.fixedValue?.hex??(e.number===void 0?e.name:`color(${e.number})`)}var Gs=class extends V{from;to;t;constructor(e,t,n){super(`blend(${Ws(e)},${Ws(t)},${n})`,B.TRUECOLOR,void 0,Us(e,t,n)),this.from=e,this.to=t,this.t=n}get fixedValue(){}getTruecolor(e){return Us(this.from,this.to,this.t,e)}};const Ks=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,qs=/^color\((\d+)\)$/,Js=/^blend\((.*)\)$/,Ys=/^\s*(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?\s*$/;function Xs(e){if(e===`default`||e===``)return V.default();let t=_c[e];if(t!==void 0)return new V(e,t<16?B.STANDARD:B.EIGHT_BIT,t);if(e.startsWith(`#`))return new V(e,B.TRUECOLOR,void 0,nc(e));let n=Ks.exec(e);if(n){let t=Qs(e,n[1],`red`),r=Qs(e,n[2],`green`),i=Qs(e,n[3],`blue`);return new V(e,B.TRUECOLOR,void 0,new z(t,r,i))}let r=qs.exec(e);if(r){let t=Qs(e,r[1],`number`);return new V(e,t<16?B.STANDARD:B.EIGHT_BIT,t)}let i=Js.exec(e);if(i){let t=Zs(i[1]),n=t[2]??``;if(t.length!==3||!Ys.test(n))throw new Rs(`ColorSpec "${e}": a blend is blend(<color>,<color>,<fraction>)`);return V.blend(V.parse(t[0]),V.parse(t[1]),Number(n))}throw new Rs(`Failed to parse color: "${e}"`)}function Zs(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?n++:a===`)`?n--:a===`,`&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function Qs(e,t,n){let r=parseInt(t,10);if(!bs(r))throw new Rs(`ColorSpec "${e}": ${n} ${t} is out of range (0-255)`);return r}const $s=/^[0-9a-fA-F]+$/,ec={6:`RRGGBB`,8:`RRGGBBAA`};function tc(e,t,n,r){if(!r.includes(n.length)||!$s.test(n)){let n=r.map(e=>t+ec[e]).join(` or `);throw new Rs(`Invalid hex colour ${JSON.stringify(e)} (expected ${n})`)}let i=e=>parseInt(n.slice(e,e+2),16);return new z(i(0),i(2),i(4),n.length===8?i(6)/255:1)}function nc(e){return tc(e,`#`,e.startsWith(`#`)?e.slice(1):``,[6,8])}function rc(e,t,n=.5){return new z(Math.round(e.red+(t.red-e.red)*n),Math.round(e.green+(t.green-e.green)*n),Math.round(e.blue+(t.blue-e.blue)*n),e.alpha+(t.alpha-e.alpha)*n)}var ic=class{backgroundColor;foregroundColor;ansiColors;palette;constructor(e,t,n,r){if(this.backgroundColor=e,this.foregroundColor=t,this.ansiColors=n,this.palette=r,n.firstIndex!==0||n.size!==16)throw RangeError(`a TerminalTheme's ansiColors are the sixteen ANSI colours, indices 0–15; got ${n.size} from index ${n.firstIndex}`)}};function ac(){return[new z(0,0,0),new z(128,0,0),new z(0,128,0),new z(128,128,0),new z(0,0,128),new z(128,0,128),new z(0,128,128),new z(192,192,192),new z(128,128,128),new z(255,0,0),new z(0,255,0),new z(255,255,0),new z(0,0,255),new z(255,0,255),new z(0,255,255),new z(255,255,255)]}function oc(){let e=ac(),t=[0,95,135,175,215,255];for(let n=0;n<6;n++)for(let r=0;r<6;r++)for(let i=0;i<6;i++)e.push(new z(t[n],t[r],t[i]));for(let t=0;t<24;t++){let n=8+10*t;e.push(new z(n,n,n))}return e}function sc(){return[new z(12,12,12),new z(197,15,31),new z(19,161,14),new z(193,156,0),new z(0,55,218),new z(136,23,152),new z(58,150,221),new z(204,204,204),new z(118,118,118),new z(231,72,86),new z(22,198,12),new z(249,241,165),new z(59,120,255),new z(180,0,158),new z(97,214,214),new z(242,242,242)]}const cc=new Ds(ac()),lc=new Ds(oc()),uc=new Ds(oc().slice(16),16),dc=new Ds(sc()),fc=new ic(new z(0,0,0),new z(255,255,255),cc,new gs(`default`,!0,new Map)),pc=new ic(dc.get(0),dc.get(7),dc,new gs(`windows`,!0,new Map));function mc(e,t){return e??(t===B.WINDOWS?pc:fc)}function hc(e){switch(e){case B.EIGHT_BIT:return uc;case B.STANDARD:return cc;case B.WINDOWS:return dc}}function gc(e){let t=Object.entries(e).filter(([e])=>e.includes(`grey`)).map(([e,t])=>[e.replace(`grey`,`gray`),t]);return{...e,...Object.fromEntries(t)}}const _c=gc({black:0,red:1,green:2,yellow:3,blue:4,magenta:5,cyan:6,white:7,bright_black:8,bright_red:9,bright_green:10,bright_yellow:11,bright_blue:12,bright_magenta:13,bright_cyan:14,bright_white:15,grey0:16,navy_blue:17,dark_blue:18,blue3:19,blue2:20,blue1:21,dark_green:22,deep_sky_blue4:23,deep_sky_blue5:24,deep_sky_blue6:25,dodger_blue3:26,dodger_blue2:27,green4:28,spring_green4:29,turquoise4:30,deep_sky_blue3:31,deep_sky_blue7:32,dodger_blue1:33,green3:34,spring_green3:35,dark_cyan:36,light_sea_green:37,deep_sky_blue2:38,deep_sky_blue1:39,green5:40,spring_green5:41,spring_green2:42,cyan3:43,dark_turquoise:44,turquoise2:45,green1:46,spring_green6:47,spring_green1:48,medium_spring_green:49,cyan2:50,cyan1:51,dark_red:52,deep_pink4:53,purple4:54,purple5:55,purple3:56,blue_violet:57,orange4:58,grey37:59,medium_purple4:60,slate_blue3:61,slate_blue4:62,royal_blue1:63,chartreuse4:64,dark_sea_green4:65,pale_turquoise4:66,steel_blue:67,steel_blue3:68,cornflower_blue:69,chartreuse3:70,dark_sea_green5:71,cadet_blue:72,cadet_blue2:73,sky_blue3:74,steel_blue1:75,chartreuse5:76,pale_green3:77,sea_green3:78,aquamarine3:79,medium_turquoise:80,steel_blue2:81,chartreuse2:82,sea_green2:83,sea_green1:84,sea_green4:85,aquamarine1:86,dark_slate_gray2:87,dark_red2:88,deep_pink5:89,dark_magenta:90,dark_magenta2:91,dark_violet:92,purple2:93,orange5:94,light_pink4:95,plum4:96,medium_purple3:97,medium_purple5:98,slate_blue1:99,yellow4:100,wheat4:101,grey53:102,light_slate_grey:103,medium_purple:104,light_slate_blue:105,yellow5:106,dark_olive_green3:107,dark_sea_green:108,light_sky_blue3:109,light_sky_blue4:110,sky_blue2:111,chartreuse6:112,dark_olive_green4:113,pale_green4:114,dark_sea_green3:115,dark_slate_gray3:116,sky_blue1:117,chartreuse1:118,light_green:119,light_green2:120,pale_green1:121,aquamarine2:122,dark_slate_gray1:123,red3:124,deep_pink6:125,medium_violet_red:126,magenta3:127,dark_violet2:128,purple:129,dark_orange3:130,indian_red:131,hot_pink3:132,medium_orchid3:133,medium_orchid:134,medium_purple2:135,dark_goldenrod:136,light_salmon3:137,rosy_brown:138,grey63:139,medium_purple6:140,medium_purple1:141,gold3:142,dark_khaki:143,navajo_white3:144,grey69:145,light_steel_blue3:146,light_steel_blue:147,yellow3:148,dark_olive_green5:149,dark_sea_green6:150,dark_sea_green2:151,light_cyan3:152,light_sky_blue1:153,green_yellow:154,dark_olive_green2:155,pale_green2:156,dark_sea_green7:157,dark_sea_green1:158,pale_turquoise1:159,red4:160,deep_pink3:161,deep_pink8:162,magenta4:163,magenta5:164,magenta2:165,dark_orange4:166,indian_red2:167,hot_pink4:168,hot_pink2:169,orchid:170,medium_orchid1:171,orange3:172,light_salmon4:173,light_pink3:174,pink3:175,plum3:176,violet:177,gold4:178,light_goldenrod3:179,tan:180,misty_rose3:181,thistle3:182,plum2:183,yellow6:184,khaki3:185,light_goldenrod2:186,light_yellow3:187,grey84:188,light_steel_blue1:189,yellow2:190,dark_olive_green1:191,dark_olive_green6:192,dark_sea_green8:193,honeydew2:194,light_cyan1:195,red1:196,deep_pink2:197,deep_pink1:198,deep_pink9:199,magenta6:200,magenta1:201,orange_red1:202,indian_red1:203,indian_red3:204,hot_pink5:205,hot_pink:206,medium_orchid2:207,dark_orange:208,salmon1:209,light_coral:210,pale_violet_red1:211,orchid2:212,orchid1:213,orange1:214,sandy_brown:215,light_salmon1:216,light_pink1:217,pink1:218,plum1:219,gold1:220,light_goldenrod4:221,light_goldenrod5:222,navajo_white1:223,misty_rose1:224,thistle1:225,yellow1:226,light_goldenrod1:227,khaki1:228,wheat1:229,cornsilk1:230,grey100:231,grey3:232,grey7:233,grey11:234,grey15:235,grey19:236,grey23:237,grey27:238,grey30:239,grey35:240,grey39:241,grey42:242,grey46:243,grey50:244,grey54:245,grey58:246,grey62:247,grey66:248,grey70:249,grey74:250,grey78:251,grey82:252,grey85:253,grey89:254,grey93:255}),vc=[`default`,...Object.keys(_c)];var yc;const bc=[`l`,`c`,`h`,`alpha`],xc=Object.freeze({hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0});Object.freeze({hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1});function Sc(e){return e.hueShift%360==0&&e.chromaScale===1&&e.lightnessScale===1&&e.lightnessShift===0}function Cc(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function wc(e){return e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055}function Tc(e){return e<0?0:e>1?1:e}const Ec=1e-4,Dc=1e-7,Oc=(e,t)=>e<Dc?0:t,kc=(e,t,n)=>e*(1-n)+t*n,Ac=e=>{let t=e%360;return t<0?t+360:t};function jc(e,t,n){return e>=-Ec&&e<=1+Ec&&t>=-Ec&&t<=1+Ec&&n>=-Ec&&n<=1+Ec}var Mc=class{l;c;h;alpha;constructor(e,t,n,r=1){if(this.l=e,this.c=t,this.h=n,this.alpha=r,!Number.isFinite(e))throw RangeError(`Oklch.l must be finite; got ${e}`);if(!Number.isFinite(t))throw RangeError(`Oklch.c must be finite; got ${t}`);if(!Number.isFinite(n))throw RangeError(`Oklch.h must be finite; got ${n}`);if(!Number.isFinite(r)||r<0||r>1)throw RangeError(`Oklch.alpha must be a finite number in [0,1]; got ${r}`)}static fromRgba(e){let[t,n,r,i]=e.normalized,a=Cc(t),o=Cc(n),s=Cc(r),c=.4122214708*a+.5363325363*o+.0514459929*s,l=.2119034982*a+.6806995451*o+.1073969566*s,u=.0883024619*a+.2817188376*o+.6299787005*s,d=Math.cbrt(c),f=Math.cbrt(l),p=Math.cbrt(u),m=.2104542553*d+.793617785*f-.0040720468*p,h=1.9779984951*d-2.428592205*f+.4505937099*p,g=.0259040371*d+.7827717662*f-.808675766*p,_=Math.sqrt(h*h+g*g),v=Ac(180/Math.PI*Math.atan2(g,h));return new yc(m,_,Oc(_,v),i)}toRgba(){let e=Tc(this.l),t=Math.max(0,this.c),n=this.findInGamutChroma(e,t,this.h),{r,g:i,b:a}=this.toLinearRgb(e,n,this.h);return new z(Math.round(Tc(wc(r))*255),Math.round(Tc(wc(i))*255),Math.round(Tc(wc(a))*255),this.alpha)}applyKey(e){if(Sc(e))return this;let t=Tc(this.l*e.lightnessScale+e.lightnessShift),n=Math.max(0,this.c*e.chromaScale),r=Ac(this.h+e.hueShift);return new yc(t,n,Oc(n,r),this.alpha)}mix(e,t){if(!(t>=0&&t<=1))throw RangeError(`Oklch.mix: t must be in [0, 1]; got ${t}`);return this.#e(e,t,t,t,t)}mixAxes(e,t){for(let e of bc){let n=t[e];if(!(n>=0&&n<=1))throw RangeError(`Oklch.mixAxes: ${e} weight must be in [0, 1]; got ${n}`)}return this.#e(e,t.l,t.c,t.h,t.alpha)}#e(e,t,n,r,i){let a=this.c>=Dc,o=e.c>=Dc,s=Ac(a?this.h:o?e.h:0),c=Ac(o?e.h:s),l=c-s,u=l<-180?s-360:s,d=l>180?c-360:c,f=kc(this.c,e.c,n);return new yc(kc(this.l,e.l,t),f,Oc(f,Ac(kc(u,d,r))),kc(this.alpha,e.alpha,i))}deltaE(e){let t=this.h*Math.PI/180,n=e.h*Math.PI/180;return Math.hypot(this.l-e.l,this.c*Math.cos(t)-e.c*Math.cos(n),this.c*Math.sin(t)-e.c*Math.sin(n))}toLinearRgb(e,t,n){let r=Math.PI/180*n,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o*o*o,u=s*s*s,d=c*c*c;return{r:4.0767416621*l-3.3077115913*u+.2309699292*d,g:-1.2684380046*l+2.6097574011*u-.3413193965*d,b:-.0041960863*l-.7034186147*u+1.707614701*d}}findInGamutChroma(e,t,n){let r=this.toLinearRgb(e,t,n);if(jc(r.r,r.g,r.b))return t;let i=0,a=t;for(let t=0;t<24;t++){let t=(i+a)/2,r=this.toLinearRgb(e,t,n);jc(r.r,r.g,r.b)?i=t:a=t}return i}};yc=Mc;var Nc=class extends Error{ref;constructor(e,t,n){super(`color reference ${JSON.stringify(e)} did not resolve — ${t}`,n),this.ref=e,this.name=`ColorRefError`}};function Pc(e,t){let n=t.trim();if(n.startsWith(`#`))try{return nc(n)}catch(e){throw e instanceof Rs?new Nc(t,e.message,{cause:e}):e}let r=e.get(n);if(r===void 0)throw new Nc(t,`no such variable in palette ${JSON.stringify(e.name)}`+Fc(e,n));return r}function Fc(e,t){let n=t.split(`-`),r=[...e.vars.keys()].filter(e=>n.some(t=>t!==``&&e.includes(t))).slice(0,8);return r.length===0?``:`; did you mean: ${r.join(`, `)}`}function Ic(e){let t=e.red/255,n=e.green/255,r=e.blue/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s=i-a;if(s===0)return{h:0,s:0,l:o};let c=s/(o>.5?2-i-a:i+a),l;return l=i===t?(n-r)/s%6:i===n?(r-t)/s+2:(t-n)/s+4,l=(l*60+360)%360,{h:l,s:c,l:o}}function Lc(e){let t=Math.round(e);return t<0?0:t>255?255:t}function Rc(e){let{h:t,s:n,l:r}=e;if(n===0){let e=Lc(r*255);return new z(e,e,e)}let i=(1-Math.abs(2*r-1))*n,a=t/60,o=i*(1-Math.abs(a%2-1)),s=0,c=0,l=0;a<1?[s,c,l]=[i,o,0]:a<2?[s,c,l]=[o,i,0]:a<3?[s,c,l]=[0,i,o]:a<4?[s,c,l]=[0,o,i]:a<5?[s,c,l]=[o,0,i]:[s,c,l]=[i,0,o];let u=r-i/2;return new z(Lc((s+u)*255),Lc((c+u)*255),Lc((l+u)*255))}function zc(e){return e<0?0:e>1?1:e}function Bc(e,t){let n=Ic(e);return n.l=zc(n.l-.1*t),Rc(n)}function Vc(e,t,n){return rc(t,e,zc(n))}function Hc(e,t=Ss){return Cs(qc(e,t))>.179?new z(0,0,0):new z(255,255,255)}function Uc(e,t,n=4.5,r=B.TRUECOLOR,i=Ss,a){let o=qc(t,i),s=Yc(e,o,n,Hc(o)),c=Jc(r,a);if(c===void 0)return s;let l=Kc(c,o);return ws(Kc(c,s),l)>=n?s:c.written.get(c.shown.matchReadable(e.compositeOver(o),l,n))}function Wc(e,t,n,r=Ss,i){let a=qc(e,r),o=Jc(t,i),s=e=>Kc(o,qc(e,r));if(n(s(a),s))return a;let c=o?.shown.matchWhere(a,e=>n(e,s));return c===void 0?void 0:o.written.get(c)}function Gc(e,t,n=Ss,r){return Kc(Jc(t,r),qc(e,n))}function Kc(e,t){return e===void 0?t:V.fromRgba(t).downgrade(e.depth).getTruecolor(e.terminal)}function qc(e,t){if(t.alpha!==1)throw RangeError(`a contrast substrate is the opaque surface under a translucent background; got ${t.hex}`);return e.compositeOver(t)}function Jc(e,t){let n=mc(t,e);switch(e){case B.EIGHT_BIT:return{depth:e,terminal:n,written:hc(e),shown:hc(e)};case B.STANDARD:case B.WINDOWS:return{depth:e,terminal:n,written:hc(e),shown:n.ansiColors};case B.TRUECOLOR:case B.DEFAULT:return}}function Yc(e,t,n,r){let i=e.compositeOver(t);if(ws(i,t)>=n)return i;let a=Mc.fromRgba(i),o=+(Cs(r)>.179);if(ws(new Mc(o,a.c,a.h,a.alpha).toRgba(),t)<n)return Hc(t);let s=a.l,c=o;for(let e=0;e<20;e++){let e=(s+c)/2;ws(new Mc(e,a.c,a.h,a.alpha).toRgba(),t)>=n?c=e:s=e}return new Mc(c,a.c,a.h,a.alpha).toRgba()}const Xc=.7,Zc=[`primary`,`secondary`,`accent`,`success`,`warning`,`error`];function Qc(e,t,n){let r=_s(e,n.background),i=t=>{let i=n[t];if(i.alpha===0)throw RangeError(`palette ${JSON.stringify(e)}: ${t} is fully transparent (${i.hex}), so there is no colour to derive the palette from`);return r(i)},a={primary:i(`primary`),secondary:i(`secondary`),accent:i(`accent`),success:i(`success`),warning:i(`warning`),error:i(`error`),background:n.background,foreground:i(`foreground`)},o=new Map;o.set(`background`,a.background),o.set(`foreground`,a.foreground);for(let e of Zc)o.set(e,a[e]);o.set(`foreground-muted`,rc(a.foreground,a.background,Xc)),o.set(`background-muted`,rc(a.background,a.foreground,Xc)),o.set(`surface`,rc(a.background,a.foreground,.05));let s=Hc(a.background);for(let e of Zc){let t=a[e],n=rc(t,a.background,Xc);o.set(`${e}-muted`,n),o.set(`text-${e}`,$c(Vc(t,s,.66),n,a.background)),o.set(`on-${e}`,Hc(t))}return new gs(e,t,o)}function $c(e,t,n){return Yc(e,t,4.5,Hc(n))}const el={name:`atom-one-dark`,dark:!0,ansi:{black:`#282C34`,red:`#E06C75`,green:`#98C379`,yellow:`#E5C07B`,blue:`#61AFEF`,magenta:`#C678DD`,cyan:`#56B6C2`,white:`#DCDFE4`,brightBlack:`#5D677A`,brightRed:`#E06C75`,brightGreen:`#98C379`,brightYellow:`#E5C07B`,brightBlue:`#61AFEF`,brightMagenta:`#C678DD`,brightCyan:`#56B6C2`,brightWhite:`#DCDFE4`},vars:{accent:`#A378C2`,"accent-darken-1":`#8E65AD`,"accent-darken-2":`#7A5299`,"accent-darken-3":`#674085`,"accent-lighten-1":`#B78BD6`,"accent-lighten-2":`#CC9FEC`,"accent-lighten-3":`#E2B3FF`,"accent-muted":`#4C425E`,background:`#282C34`,"background-darken-1":`#181C23`,"background-darken-2":`#050A14`,"background-darken-3":`#000000`,"background-lighten-1":`#383C44`,"background-lighten-2":`#494D56`,"background-lighten-3":`#5B5F68`,"block-cursor-background":`#61AFEF`,"block-cursor-blurred-background":`#61AFEF4C`,"block-cursor-blurred-foreground":`#ABB2BF`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#61AFEF`,"border-blurred":`#353B47`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#ABB2BF`,error:`#EF6262`,"error-darken-1":`#D84D50`,"error-darken-2":`#C1373E`,"error-darken-3":`#AA1F2E`,"error-lighten-1":`#FF7674`,"error-lighten-2":`#FF8B87`,"error-lighten-3":`#FFA09B`,"error-muted":`#643C41`,"footer-background":`#4F5666`,"footer-description-background":`#00000000`,"footer-description-foreground":`#ABB2BF`,"footer-foreground":`#ABB2BF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#A378C2`,foreground:`#ABB2BF`,"foreground-darken-1":`#979DAA`,"foreground-darken-2":`#838A96`,"foreground-darken-3":`#707783`,"foreground-disabled":`#ABB2BF60`,"foreground-lighten-1":`#BFC6D3`,"foreground-lighten-2":`#D4DBE8`,"foreground-lighten-3":`#E9F0FE`,"foreground-muted":`#ABB2BF99`,"input-cursor-background":`#ABB2BF`,"input-cursor-foreground":`#282C34`,"input-selection-background":`#77C3FF66`,"link-background":`#00000000`,"link-background-hover":`#61AFEF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#61AFEF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#61AFEF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#61AFEF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#ABB2BF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#ABB2BF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#ABB2BF99`,panel:`#4F5666`,"panel-darken-1":`#3D4453`,"panel-darken-2":`#2C3342`,"panel-darken-3":`#1C2331`,"panel-lighten-1":`#616878`,"panel-lighten-2":`#737A8B`,"panel-lighten-3":`#868E9F`,primary:`#61AFEF`,"primary-background":`#4F5B6A`,"primary-background-darken-1":`#3F4D5D`,"primary-background-darken-2":`#303F50`,"primary-background-darken-3":`#303F50`,"primary-background-lighten-1":`#5E6A77`,"primary-background-lighten-2":`#6E7884`,"primary-background-lighten-3":`#7D8791`,"primary-darken-1":`#489BD9`,"primary-darken-2":`#2C87C4`,"primary-darken-3":`#0074AF`,"primary-lighten-1":`#77C3FF`,"primary-lighten-2":`#8ED8FF`,"primary-lighten-3":`#A4EDFF`,"primary-muted":`#39536C`,scrollbar:`#355674`,"scrollbar-active":`#61AFEF`,"scrollbar-background":`#181C23`,"scrollbar-background-active":`#181C23`,"scrollbar-background-hover":`#181C23`,"scrollbar-corner-color":`#181C23`,"scrollbar-hover":`#3C6589`,secondary:`#C678DD`,"secondary-background":`#5B5567`,"secondary-background-darken-1":`#4D465A`,"secondary-background-darken-2":`#3F374D`,"secondary-background-darken-3":`#3F374D`,"secondary-background-lighten-1":`#6A6475`,"secondary-background-lighten-2":`#787382`,"secondary-background-lighten-3":`#87828F`,"secondary-darken-1":`#B064C7`,"secondary-darken-2":`#9B50B3`,"secondary-darken-3":`#873D9E`,"secondary-lighten-1":`#DB8CF2`,"secondary-lighten-2":`#F1A0FF`,"secondary-lighten-3":`#FFB5FF`,"secondary-muted":`#574266`,success:`#62F062`,"success-darken-1":`#48DA4D`,"success-darken-2":`#29C438`,"success-darken-3":`#00AF22`,"success-lighten-1":`#7AFF76`,"success-lighten-2":`#91FF8A`,"success-lighten-3":`#A8FF9F`,"success-muted":`#396641`,surface:`#3B414D`,"surface-active":`#484E5B`,"surface-darken-1":`#2A303B`,"surface-darken-2":`#1A202B`,"surface-darken-3":`#09101B`,"surface-lighten-1":`#4C525E`,"surface-lighten-2":`#5E6471`,"surface-lighten-3":`#707684`,text:`#FFFFFFDD`,"text-accent":`#C2A5D6`,"text-disabled":`#FFFFFF60`,"text-error":`#F59797`,"text-muted":`#FFFFFF99`,"text-primary":`#96CAF4`,"text-secondary":`#D9A5E8`,"text-success":`#97F597`,"text-warning":`#E9CC92`,warning:`#DDB25B`,"warning-darken-1":`#C79D47`,"warning-darken-2":`#B28A34`,"warning-darken-3":`#9C7721`,"warning-lighten-1":`#F4C66E`,"warning-lighten-2":`#FFDB82`,"warning-lighten-3":`#FFF096`,"warning-muted":`#5E543F`}},tl={name:`atom-one-light`,dark:!1,ansi:{black:`#383A42`,red:`#E45649`,green:`#50A14F`,yellow:`#C18401`,blue:`#0184BC`,magenta:`#A626A4`,cyan:`#0997B3`,white:`#BABABA`,brightBlack:`#4F525E`,brightRed:`#E06C75`,brightGreen:`#98C379`,brightYellow:`#D8B36E`,brightBlue:`#61AFEF`,brightMagenta:`#C678DD`,brightCyan:`#56B6C2`,brightWhite:`#FFFFFF`},vars:{accent:`#BE9232`,"accent-darken-1":`#A97E1D`,"accent-darken-2":`#936B01`,"accent-darken-3":`#7E5900`,"accent-lighten-1":`#D5A545`,"accent-lighten-2":`#EBB959`,"accent-lighten-3":`#FFCE6C`,"accent-muted":`#E8DABE`,background:`#FAFAFA`,"background-darken-1":`#E4E4E4`,"background-darken-2":`#CFCFCF`,"background-darken-3":`#BABABA`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#4078F2`,"block-cursor-blurred-background":`#4078F24C`,"block-cursor-blurred-foreground":`#383A42`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#4078F2`,"border-blurred":`#D8D8D8`,"button-color-foreground":`#000000DD`,"button-foreground":`#383A42`,error:`#F13F3F`,"error-darken-1":`#D9232D`,"error-darken-2":`#C1001D`,"error-darken-3":`#A9000D`,"error-lighten-1":`#FF5650`,"error-lighten-2":`#FF6C62`,"error-lighten-3":`#FF8275`,"error-muted":`#F7C1C1`,"footer-background":`#CCCCCC`,"footer-description-background":`#00000000`,"footer-description-foreground":`#383A42`,"footer-foreground":`#383A42`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#BF9232`,foreground:`#383A42`,"foreground-darken-1":`#272931`,"foreground-darken-2":`#181A21`,"foreground-darken-3":`#040612`,"foreground-disabled":`#383A4260`,"foreground-lighten-1":`#494B53`,"foreground-lighten-2":`#5A5C65`,"foreground-lighten-3":`#6D6F78`,"foreground-muted":`#383A4299`,"input-cursor-background":`#383A42`,"input-cursor-foreground":`#FAFAFA`,"input-selection-background":`#5C8AFF66`,"link-background":`#00000000`,"link-background-hover":`#4078F2`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#4078F2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#4078F2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#4078F2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#383A42`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#383A42`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#383A4299`,panel:`#CCCCCC`,"panel-darken-1":`#B7B7B7`,"panel-darken-2":`#A3A3A3`,"panel-darken-3":`#8F8F8F`,"panel-lighten-1":`#E1E1E1`,"panel-lighten-2":`#F6F6F6`,"panel-lighten-3":`#FFFFFF`,primary:`#4078F2`,"primary-background":`#4078F2`,"primary-background-darken-1":`#1865DC`,"primary-background-darken-2":`#0053C6`,"primary-background-darken-3":`#0043B1`,"primary-background-lighten-1":`#5C8AFF`,"primary-background-lighten-2":`#759EFF`,"primary-background-lighten-3":`#8DB2FF`,"primary-darken-1":`#1865DC`,"primary-darken-2":`#0053C6`,"primary-darken-3":`#0043B1`,"primary-lighten-1":`#5C8AFF`,"primary-lighten-2":`#759EFF`,"primary-lighten-3":`#8DB2FF`,"primary-muted":`#C2D3F7`,scrollbar:`#A2B8E9`,"scrollbar-active":`#4078F2`,"scrollbar-background":`#E4E4E4`,"scrollbar-background-active":`#E4E4E4`,"scrollbar-background-hover":`#E4E4E4`,"scrollbar-corner-color":`#E4E4E4`,"scrollbar-hover":`#92AEEB`,secondary:`#A626A4`,"secondary-background":`#A626A4`,"secondary-background-darken-1":`#90008F`,"secondary-background-darken-2":`#7B007C`,"secondary-background-darken-3":`#670069`,"secondary-background-lighten-1":`#BB3EB8`,"secondary-background-lighten-2":`#D154CD`,"secondary-background-lighten-3":`#E769E2`,"secondary-darken-1":`#90008F`,"secondary-darken-2":`#7B007C`,"secondary-darken-3":`#670069`,"secondary-lighten-1":`#BB3EB8`,"secondary-lighten-2":`#D154CD`,"secondary-lighten-3":`#E769E2`,"secondary-muted":`#E0BAE0`,success:`#6BF23F`,"success-darken-1":`#52DC25`,"success-darken-2":`#36C600`,"success-darken-3":`#05B100`,"success-lighten-1":`#83FF55`,"success-lighten-2":`#9BFF6B`,"success-lighten-3":`#B2FF80`,"success-muted":`#CFF7C1`,surface:`#E0E0E0`,"surface-active":`#F1F1F1`,"surface-darken-1":`#CACACA`,"surface-darken-2":`#B6B6B6`,"surface-darken-3":`#A2A2A2`,"surface-lighten-1":`#F5F5F5`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#7E6021`,"text-disabled":`#00000060`,"text-error":`#9F2929`,"text-muted":`#00000099`,"text-primary":`#2A4F9F`,"text-secondary":`#6D196C`,"text-success":`#479F29`,"text-warning":`#8E8F24`,warning:`#D7D938`,"warning-darken-1":`#C1C41C`,"warning-darken-2":`#ABAF00`,"warning-darken-3":`#969B00`,"warning-lighten-1":`#EEEE4E`,"warning-lighten-2":`#FFFF64`,"warning-lighten-3":`#FFFF79`,"warning-muted":`#EFF0BF`}},nl={name:`catppuccin-frappe`,dark:!0,ansi:{black:`#51576D`,red:`#E78284`,green:`#A6D189`,yellow:`#E5C890`,blue:`#8CAAEE`,magenta:`#F4B8E4`,cyan:`#81C8BE`,white:`#B5BFE2`,brightBlack:`#626880`,brightRed:`#EDA0A2`,brightGreen:`#B9DBA2`,brightYellow:`#ECD7AE`,brightBlue:`#ADC2F3`,brightMagenta:`#F38ED8`,brightCyan:`#98D2CA`,brightWhite:`#A5ADCE`},vars:{accent:`#F4B8E4`,"accent-darken-1":`#DEA3CE`,"accent-darken-2":`#C98FBA`,"accent-darken-3":`#B47BA5`,"accent-lighten-1":`#FFCCF9`,"accent-lighten-2":`#FFE2FF`,"accent-lighten-3":`#FFF7FF`,"accent-muted":`#6A5B75`,background:`#303446`,"background-darken-1":`#1F2435`,"background-darken-2":`#101424`,"background-darken-3":`#000016`,"background-lighten-1":`#404457`,"background-lighten-2":`#525669`,"background-lighten-3":`#64687C`,"block-cursor-background":`#CA9EE6`,"block-cursor-blurred-background":`#CA9EE64C`,"block-cursor-blurred-foreground":`#C6D0F5`,"block-cursor-foreground":`#292C3C`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BABBF1`,"border-blurred":`#838BA7`,"button-color-foreground":`#303446`,"button-foreground":`#C6D0F5`,error:`#E68284`,"error-darken-1":`#D06E71`,"error-darken-2":`#BA5A5E`,"error-darken-3":`#A4474C`,"error-lighten-1":`#FD9697`,"error-lighten-2":`#FFAAAB`,"error-lighten-3":`#FFBFBF`,"error-muted":`#664B58`,"footer-background":`#51576D`,"footer-description-background":`#00000000`,"footer-description-foreground":`#C6D0F5`,"footer-foreground":`#C6D0F5`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#F4B8E4`,foreground:`#C6D0F5`,"foreground-darken-1":`#B1BBDF`,"foreground-darken-2":`#9CA7CA`,"foreground-darken-3":`#8993B5`,"foreground-disabled":`#C6D0F560`,"foreground-lighten-1":`#DBE5FF`,"foreground-lighten-2":`#F0FAFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#C6D0F599`,"input-cursor-background":`#F2D5CF`,"input-cursor-foreground":`#232634`,"input-selection-background":`#949CBB4C`,"link-background":`#00000000`,"link-background-hover":`#CA9EE6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#CA9EE6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#CA9EE6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#CA9EE6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#C6D0F5`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#C6D0F5`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#C6D0F599`,panel:`#51576D`,"panel-darken-1":`#3F455A`,"panel-darken-2":`#2E3448`,"panel-darken-3":`#1D2437`,"panel-lighten-1":`#63697F`,"panel-lighten-2":`#767B93`,"panel-lighten-3":`#898FA7`,primary:`#CA9EE6`,"primary-background":`#625F76`,"primary-background-darken-1":`#54516A`,"primary-background-darken-2":`#47435E`,"primary-background-darken-3":`#47435E`,"primary-background-lighten-1":`#706D82`,"primary-background-lighten-2":`#7E7B8E`,"primary-background-lighten-3":`#8C899A`,"primary-darken-1":`#B58AD0`,"primary-darken-2":`#A076BB`,"primary-darken-3":`#8C63A7`,"primary-lighten-1":`#DFB2FB`,"primary-lighten-2":`#F4C7FF`,"primary-lighten-3":`#FFDCFF`,"primary-muted":`#5E5376`,scrollbar:`#63547B`,"scrollbar-active":`#CA9EE6`,"scrollbar-background":`#1F2435`,"scrollbar-background-active":`#1F2435`,"scrollbar-background-hover":`#1F2435`,"scrollbar-corner-color":`#1F2435`,"scrollbar-hover":`#74618D`,secondary:`#EE9F76`,"secondary-background":`#666067`,"secondary-background-darken-1":`#59525A`,"secondary-background-darken-2":`#4C444D`,"secondary-background-darken-3":`#4C444D`,"secondary-background-lighten-1":`#746E75`,"secondary-background-lighten-2":`#817C82`,"secondary-background-lighten-3":`#8F8A8F`,"secondary-darken-1":`#D88B63`,"secondary-darken-2":`#C27750`,"secondary-darken-3":`#AC643E`,"secondary-lighten-1":`#FFB389`,"secondary-lighten-2":`#FFC89D`,"secondary-lighten-3":`#FFDDB1`,"secondary-muted":`#695454`,success:`#A6D189`,"success-darken-1":`#91BC75`,"success-darken-2":`#7DA762`,"success-darken-3":`#6A9350`,"success-lighten-1":`#BAE69C`,"success-lighten-2":`#CFFBB1`,"success-lighten-3":`#E5FFC5`,"success-muted":`#53635A`,surface:`#414559`,"surface-active":`#4F5267`,"surface-darken-1":`#303447`,"surface-darken-2":`#1F2436`,"surface-darken-3":`#101526`,"surface-lighten-1":`#52566B`,"surface-lighten-2":`#64687E`,"surface-lighten-3":`#777B91`,text:`#FFFFFFDD`,"text-accent":`#F7D0ED`,"text-disabled":`#FFFFFF60`,"text-error":`#EFACAD`,"text-muted":`#FFFFFF99`,"text-primary":`#DCBEEE`,"text-secondary":`#F4BFA4`,"text-success":`#C4E0B1`,"text-warning":`#EDDAB5`,warning:`#E4C890`,"warning-darken-1":`#CFB37C`,"warning-darken-2":`#BA9F69`,"warning-darken-3":`#A58B56`,"warning-lighten-1":`#FADCA4`,"warning-lighten-2":`#FFF2B8`,"warning-lighten-3":`#FFFFCD`,"warning-muted":`#66605C`}},rl={name:`catppuccin-latte`,dark:!1,ansi:{black:`#BCC0CC`,red:`#D20F39`,green:`#40A02B`,yellow:`#DF8E1D`,blue:`#1E66F5`,magenta:`#EA76CB`,cyan:`#179299`,white:`#5C5F77`,brightBlack:`#ACB0BE`,brightRed:`#E7103F`,brightGreen:`#46B02F`,brightYellow:`#E49931`,brightBlue:`#3878F6`,brightMagenta:`#EF95D7`,brightCyan:`#19A1A8`,brightWhite:`#6C6F85`},vars:{accent:`#FD640B`,"accent-darken-1":`#E54F00`,"accent-darken-2":`#CC3900`,"accent-darken-3":`#B42200`,"accent-lighten-1":`#FF7825`,"accent-lighten-2":`#FF8D3A`,"accent-lighten-3":`#FFA24F`,"accent-muted":`#F3C6AE`,background:`#EFF1F5`,"background-darken-1":`#D9DBDF`,"background-darken-2":`#C4C6CA`,"background-darken-3":`#B0B2B5`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#8839EF`,"block-cursor-blurred-background":`#8839EF4C`,"block-cursor-blurred-foreground":`#4C4F69`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#8839EF`,"border-blurred":`#DEE1E7`,"button-color-foreground":`#EFF1F5`,"button-foreground":`#4C4F69`,error:`#D10F39`,"error-darken-1":`#BA0028`,"error-darken-2":`#A20019`,"error-darken-3":`#8A0008`,"error-lighten-1":`#EA324A`,"error-lighten-2":`#FF4B5B`,"error-lighten-3":`#FF626E`,"error-muted":`#E6ADBC`,"footer-background":`#CCD0DA`,"footer-description-background":`#00000000`,"footer-description-foreground":`#4C4F69`,"footer-foreground":`#4C4F69`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FE640B`,foreground:`#4C4F69`,"foreground-darken-1":`#3A3D56`,"foreground-darken-2":`#292D45`,"foreground-darken-3":`#191D34`,"foreground-disabled":`#4C4F6960`,"foreground-lighten-1":`#5E607B`,"foreground-lighten-2":`#70738F`,"foreground-lighten-3":`#8386A2`,"foreground-muted":`#4C4F6999`,"input-cursor-background":`#4C4F69`,"input-cursor-foreground":`#EFF1F5`,"input-selection-background":`#9E4DFF66`,"link-background":`#00000000`,"link-background-hover":`#8839EF`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#8839EF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#8839EF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#8839EF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#4C4F69`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#4C4F69`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#4C4F6999`,panel:`#CCD0DA`,"panel-darken-1":`#B7BBC5`,"panel-darken-2":`#A3A6B0`,"panel-darken-3":`#8F939C`,"panel-lighten-1":`#E1E5EF`,"panel-lighten-2":`#F6FAFF`,"panel-lighten-3":`#FFFFFF`,primary:`#8839EF`,"primary-background":`#8839EF`,"primary-background-darken-1":`#7122D9`,"primary-background-darken-2":`#5901C3`,"primary-background-darken-3":`#4000AE`,"primary-background-lighten-1":`#9E4DFF`,"primary-background-lighten-2":`#B562FF`,"primary-background-lighten-3":`#CC76FF`,"primary-darken-1":`#7122D9`,"primary-darken-2":`#5901C3`,"primary-darken-3":`#4000AE`,"primary-lighten-1":`#9E4DFF`,"primary-lighten-2":`#B562FF`,"primary-lighten-3":`#CC76FF`,"primary-muted":`#D0B9F3`,scrollbar:`#B89AE5`,"scrollbar-active":`#8839EF`,"scrollbar-background":`#D9DBDF`,"scrollbar-background-active":`#D9DBDF`,"scrollbar-background-hover":`#D9DBDF`,"scrollbar-corner-color":`#D9DBDF`,"scrollbar-hover":`#B08AE7`,secondary:`#DB8A78`,"secondary-background":`#DB8A78`,"secondary-background-darken-1":`#C57665`,"secondary-background-darken-2":`#B06353`,"secondary-background-darken-3":`#9A5041`,"secondary-background-lighten-1":`#F29D8B`,"secondary-background-lighten-2":`#FFB29E`,"secondary-background-lighten-3":`#FFC7B3`,"secondary-darken-1":`#C57665`,"secondary-darken-2":`#B06353`,"secondary-darken-3":`#9A5041`,"secondary-lighten-1":`#F29D8B`,"secondary-lighten-2":`#FFB29E`,"secondary-lighten-3":`#FFC7B3`,"secondary-muted":`#E9D2CF`,success:`#40A02B`,"success-darken-1":`#278B14`,"success-darken-2":`#007800`,"success-darken-3":`#006400`,"success-lighten-1":`#56B43F`,"success-lighten-2":`#6BC952`,"success-lighten-3":`#81DE66`,"success-muted":`#BAD8B8`,surface:`#E6E9EF`,"surface-active":`#F7FAFF`,"surface-darken-1":`#D0D3D9`,"surface-darken-2":`#BCBFC4`,"surface-darken-3":`#A7AAB0`,"surface-lighten-1":`#FBFEFF`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#A74207`,"text-disabled":`#00000060`,"text-error":`#8A0925`,"text-muted":`#00000099`,"text-primary":`#59259D`,"text-secondary":`#915B4F`,"text-success":`#2A691C`,"text-warning":`#935D13`,warning:`#DE8E1D`,"warning-darken-1":`#C77A00`,"warning-darken-2":`#B06700`,"warning-darken-3":`#9A5500`,"warning-lighten-1":`#F6A134`,"warning-lighten-2":`#FFB648`,"warning-lighten-3":`#FFCA5D`,"warning-muted":`#EAD3B4`}},il={name:`catppuccin-macchiato`,dark:!0,ansi:{black:`#494D64`,red:`#ED8796`,green:`#A6DA95`,yellow:`#EED49F`,blue:`#8AADF4`,magenta:`#F5BDE6`,cyan:`#8BD5CA`,white:`#B8C0E0`,brightBlack:`#5B6078`,brightRed:`#F2A7B2`,brightGreen:`#BDE3B0`,brightYellow:`#F4E3C1`,brightBlue:`#ADC5F7`,brightMagenta:`#F493DA`,brightCyan:`#A5DED6`,brightWhite:`#A5ADCB`},vars:{accent:`#F5BDE6`,"accent-darken-1":`#DFA8D0`,"accent-darken-2":`#CA94BC`,"accent-darken-3":`#B580A7`,"accent-lighten-1":`#FFD1FB`,"accent-lighten-2":`#FFE7FF`,"accent-lighten-3":`#FFFCFF`,"accent-muted":`#62546D`,background:`#24273A`,"background-darken-1":`#141729`,"background-darken-2":`#00021A`,"background-darken-3":`#000007`,"background-lighten-1":`#34374B`,"background-lighten-2":`#45485C`,"background-lighten-3":`#57596F`,"block-cursor-background":`#C6A0F6`,"block-cursor-blurred-background":`#C6A0F64C`,"block-cursor-blurred-foreground":`#CAD3F5`,"block-cursor-foreground":`#1E2030`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#B7BDF8`,"border-blurred":`#737994`,"button-color-foreground":`#24273A`,"button-foreground":`#CAD3F5`,error:`#ED8796`,"error-darken-1":`#D67382`,"error-darken-2":`#C05F6F`,"error-darken-3":`#AB4C5D`,"error-lighten-1":`#FF9BA9`,"error-lighten-2":`#FFAFBE`,"error-lighten-3":`#FFC4D3`,"error-muted":`#604355`,"footer-background":`#494D64`,"footer-description-background":`#00000000`,"footer-description-foreground":`#CAD3F5`,"footer-foreground":`#CAD3F5`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#F5BDE6`,foreground:`#CAD3F5`,"foreground-darken-1":`#B5BEDF`,"foreground-darken-2":`#A0A9CA`,"foreground-darken-3":`#8C95B5`,"foreground-disabled":`#CAD3F560`,"foreground-lighten-1":`#DFE8FF`,"foreground-lighten-2":`#F4FDFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#CAD3F599`,"input-cursor-background":`#F4DBD6`,"input-cursor-foreground":`#181926`,"input-selection-background":`#838BA74C`,"link-background":`#00000000`,"link-background-hover":`#C6A0F6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C6A0F6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C6A0F6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C6A0F6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#CAD3F5`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#CAD3F5`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#CAD3F599`,panel:`#494D64`,"panel-darken-1":`#373B51`,"panel-darken-2":`#262B40`,"panel-darken-3":`#161C2F`,"panel-lighten-1":`#5A5E76`,"panel-lighten-2":`#6D7189`,"panel-lighten-3":`#80849D`,primary:`#C6A0F6`,"primary-background":`#59566F`,"primary-background-darken-1":`#4A4762`,"primary-background-darken-2":`#3C3956`,"primary-background-darken-3":`#3C3956`,"primary-background-lighten-1":`#67657C`,"primary-background-lighten-2":`#767488`,"primary-background-lighten-3":`#858395`,"primary-darken-1":`#B08CE0`,"primary-darken-2":`#9C78CB`,"primary-darken-3":`#8865B6`,"primary-lighten-1":`#DBB4FF`,"primary-lighten-2":`#F1C9FF`,"primary-lighten-3":`#FFDEFF`,"primary-muted":`#544B72`,scrollbar:`#5B4D7B`,"scrollbar-active":`#C6A0F6`,"scrollbar-background":`#141729`,"scrollbar-background-active":`#141729`,"scrollbar-background-hover":`#141729`,"scrollbar-corner-color":`#141729`,"scrollbar-hover":`#6D5B8F`,secondary:`#F4A97F`,"secondary-background":`#5F5760`,"secondary-background-darken-1":`#514852`,"secondary-background-darken-2":`#433A44`,"secondary-background-darken-3":`#433A44`,"secondary-background-lighten-1":`#6D666E`,"secondary-background-lighten-2":`#7B757C`,"secondary-background-lighten-3":`#89838A`,"secondary-darken-1":`#DE946B`,"secondary-darken-2":`#C88159`,"secondary-darken-3":`#B26E47`,"secondary-lighten-1":`#FFBD92`,"secondary-lighten-2":`#FFD2A6`,"secondary-lighten-3":`#FFE7BB`,"secondary-muted":`#624E4E`,success:`#A6DA95`,"success-darken-1":`#91C481`,"success-darken-2":`#7DB06E`,"success-darken-3":`#6A9C5B`,"success-lighten-1":`#BAEFA9`,"success-lighten-2":`#CFFFBD`,"success-lighten-3":`#E5FFD2`,"success-muted":`#4B5C55`,surface:`#363A4F`,"surface-active":`#43475D`,"surface-darken-1":`#25293D`,"surface-darken-2":`#151A2D`,"surface-darken-3":`#03061D`,"surface-lighten-1":`#474B60`,"surface-lighten-2":`#595C73`,"surface-lighten-3":`#6B6F86`,text:`#FFFFFFDD`,"text-accent":`#F8D3EE`,"text-disabled":`#FFFFFF60`,"text-error":`#F3AFB9`,"text-muted":`#FFFFFF99`,"text-primary":`#D9C0F9`,"text-secondary":`#F8C6AA`,"text-success":`#C4E6B9`,"text-warning":`#F3E2BF`,warning:`#EED49F`,"warning-darken-1":`#D8BF8B`,"warning-darken-2":`#C3AA77`,"warning-darken-3":`#AE9664`,"warning-lighten-1":`#FFE9B3`,"warning-lighten-2":`#FFFEC7`,"warning-lighten-3":`#FFFFDD`,"warning-muted":`#605A58`}},al={name:`catppuccin-mocha`,dark:!0,ansi:{black:`#45475A`,red:`#F38BA8`,green:`#A6E3A1`,yellow:`#F9E2AF`,blue:`#89B4FA`,magenta:`#F5C2E7`,cyan:`#94E2D5`,white:`#BAC2DE`,brightBlack:`#585B70`,brightRed:`#F7AEC2`,brightGreen:`#C2ECBF`,brightYellow:`#FCD682`,brightBlue:`#AECCFC`,brightMagenta:`#F398DA`,brightCyan:`#B1EAE1`,brightWhite:`#A6ADC8`},vars:{accent:`#F9B387`,"accent-darken-1":`#E39E73`,"accent-darken-2":`#CD8A60`,"accent-darken-3":`#B7774E`,"accent-lighten-1":`#FFC79A`,"accent-lighten-2":`#FFDCAE`,"accent-lighten-3":`#FFF2C3`,"accent-muted":`#5B4642`,background:`#181825`,"background-darken-1":`#040216`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#272735`,"background-lighten-2":`#373746`,"background-lighten-3":`#484857`,"block-cursor-background":`#F5C2E7`,"block-cursor-blurred-background":`#F5C2E74C`,"block-cursor-blurred-foreground":`#CDD6F4`,"block-cursor-foreground":`#1E1E2E`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#B4BEFE`,"border-blurred":`#585B70`,"button-color-foreground":`#181825`,"button-foreground":`#CDD6F4`,error:`#F28FAD`,"error-darken-1":`#DB7A99`,"error-darken-2":`#C66785`,"error-darken-3":`#B05372`,"error-lighten-1":`#FFA3C1`,"error-lighten-2":`#FFB8D6`,"error-lighten-3":`#FFCDEB`,"error-muted":`#593B4D`,"footer-background":`#45475A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#CDD6F4`,"footer-foreground":`#CDD6F4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FAB387`,foreground:`#CDD6F4`,"foreground-darken-1":`#B8C1DE`,"foreground-darken-2":`#A3ACC9`,"foreground-darken-3":`#8F98B4`,"foreground-disabled":`#CDD6F460`,"foreground-lighten-1":`#E2EBFF`,"foreground-lighten-2":`#F7FFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#CDD6F499`,"input-cursor-background":`#F5E0DC`,"input-cursor-foreground":`#11111B`,"input-selection-background":`#9399B24C`,"link-background":`#00000000`,"link-background-hover":`#F5C2E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#F5C2E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#F5C2E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#F5C2E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#CDD6F4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#CDD6F4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#CDD6F499`,panel:`#45475A`,"panel-darken-1":`#333648`,"panel-darken-2":`#232637`,"panel-darken-3":`#131627`,"panel-lighten-1":`#56586C`,"panel-lighten-2":`#696A7F`,"panel-lighten-3":`#7B7D92`,primary:`#F5C2E7`,"primary-background":`#564F5E`,"primary-background-darken-1":`#474050`,"primary-background-darken-2":`#393142`,"primary-background-darken-3":`#393142`,"primary-background-lighten-1":`#655F6C`,"primary-background-lighten-2":`#746E7A`,"primary-background-lighten-3":`#837E88`,"primary-darken-1":`#DFADD1`,"primary-darken-2":`#CA99BD`,"primary-darken-3":`#B585A8`,"primary-lighten-1":`#FFD6FC`,"primary-lighten-2":`#FFECFF`,"primary-lighten-3":`#FFFFFF`,"primary-muted":`#5A4B5F`,scrollbar:`#644E69`,"scrollbar-active":`#F5C2E7`,"scrollbar-background":`#040216`,"scrollbar-background-active":`#040216`,"scrollbar-background-hover":`#040216`,"scrollbar-corner-color":`#040216`,"scrollbar-hover":`#7C627E`,secondary:`#CBA6F7`,"secondary-background":`#504C60`,"secondary-background-darken-1":`#413C52`,"secondary-background-darken-2":`#322D44`,"secondary-background-darken-3":`#322D44`,"secondary-background-lighten-1":`#605C6E`,"secondary-background-lighten-2":`#6F6C7C`,"secondary-background-lighten-3":`#7E7B8A`,"secondary-darken-1":`#B592E1`,"secondary-darken-2":`#A17ECC`,"secondary-darken-3":`#8C6BB7`,"secondary-lighten-1":`#E0BAFF`,"secondary-lighten-2":`#F6CFFF`,"secondary-lighten-3":`#FFE4FF`,"secondary-muted":`#4D4264`,success:`#ABE9B3`,"success-darken-1":`#96D39E`,"success-darken-2":`#82BE8B`,"success-darken-3":`#6EAA77`,"success-lighten-1":`#BFFEC7`,"success-lighten-2":`#D5FFDC`,"success-lighten-3":`#EAFFF2`,"success-muted":`#44564F`,surface:`#313244`,"surface-active":`#3E3F51`,"surface-darken-1":`#202233`,"surface-darken-2":`#111223`,"surface-darken-3":`#000014`,"surface-lighten-1":`#414255`,"surface-lighten-2":`#535467`,"surface-lighten-3":`#65667A`,text:`#FFFFFFDD`,"text-accent":`#FBCCAF`,"text-disabled":`#FFFFFF60`,"text-error":`#F6B5C8`,"text-muted":`#FFFFFF99`,"text-primary":`#F8D6EF`,"text-secondary":`#DCC4F9`,"text-success":`#C7F0CC`,"text-warning":`#FBECCA`,warning:`#FAE3B0`,"warning-darken-1":`#E4CD9B`,"warning-darken-2":`#CEB988`,"warning-darken-3":`#B9A574`,"warning-lighten-1":`#FFF8C4`,"warning-lighten-2":`#FFFFD9`,"warning-lighten-3":`#FFFFEF`,"warning-muted":`#5B544E`}},ol=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],sl=Object.fromEntries(ol.map((e,t)=>[e,cc.get(t).hex])),cl={black:`#1A1A1A`,red:`#F4005F`,green:`#98E024`,yellow:`#FD971F`,blue:`#9D65FF`,magenta:`#F4005F`,cyan:`#58D1EB`,white:`#C4C5B5`,brightBlack:`#625E4C`,brightRed:`#F4005F`,brightGreen:`#98E024`,brightYellow:`#E0D561`,brightBlue:`#9D65FF`,brightMagenta:`#F4005F`,brightCyan:`#58D1EB`,brightWhite:`#F6F6EF`},ll={"atom-one-dark":el,"atom-one-light":tl,"catppuccin-frappe":nl,"catppuccin-latte":rl,"catppuccin-macchiato":il,"catppuccin-mocha":al,cyberpunk:{name:`cyberpunk`,dark:!0,ansi:cl,vars:{background:`#070714`,"background-darken-1":`#03030A`,"background-darken-2":`#000003`,"background-darken-3":`#000000`,"background-lighten-1":`#11111E`,"background-lighten-2":`#1A1A2B`,"background-lighten-3":`#25253A`,foreground:`#E2E2FF`,"foreground-darken-1":`#CACAE4`,"foreground-darken-2":`#B3B3CC`,"foreground-darken-3":`#9C9CB5`,"foreground-disabled":`#E2E2FF60`,"foreground-lighten-1":`#EEEEFF`,"foreground-lighten-2":`#F6F6FF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E2E2FF99`,primary:`#00E5FFD9`,"primary-darken-1":`#00CCE6D9`,"primary-darken-2":`#00B2CCD9`,"primary-darken-3":`#0099B3D9`,"primary-lighten-1":`#1AF0FFD9`,"primary-lighten-2":`#33F5FFD9`,"primary-lighten-3":`#4DFAFFD9`,"primary-muted":`#054A5BF4`,"primary-background":`#0A3340`,"primary-background-darken-1":`#072833`,"primary-background-darken-2":`#051E27`,"primary-background-darken-3":`#051E27`,"primary-background-lighten-1":`#0F404F`,"primary-background-lighten-2":`#154E5F`,"primary-background-lighten-3":`#1A5C6F`,secondary:`#FF1E8ECC`,"secondary-darken-1":`#E60A76CC`,"secondary-darken-2":`#CC005FCC`,"secondary-darken-3":`#B20048CC`,"secondary-lighten-1":`#FF3CA2CC`,"secondary-lighten-2":`#FF5AB6CC`,"secondary-lighten-3":`#FF78CACC`,"secondary-muted":`#510E39EF`,"secondary-background":`#3A0A28`,"secondary-background-darken-1":`#2E071F`,"secondary-background-darken-2":`#220517`,"secondary-background-darken-3":`#220517`,"secondary-background-lighten-1":`#470D33`,"secondary-background-lighten-2":`#54103F`,"secondary-background-lighten-3":`#61134B`,accent:`#EEFF00CC`,"accent-darken-1":`#D6E600CC`,"accent-darken-2":`#BECC00CC`,"accent-darken-3":`#A5B200CC`,"accent-lighten-1":`#FFFF26CC`,"accent-lighten-2":`#FFFF4DCC`,"accent-lighten-3":`#FFFF73CC`,"accent-muted":`#4C510EEF`,success:`#39FF14BF`,"success-darken-1":`#23E60ABF`,"success-darken-2":`#0FCC00BF`,"success-darken-3":`#00B200BF`,"success-lighten-1":`#4DFF32BF`,"success-lighten-2":`#69FF5ABF`,"success-lighten-3":`#87FF82BF`,"success-muted":`#164D14F0`,warning:`#FF6E00CC`,"warning-darken-1":`#E65800CC`,"warning-darken-2":`#CC4300CC`,"warning-darken-3":`#B23000CC`,"warning-lighten-1":`#FF8C26CC`,"warning-lighten-2":`#FFA54DCC`,"warning-lighten-3":`#FFBE73CC`,"warning-muted":`#51260EEF`,error:`#FF1133BF`,"error-darken-1":`#E6051EBF`,"error-darken-2":`#CC000CBF`,"error-darken-3":`#B20000BF`,"error-lighten-1":`#FF3758BF`,"error-lighten-2":`#FF5A78BF`,"error-lighten-3":`#FF7D96BF`,"error-muted":`#510A1DF0`,surface:`#0F0F22`,"surface-active":`#161630`,"surface-darken-1":`#08081A`,"surface-darken-2":`#040411`,"surface-darken-3":`#020209`,"surface-lighten-1":`#17172E`,"surface-lighten-2":`#1F1F3C`,"surface-lighten-3":`#28284A`,panel:`#0C0C1E`,"panel-darken-1":`#060614`,"panel-darken-2":`#03030C`,"panel-darken-3":`#010108`,"panel-lighten-1":`#14142C`,"panel-lighten-2":`#1C1C3A`,"panel-lighten-3":`#242448`,scrollbar:`#151535`,"scrollbar-active":`#00E5FFD9`,"scrollbar-background":`#040412`,"scrollbar-background-active":`#040412`,"scrollbar-background-hover":`#040412`,"scrollbar-corner-color":`#040412`,"scrollbar-hover":`#1F1F48`,"block-cursor-background":`#00E5FF`,"block-cursor-blurred-background":`#00E5FF4C`,"block-cursor-blurred-foreground":`#E2E2FF`,"block-cursor-foreground":`#070714`,"block-hover-background":`#00E5FF19`,boost:`#00E5FF0A`,"boost-darken-1":`#00CCE60A`,"boost-darken-2":`#00B2CC0A`,"boost-darken-3":`#0099B30A`,"boost-lighten-1":`#00E5FF0A`,"boost-lighten-2":`#00E5FF0A`,"boost-lighten-3":`#00E5FF0A`,border:`#00E5FFD9`,"border-blurred":`#1A1A35`,"button-color-foreground":`#070714`,"button-foreground":`#E2E2FF`,"footer-background":`#0C0C1E`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E2E2FF`,"footer-foreground":`#E2E2FF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#00E5FFD9`,"input-cursor-background":`#E2E2FF`,"input-cursor-foreground":`#070714`,"input-selection-background":`#00E5FF40`,"link-background":`#00000000`,"link-background-hover":`#00E5FFD9`,"link-color":`#E2E2FFDD`,"link-color-hover":`#070714`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#00E5FFD9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#00E5FFD9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#FF1E8ECC`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E2E2FF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E2E2FF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E2E2FF99`,text:`#E2E2FFDD`,"text-accent":`#F4FF66CC`,"text-disabled":`#E2E2FF60`,"text-error":`#FF6677BF`,"text-muted":`#E2E2FF99`,"text-primary":`#66F0FFD9`,"text-secondary":`#FF80B0CC`,"text-success":`#80FF55BF`,"text-warning":`#FFB055CC`}},default:{name:`default`,dark:!0,ansi:sl,vars:{accent:`#006FB8`,"accent-darken-1":`#005CA3`,"accent-darken-2":`#004B8F`,"accent-darken-3":`#003A7B`,"accent-lighten-1":`#3081CC`,"accent-lighten-2":`#4C95E2`,"accent-lighten-3":`#64A8F7`,"accent-muted":`#002137`,background:`#000000`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#161616`,"background-lighten-2":`#252525`,"background-lighten-3":`#353535`,"block-cursor-background":`#006FB8`,"block-cursor-blurred-background":`#006FB84C`,"block-cursor-blurred-foreground":`#FFFFFF`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#006FB8`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#FFFFFF`,error:`#7F0000`,"error-darken-1":`#6A0000`,"error-darken-2":`#560000`,"error-darken-3":`#450000`,"error-lighten-1":`#961E12`,"error-lighten-2":`#AD3423`,"error-lighten-3":`#C44934`,"error-muted":`#260000`,"footer-background":`#242E35`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FFFFFF`,"footer-foreground":`#FFFFFF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#006FB8`,foreground:`#FFFFFF`,"foreground-darken-1":`#E9E9E9`,"foreground-darken-2":`#D4D4D4`,"foreground-darken-3":`#BFBFBF`,"foreground-disabled":`#FFFFFF60`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FFFFFF99`,"input-cursor-background":`#FFFFFF`,"input-cursor-foreground":`#000000`,"input-selection-background":`#3081CC66`,"link-background":`#00000000`,"link-background-hover":`#006FB8`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#006FB8`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#006FB8`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#006FB8`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FFFFFF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FFFFFF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FFFFFF99`,panel:`#242E35`,"panel-darken-1":`#141E24`,"panel-darken-2":`#000D15`,"panel-darken-3":`#000000`,"panel-lighten-1":`#343E45`,"panel-lighten-2":`#454F57`,"panel-lighten-3":`#566169`,primary:`#006FB8`,"primary-background":`#26333D`,"primary-background-darken-1":`#13212C`,"primary-background-darken-2":`#00101B`,"primary-background-darken-3":`#00101B`,"primary-background-lighten-1":`#39454E`,"primary-background-lighten-2":`#4C575F`,"primary-background-lighten-3":`#5F6970`,"primary-darken-1":`#005CA3`,"primary-darken-2":`#004B8F`,"primary-darken-3":`#003A7B`,"primary-lighten-1":`#3081CC`,"primary-lighten-2":`#4C95E2`,"primary-lighten-3":`#64A8F7`,"primary-muted":`#002137`,scrollbar:`#002C49`,"scrollbar-active":`#006FB8`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#00375C`,secondary:`#762671`,"secondary-background":`#342A33`,"secondary-background-darken-1":`#221721`,"secondary-background-darken-2":`#110510`,"secondary-background-darken-3":`#110510`,"secondary-background-lighten-1":`#463D45`,"secondary-background-lighten-2":`#585057`,"secondary-background-lighten-3":`#6A6269`,"secondary-darken-1":`#620F5E`,"secondary-darken-2":`#4E004C`,"secondary-darken-3":`#3B003A`,"secondary-lighten-1":`#8A3984`,"secondary-lighten-2":`#9E4C97`,"secondary-lighten-3":`#B360AB`,"secondary-muted":`#230B21`,success:`#008000`,"success-darken-1":`#006C00`,"success-darken-2":`#005900`,"success-darken-3":`#004600`,"success-lighten-1":`#29931C`,"success-lighten-2":`#42A832`,"success-lighten-3":`#58BD46`,"success-muted":`#002600`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#569FD0`,"text-disabled":`#FFFFFF60`,"text-error":`#AB5656`,"text-muted":`#FFFFFF99`,"text-primary":`#569FD0`,"text-secondary":`#A46FA1`,"text-success":`#56AB56`,"text-warning":`#ABAB56`,warning:`#7F8000`,"warning-darken-1":`#6B6D00`,"warning-darken-2":`#575A00`,"warning-darken-3":`#454900`,"warning-lighten-1":`#94931E`,"warning-lighten-2":`#A9A734`,"warning-lighten-3":`#BFBB48`,"warning-muted":`#262600`}},dracula:{name:`dracula`,dark:!0,ansi:{black:`#21222C`,red:`#FF5555`,green:`#50FA7B`,yellow:`#F1FA8C`,blue:`#BD93F9`,magenta:`#FF79C6`,cyan:`#8BE9FD`,white:`#F8F8F2`,brightBlack:`#6272A4`,brightRed:`#FF6E6E`,brightGreen:`#69FF94`,brightYellow:`#FFFFA5`,brightBlue:`#D6ACFF`,brightMagenta:`#FF92DF`,brightCyan:`#A4FFFF`,brightWhite:`#FFFFFF`},vars:{accent:`#FF79C6`,"accent-darken-1":`#E864B1`,"accent-darken-2":`#D24F9D`,"accent-darken-3":`#BC3989`,"accent-lighten-1":`#FF8DDA`,"accent-lighten-2":`#FFA3F0`,"accent-lighten-3":`#FFB8FF`,"accent-muted":`#684161`,background:`#282A36`,"background-darken-1":`#181A25`,"background-darken-2":`#050716`,"background-darken-3":`#000000`,"background-lighten-1":`#383A46`,"background-lighten-2":`#494B58`,"background-lighten-3":`#5B5D6A`,"block-cursor-background":`#BD93F9`,"block-cursor-blurred-background":`#BD93F94C`,"block-cursor-blurred-foreground":`#F8F8F2`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BD93F9`,"border-blurred":`#252835`,"button-color-foreground":`#282A36`,"button-foreground":`#F8F8F2`,error:`#FE5555`,"error-darken-1":`#E63E43`,"error-darken-2":`#CE2332`,"error-darken-3":`#B70022`,"error-lighten-1":`#FF6A67`,"error-lighten-2":`#FF807A`,"error-lighten-3":`#FF958D`,"error-muted":`#68363F`,"footer-background":`#313442`,"footer-description-background":`#00000000`,"footer-description-foreground":`#F8F8F2`,"footer-foreground":`#F8F8F2`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FF79C6`,foreground:`#F8F8F2`,"foreground-darken-1":`#E2E2DC`,"foreground-darken-2":`#CDCDC7`,"foreground-darken-3":`#B8B8B3`,"foreground-disabled":`#F8F8F260`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#F8F8F299`,"input-cursor-background":`#F8F8F2`,"input-cursor-foreground":`#282A36`,"input-selection-background":`#D2A7FF66`,"link-background":`#00000000`,"link-background-hover":`#BD93F9`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#BD93F9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#BD93F9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#BD93F9`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#F8F8F2`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#F8F8F2`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#F8F8F299`,panel:`#313442`,"panel-darken-1":`#202431`,"panel-darken-2":`#111421`,"panel-darken-3":`#000012`,"panel-lighten-1":`#414453`,"panel-lighten-2":`#535665`,"panel-lighten-3":`#656878`,primary:`#BD93F9`,"primary-background":`#5A566C`,"primary-background-darken-1":`#4C475F`,"primary-background-darken-2":`#3E3953`,"primary-background-darken-3":`#3E3953`,"primary-background-lighten-1":`#696579`,"primary-background-lighten-2":`#777486`,"primary-background-lighten-3":`#868393`,"primary-darken-1":`#A77FE3`,"primary-darken-2":`#936CCE`,"primary-darken-3":`#7E59B9`,"primary-lighten-1":`#D2A7FF`,"primary-lighten-2":`#E8BBFF`,"primary-lighten-3":`#FED0FF`,"primary-muted":`#544970`,scrollbar:`#5A4A79`,"scrollbar-active":`#BD93F9`,"scrollbar-background":`#181A25`,"scrollbar-background-active":`#181A25`,"scrollbar-background-hover":`#181A25`,"scrollbar-corner-color":`#181A25`,"scrollbar-hover":`#6A568F`,secondary:`#6272A4`,"secondary-background":`#4F5261`,"secondary-background-darken-1":`#3F4353`,"secondary-background-darken-2":`#303446`,"secondary-background-darken-3":`#303446`,"secondary-background-lighten-1":`#5E616F`,"secondary-background-lighten-2":`#6E707D`,"secondary-background-lighten-3":`#7D808B`,"secondary-darken-1":`#4E5F90`,"secondary-darken-2":`#3B4D7C`,"secondary-darken-3":`#283C69`,"secondary-lighten-1":`#7584B8`,"secondary-lighten-2":`#8998CD`,"secondary-lighten-3":`#9DACE2`,"secondary-muted":`#393F57`,success:`#50FA7B`,"success-darken-1":`#2FE467`,"success-darken-2":`#00CE53`,"success-darken-3":`#00B83F`,"success-lighten-1":`#6AFF8F`,"success-lighten-2":`#83FFA3`,"success-lighten-3":`#9BFFB8`,"success-muted":`#34684A`,surface:`#2B2E3B`,"surface-active":`#383B48`,"surface-darken-1":`#1B1E2A`,"surface-darken-2":`#0A0D1B`,"surface-darken-3":`#000009`,"surface-lighten-1":`#3B3E4C`,"surface-lighten-2":`#4C4F5D`,"surface-lighten-3":`#5E6170`,text:`#FFFFFFDD`,"text-accent":`#FFA6D9`,"text-disabled":`#FFFFFF60`,"text-error":`#FF8E8E`,"text-muted":`#FFFFFF99`,"text-primary":`#D3B7FB`,"text-secondary":`#97A1C2`,"text-success":`#8BFBA7`,"text-warning":`#FFD09D`,warning:`#FEB86C`,"warning-darken-1":`#E8A358`,"warning-darken-2":`#D18F45`,"warning-darken-3":`#BB7C33`,"warning-lighten-1":`#FFCC7F`,"warning-lighten-2":`#FFE193`,"warning-lighten-3":`#FFF7A7`,"warning-muted":`#685446`}},flexoki:{name:`flexoki`,dark:!0,ansi:{black:`#100F0F`,red:`#D14D41`,green:`#879A39`,yellow:`#D0A215`,blue:`#4385BE`,magenta:`#CE5D97`,cyan:`#3AA99F`,white:`#878580`,brightBlack:`#575653`,brightRed:`#AF3029`,brightGreen:`#66800B`,brightYellow:`#AD8301`,brightBlue:`#205EA6`,brightMagenta:`#A02F6F`,brightCyan:`#24837B`,brightWhite:`#CECDC3`},vars:{accent:`#9B76C8`,"accent-darken-1":`#8663B3`,"accent-darken-2":`#72509E`,"accent-darken-3":`#5F3E8B`,"accent-lighten-1":`#AF89DD`,"accent-lighten-2":`#C49DF2`,"accent-lighten-3":`#D9B1FF`,"accent-muted":`#392D46`,background:`#100F0F`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#1F1F1F`,"background-lighten-2":`#2F2E2E`,"background-lighten-3":`#403F3F`,"block-cursor-background":`#205EA6`,"block-cursor-blurred-background":`#205EA64C`,"block-cursor-blurred-foreground":`#FFFCF0`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#205EA6`,"border-blurred":`#171614`,"button-color-foreground":`#FFFCF0`,"button-foreground":`#FFFCF0`,error:`#AE3029`,"error-darken-1":`#981818`,"error-darken-2":`#810007`,"error-darken-3":`#6B0000`,"error-lighten-1":`#C64539`,"error-lighten-2":`#DD594B`,"error-lighten-3":`#F46D5D`,"error-muted":`#3F1816`,"footer-background":`#282726`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FFFCF0`,"footer-foreground":`#FFFCF0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#9B76C8`,foreground:`#FFFCF0`,"foreground-darken-1":`#E9E6DA`,"foreground-darken-2":`#D4D1C5`,"foreground-darken-3":`#BFBCB1`,"foreground-disabled":`#FFFCF060`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FFFCF099`,"input-cursor-background":`#FFFCF0`,"input-cursor-foreground":`#5E409D`,"input-selection-background":`#6F6E6959`,"link-background":`#00000000`,"link-background-hover":`#205EA6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#205EA6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#205EA6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#205EA6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FFFCF0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FFFCF0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FFFCF099`,panel:`#282726`,"panel-darken-1":`#181716`,"panel-darken-2":`#040200`,"panel-darken-3":`#000000`,"panel-lighten-1":`#383736`,"panel-lighten-2":`#494846`,"panel-lighten-3":`#5A5958`,primary:`#205EA6`,"primary-background":`#353C45`,"primary-background-darken-1":`#232B35`,"primary-background-darken-2":`#121A25`,"primary-background-darken-3":`#121A25`,"primary-background-lighten-1":`#474D56`,"primary-background-lighten-2":`#595E66`,"primary-background-lighten-3":`#6A6F76`,"primary-darken-1":`#004C91`,"primary-darken-2":`#003B7E`,"primary-darken-3":`#002B6B`,"primary-lighten-1":`#3C70BA`,"primary-lighten-2":`#5383CF`,"primary-lighten-3":`#6996E4`,"primary-muted":`#14263C`,scrollbar:`#0C2542`,"scrollbar-active":`#205EA6`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#102F53`,secondary:`#24837B`,"secondary-background":`#364140`,"secondary-background-darken-1":`#24302F`,"secondary-background-darken-2":`#13201F`,"secondary-background-darken-3":`#13201F`,"secondary-background-lighten-1":`#485251`,"secondary-background-lighten-2":`#596262`,"secondary-background-lighten-3":`#6B7373`,"secondary-darken-1":`#006F68`,"secondary-darken-2":`#005D56`,"secondary-darken-3":`#004A44`,"secondary-lighten-1":`#3C968E`,"secondary-lighten-2":`#52AAA1`,"secondary-lighten-3":`#67BFB6`,"secondary-muted":`#16312F`,success:`#65800B`,"success-darken-1":`#526D00`,"success-darken-2":`#3E5A00`,"success-darken-3":`#2D4800`,"success-lighten-1":`#7A9324`,"success-lighten-2":`#8EA738`,"success-lighten-3":`#A3BB4C`,"success-muted":`#29300D`,surface:`#1C1B1A`,"surface-active":`#282726`,"surface-darken-1":`#0A0806`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2B2A29`,"surface-lighten-2":`#3B3A39`,"surface-lighten-3":`#4D4B4A`,text:`#FFFFFFDD`,"text-accent":`#BDA4DA`,"text-disabled":`#FFFFFF60`,"text-error":`#CA7671`,"text-muted":`#FFFFFF99`,"text-primary":`#6B94C4`,"text-secondary":`#6EADA7`,"text-success":`#9AAB5D`,"text-warning":`#C8AD57`,warning:`#AC8301`,"warning-darken-1":`#977000`,"warning-darken-2":`#815D00`,"warning-darken-3":`#6C4C00`,"warning-lighten-1":`#C39621`,"warning-lighten-2":`#D9AA37`,"warning-lighten-3":`#F0BE4B`,"warning-muted":`#3F310A`}},gruvbox:{name:`gruvbox`,dark:!0,ansi:{black:`#282828`,red:`#CC241D`,green:`#98971A`,yellow:`#D79921`,blue:`#458588`,magenta:`#B16286`,cyan:`#689D6A`,white:`#A89984`,brightBlack:`#928374`,brightRed:`#FB4934`,brightGreen:`#B8BB26`,brightYellow:`#FABD2F`,brightBlue:`#83A598`,brightMagenta:`#D3869B`,brightCyan:`#8EC07C`,brightWhite:`#EBDBB2`},vars:{accent:`#F9BD2F`,"accent-darken-1":`#E2A811`,"accent-darken-2":`#CB9400`,"accent-darken-3":`#B48100`,"accent-lighten-1":`#FFD146`,"accent-lighten-2":`#FFE65B`,"accent-lighten-3":`#FFFC70`,"accent-muted":`#67542A`,background:`#282828`,"background-darken-1":`#181818`,"background-darken-2":`#040404`,"background-darken-3":`#000000`,"background-lighten-1":`#383838`,"background-lighten-2":`#494949`,"background-lighten-3":`#5A5A5A`,"block-cursor-background":`#85A598`,"block-cursor-blurred-background":`#85A5984C`,"block-cursor-blurred-foreground":`#FBF1C7`,"block-cursor-foreground":`#FBF1C7`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#85A598`,"border-blurred":`#363230`,"button-color-foreground":`#282828`,"button-foreground":`#FBF1C7`,error:`#FA4934`,"error-darken-1":`#E23022`,"error-darken-2":`#C90D10`,"error-darken-3":`#B10000`,"error-lighten-1":`#FF5F45`,"error-lighten-2":`#FF7558`,"error-lighten-3":`#FF8B6B`,"error-muted":`#67312B`,"footer-background":`#504945`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FBF1C7`,"footer-foreground":`#FBF1C7`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FABD2F`,foreground:`#FBF1C7`,"foreground-darken-1":`#E5DBB2`,"foreground-darken-2":`#D0C69E`,"foreground-darken-3":`#BBB28A`,"foreground-disabled":`#FBF1C760`,"foreground-lighten-1":`#FFFFDC`,"foreground-lighten-2":`#FFFFF1`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FBF1C799`,"input-cursor-background":`#FBF1C7`,"input-cursor-foreground":`#282828`,"input-selection-background":`#689D6A40`,"link-background":`#00000000`,"link-background-hover":`#85A598`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#85A598`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#85A598`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#85A598`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FBF1C7`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FBF1C7`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FBF1C799`,panel:`#504945`,"panel-darken-1":`#3E3834`,"panel-darken-2":`#2E2724`,"panel-darken-3":`#1E1815`,"panel-lighten-1":`#615A56`,"panel-lighten-2":`#746C68`,"panel-lighten-3":`#877F7B`,primary:`#85A598`,"primary-background":`#535755`,"primary-background-darken-1":`#444846`,"primary-background-darken-2":`#353A38`,"primary-background-darken-3":`#353A38`,"primary-background-lighten-1":`#626664`,"primary-background-lighten-2":`#717573`,"primary-background-lighten-3":`#808382`,"primary-darken-1":`#719184`,"primary-darken-2":`#5F7D71`,"primary-darken-3":`#4C6A5F`,"primary-lighten-1":`#98B9AB`,"primary-lighten-2":`#ACCEC0`,"primary-lighten-3":`#C1E3D5`,"primary-muted":`#434D49`,scrollbar:`#43504B`,"scrollbar-active":`#85A598`,"scrollbar-background":`#181818`,"scrollbar-background-active":`#181818`,"scrollbar-background-hover":`#181818`,"scrollbar-corner-color":`#181818`,"scrollbar-hover":`#4E5E58`,secondary:`#A89A85`,"secondary-background":`#585653`,"secondary-background-darken-1":`#494744`,"secondary-background-darken-2":`#3B3935`,"secondary-background-darken-3":`#3B3935`,"secondary-background-lighten-1":`#676562`,"secondary-background-lighten-2":`#757471`,"secondary-background-lighten-3":`#848380`,"secondary-darken-1":`#938671`,"secondary-darken-2":`#80735F`,"secondary-darken-3":`#6D604D`,"secondary-lighten-1":`#BCAE98`,"secondary-lighten-2":`#D1C2AC`,"secondary-lighten-3":`#E6D7C1`,"secondary-muted":`#4E4A43`,success:`#B7BB26`,"success-darken-1":`#A2A601`,"success-darken-2":`#8C9300`,"success-darken-3":`#777F00`,"success-lighten-1":`#CDCF3D`,"success-lighten-2":`#E4E453`,"success-lighten-3":`#FAFA68`,"success-muted":`#535427`,surface:`#3C3836`,"surface-active":`#494543`,"surface-darken-1":`#2B2725`,"surface-darken-2":`#1C1816`,"surface-darken-3":`#0A0300`,"surface-lighten-1":`#4D4846`,"surface-lighten-2":`#5F5A58`,"surface-lighten-3":`#716C6A`,text:`#FFFFFFDD`,"text-accent":`#FBD375`,"text-disabled":`#FFFFFF60`,"text-error":`#FC8679`,"text-muted":`#FFFFFF99`,"text-primary":`#AEC3BB`,"text-secondary":`#C5BCAE`,"text-success":`#D0D26F`,"text-warning":`#FEAB67`,warning:`#FD8019`,"warning-darken-1":`#E56C00`,"warning-darken-2":`#CD5800`,"warning-darken-3":`#B54500`,"warning-lighten-1":`#FF9430`,"warning-lighten-2":`#FFA845`,"warning-lighten-3":`#FFBD5A`,"warning-muted":`#684223`}},monokai:{name:`monokai`,dark:!0,ansi:{black:`#333333`,red:`#C4265E`,green:`#86B42B`,yellow:`#B3B42B`,blue:`#6A7EC8`,magenta:`#8C6BC8`,cyan:`#56ADBC`,white:`#E3E3DD`,brightBlack:`#666666`,brightRed:`#F92672`,brightGreen:`#A6E22E`,brightYellow:`#E2E22E`,brightBlue:`#819AFF`,brightMagenta:`#AE81FF`,brightCyan:`#66D9EF`,brightWhite:`#F8F8F2`},vars:{accent:`#66D9EF`,"accent-darken-1":`#4DC3D9`,"accent-darken-2":`#31AFC4`,"accent-darken-3":`#009BB0`,"accent-lighten-1":`#7DEEFF`,"accent-lighten-2":`#94FFFF`,"accent-lighten-3":`#AAFFFF`,"accent-muted":`#395D5F`,background:`#272822`,"background-darken-1":`#171812`,"background-darken-2":`#020400`,"background-darken-3":`#000000`,"background-lighten-1":`#373831`,"background-lighten-2":`#484942`,"background-lighten-3":`#595A54`,"block-cursor-background":`#AE81FF`,"block-cursor-blurred-background":`#AE81FF4C`,"block-cursor-blurred-foreground":`#D6D6D6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#AE81FF`,"border-blurred":`#282828`,"button-color-foreground":`#272822`,"button-foreground":`#D6D6D6`,error:`#F82672`,"error-darken-1":`#E1005F`,"error-darken-2":`#C9004E`,"error-darken-3":`#B1003D`,"error-lighten-1":`#FF4484`,"error-lighten-2":`#FF5D98`,"error-lighten-3":`#FF75AC`,"error-muted":`#66273A`,"footer-background":`#3E3D32`,"footer-description-background":`#00000000`,"footer-description-foreground":`#D6D6D6`,"footer-foreground":`#D6D6D6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#66D9EF`,foreground:`#D6D6D6`,"foreground-darken-1":`#C1C1C1`,"foreground-darken-2":`#ACACAC`,"foreground-darken-3":`#989898`,"foreground-disabled":`#D6D6D660`,"foreground-lighten-1":`#EBEBEB`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#797979`,"input-cursor-background":`#D6D6D6`,"input-cursor-foreground":`#272822`,"input-selection-background":`#575B6190`,"link-background":`#00000000`,"link-background-hover":`#AE81FF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#AE81FF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#AE81FF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#AE81FF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#D6D6D6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#D6D6D6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#797979`,panel:`#3E3D32`,"panel-darken-1":`#2D2C22`,"panel-darken-2":`#1D1C12`,"panel-darken-3":`#0D0B00`,"panel-lighten-1":`#4F4E42`,"panel-lighten-2":`#616054`,"panel-lighten-3":`#737266`,primary:`#AE81FF`,"primary-background":`#58535F`,"primary-background-darken-1":`#494451`,"primary-background-darken-2":`#3B3543`,"primary-background-darken-3":`#3B3543`,"primary-background-lighten-1":`#67626D`,"primary-background-lighten-2":`#75717B`,"primary-background-lighten-3":`#848089`,"primary-darken-1":`#986DE9`,"primary-darken-2":`#835AD3`,"primary-darken-3":`#6E48BE`,"primary-lighten-1":`#C394FF`,"primary-lighten-2":`#D9A9FF`,"primary-lighten-3":`#EFBDFF`,"primary-muted":`#4F4264`,scrollbar:`#534270`,"scrollbar-active":`#AE81FF`,"scrollbar-background":`#171812`,"scrollbar-background-active":`#171812`,"scrollbar-background-hover":`#171812`,"scrollbar-corner-color":`#171812`,"scrollbar-hover":`#624C88`,secondary:`#F82672`,"secondary-background":`#61474D`,"secondary-background-darken-1":`#53373D`,"secondary-background-darken-2":`#46272E`,"secondary-background-darken-3":`#46272E`,"secondary-background-lighten-1":`#6F575D`,"secondary-background-lighten-2":`#7D676C`,"secondary-background-lighten-3":`#8B787C`,"secondary-darken-1":`#E1005F`,"secondary-darken-2":`#C9004E`,"secondary-darken-3":`#B1003D`,"secondary-lighten-1":`#FF4484`,"secondary-lighten-2":`#FF5D98`,"secondary-lighten-3":`#FF75AC`,"secondary-muted":`#66273A`,success:`#A5E22E`,"success-darken-1":`#90CC09`,"success-darken-2":`#7AB700`,"success-darken-3":`#64A300`,"success-lighten-1":`#BBF746`,"success-lighten-2":`#D2FF5D`,"success-lighten-3":`#E8FF72`,"success-muted":`#4D5F25`,surface:`#2E2E2E`,"surface-active":`#3B3B3B`,"surface-darken-1":`#1E1E1E`,"surface-darken-2":`#0D0D0D`,"surface-darken-3":`#000000`,"surface-lighten-1":`#3E3E3E`,"surface-lighten-2":`#4F4F4F`,"surface-lighten-3":`#616161`,text:`#FFFFFFDD`,"text-accent":`#9AE5F4`,"text-disabled":`#FFFFFF60`,"text-error":`#FB6FA1`,"text-muted":`#FFFFFF99`,"text-primary":`#C9ABFF`,"text-secondary":`#FB6FA1`,"text-success":`#C4EB75`,"text-warning":`#FDBA6B`,warning:`#FC971F`,"warning-darken-1":`#E58300`,"warning-darken-2":`#CD6F00`,"warning-darken-3":`#B65D00`,"warning-lighten-1":`#FFAB36`,"warning-lighten-2":`#FFBF4C`,"warning-lighten-3":`#FFD460`,"warning-muted":`#674921`}},nord:{name:`nord`,dark:!0,ansi:{black:`#3B4252`,red:`#BF616A`,green:`#A3BE8C`,yellow:`#EBCB8B`,blue:`#81A1C1`,magenta:`#B48EAD`,cyan:`#88C0D0`,white:`#E5E9F0`,brightBlack:`#596377`,brightRed:`#BF616A`,brightGreen:`#A3BE8C`,brightYellow:`#EBCB8B`,brightBlue:`#81A1C1`,brightMagenta:`#B48EAD`,brightCyan:`#8FBCBB`,brightWhite:`#ECEFF4`},vars:{accent:`#B48EAD`,"accent-darken-1":`#9F7A98`,"accent-darken-2":`#8B6785`,"accent-darken-3":`#785572`,"accent-lighten-1":`#C8A1C1`,"accent-lighten-2":`#DDB6D6`,"accent-lighten-3":`#F3CAEB`,"accent-muted":`#564F60`,background:`#2E3440`,"background-darken-1":`#1E242F`,"background-darken-2":`#0E141F`,"background-darken-3":`#000010`,"background-lighten-1":`#3E4451`,"background-lighten-2":`#505663`,"background-lighten-3":`#626875`,"block-cursor-background":`#88C0D0`,"block-cursor-blurred-background":`#88C0D04C`,"block-cursor-blurred-foreground":`#D8DEE9`,"block-cursor-foreground":`#2E3440`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#88C0D0`,"border-blurred":`#353C4C`,"button-color-foreground":`#2E3440`,"button-foreground":`#D8DEE9`,error:`#BE616A`,"error-darken-1":`#A94D57`,"error-darken-2":`#933A46`,"error-darken-3":`#7E2735`,"error-lighten-1":`#D4747C`,"error-lighten-2":`#EB8890`,"error-lighten-3":`#FF9CA3`,"error-muted":`#59414C`,"footer-background":`#434C5E`,"footer-description-background":`#00000000`,"footer-description-foreground":`#D8DEE9`,"footer-foreground":`#D8DEE9`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#88C0D0`,foreground:`#D8DEE9`,"foreground-darken-1":`#C3C9D3`,"foreground-darken-2":`#AEB4BF`,"foreground-darken-3":`#9AA0AA`,"foreground-disabled":`#D8DEE960`,"foreground-lighten-1":`#EDF3FE`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#D8DEE999`,"input-cursor-background":`#D8DEE9`,"input-cursor-foreground":`#2E3440`,"input-selection-background":`#81A1C159`,"link-background":`#00000000`,"link-background-hover":`#88C0D0`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#88C0D0`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#88C0D0`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#88C0D0`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#D8DEE9`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#D8DEE9`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#D8DEE999`,panel:`#434C5E`,"panel-darken-1":`#313A4C`,"panel-darken-2":`#212A3A`,"panel-darken-3":`#111B2A`,"panel-lighten-1":`#545D70`,"panel-lighten-2":`#677083`,"panel-lighten-3":`#798396`,primary:`#88C0D0`,"primary-background":`#58646E`,"primary-background-darken-1":`#495661`,"primary-background-darken-2":`#3B4955`,"primary-background-darken-3":`#3B4955`,"primary-background-lighten-1":`#67717B`,"primary-background-lighten-2":`#757F88`,"primary-background-lighten-3":`#848D94`,"primary-darken-1":`#73ABBB`,"primary-darken-2":`#5F97A6`,"primary-darken-3":`#4B8393`,"primary-lighten-1":`#9CD4E5`,"primary-lighten-2":`#B1EAFA`,"primary-lighten-3":`#C6FFFF`,"primary-muted":`#495E6B`,scrollbar:`#48626F`,"scrollbar-active":`#88C0D0`,"scrollbar-background":`#1E242F`,"scrollbar-background-active":`#1E242F`,"scrollbar-background-hover":`#1E242F`,"scrollbar-corner-color":`#1E242F`,"scrollbar-hover":`#53727F`,secondary:`#81A1C1`,"secondary-background":`#57606C`,"secondary-background-darken-1":`#48525F`,"secondary-background-darken-2":`#3A4453`,"secondary-background-darken-3":`#3A4453`,"secondary-background-lighten-1":`#666E79`,"secondary-background-lighten-2":`#757C86`,"secondary-background-lighten-3":`#838A93`,"secondary-darken-1":`#6D8DAC`,"secondary-darken-2":`#597A98`,"secondary-darken-3":`#466784`,"secondary-lighten-1":`#95B5D5`,"secondary-lighten-2":`#A9C9EB`,"secondary-lighten-3":`#BEDEFF`,"secondary-muted":`#465466`,success:`#A3BE8C`,"success-darken-1":`#8FA978`,"success-darken-2":`#7B9565`,"success-darken-3":`#688253`,"success-lighten-1":`#B7D29F`,"success-lighten-2":`#CCE8B4`,"success-lighten-3":`#E1FDC8`,"success-muted":`#515D56`,surface:`#3B4252`,"surface-active":`#484F60`,"surface-darken-1":`#2A3140`,"surface-darken-2":`#1A212F`,"surface-darken-3":`#0A1120`,"surface-lighten-1":`#4C5364`,"surface-lighten-2":`#5E6576`,"surface-lighten-3":`#707889`,text:`#FFFFFFDD`,"text-accent":`#CDB4C8`,"text-disabled":`#FFFFFF60`,"text-error":`#D4969C`,"text-muted":`#FFFFFF99`,"text-primary":`#B0D5DF`,"text-secondary":`#ABC0D6`,"text-success":`#C2D4B3`,"text-warning":`#F1DCB2`,warning:`#EACB8B`,"warning-darken-1":`#D5B677`,"warning-darken-2":`#BFA264`,"warning-darken-3":`#AA8E51`,"warning-lighten-1":`#FFE09E`,"warning-lighten-2":`#FFF5B3`,"warning-lighten-3":`#FFFFC8`,"warning-muted":`#666156`}},"rose-pine":{name:`rose-pine`,dark:!0,ansi:{black:`#26233A`,red:`#EB6F92`,green:`#31748F`,yellow:`#F6C177`,blue:`#9CCFD8`,magenta:`#C4A7E7`,cyan:`#EBBCBA`,white:`#E0DEF4`,brightBlack:`#6E6A86`,brightRed:`#EB6F92`,brightGreen:`#31748F`,brightYellow:`#F6C177`,brightBlue:`#9CCFD8`,brightMagenta:`#C4A7E7`,brightCyan:`#EBBCBA`,brightWhite:`#E0DEF4`},vars:{accent:`#EBBCBA`,"accent-darken-1":`#D5A7A5`,"accent-darken-2":`#C09391`,"accent-darken-3":`#AB807E`,"accent-lighten-1":`#FFD0CE`,"accent-lighten-2":`#FFE5E3`,"accent-lighten-3":`#FFFBF9`,"accent-muted":`#584851`,background:`#191724`,"background-darken-1":`#060015`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#282634`,"background-lighten-2":`#383644`,"background-lighten-3":`#4A4756`,"block-cursor-background":`#C4A7E7`,"block-cursor-blurred-background":`#C4A7E74C`,"block-cursor-blurred-foreground":`#E0DEF4`,"block-cursor-foreground":`#191724`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#524F67`,"border-blurred":`#6E6A86`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0DEF4`,error:`#EA6F92`,"error-darken-1":`#D45A7E`,"error-darken-2":`#BE466B`,"error-darken-3":`#A83159`,"error-lighten-1":`#FF83A5`,"error-lighten-2":`#FF98BA`,"error-lighten-3":`#FFADCE`,"error-muted":`#583145`,"footer-background":`#26233A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0DEF4`,"footer-foreground":`#E0DEF4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#EBBCBA`,foreground:`#E0DEF4`,"foreground-darken-1":`#CAC9DE`,"foreground-darken-2":`#B6B4C9`,"foreground-darken-3":`#A2A0B4`,"foreground-disabled":`#E0DEF460`,"foreground-lighten-1":`#F5F3FF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0DEF499`,"input-cursor-background":`#F4EDE8`,"input-cursor-foreground":`#191724`,"input-selection-background":`#403D52`,"link-background":`#00000000`,"link-background-hover":`#C4A7E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C4A7E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C4A7E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C4A7E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0DEF4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0DEF4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0DEF499`,panel:`#26233A`,"panel-darken-1":`#161329`,"panel-darken-2":`#04001A`,"panel-darken-3":`#000008`,"panel-lighten-1":`#36324B`,"panel-lighten-2":`#47435D`,"panel-lighten-3":`#59556F`,primary:`#C4A7E7`,"primary-background":`#504B5D`,"primary-background-darken-1":`#413B4F`,"primary-background-darken-2":`#322C41`,"primary-background-darken-3":`#322C41`,"primary-background-lighten-1":`#605B6B`,"primary-background-lighten-2":`#6F6B7A`,"primary-background-lighten-3":`#7E7B88`,"primary-darken-1":`#AF93D1`,"primary-darken-2":`#9A7FBC`,"primary-darken-3":`#866CA8`,"primary-lighten-1":`#D9BBFC`,"primary-lighten-2":`#EED0FF`,"primary-lighten-3":`#FFE5FF`,"primary-muted":`#4C425E`,scrollbar:`#524269`,"scrollbar-active":`#C4A7E7`,"scrollbar-background":`#060015`,"scrollbar-background-active":`#060015`,"scrollbar-background-hover":`#060015`,"scrollbar-corner-color":`#060015`,"scrollbar-hover":`#65537E`,secondary:`#31748F`,"secondary-background":`#3E4452`,"secondary-background-darken-1":`#2D3443`,"secondary-background-darken-2":`#1C2434`,"secondary-background-darken-3":`#1C2434`,"secondary-background-lighten-1":`#4F5561`,"secondary-background-lighten-2":`#606570`,"secondary-background-lighten-3":`#717680`,"secondary-darken-1":`#17617B`,"secondary-darken-2":`#004F68`,"secondary-darken-3":`#003E56`,"secondary-lighten-1":`#4687A2`,"secondary-lighten-2":`#5B9AB7`,"secondary-lighten-3":`#70AECB`,"secondary-muted":`#203244`,success:`#9CCFD8`,"success-darken-1":`#87BAC3`,"success-darken-2":`#73A5AE`,"success-darken-3":`#60929A`,"success-lighten-1":`#B0E4ED`,"success-lighten-2":`#C5F9FF`,"success-lighten-3":`#DAFFFF`,"success-muted":`#404E5A`,surface:`#1F1D2E`,"surface-active":`#2B293B`,"surface-darken-1":`#100B1E`,"surface-darken-2":`#00000E`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2F2C3E`,"surface-lighten-2":`#3F3D4F`,"surface-lighten-3":`#514E61`,text:`#FFFFFFDD`,"text-accent":`#F1D2D1`,"text-disabled":`#FFFFFF60`,"text-error":`#F19FB7`,"text-muted":`#FFFFFF99`,"text-primary":`#D8C4EF`,"text-secondary":`#77A3B5`,"text-success":`#BDDFE5`,"text-warning":`#F9D6A5`,warning:`#F5C177`,"warning-darken-1":`#DFAC63`,"warning-darken-2":`#C99850`,"warning-darken-3":`#B3853E`,"warning-lighten-1":`#FFD58A`,"warning-lighten-2":`#FFEB9E`,"warning-lighten-3":`#FFFFB3`,"warning-muted":`#5B4A3C`}},"rose-pine-dawn":{name:`rose-pine-dawn`,dark:!1,ansi:{black:`#F2E9E1`,red:`#B4637A`,green:`#286983`,yellow:`#EA9D34`,blue:`#56949F`,magenta:`#907AA9`,cyan:`#D7827E`,white:`#575279`,brightBlack:`#9893A5`,brightRed:`#B4637A`,brightGreen:`#286983`,brightYellow:`#EA9D34`,brightBlue:`#56949F`,brightMagenta:`#907AA9`,brightCyan:`#D7827E`,brightWhite:`#575279`},vars:{accent:`#D6827E`,"accent-darken-1":`#C16E6B`,"accent-darken-2":`#AB5B58`,"accent-darken-3":`#964847`,"accent-lighten-1":`#ED9591`,"accent-lighten-2":`#FFAAA5`,"accent-lighten-3":`#FFBEB9`,"accent-muted":`#EFD1CB`,background:`#FAF4ED`,"background-darken-1":`#E4DED7`,"background-darken-2":`#CFC9C2`,"background-darken-3":`#BAB5AE`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#575279`,"block-cursor-blurred-background":`#907AA94C`,"block-cursor-blurred-foreground":`#575279`,"block-cursor-foreground":`#FAF4ED`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#CECACD`,"border-blurred":`#9893A5`,"button-color-foreground":`#000000DD`,"button-foreground":`#575279`,error:`#B4637A`,"error-darken-1":`#9E5067`,"error-darken-2":`#8A3D55`,"error-darken-3":`#752A43`,"error-lighten-1":`#C9768D`,"error-lighten-2":`#DF8AA0`,"error-lighten-3":`#F59EB5`,"error-muted":`#E5C8CA`,"footer-background":`#F2E9E1`,"footer-description-background":`#00000000`,"footer-description-foreground":`#575279`,"footer-foreground":`#575279`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#D7827E`,foreground:`#575279`,"foreground-darken-1":`#444066`,"foreground-darken-2":`#332F53`,"foreground-darken-3":`#222042`,"foreground-disabled":`#57527960`,"foreground-lighten-1":`#69648C`,"foreground-lighten-2":`#7C76A0`,"foreground-lighten-3":`#9089B4`,"foreground-muted":`#57527999`,"input-cursor-background":`#575279`,"input-cursor-foreground":`#FAF4ED`,"input-selection-background":`#DFDAD9`,"link-background":`#00000000`,"link-background-hover":`#907AA9`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#907AA9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#907AA9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#907AA9`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#575279`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#575279`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#57527999`,panel:`#F2E9E1`,"panel-darken-1":`#DCD3CB`,"panel-darken-2":`#C7BFB7`,"panel-darken-3":`#B3AAA3`,"panel-lighten-1":`#FFFEF6`,"panel-lighten-2":`#FFFFFF`,"panel-lighten-3":`#FFFFFF`,primary:`#907AA9`,"primary-background":`#907AA9`,"primary-background-darken-1":`#7C6795`,"primary-background-darken-2":`#695481`,"primary-background-darken-3":`#56436E`,"primary-background-lighten-1":`#A48DBD`,"primary-background-lighten-2":`#B8A1D2`,"primary-background-lighten-3":`#CDB5E7`,"primary-darken-1":`#7C6795`,"primary-darken-2":`#695481`,"primary-darken-3":`#56436E`,"primary-lighten-1":`#A48DBD`,"primary-lighten-2":`#B8A1D2`,"primary-lighten-3":`#CDB5E7`,"primary-muted":`#DACFD8`,scrollbar:`#C2B6C4`,"scrollbar-active":`#907AA9`,"scrollbar-background":`#E4DED7`,"scrollbar-background-active":`#E4DED7`,"scrollbar-background-hover":`#E4DED7`,"scrollbar-corner-color":`#E4DED7`,"scrollbar-hover":`#BAACC0`,secondary:`#286983`,"secondary-background":`#286983`,"secondary-background-darken-1":`#0A566F`,"secondary-background-darken-2":`#00455D`,"secondary-background-darken-3":`#00344B`,"secondary-background-lighten-1":`#3E7B96`,"secondary-background-lighten-2":`#538FAA`,"secondary-background-lighten-3":`#67A2BE`,"secondary-darken-1":`#0A566F`,"secondary-darken-2":`#00455D`,"secondary-darken-3":`#00344B`,"secondary-lighten-1":`#3E7B96`,"secondary-lighten-2":`#538FAA`,"secondary-lighten-3":`#67A2BE`,"secondary-muted":`#BBCACD`,success:`#56949F`,"success-darken-1":`#41808B`,"success-darken-2":`#2D6D78`,"success-darken-3":`#155B65`,"success-lighten-1":`#6AA7B3`,"success-lighten-2":`#7EBCC7`,"success-lighten-3":`#92D1DC`,"success-muted":`#C8D7D5`,surface:`#FFFAF3`,"surface-active":`#FFFFFF`,"surface-darken-1":`#E9E4DD`,"surface-darken-2":`#D4CFC8`,"surface-darken-3":`#BFBAB4`,"surface-lighten-1":`#FFFFFF`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#8D5553`,"text-disabled":`#00000060`,"text-error":`#764150`,"text-muted":`#00000099`,"text-primary":`#5F506F`,"text-secondary":`#1A4556`,"text-success":`#386168`,"text-warning":`#9A6722`,warning:`#E99D34`,"warning-darken-1":`#D2891D`,"warning-darken-2":`#BC7600`,"warning-darken-3":`#A56300`,"warning-lighten-1":`#FFB148`,"warning-lighten-2":`#FFC55C`,"warning-lighten-3":`#FFDA70`,"warning-muted":`#F5D9B5`}},"rose-pine-moon":{name:`rose-pine-moon`,dark:!0,ansi:{black:`#393552`,red:`#EB6F92`,green:`#3E8FB0`,yellow:`#F6C177`,blue:`#9CCFD8`,magenta:`#C4A7E7`,cyan:`#EA9A97`,white:`#E0DEF4`,brightBlack:`#6E6A86`,brightRed:`#EB6F92`,brightGreen:`#3E8FB0`,brightYellow:`#F6C177`,brightBlue:`#9CCFD8`,brightMagenta:`#C4A7E7`,brightCyan:`#EA9A97`,brightWhite:`#E0DEF4`},vars:{accent:`#EA9A97`,"accent-darken-1":`#D48683`,"accent-darken-2":`#BE7270`,"accent-darken-3":`#A95F5E`,"accent-lighten-1":`#FFAEAA`,"accent-lighten-2":`#FFC3BF`,"accent-lighten-3":`#FFD8D4`,"accent-muted":`#5E4553`,background:`#232136`,"background-darken-1":`#131125`,"background-darken-2":`#000017`,"background-darken-3":`#000001`,"background-lighten-1":`#333046`,"background-lighten-2":`#444158`,"background-lighten-3":`#56526A`,"block-cursor-background":`#C4A7E7`,"block-cursor-blurred-background":`#C4A7E74C`,"block-cursor-blurred-foreground":`#E0DEF4`,"block-cursor-foreground":`#232136`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#56526E`,"border-blurred":`#6E6A86`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0DEF4`,error:`#EA6F92`,"error-darken-1":`#D45A7E`,"error-darken-2":`#BE466B`,"error-darken-3":`#A83159`,"error-lighten-1":`#FF83A5`,"error-lighten-2":`#FF98BA`,"error-lighten-3":`#FFADCE`,"error-muted":`#5F3851`,"footer-background":`#393552`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0DEF4`,"footer-foreground":`#E0DEF4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#EA9A97`,foreground:`#E0DEF4`,"foreground-darken-1":`#CAC9DE`,"foreground-darken-2":`#B6B4C9`,"foreground-darken-3":`#A2A0B4`,"foreground-disabled":`#E0DEF460`,"foreground-lighten-1":`#F5F3FF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0DEF499`,"input-cursor-background":`#F4EDE8`,"input-cursor-foreground":`#232136`,"input-selection-background":`#44415A`,"link-background":`#00000000`,"link-background-hover":`#C4A7E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C4A7E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C4A7E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C4A7E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0DEF4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0DEF4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0DEF499`,panel:`#393552`,"panel-darken-1":`#282440`,"panel-darken-2":`#17152F`,"panel-darken-3":`#080020`,"panel-lighten-1":`#4A4564`,"panel-lighten-2":`#5C5776`,"panel-lighten-3":`#6F6989`,primary:`#C4A7E7`,"primary-background":`#58536A`,"primary-background-darken-1":`#49445D`,"primary-background-darken-2":`#3B3550`,"primary-background-darken-3":`#3B3550`,"primary-background-lighten-1":`#676277`,"primary-background-lighten-2":`#757184`,"primary-background-lighten-3":`#848091`,"primary-darken-1":`#AF93D1`,"primary-darken-2":`#9A7FBC`,"primary-darken-3":`#866CA8`,"primary-lighten-1":`#D9BBFC`,"primary-lighten-2":`#EED0FF`,"primary-lighten-3":`#FFE5FF`,"primary-muted":`#53496B`,scrollbar:`#594D72`,"scrollbar-active":`#C4A7E7`,"scrollbar-background":`#131125`,"scrollbar-background-active":`#131125`,"scrollbar-background-hover":`#131125`,"scrollbar-corner-color":`#131125`,"scrollbar-hover":`#6B5C86`,secondary:`#3E8FB0`,"secondary-background":`#474F63`,"secondary-background-darken-1":`#374055`,"secondary-background-darken-2":`#273148`,"secondary-background-darken-3":`#273148`,"secondary-background-lighten-1":`#575F71`,"secondary-background-lighten-2":`#676E7E`,"secondary-background-lighten-3":`#787E8C`,"secondary-darken-1":`#237B9B`,"secondary-darken-2":`#006888`,"secondary-darken-3":`#005674`,"secondary-lighten-1":`#54A2C4`,"secondary-lighten-2":`#6AB7D9`,"secondary-lighten-3":`#80CBEE`,"secondary-muted":`#2B425A`,success:`#9CCFD8`,"success-darken-1":`#87BAC3`,"success-darken-2":`#73A5AE`,"success-darken-3":`#60929A`,"success-lighten-1":`#B0E4ED`,"success-lighten-2":`#C5F9FF`,"success-lighten-3":`#DAFFFF`,"success-muted":`#475566`,surface:`#2A273F`,"surface-active":`#37334C`,"surface-darken-1":`#19172E`,"surface-darken-2":`#0A021E`,"surface-darken-3":`#00000F`,"surface-lighten-1":`#3A3750`,"surface-lighten-2":`#4C4862`,"surface-lighten-3":`#5E5975`,text:`#FFFFFFDD`,"text-accent":`#F1BCBA`,"text-disabled":`#FFFFFF60`,"text-error":`#F19FB7`,"text-muted":`#FFFFFF99`,"text-primary":`#D8C4EF`,"text-secondary":`#7FB5CA`,"text-success":`#BDDFE5`,"text-warning":`#F9D6A5`,warning:`#F5C177`,"warning-darken-1":`#DFAC63`,"warning-darken-2":`#C99850`,"warning-darken-3":`#B3853E`,"warning-lighten-1":`#FFD58A`,"warning-lighten-2":`#FFEB9E`,"warning-lighten-3":`#FFFFB3`,"warning-muted":`#625149`}},"solarized-dark":{name:`solarized-dark`,dark:!0,ansi:{black:`#073642`,red:`#DC322F`,green:`#859900`,yellow:`#B58900`,blue:`#268BD2`,magenta:`#D33682`,cyan:`#2AA198`,white:`#EEE8D5`,brightBlack:`#335E69`,brightRed:`#CB4B16`,brightGreen:`#586E75`,brightYellow:`#657B83`,brightBlue:`#839496`,brightMagenta:`#6C71C4`,brightCyan:`#93A1A1`,brightWhite:`#FDF6E3`},vars:{accent:`#6C71C4`,"accent-darken-1":`#575EAF`,"accent-darken-2":`#424C9A`,"accent-darken-3":`#2D3B87`,"accent-lighten-1":`#8083D9`,"accent-lighten-2":`#9597EE`,"accent-lighten-3":`#AAABFF`,"accent-muted":`#204060`,background:`#002B36`,"background-darken-1":`#001B25`,"background-darken-2":`#000A17`,"background-darken-3":`#000000`,"background-lighten-1":`#143B46`,"background-lighten-2":`#274C58`,"background-lighten-3":`#3A5E6A`,"block-cursor-background":`#268BD2`,"block-cursor-blurred-background":`#268BD24C`,"block-cursor-blurred-foreground":`#839496`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#268BD2`,"border-blurred":`#00303C`,"button-color-foreground":`#FDF6E3`,"button-foreground":`#839496`,error:`#DB322F`,"error-darken-1":`#C3121E`,"error-darken-2":`#AB000D`,"error-darken-3":`#940000`,"error-lighten-1":`#F44940`,"error-lighten-2":`#FF6052`,"error-lighten-3":`#FF7564`,"error-muted":`#422D33`,"footer-background":`#268BD2`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FDF6E3`,"footer-foreground":`#839496`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FDF6E3`,foreground:`#839496`,"foreground-darken-1":`#6F8082`,"foreground-darken-2":`#5D6D6F`,"foreground-darken-3":`#4B5B5D`,"foreground-disabled":`#83949660`,"foreground-lighten-1":`#96A7A9`,"foreground-lighten-2":`#AABCBE`,"foreground-lighten-3":`#BED0D3`,"foreground-muted":`#83949699`,"input-cursor-background":`#839496`,"input-cursor-foreground":`#002B36`,"input-selection-background":`#073642`,"link-background":`#00000000`,"link-background-hover":`#268BD2`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#268BD2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#268BD2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#268BD2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#839496`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#839496`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#83949699`,panel:`#073642`,"panel-darken-1":`#002531`,"panel-darken-2":`#001721`,"panel-darken-3":`#000112`,"panel-lighten-1":`#1D4653`,"panel-lighten-2":`#305865`,"panel-lighten-3":`#436A78`,primary:`#268BD2`,"primary-background":`#2A5667`,"primary-background-darken-1":`#17475A`,"primary-background-darken-2":`#05394D`,"primary-background-darken-3":`#05394D`,"primary-background-lighten-1":`#3D6575`,"primary-background-lighten-2":`#507482`,"primary-background-lighten-3":`#62838F`,"primary-darken-1":`#0077BD`,"primary-darken-2":`#0065A8`,"primary-darken-3":`#005394`,"primary-lighten-1":`#459EE7`,"primary-lighten-2":`#5FB2FD`,"primary-lighten-3":`#77C7FF`,"primary-muted":`#0B4764`,scrollbar:`#0F476A`,"scrollbar-active":`#268BD2`,"scrollbar-background":`#001B25`,"scrollbar-background-active":`#001B25`,"scrollbar-background-hover":`#001B25`,"scrollbar-corner-color":`#001B25`,"scrollbar-hover":`#13537B`,secondary:`#2AA198`,"secondary-background":`#2B5960`,"secondary-background-darken-1":`#184A52`,"secondary-background-darken-2":`#063C44`,"secondary-background-darken-3":`#063C44`,"secondary-background-lighten-1":`#3E676E`,"secondary-background-lighten-2":`#50767C`,"secondary-background-lighten-3":`#63858A`,"secondary-darken-1":`#008C84`,"secondary-darken-2":`#007971`,"secondary-darken-3":`#00665F`,"secondary-lighten-1":`#44B5AB`,"secondary-lighten-2":`#5BCAC0`,"secondary-lighten-3":`#72DFD5`,"secondary-muted":`#0C4E53`,success:`#849900`,"success-darken-1":`#708500`,"success-darken-2":`#5B7200`,"success-darken-3":`#485F00`,"success-lighten-1":`#99AC22`,"success-lighten-2":`#AFC139`,"success-lighten-3":`#C4D64E`,"success-muted":`#274C25`,surface:`#073642`,"surface-active":`#19434F`,"surface-darken-1":`#002531`,"surface-darken-2":`#001721`,"surface-darken-3":`#000112`,"surface-lighten-1":`#1D4653`,"surface-lighten-2":`#305865`,"surface-lighten-3":`#436A78`,text:`#FFFFFFDD`,"text-accent":`#9DA1D8`,"text-disabled":`#FFFFFF60`,"text-error":`#E77775`,"text-muted":`#FFFFFF99`,"text-primary":`#6FB2E1`,"text-secondary":`#72C0BB`,"text-success":`#AEBB56`,"text-warning":`#DC8865`,warning:`#CA4B16`,"warning-darken-1":`#B33600`,"warning-darken-2":`#9C2000`,"warning-darken-3":`#850100`,"warning-lighten-1":`#E25F29`,"warning-lighten-2":`#FA733C`,"warning-lighten-3":`#FF874E`,"warning-muted":`#3C342C`}},"solarized-light":{name:`solarized-light`,dark:!1,ansi:{black:`#073642`,red:`#DC322F`,green:`#859900`,yellow:`#B58900`,blue:`#268BD2`,magenta:`#D33682`,cyan:`#2AA198`,white:`#BBB5A2`,brightBlack:`#002B36`,brightRed:`#CB4B16`,brightGreen:`#586E75`,brightYellow:`#657B83`,brightBlue:`#839496`,brightMagenta:`#6C71C4`,brightCyan:`#93A1A1`,brightWhite:`#FDF6E3`},vars:{accent:`#6C71C4`,"accent-darken-1":`#575EAF`,"accent-darken-2":`#424C9A`,"accent-darken-3":`#2D3B87`,"accent-lighten-1":`#8083D9`,"accent-lighten-2":`#9597EE`,"accent-lighten-3":`#AAABFF`,"accent-muted":`#D1CED9`,background:`#FDF6E3`,"background-darken-1":`#E7E0CD`,"background-darken-2":`#D2CBB9`,"background-darken-3":`#BDB6A4`,"background-lighten-1":`#FFFFF8`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#268BD2`,"block-cursor-blurred-background":`#268BD24C`,"block-cursor-blurred-foreground":`#586E75`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#268BD2`,"border-blurred":`#E6E0CE`,"button-color-foreground":`#FDF6E3`,"button-foreground":`#586E75`,error:`#DB322F`,"error-darken-1":`#C3121E`,"error-darken-2":`#AB000D`,"error-darken-3":`#940000`,"error-lighten-1":`#F44940`,"error-lighten-2":`#FF6052`,"error-lighten-3":`#FF7564`,"error-muted":`#F3BBAD`,"footer-background":`#268BD2`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FDF6E3`,"footer-foreground":`#586E75`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FDF6E3`,foreground:`#586E75`,"foreground-darken-1":`#465B62`,"foreground-darken-2":`#344950`,"foreground-darken-3":`#23383F`,"foreground-disabled":`#586E7560`,"foreground-lighten-1":`#6A8088`,"foreground-lighten-2":`#7D949B`,"foreground-lighten-3":`#91A8AF`,"foreground-muted":`#586E7599`,"input-cursor-background":`#586E75`,"input-cursor-foreground":`#FDF6E3`,"input-selection-background":`#459EE766`,"link-background":`#00000000`,"link-background-hover":`#268BD2`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#268BD2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#268BD2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#268BD2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#586E75`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#586E75`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#586E7599`,panel:`#EEE8D5`,"panel-darken-1":`#D8D2C0`,"panel-darken-2":`#C3BEAB`,"panel-darken-3":`#AFA997`,"panel-lighten-1":`#FFFDEA`,"panel-lighten-2":`#FFFFFF`,"panel-lighten-3":`#FFFFFF`,primary:`#268BD2`,"primary-background":`#268BD2`,"primary-background-darken-1":`#0077BD`,"primary-background-darken-2":`#0065A8`,"primary-background-darken-3":`#005394`,"primary-background-lighten-1":`#459EE7`,"primary-background-lighten-2":`#5FB2FD`,"primary-background-lighten-3":`#77C7FF`,"primary-darken-1":`#0077BD`,"primary-darken-2":`#0065A8`,"primary-darken-3":`#005394`,"primary-lighten-1":`#459EE7`,"primary-lighten-2":`#5FB2FD`,"primary-lighten-3":`#77C7FF`,"primary-muted":`#BCD5DD`,scrollbar:`#99BECF`,"scrollbar-active":`#268BD2`,"scrollbar-background":`#E7E0CD`,"scrollbar-background-active":`#E7E0CD`,"scrollbar-background-hover":`#E7E0CD`,"scrollbar-corner-color":`#E7E0CD`,"scrollbar-hover":`#86B5CF`,secondary:`#2AA198`,"secondary-background":`#2AA198`,"secondary-background-darken-1":`#008C84`,"secondary-background-darken-2":`#007971`,"secondary-background-darken-3":`#00665F`,"secondary-background-lighten-1":`#44B5AB`,"secondary-background-lighten-2":`#5BCAC0`,"secondary-background-lighten-3":`#72DFD5`,"secondary-darken-1":`#008C84`,"secondary-darken-2":`#007971`,"secondary-darken-3":`#00665F`,"secondary-lighten-1":`#44B5AB`,"secondary-lighten-2":`#5BCAC0`,"secondary-lighten-3":`#72DFD5`,"secondary-muted":`#BDDCCC`,success:`#849900`,"success-darken-1":`#708500`,"success-darken-2":`#5B7200`,"success-darken-3":`#485F00`,"success-lighten-1":`#99AC22`,"success-lighten-2":`#AFC139`,"success-lighten-3":`#C4D64E`,"success-muted":`#D9DA9E`,surface:`#EEE8D5`,"surface-active":`#FFF9E5`,"surface-darken-1":`#D8D2C0`,"surface-darken-2":`#C3BEAB`,"surface-darken-3":`#AFA997`,"surface-lighten-1":`#FFFDEA`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#474A81`,"text-disabled":`#00000060`,"text-error":`#91211F`,"text-muted":`#00000099`,"text-primary":`#195B8A`,"text-secondary":`#1B6A64`,"text-success":`#576400`,"text-warning":`#85310E`,warning:`#CA4B16`,"warning-darken-1":`#B33600`,"warning-darken-2":`#9C2000`,"warning-darken-3":`#850100`,"warning-lighten-1":`#E25F29`,"warning-lighten-2":`#FA733C`,"warning-lighten-3":`#FF874E`,"warning-muted":`#EEC2A5`}},"svg-export":{name:`svg-export`,dark:!0,ansi:{black:`#4B4E55`,red:`#CC555A`,green:`#98A84B`,yellow:`#D0B344`,blue:`#608AB1`,magenta:`#98729F`,cyan:`#68A0B3`,white:`#C5C8C6`,brightBlack:`#9A9B99`,brightRed:`#FF2627`,brightGreen:`#00823D`,brightYellow:`#D08442`,brightBlue:`#1984E9`,brightMagenta:`#FF2C7A`,brightCyan:`#398280`,brightWhite:`#FDFDC5`},vars:{accent:`#56B6C2`,"accent-darken-1":`#3EA1AD`,"accent-darken-2":`#238D99`,"accent-darken-3":`#007A85`,"accent-lighten-1":`#6CCAD6`,"accent-lighten-2":`#81DFEC`,"accent-lighten-3":`#97F5FF`,"accent-muted":`#365356`,background:`#292929`,"background-darken-1":`#191919`,"background-darken-2":`#050505`,"background-darken-3":`#000000`,"background-lighten-1":`#393939`,"background-lighten-2":`#4A4A4A`,"background-lighten-3":`#5C5C5C`,"block-cursor-background":`#61AFEF`,"block-cursor-blurred-background":`#61AFEF4C`,"block-cursor-blurred-foreground":`#C5C8C6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#61AFEF`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#C5C8C6`,error:`#CB555A`,"error-darken-1":`#B54048`,"error-darken-2":`#9F2C37`,"error-darken-3":`#891427`,"error-lighten-1":`#E2686C`,"error-lighten-2":`#F97D7F`,"error-lighten-3":`#FF9192`,"error-muted":`#593637`,"footer-background":`#2C343A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#C5C8C6`,"footer-foreground":`#C5C8C6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#56B6C2`,foreground:`#C5C8C6`,"foreground-darken-1":`#B0B3B1`,"foreground-darken-2":`#9C9F9D`,"foreground-darken-3":`#888B89`,"foreground-disabled":`#C5C8C660`,"foreground-lighten-1":`#D9DCDA`,"foreground-lighten-2":`#EFF2F0`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#C5C8C699`,"input-cursor-background":`#C5C8C6`,"input-cursor-foreground":`#292929`,"input-selection-background":`#77C3FF66`,"link-background":`#00000000`,"link-background-hover":`#61AFEF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#61AFEF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#61AFEF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#61AFEF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#C5C8C6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#C5C8C6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#C5C8C699`,panel:`#2C343A`,"panel-darken-1":`#1C2429`,"panel-darken-2":`#0C141A`,"panel-darken-3":`#000007`,"panel-lighten-1":`#3C444B`,"panel-lighten-2":`#4D565C`,"panel-lighten-3":`#5F686F`,primary:`#61AFEF`,"primary-background":`#4F5A61`,"primary-background-darken-1":`#404B53`,"primary-background-darken-2":`#313D46`,"primary-background-darken-3":`#313D46`,"primary-background-lighten-1":`#5F686F`,"primary-background-lighten-2":`#6E777D`,"primary-background-lighten-3":`#7E858B`,"primary-darken-1":`#489BD9`,"primary-darken-2":`#2C87C4`,"primary-darken-3":`#0074AF`,"primary-lighten-1":`#77C3FF`,"primary-lighten-2":`#8ED8FF`,"primary-lighten-3":`#A4EDFF`,"primary-muted":`#395164`,scrollbar:`#35556E`,"scrollbar-active":`#61AFEF`,"scrollbar-background":`#191919`,"scrollbar-background-active":`#191919`,"scrollbar-background-hover":`#191919`,"scrollbar-corner-color":`#191919`,"scrollbar-hover":`#3D6484`,secondary:`#C678DD`,"secondary-background":`#5C5260`,"secondary-background-darken-1":`#4E4352`,"secondary-background-darken-2":`#403444`,"secondary-background-darken-3":`#403444`,"secondary-background-lighten-1":`#6A616E`,"secondary-background-lighten-2":`#79707C`,"secondary-background-lighten-3":`#87808A`,"secondary-darken-1":`#B064C7`,"secondary-darken-2":`#9B50B3`,"secondary-darken-3":`#873D9E`,"secondary-lighten-1":`#DB8CF2`,"secondary-lighten-2":`#F1A0FF`,"secondary-lighten-3":`#FFB5FF`,"secondary-muted":`#58405F`,success:`#98C379`,"success-darken-1":`#83AE65`,"success-darken-2":`#709A53`,"success-darken-3":`#5C8641`,"success-lighten-1":`#ACD78C`,"success-lighten-2":`#C1EDA0`,"success-lighten-3":`#D6FFB4`,"success-muted":`#4A5741`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#8FCED6`,"text-disabled":`#FFFFFF60`,"text-error":`#DD8E92`,"text-muted":`#FFFFFF99`,"text-primary":`#96CAF4`,"text-secondary":`#D9A5E8`,"text-success":`#BBD7A6`,"text-warning":`#EDD5A7`,warning:`#E4C07B`,"warning-darken-1":`#CFAB67`,"warning-darken-2":`#B99754`,"warning-darken-3":`#A48442`,"warning-lighten-1":`#FBD48E`,"warning-lighten-2":`#FFE9A2`,"warning-lighten-3":`#FFFFB7`,"warning-muted":`#615641`}},"textual-ansi":{name:`textual-ansi`,dark:!0,ansi:sl,vars:{accent:`#0000FF`,"accent-darken-1":`#0000FF`,"accent-darken-2":`#0000FF`,"accent-darken-3":`#0000FF`,"accent-lighten-1":`#0000FF`,"accent-lighten-2":`#0000FF`,"accent-lighten-3":`#0000FF`,"accent-muted":`#0178D4`,background:`#121212`,"background-darken-1":`#121212`,"background-darken-2":`#121212`,"background-darken-3":`#121212`,"background-lighten-1":`#121212`,"background-lighten-2":`#121212`,"background-lighten-3":`#121212`,"block-cursor-background":`#000080`,"block-cursor-blurred-background":`#0000804C`,"block-cursor-blurred-foreground":`#E0E0E0`,"block-cursor-foreground":`#E0E0E0`,"block-hover-background":`#00000019`,boost:`#0178D4`,"boost-darken-1":`#0178D4`,"boost-darken-2":`#0178D4`,"boost-darken-3":`#0178D4`,"boost-lighten-1":`#0178D4`,"boost-lighten-2":`#0178D4`,"boost-lighten-3":`#0178D4`,border:`#0000FF`,"border-blurred":`#000080`,"button-color-foreground":`#E0E0E0`,"button-foreground":`#E0E0E0`,error:`#800000`,"error-darken-1":`#800000`,"error-darken-2":`#800000`,"error-darken-3":`#800000`,"error-lighten-1":`#800000`,"error-lighten-2":`#800000`,"error-lighten-3":`#800000`,"error-muted":`#0178D4`,"footer-background":`#121212`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0E0E0`,"footer-foreground":`#E0E0E0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#0000FF`,foreground:`#E0E0E0`,"foreground-darken-1":`#E0E0E0`,"foreground-darken-2":`#E0E0E0`,"foreground-darken-3":`#E0E0E0`,"foreground-disabled":`#00000060`,"foreground-lighten-1":`#E0E0E0`,"foreground-lighten-2":`#E0E0E0`,"foreground-lighten-3":`#E0E0E0`,"foreground-muted":`#00000099`,"input-cursor-background":`#121212`,"input-cursor-foreground":`#E0E0E0`,"input-selection-background":`#000080`,"link-background":`#00000000`,"link-background-hover":`#000080`,"link-color":`#E0E0E0`,"link-color-hover":`#0178D4`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#000080`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#000080`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#000080`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0E0E0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0E0E0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#00000099`,panel:`#121212`,"panel-darken-1":`#121212`,"panel-darken-2":`#121212`,"panel-darken-3":`#121212`,"panel-lighten-1":`#121212`,"panel-lighten-2":`#121212`,"panel-lighten-3":`#121212`,primary:`#000080`,"primary-background":`#000080`,"primary-background-darken-1":`#000080`,"primary-background-darken-2":`#000080`,"primary-background-darken-3":`#000080`,"primary-background-lighten-1":`#000080`,"primary-background-lighten-2":`#000080`,"primary-background-lighten-3":`#000080`,"primary-darken-1":`#000080`,"primary-darken-2":`#000080`,"primary-darken-3":`#000080`,"primary-lighten-1":`#000080`,"primary-lighten-2":`#000080`,"primary-lighten-3":`#000080`,"primary-muted":`#0178D4`,scrollbar:`#000080`,"scrollbar-active":`#000080`,"scrollbar-background":`#121212`,"scrollbar-background-active":`#121212`,"scrollbar-background-hover":`#121212`,"scrollbar-corner-color":`#E0E0E0`,"scrollbar-hover":`#000040`,secondary:`#008080`,"secondary-background":`#008080`,"secondary-background-darken-1":`#008080`,"secondary-background-darken-2":`#008080`,"secondary-background-darken-3":`#008080`,"secondary-background-lighten-1":`#008080`,"secondary-background-lighten-2":`#008080`,"secondary-background-lighten-3":`#008080`,"secondary-darken-1":`#008080`,"secondary-darken-2":`#008080`,"secondary-darken-3":`#008080`,"secondary-lighten-1":`#008080`,"secondary-lighten-2":`#008080`,"secondary-lighten-3":`#008080`,"secondary-muted":`#0178D4`,success:`#008000`,"success-darken-1":`#008000`,"success-darken-2":`#008000`,"success-darken-3":`#008000`,"success-lighten-1":`#008000`,"success-lighten-2":`#008000`,"success-lighten-3":`#008000`,"success-muted":`#0178D4`,surface:`#121212`,"surface-active":`#131313`,"surface-darken-1":`#121212`,"surface-darken-2":`#121212`,"surface-darken-3":`#121212`,"surface-lighten-1":`#121212`,"surface-lighten-2":`#121212`,"surface-lighten-3":`#121212`,text:`#E0E0E0`,"text-accent":`#5656FF`,"text-disabled":`#E0E0E0`,"text-error":`#AB5656`,"text-muted":`#E0E0E0`,"text-primary":`#5656AB`,"text-secondary":`#56ABAB`,"text-success":`#56AB56`,"text-warning":`#ABAB56`,warning:`#808000`,"warning-darken-1":`#808000`,"warning-darken-2":`#808000`,"warning-darken-3":`#808000`,"warning-lighten-1":`#808000`,"warning-lighten-2":`#808000`,"warning-lighten-3":`#808000`,"warning-muted":`#0178D4`}},"textual-dark":{name:`textual-dark`,dark:!0,ansi:cl,vars:{accent:`#FEA62B`,"accent-darken-1":`#E7920D`,"accent-darken-2":`#CF7E00`,"accent-darken-3":`#B86B00`,"accent-lighten-1":`#FFBA41`,"accent-lighten-2":`#FFCF56`,"accent-lighten-3":`#FFE46B`,"accent-muted":`#593E19`,background:`#121212`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#212121`,"background-lighten-2":`#313131`,"background-lighten-3":`#414141`,"block-cursor-background":`#0178D4`,"block-cursor-blurred-background":`#0178D44C`,"block-cursor-blurred-foreground":`#E0E0E0`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#0178D4`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0E0E0`,error:`#B93C5B`,"error-darken-1":`#A32549`,"error-darken-2":`#8D0638`,"error-darken-3":`#780028`,"error-lighten-1":`#D0506D`,"error-lighten-2":`#E76580`,"error-lighten-3":`#FE7993`,"error-muted":`#441E27`,"footer-background":`#242F38`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0E0E0`,"footer-foreground":`#E0E0E0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FFA62B`,foreground:`#E0E0E0`,"foreground-darken-1":`#CACACA`,"foreground-darken-2":`#B6B6B6`,"foreground-darken-3":`#A2A2A2`,"foreground-disabled":`#E0E0E060`,"foreground-lighten-1":`#F5F5F5`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0E0E099`,"input-cursor-background":`#E0E0E0`,"input-cursor-foreground":`#121212`,"input-selection-background":`#368AE966`,"link-background":`#00000000`,"link-background-hover":`#0178D4`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#0178D4`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#0178D4`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#0178D4`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0E0E0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0E0E0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0E0E099`,panel:`#242F38`,"panel-darken-1":`#141F27`,"panel-darken-2":`#000F18`,"panel-darken-3":`#000003`,"panel-lighten-1":`#343F49`,"panel-lighten-2":`#45505A`,"panel-lighten-3":`#57626D`,primary:`#0178D4`,"primary-background":`#33424E`,"primary-background-darken-1":`#21313E`,"primary-background-darken-2":`#0F212F`,"primary-background-darken-3":`#0F212F`,"primary-background-lighten-1":`#45525D`,"primary-background-lighten-2":`#57636D`,"primary-background-lighten-3":`#69747D`,"primary-darken-1":`#0065BE`,"primary-darken-2":`#0053AA`,"primary-darken-3":`#004295`,"primary-lighten-1":`#368AE9`,"primary-lighten-2":`#539EFF`,"primary-lighten-3":`#6DB2FF`,"primary-muted":`#0C304C`,scrollbar:`#003054`,"scrollbar-active":`#0178D4`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#003C6A`,secondary:`#004578`,"secondary-background":`#333B42`,"secondary-background-darken-1":`#212A31`,"secondary-background-darken-2":`#0F1921`,"secondary-background-darken-3":`#0F1921`,"secondary-background-lighten-1":`#454C52`,"secondary-background-lighten-2":`#575E63`,"secondary-background-lighten-3":`#696F74`,"secondary-darken-1":`#003465`,"secondary-darken-2":`#002452`,"secondary-darken-3":`#001541`,"secondary-lighten-1":`#23568B`,"secondary-lighten-2":`#3B689F`,"secondary-lighten-3":`#507BB3`,"secondary-muted":`#0C2130`,success:`#4EBF71`,"success-darken-1":`#36AA5E`,"success-darken-2":`#18954B`,"success-darken-3":`#008139`,"success-lighten-1":`#64D484`,"success-lighten-2":`#7AE998`,"success-lighten-3":`#8FFFAC`,"success-muted":`#24452E`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#FFC473`,"text-disabled":`#FFFFFF60`,"text-error":`#D17E92`,"text-muted":`#FFFFFF99`,"text-primary":`#57A5E2`,"text-secondary":`#5684A5`,"text-success":`#8AD4A1`,"text-warning":`#FFC473`,warning:`#FEA62B`,"warning-darken-1":`#E7920D`,"warning-darken-2":`#CF7E00`,"warning-darken-3":`#B86B00`,"warning-lighten-1":`#FFBA41`,"warning-lighten-2":`#FFCF56`,"warning-lighten-3":`#FFE46B`,"warning-muted":`#593E19`}},"textual-light":{name:`textual-light`,dark:!1,ansi:{black:`#000000`,red:`#AA3731`,green:`#448C27`,yellow:`#CB9000`,blue:`#325CC0`,magenta:`#7A3E9D`,cyan:`#0083B2`,white:`#F7F7F7`,brightBlack:`#777777`,brightRed:`#F05050`,brightGreen:`#60CB00`,brightYellow:`#FFBC5D`,brightBlue:`#007ACC`,brightMagenta:`#E64CE6`,brightCyan:`#00AACB`,brightWhite:`#F7F7F7`},vars:{accent:`#FEA62B`,"accent-darken-1":`#E7920D`,"accent-darken-2":`#CF7E00`,"accent-darken-3":`#B86B00`,"accent-lighten-1":`#FFBA41`,"accent-lighten-2":`#FFCF56`,"accent-lighten-3":`#FFE46B`,"accent-muted":`#E9CEA9`,background:`#E0E0E0`,"background-darken-1":`#CACACA`,"background-darken-2":`#B6B6B6`,"background-darken-3":`#A2A2A2`,"background-lighten-1":`#F5F5F5`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#004578`,"block-cursor-blurred-background":`#0045784C`,"block-cursor-blurred-foreground":`#1F1F1F`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#004578`,"border-blurred":`#D0D1D0`,"button-color-foreground":`#000000DD`,"button-foreground":`#1F1F1F`,error:`#B93C5B`,"error-darken-1":`#A32549`,"error-darken-2":`#8D0638`,"error-darken-3":`#780028`,"error-lighten-1":`#D0506D`,"error-lighten-2":`#E76580`,"error-lighten-3":`#FE7993`,"error-muted":`#D4AEB8`,"footer-background":`#D0D0D0`,"footer-description-background":`#00000000`,"footer-description-foreground":`#1F1F1F`,"footer-foreground":`#1F1F1F`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#0178D4`,foreground:`#1F1F1F`,"foreground-darken-1":`#0E0E0E`,"foreground-darken-2":`#000000`,"foreground-darken-3":`#000000`,"foreground-disabled":`#1F1F1F60`,"foreground-lighten-1":`#2E2E2E`,"foreground-lighten-2":`#3F3F3F`,"foreground-lighten-3":`#505050`,"foreground-muted":`#1F1F1F99`,"input-cursor-background":`#1F1F1F`,"input-cursor-foreground":`#E0E0E0`,"input-selection-background":`#23568B66`,"link-background":`#00000000`,"link-background-hover":`#004578`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#004578`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#004578`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#004578`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#1F1F1F`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#1F1F1F`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#1F1F1F99`,panel:`#D0D0D0`,"panel-darken-1":`#BBBBBB`,"panel-darken-2":`#A6A6A6`,"panel-darken-3":`#939393`,"panel-lighten-1":`#E5E5E5`,"panel-lighten-2":`#FAFAFA`,"panel-lighten-3":`#FFFFFF`,primary:`#004578`,"primary-background":`#004578`,"primary-background-darken-1":`#003465`,"primary-background-darken-2":`#002452`,"primary-background-darken-3":`#001541`,"primary-background-lighten-1":`#23568B`,"primary-background-lighten-2":`#3B689F`,"primary-background-lighten-3":`#507BB3`,"primary-darken-1":`#003465`,"primary-darken-2":`#002452`,"primary-darken-3":`#001541`,"primary-lighten-1":`#23568B`,"primary-lighten-2":`#3B689F`,"primary-lighten-3":`#507BB3`,"primary-muted":`#9CB1C0`,scrollbar:`#7994A9`,"scrollbar-active":`#004578`,"scrollbar-background":`#CACACA`,"scrollbar-background-active":`#CACACA`,"scrollbar-background-hover":`#CACACA`,"scrollbar-corner-color":`#CACACA`,"scrollbar-hover":`#6587A1`,secondary:`#0178D4`,"secondary-background":`#0178D4`,"secondary-background-darken-1":`#0065BE`,"secondary-background-darken-2":`#0053AA`,"secondary-background-darken-3":`#004295`,"secondary-background-lighten-1":`#368AE9`,"secondary-background-lighten-2":`#539EFF`,"secondary-background-lighten-3":`#6DB2FF`,"secondary-darken-1":`#0065BE`,"secondary-darken-2":`#0053AA`,"secondary-darken-3":`#004295`,"secondary-lighten-1":`#368AE9`,"secondary-lighten-2":`#539EFF`,"secondary-lighten-3":`#6DB2FF`,"secondary-muted":`#9DC0DC`,success:`#4EBF71`,"success-darken-1":`#36AA5E`,"success-darken-2":`#18954B`,"success-darken-3":`#008139`,"success-lighten-1":`#64D484`,"success-lighten-2":`#7AE998`,"success-lighten-3":`#8FFFAC`,"success-muted":`#B4D6BE`,surface:`#D8D8D8`,"surface-active":`#E8E8E8`,"surface-darken-1":`#C3C3C3`,"surface-darken-2":`#AEAEAE`,"surface-darken-3":`#9A9A9A`,"surface-lighten-1":`#EDEDED`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#A86D1C`,"text-disabled":`#00000060`,"text-error":`#7A273C`,"text-muted":`#00000099`,"text-primary":`#002D4F`,"text-secondary":`#004F8B`,"text-success":`#337E4A`,"text-warning":`#A86D1C`,warning:`#FEA62B`,"warning-darken-1":`#E7920D`,"warning-darken-2":`#CF7E00`,"warning-darken-3":`#B86B00`,"warning-lighten-1":`#FFBA41`,"warning-lighten-2":`#FFCF56`,"warning-lighten-3":`#FFE46B`,"warning-muted":`#E9CEA9`}},"tokyo-night":{name:`tokyo-night`,dark:!0,ansi:{black:`#15161E`,red:`#F7768E`,green:`#9ECE6A`,yellow:`#E0AF68`,blue:`#7AA2F7`,magenta:`#BB9AF7`,cyan:`#7DCFFF`,white:`#A9B1D6`,brightBlack:`#414868`,brightRed:`#F7768E`,brightGreen:`#9ECE6A`,brightYellow:`#E0AF68`,brightBlue:`#7AA2F7`,brightMagenta:`#BB9AF7`,brightCyan:`#7DCFFF`,brightWhite:`#C0CAF5`},vars:{accent:`#FE9E64`,"accent-darken-1":`#E78A51`,"accent-darken-2":`#D0763E`,"accent-darken-3":`#BA632C`,"accent-lighten-1":`#FFB277`,"accent-lighten-2":`#FFC78A`,"accent-lighten-3":`#FFDC9E`,"accent-muted":`#5E4238`,background:`#1A1B26`,"background-darken-1":`#070817`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#292A36`,"background-lighten-2":`#3A3A47`,"background-lighten-3":`#4B4B58`,"block-cursor-background":`#BB9AF7`,"block-cursor-blurred-background":`#BB9AF74C`,"block-cursor-blurred-foreground":`#A9B1D6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BB9AF7`,"border-blurred":`#1E2235`,"button-color-foreground":`#24283B`,"button-foreground":`#A9B1D6`,error:`#F6768E`,"error-darken-1":`#E0617A`,"error-darken-2":`#C94D68`,"error-darken-3":`#B33856`,"error-lighten-1":`#FF8AA1`,"error-lighten-2":`#FF9FB5`,"error-lighten-3":`#FFB4CA`,"error-muted":`#5C3645`,"footer-background":`#414868`,"footer-description-background":`#00000000`,"footer-description-foreground":`#A9B1D6`,"footer-foreground":`#A9B1D6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FF9E64`,foreground:`#A9B1D6`,"foreground-darken-1":`#949CC1`,"foreground-darken-2":`#8189AC`,"foreground-darken-3":`#6D7698`,"foreground-disabled":`#A9B1D660`,"foreground-lighten-1":`#BDC5EB`,"foreground-lighten-2":`#D2DAFF`,"foreground-lighten-3":`#E7EFFF`,"foreground-muted":`#A9B1D699`,"input-cursor-background":`#A9B1D6`,"input-cursor-foreground":`#1A1B26`,"input-selection-background":`#D0AEFF66`,"link-background":`#00000000`,"link-background-hover":`#BB9AF7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#BB9AF7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#BB9AF7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#BB9AF7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#A9B1D6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#A9B1D6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#A9B1D699`,panel:`#414868`,"panel-darken-1":`#2F3755`,"panel-darken-2":`#1E2744`,"panel-darken-3":`#0C1733`,"panel-lighten-1":`#53597A`,"panel-lighten-2":`#656B8E`,"panel-lighten-3":`#787EA1`,primary:`#BB9AF7`,"primary-background":`#504D60`,"primary-background-darken-1":`#413D52`,"primary-background-darken-2":`#322E45`,"primary-background-darken-3":`#322E45`,"primary-background-lighten-1":`#605D6E`,"primary-background-lighten-2":`#6F6C7C`,"primary-background-lighten-3":`#7E7C8A`,"primary-darken-1":`#A686E1`,"primary-darken-2":`#9173CC`,"primary-darken-3":`#7D60B7`,"primary-lighten-1":`#D0AEFF`,"primary-lighten-2":`#E5C2FF`,"primary-lighten-3":`#FBD7FF`,"primary-muted":`#4A4164`,scrollbar:`#4F4270`,"scrollbar-active":`#BB9AF7`,"scrollbar-background":`#070817`,"scrollbar-background-active":`#070817`,"scrollbar-background-hover":`#070817`,"scrollbar-corner-color":`#070817`,"scrollbar-hover":`#615187`,secondary:`#7AA2F7`,"secondary-background":`#484E60`,"secondary-background-darken-1":`#383E52`,"secondary-background-darken-2":`#282F45`,"secondary-background-darken-3":`#282F45`,"secondary-background-lighten-1":`#585D6E`,"secondary-background-lighten-2":`#686D7C`,"secondary-background-lighten-3":`#787D8A`,"secondary-darken-1":`#648EE1`,"secondary-darken-2":`#4D7BCC`,"secondary-darken-3":`#3468B7`,"secondary-lighten-1":`#8FB6FF`,"secondary-lighten-2":`#A5CAFF`,"secondary-lighten-3":`#BBDFFF`,"secondary-muted":`#364364`,success:`#9ECE6A`,"success-darken-1":`#89B956`,"success-darken-2":`#75A443`,"success-darken-3":`#619030`,"success-lighten-1":`#B2E37D`,"success-lighten-2":`#C8F891`,"success-lighten-3":`#DDFFA6`,"success-muted":`#41503A`,surface:`#24283B`,"surface-active":`#313448`,"surface-darken-1":`#14182A`,"surface-darken-2":`#00031B`,"surface-darken-3":`#000009`,"surface-lighten-1":`#34384C`,"surface-lighten-2":`#45495E`,"surface-lighten-3":`#575A70`,text:`#FFFFFFDD`,"text-accent":`#FFBE98`,"text-disabled":`#FFFFFF60`,"text-error":`#F9A4B4`,"text-muted":`#FFFFFF99`,"text-primary":`#D2BCF9`,"text-secondary":`#A7C1F9`,"text-success":`#BEDE9C`,"text-warning":`#EACA9B`,warning:`#DFAF68`,"warning-darken-1":`#C99A55`,"warning-darken-2":`#B48742`,"warning-darken-3":`#9E7430`,"warning-lighten-1":`#F6C37B`,"warning-lighten-2":`#FFD88F`,"warning-lighten-3":`#FFEDA3`,"warning-muted":`#554739`}}},ul=Object.freeze(Object.keys(ll).sort()),dl=new Map;function fl(){return ul}function pl(e){if(!ml(e))return null;let t=dl.get(e);if(t!==void 0)return t;let n=_l(ll[e]);return dl.set(e,n),n}function ml(e){return Object.hasOwn(ll,e)}function hl(e){let t=ll[e],n=gl(t,`background`),r=_s(t.name,n),i=e=>r(gl(t,e));return{name:t.name,dark:t.dark,bg:n,fg:i(`foreground`),primary:i(`primary`),secondary:i(`secondary`),accent:i(`accent`),success:i(`success`),warning:i(`warning`),error:i(`error`),ansi:new Ds(ol.map(e=>yl(t.ansi[e],t.name,`ansi.${e}`)))}}function gl(e,t){let n=e.vars[t];if(n===void 0)throw Error(`Theme ${e.name}: required base var "${t}" missing from data file`);return vl(n,e.name,t)}function _l(e){let t=new Map;for(let[n,r]of Object.entries(e.vars))t.set(n,vl(r,e.name,`var ${n}`));for(let n of Zc){let r=gl(e,`text-${n}`);t.set(`text-${n}`,$c(r,gl(e,`${n}-muted`),gl(e,`background`)))}return new gs(e.name,e.dark,t)}function vl(e,t,n){try{return nc(e)}catch(e){throw e instanceof Rs?Error(`Theme ${t}: ${n}: ${e.message}`,{cause:e}):e}}function yl(e,t,n){let r=vl(e,t,n);if(r.alpha!==1)throw Error(`Theme ${t}: ${n} has alpha in ${JSON.stringify(e)} (expected #RRGGBB)`);return r}function bl(e){return new ic(e.bg,e.fg,e.ansi,Qc(e.name,e.dark,{primary:e.primary,secondary:e.secondary,accent:e.accent,success:e.success,warning:e.warning,error:e.error,background:e.bg,foreground:e.fg}))}const xl=bl(hl(`default`));bl(hl(`svg-export`)),bl(hl(`monokai`)),bl(hl(`nord`)),bl(hl(`gruvbox`)),bl(hl(`dracula`)),bl(hl(`tokyo-night`)),bl(hl(`flexoki`)),bl(hl(`cyberpunk`)),bl(hl(`catppuccin-mocha`)),bl(hl(`catppuccin-latte`)),bl(hl(`catppuccin-frappe`)),bl(hl(`catppuccin-macchiato`)),bl(hl(`solarized-dark`)),bl(hl(`solarized-light`)),bl(hl(`rose-pine`)),bl(hl(`rose-pine-moon`)),bl(hl(`rose-pine-dawn`)),bl(hl(`atom-one-dark`)),bl(hl(`atom-one-light`)),bl(hl(`textual-dark`)),bl(hl(`textual-light`)),bl(hl(`textual-ansi`));const Sl=new Set([`error`,`success`,`warning`]);function Cl(e){let t=e.indexOf(`-`);return t===-1?e:e.slice(0,t)}function wl(e){return Sl.has(Cl(e))}function Tl(e,t,n){if(Sc(t))return new gs(n??e.name,e.dark,e.vars);let r={...t,hueShift:0},i=new Map;for(let[n,a]of e.vars){let e=wl(n)?r:t;i.set(n,Mc.fromRgba(a).applyKey(e).toRgba())}let a=i.get(`background`);if(a===void 0)throw Error(`transposePalette: palette "${e.name}" has no "background" var; cannot derive the dark flag without a background color.`);let o=Mc.fromRgba(a).l<.5;return new gs(n??e.name,o,i)}function El(e,t,n,r){for(let[i,a]of[[`x1`,e],[`y1`,t],[`x2`,n],[`y2`,r]])if(!Number.isFinite(a))throw RangeError(`cubicBezier ${i} must be finite, got ${a}`);if(e<0||e>1||n<0||n>1)throw RangeError(`cubicBezier x1 and x2 must lie in [0, 1], got ${e} and ${n}`);let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=1e-9,m=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<p)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;for(t=e;r-n>p;)u(t)<e?n=t:r=t,t=(n+r)/2;return t};return Ol(e=>d(m(e)))}function Dl(e,t=`jump-end`){let n=t===`jump-none`?2:1;if(!Number.isInteger(e)||e<n)throw RangeError(`steps(${e}, "${t}") needs a whole number of steps ≥ ${n}`);let r=t===`jump-start`||t===`start`||t===`jump-both`,i={"jump-start":e,start:e,"jump-end":e,end:e,"jump-both":e+1,"jump-none":e-1}[t],a=+!!r;return Ol(t=>Math.min(i,Math.floor(t*e)+a)/i)}const Ol=e=>t=>{let n=Math.min(1,Math.max(0,t));return n===1?1:e(n)},kl=Ol(e=>e),Al=Dl(1,`jump-end`),jl=Ol(e=>(1-Math.cos(Math.PI*e))/2),Ml=.001,Nl={stiffness:100,damping:10,mass:1};function Pl(e={}){let{stiffness:t,damping:n,mass:r}={...Nl,...e};for(let[e,i]of[[`stiffness`,t],[`damping`,n],[`mass`,r]])Yl(`spring ${e}`,i);let i=Math.sqrt(t/r),a=n/(2*Math.sqrt(t*r)),o=a*i,{displacement:s,seconds:c}=a<1?Il(i,a,o):Ll(i,a,o);return{seconds:c,ease:Ol(e=>1-s(e*c))}}function Fl(e,t,n){for(let r=0;r<64;r++){let r=(t+n)/2;Math.abs(e(r))>.001?t=r:n=r}return n}function Il(e,t,n){let r=e*Math.sqrt(1-t*t),i=n/r,a=e=>Math.exp(-n*e)*(Math.cos(r*e)+i*Math.sin(r*e)),o=Math.ceil(Math.log(1/Ml)/(n*Math.PI/r));return{displacement:a,seconds:Fl(a,(o-1)*Math.PI/r,(o*Math.PI-Math.atan(1/i))/r)}}function Ll(e,t,n){let{displacement:r,far:i}=t===1?Rl(e):zl(e,t,n);return{displacement:r,seconds:Fl(r,0,i)}}function Rl(e){return{displacement:t=>Math.exp(-e*t)*(1+e*t),far:10/e}}function zl(e,t,n){let r=Math.sqrt(t*t-1),i=e*r,a=e/(t+r),o=n+i,s=n/i;return{displacement:e=>((1+s)*Math.exp(-a*e)+(1-s)*Math.exp(-o*e))/2,far:Math.log((1+s)/(2*Ml))/a}}const Bl=[{until:1/2.75,centre:0,floor:0},{until:2/2.75,centre:1.5/2.75,floor:.75},{until:2.5/2.75,centre:2.25/2.75,floor:.9375},{until:1/0,centre:2.625/2.75,floor:.984375}],Vl=Ol(e=>{let t=Bl.find(({until:t})=>e<t);return 7.5625*(e-t.centre)**2+t.floor}),Hl=1.70158,Ul=Ol(e=>e**3+Hl*e**2*(e-1)),Wl=Ol(e=>{let t=e-1;return 1+t**3+Hl*t**2*(t+1)}),Gl=2*Math.PI/3,Kl=Ol(e=>2**(-10*e)*Math.sin((10*e-.75)*Gl)+1),ql={linear:kl,ease:El(.25,.1,.25,1),"ease-in":El(.42,0,1,1),"ease-out":El(0,0,.58,1),"ease-in-out":El(.42,0,.58,1),"step-start":Dl(1,`jump-start`),"step-end":Al,step:Al,sine:jl,spring:Pl().ease,bounce:Vl,"back-in":Ul,"back-out":Wl,elastic:Kl};function Jl(e){if(!Object.hasOwn(ql,e))throw RangeError(`unknown ease ${JSON.stringify(e)}; expected one of `+Object.keys(ql).map(e=>JSON.stringify(e)).join(`, `));return ql[e]}function Yl(e,t,n=``){if(!(Number.isFinite(t)&&t>0))throw RangeError(`${e} must be a positive number${n}, got ${t}`)}function Xl(e,t){Yl(e,t,` of seconds`)}function Zl(e,t,n){if(!Number.isFinite(t))throw RangeError(`${e} needs a finite t, got ${t}`);let r=t%n;if(r>=0)return r;let i=r+n;return i>=n?0:i}function Ql(e){return e===0?Number.MIN_VALUE:($l[0]=e,eu[0]+=e>0?1n:-1n,$l[0])}const $l=new Float64Array(1),eu=new BigUint64Array($l.buffer);function tu(e,t,n){let r=e;for(let e=0;!t(r);e++){if(e===8)throw RangeError(n());r=Ql(r)}return r}function nu(e,t){if(!Number.isFinite(e))throw RangeError(`firstReaching needs a finite guess, got ${e}`);let n=e,r=e;for(let i=Ql(Math.abs(e))-Math.abs(e);t(n);i*=2){if(n===-Number.MAX_VALUE)return-1/0;r=n,n=Math.max(e-i,-Number.MAX_VALUE)}for(let i=Ql(Math.abs(e))-Math.abs(e);!t(r);i*=2){if(r===Number.MAX_VALUE)return 1/0;n=r,r=Math.min(e+i,Number.MAX_VALUE)}for(;;){let e=n+(r-n)/2;if(e<=n||e>=r)return r;t(e)?r=e:n=e}}function ru(e){if(e.length===0)throw RangeError(`a beat needs at least one hold`);e.forEach((e,t)=>Xl(`beat hold ${t}`,e));let t=e.reduce((e,t)=>e+t,0),n=[],r=0;for(let t of e)n.push(r),r+=t;let i=[...e],a=e=>{let t=i.length-1;for(;n[t]>e;)t--;return t},o=(e,r,o,s)=>tu(r*t+n[o],n=>a(Zl(e,n,t))===o,()=>`${e}: hold ${o} (${i[o]} s) is finer than time resolves near t = ${s}`),s=(e,n)=>Math.round((e-n)/t);return{holds:i,period:t,at(e){return a(Zl(`Beat.at`,e,t))},lastChange(e){let n=Zl(`Beat.lastChange`,e,t);return o(`Beat.lastChange`,s(e,n),a(n),e)},nextChange(e){let n=Zl(`Beat.nextChange`,e,t),r=a(n),c=r===i.length-1;return o(`Beat.nextChange`,s(e,n)+ +!!c,c?0:r+1,e)}}}const iu={once(e,t){if(!Number.isFinite(e))throw RangeError(`Phase.once start must be finite, got ${e}`);return Xl(`Phase.once duration`,t),n=>Math.min(1,Math.max(0,(n-e)/t))},loop(e){return Xl(`Phase.loop period`,e),t=>Zl(`Phase.loop`,t,e)/e},pingPong(e){Xl(`Phase.pingPong period`,e);let t=iu.loop(e);return e=>1-Math.abs(2*t(e)-1)}},au={constant(e){return{at:()=>e,nextChange:()=>1/0,lastChange:()=>-1/0}},continuous(e){return{at:e,nextChange:e=>e,lastChange:e=>e}},map(e,t){return{at:n=>t(e.at(n)),nextChange:t=>e.nextChange(t),lastChange:t=>e.lastChange(t)}},all(e){return{at:t=>e.map(e=>e.at(t)),nextChange:t=>Math.min(...e.map(e=>e.nextChange(t))),lastChange:t=>Math.max(...e.map(e=>e.lastChange(t)))}},sequence(e,t,n){Xl(`Animation.sequence seconds`,t);let r=e=>Number.isFinite(e)?nu(e+t,n=>n-t>=e):e;return{at:r=>r-t>=0?n.at(r-t):e.at(r),nextChange(i){let a=i-t;return a<0?Math.min(e.nextChange(i),t):Math.max(i,r(n.nextChange(a)))},lastChange(i){let a=i-t;return a<0?e.lastChange(i):Math.min(i,Math.max(t,r(n.lastChange(a))))}}}};function ou(e,t,n){for(let[n,r]of[[`from`,e],[`to`,t]])if(!Number.isFinite(r))throw RangeError(`tween ${n} must be finite, got ${r}`);let{ease:r,seconds:i}=n,a=iu.once(0,i);return e===t?au.constant(e):{at(n){let i=r(a(n));return(1-i)*e+i*t},nextChange:e=>e<0?0:e<i?e:1/0,lastChange:e=>e<0?-1/0:e<i?e:i}}var su=class{ease;stops;constructor(e,t){if(this.ease=e,this.stops=t,t.length===0)throw RangeError(`a ColorRamp needs at least one stop`);for(let[e,n]of t.entries()){if(!Number.isFinite(n.at))throw RangeError(`ColorRamp stop ${e} has a non-finite position ${n.at}`);let r=t[e-1];if(r!==void 0&&n.at<r.at)throw RangeError(`ColorRamp stops must be in ascending position order; stop ${e} at ${n.at} follows stop ${e-1} at ${r.at}`)}}at(e){if(!Number.isFinite(e))throw RangeError(`ColorRamp.at needs a finite value, got ${e}`);let t=this.stops,n=-1;for(;n+1<t.length&&t[n+1].at<=e;)n++;if(n<0)return t[0].color;let r=t[n];if(n===t.length-1)return r.color;let i=t[n+1],a=this.ease((e-r.at)/(i.at-r.at));return a<=0?r.color:a>=1?i.color:Mc.fromRgba(r.color).mix(Mc.fromRgba(i.color),a).toRgba()}over(e){let t=this.stops[0].at,n=this.stops[this.stops.length-1].at;return au.map(ou(t,n,{seconds:e,ease:ql.linear}),e=>this.at(e))}};function cu(e,t){if(!Number.isFinite(t))throw RangeError(`${e} must be a finite number of seconds, got ${t}`);return t}const lu=e=>cu(`Timeline host time`,e);function uu(e){if(!Number.isFinite(e)||e===0)throw RangeError(`Timeline rate must be finite and not zero, got ${e}`);return e}function du(e,t,n,r){let i=lu(t);return e.playing?{playing:!0,origin:i,time:n,rate:r}:{playing:!1,time:n,rate:r}}function fu(e,{origin:t,time:n,rate:r}){let i=e=>n+r*(e-t),a=r>0,o=a?t=>e.nextChange(t):t=>e.lastChange(t),s=a?t=>e.lastChange(t):t=>e.nextChange(t),c=a?(e,t)=>e>=t:(e,t)=>e<t,l=e=>{let a=t+(e-n)/r;return Number.isFinite(a)?nu(a,t=>c(i(t),e)):a};return{at:t=>e.at(i(lu(t))),nextChange(e){let t=lu(e),n=i(t),r=o(n);return r===n?t:Math.max(t,l(r))},lastChange(e){let t=lu(e),n=i(t),r=s(n);return r===n?t:Math.min(t,l(r))}}}const pu={play(e,t=1){return{playing:!0,origin:cu(`Timeline.play origin`,e),time:0,rate:uu(t)}},at(e,t){let n=lu(t);return e.playing?e.time+e.rate*(n-e.origin):e.time},pause(e,t){return{playing:!1,time:pu.at(e,t),rate:e.rate}},resume(e,t){return{playing:!0,origin:lu(t),time:pu.at(e,t),rate:e.rate}},seek(e,t,n){return du(e,t,cu(`Timeline.seek time`,n),e.rate)},withRate(e,t,n){return du(e,t,pu.at(e,t),uu(n))},run(e,t){return e.playing?fu(t,e):{at:n=>t.at(pu.at(e,n)),nextChange:e=>(lu(e),1/0),lastChange:e=>(lu(e),-1/0)}}};function mu(e,t){return{owner:e.owner,row:e.row,col:e.col+t,inner:e.inner&&mu(e.inner,t)}}function hu(e,t){for(let n=e;n;n=n.inner)if(n.owner===t)return!0;return!1}const gu=[`bold`,`dim`,`italic`,`underline`,`blink`,`blink2`,`reverse`,`conceal`,`strike`,`underline2`,`frame`,`encircle`,`overline`],_u={bold:1,dim:2,italic:3,underline:4,blink:5,blink2:6,reverse:7,conceal:8,strike:9,underline2:21,frame:51,encircle:52,overline:53},vu={b:`bold`,d:`dim`,i:`italic`,u:`underline`,s:`strike`,r:`reverse`,o:`overline`,uu:`underline2`};var yu=class extends Error{constructor(e,t){super(e,t),this.name=`StyleSyntaxError`}};const bu=new Go;var H=class e{color;bgcolor;bold;dim;italic;underline;blink;blink2;reverse;conceal;strike;underline2;frame;encircle;overline;link;meta;anchor;nextChange;constructor(e={}){let t=e.nextChange??1/0;if(!(t>-1/0))throw RangeError(`Style nextChange must be a time in seconds or Infinity, got ${t}`);this.nextChange=t,this.color=Au(e.color),this.bgcolor=ju(e.bgcolor),this.bold=e.bold,this.dim=e.dim,this.italic=e.italic,this.underline=e.underline,this.blink=e.blink,this.blink2=e.blink2,this.reverse=e.reverse,this.conceal=e.conceal,this.strike=e.strike,this.underline2=e.underline2,this.frame=e.frame,this.encircle=e.encircle,this.overline=e.overline,this.link=e.link||void 0,this.meta=e.meta,this.anchor=e.anchor}get isNull(){return this.color===void 0&&this.bgcolor===void 0&&this.bold===void 0&&this.dim===void 0&&this.italic===void 0&&this.underline===void 0&&this.blink===void 0&&this.blink2===void 0&&this.reverse===void 0&&this.conceal===void 0&&this.strike===void 0&&this.underline2===void 0&&this.frame===void 0&&this.encircle===void 0&&this.overline===void 0&&this.link===void 0&&this.meta===void 0&&this.anchor===void 0&&this.nextChange===1/0}get transparentBackground(){return this.bgcolor===void 0||this.bgcolor.isDefault}get backgroundStyle(){return new e({bgcolor:this.bgcolor})}with(t){return new e({...this,...t})}get withoutColor(){return this.with({color:void 0,bgcolor:void 0})}withLink(e){return this.with({link:e})}clearMetaAndLinks(){return this.with({link:void 0,meta:void 0})}withAnchor(e){return this.with({anchor:e})}shiftedBy(e){return this.anchor?this.withAnchor(mu(this.anchor,e)):this}add(t){return!t||t.isNull?this:this.isNull?t:new e({color:t.color??this.color,bgcolor:t.bgcolor??this.bgcolor,bold:t.bold??this.bold,dim:t.dim??this.dim,italic:t.italic??this.italic,underline:t.underline??this.underline,blink:t.blink??this.blink,blink2:t.blink2??this.blink2,reverse:t.reverse??this.reverse,conceal:t.conceal??this.conceal,strike:t.strike??this.strike,underline2:t.underline2??this.underline2,frame:t.frame??this.frame,encircle:t.encircle??this.encircle,overline:t.overline??this.overline,link:t.link??this.link,meta:t.meta&&this.meta?{...this.meta,...t.meta}:t.meta??this.meta,anchor:t.anchor??this.anchor,nextChange:Math.min(this.nextChange,t.nextChange)})}equals(e){return this===e?!0:this.color?.name===e.color?.name&&this.bgcolor?.name===e.bgcolor?.name&&this.bold===e.bold&&this.dim===e.dim&&this.italic===e.italic&&this.underline===e.underline&&this.blink===e.blink&&this.blink2===e.blink2&&this.reverse===e.reverse&&this.conceal===e.conceal&&this.strike===e.strike&&this.underline2===e.underline2&&this.frame===e.frame&&this.encircle===e.encircle&&this.overline===e.overline&&this.link===e.link&&Pu(this.anchor,e.anchor)&&this.nextChange===e.nextChange}drawnColors(e){let t=Ss,n=this.bgcolor?.flattenAlpha(t),r=n?.getTruecolor(void 0,!1)??t,i=this.color?.flattenAlpha(r),a=t=>e===void 0?t:t.downgrade(e);return{color:i===void 0?void 0:a(i),bgcolor:n===void 0?void 0:a(n)}}toSgrCodes(e){if(this.isNull)return``;let t=this.drawnColors(e);return[...gu.filter(e=>this[e]===!0).map(e=>`${_u[e]}`),...t.color?.getAnsiCodes(!0)??[],...t.bgcolor?.getAnsiCodes(!1)??[]].join(`;`)}toString(){if(this.isNull)return`none`;let e=[];for(let t of gu)this[t]===!1&&e.push(`not ${t}`);for(let t of gu)this[t]===!0&&e.push(t);return this.color&&e.push(this.color.name),this.bgcolor&&e.push(`on ${this.bgcolor.name}`),this.link&&e.push(`link ${this.link}`),e.join(` `)||`none`}static null(){return U}static fromColor(t,n){return new e({color:t,bgcolor:n})}static fromMeta(t){return new e({meta:t})}static pickFirst(...e){for(let t of e)if(t!==void 0)return t;throw Error(`All arguments are undefined`)}static combine(e){let t=U;for(let n of e)n&&(t=t.add(n));return t}static chain(...t){return e.combine(t)}static normalize(e){return e.trim().replace(/\s+/g,` `)}static parse(t){let n=e.normalize(t);return n===``||n===`none`?U:bu.get(n,ku)}};const U=new H,xu=/^[a-z][a-z0-9._-]*$/;function Su(e,t){return e instanceof H?e.add(t):e===``?t:typeof e==`string`?{under:e,over:t}:{under:e.under,over:e.over.add(t)}}var Cu=class{styles;constructor(e={},t){if(this.styles=new Map,t?.inherit!==!1)for(let[e,t]of Object.entries(Mu))this.styles.set(e,t);for(let[t,n]of Object.entries(e)){if(!xu.test(t))throw Error(`Invalid style name: "${t}" (must be lowercase, start with letter, contain only letters, digits, ".", "-", "_")`);this.styles.set(t,H.parse(n))}}get(e){return this.styles.get(e)}resolve(e){return e instanceof H?e:typeof e==`string`?this.styles.get(e)??H.parse(e):this.resolve(e.under).add(e.over)}has(e){return this.styles.has(e)}};const wu=new Set(gu),Tu=[`not`,`on`,`link`,...gu,...vc];function Eu(e,t){let n=[],r=Array.from({length:t.length+1},(e,t)=>t);for(let i=1;i<=e.length;i++){let a=[i];for(let o=1;o<=t.length;o++){let s=i>1&&o>1&&e[i-1]===t[o-2]&&e[i-2]===t[o-1];a[o]=Math.min(r[o]+1,a[o-1]+1,r[o-1]+Number(e[i-1]!==t[o-1]),s?n[o-2]+1:1/0)}[n,r]=[r,a]}return r[t.length]}function Du(e,t){let n=e.toLowerCase(),r=Math.max(1,Math.floor(n.length/3)),i=t.filter(e=>Math.abs(e.length-n.length)<=r).map(e=>({name:e,distance:Eu(n,e)})),a=Math.min(r,...i.map(e=>e.distance)),o=i.filter(e=>e.distance===a).map(e=>`"${e.name}"`).sort();return o.length===0?``:` (did you mean ${o.join(` or `)}?)`}function Ou(e,t,n){try{return V.parse(e)}catch(r){throw new yu(`${t} "${e}"${Du(e,n)}: ${String(r)}`,{cause:r})}}function ku(e){let t=e.split(/\s+/),n={},r=0;for(;r<t.length;){let e=t[r];if(e===`not`){r++;let e=t[r];if(!e)throw new yu(`Expected attribute after "not" in style definition`);let i=vu[e]??e;if(!wu.has(i))throw new yu(`Invalid attribute: "${e}"${Du(e,gu)}`);n[i]=!1,r++;continue}if(e===`on`){r++;let e=t[r];if(!e)throw new yu(`Expected color after "on" in style definition`);n.bgcolor=Ou(e,`Invalid background color`,vc),r++;continue}if(e===`link`){r++;let e=t[r];e&&(n.link=e),r++;continue}let i=vu[e]??e;if(wu.has(i)){n[i]=!0,r++;continue}n.color=Ou(e,`Invalid style definition`,Tu),r++}return new H(n)}function Au(e){if(e!==void 0)return e instanceof V?e:V.parse(e)}function ju(e){let t=Au(e);return t?.value?.alpha===0?void 0:t}const Mu={none:U,reset:new H({color:V.default(),bgcolor:V.default(),bold:!1,dim:!1,italic:!1,underline:!1,blink:!1,blink2:!1,reverse:!1,conceal:!1,strike:!1,underline2:!1,frame:!1,encircle:!1,overline:!1}),bold:new H({bold:!0}),dim:new H({dim:!0}),italic:new H({italic:!0}),underline:new H({underline:!0}),blink:new H({blink:!0}),blink2:new H({blink2:!0}),reverse:new H({reverse:!0}),conceal:new H({conceal:!0}),strike:new H({strike:!0}),underline2:new H({underline2:!0}),frame:new H({frame:!0}),encircle:new H({encircle:!0}),overline:new H({overline:!0}),"table.header":new H({bold:!0}),"table.footer":new H({bold:!0}),"table.cell":U,"table.title":new H({italic:!0}),"table.caption":new H({italic:!0,dim:!0}),"repr.ellipsis":H.parse(`yellow`),"repr.indent":H.parse(`dim green`),"repr.error":H.parse(`bold red`),"repr.str":H.parse(`not bold not italic green`),"repr.brace":H.parse(`bold`),"repr.comma":H.parse(`bold`),"repr.ipv4":H.parse(`bold bright_green`),"repr.ipv6":H.parse(`bold bright_green`),"repr.eui48":H.parse(`bold bright_green`),"repr.eui64":H.parse(`bold bright_green`),"repr.tag_start":H.parse(`bold`),"repr.tag_name":H.parse(`bold bright_magenta`),"repr.tag_contents":H.parse(`default`),"repr.tag_end":H.parse(`bold`),"repr.attrib_name":H.parse(`not italic yellow`),"repr.attrib_equal":H.parse(`bold`),"repr.attrib_value":H.parse(`not italic magenta`),"repr.number":H.parse(`bold not italic cyan`),"repr.number_complex":H.parse(`bold not italic cyan`),"repr.bool_true":H.parse(`italic bright_green`),"repr.bool_false":H.parse(`italic bright_red`),"repr.none":H.parse(`italic magenta`),"repr.url":H.parse(`not bold not italic underline bright_blue`),"repr.uuid":H.parse(`not bold bright_yellow`),"repr.call":H.parse(`bold magenta`),"repr.path":H.parse(`magenta`),"repr.filename":H.parse(`bright_magenta`),"log.time":H.parse(`cyan dim`),"log.message":U,"log.path":H.parse(`dim`),"log.line_no":H.parse(`cyan`),"log.level":U,"rule.line":H.parse(`bright_green`),"rule.text":U,"strip.separator":H.parse(`bright_black`),"strip.rail":H.parse(`bright_black`),"json.brace":H.parse(`bold`),"json.bool_true":H.parse(`italic bright_green`),"json.bool_false":H.parse(`italic bright_red`),"json.key":H.parse(`bold blue`),"json.null":H.parse(`italic magenta`),"json.number":H.parse(`bold not italic cyan`),"json.str":H.parse(`not bold not italic green`),"syntax.keyword":H.parse(`bold magenta`),"syntax.constant":H.parse(`italic bright_magenta`),"syntax.string":H.parse(`green`),"syntax.number":H.parse(`cyan`),"syntax.comment":H.parse(`dim italic`),"syntax.line_number":H.parse(`dim`),"syntax.line_number.highlight":H.parse(`bold grey93 on grey27`),"markdown.h1":H.parse(`bold underline`),"markdown.h2":H.parse(`underline magenta`),"markdown.h3":H.parse(`bold magenta`),"markdown.h4":H.parse(`italic magenta`),"markdown.h5":H.parse(`italic`),"markdown.h6":H.parse(`dim`),"markdown.code":H.parse(`bold dark_turquoise on grey11`),"markdown.em":H.parse(`italic`),"markdown.strong":H.parse(`bold`),"markdown.s":H.parse(`strike`),"markdown.kbd":H.parse(`bold bright_yellow`),"markdown.block_quote":H.parse(`magenta`),"markdown.hr":H.parse(`dim`),"markdown.item":U,"markdown.item.bullet":H.parse(`bold`),"markdown.item.number":H.parse(`cyan`),"markdown.link":H.parse(`bright_blue`),"markdown.link_url":H.parse(`underline blue`),"markdown.table.border":H.parse(`cyan`),"markdown.table.header":H.parse(`not bold cyan`),"progress.description":U,"progress.percentage":H.parse(`magenta`),"progress.remaining":H.parse(`cyan`),"progress.elapsed":H.parse(`yellow`),"progress.spinner":H.parse(`green`),"progress.download":H.parse(`green`),"progress.filesize":H.parse(`green`),"progress.filesize.total":H.parse(`green`),"progress.data.speed":H.parse(`red`),"bar.back":H.parse(`grey23`),"bar.complete":H.parse(`rgb(249,38,114)`),"bar.finished":H.parse(`rgb(114,156,31)`),"bar.pulse":H.parse(`rgb(249,38,114)`),"scrollbar.thumb":U,"scrollbar.track":H.parse(`grey37`),tree:U,"tree.guide":U,"status.spinner":H.parse(`green`),"status.message":U,prompt:U,"prompt.choices":H.parse(`bold magenta`),"prompt.default":H.parse(`bold cyan`),"prompt.invalid":H.parse(`red`),"prompt.invalid.choice":H.parse(`red`),"inspect.attr":H.parse(`yellow italic`),"inspect.attr.dunder":H.parse(`yellow italic dim`),"inspect.callable":H.parse(`bold magenta`),"inspect.error":H.parse(`bold red`),"inspect.help":H.parse(`cyan`),"inspect.doc":H.parse(`dim`),"inspect.value.border":H.parse(`green`),"traceback.border":H.parse(`red`),"traceback.text":H.parse(`red`),"traceback.title":H.parse(`bold red`),"traceback.exc_type":H.parse(`bold bright_red`),"traceback.exc_value":U,"traceback.offset":H.parse(`bold bright_red`),"scope.border":H.parse(`blue`),"scope.key":H.parse(`italic`),"scope.key.special":H.parse(`dim italic`),pretty:U,"iso8601.date":H.parse(`blue`),"iso8601.time":H.parse(`magenta`),"iso8601.timezone":H.parse(`yellow`),"iso8601.year":U,"iso8601.month":U,"iso8601.day":U,"iso8601.week":U,"iso8601.hour":U,"iso8601.minute":U,"iso8601.second":U,"iso8601.frac":U,"iso8601.ms":U,"iso8601.hyphen":U},Nu=new Cu;function Pu(e,t){return e===t?!0:!e||!t?!1:e.owner===t.owner&&e.row===t.row&&e.col===t.col&&Pu(e.inner,t.inner)}var Fu;(function(e){e.BELL=`bell`,e.CARRIAGE_RETURN=`carriage_return`,e.HOME=`home`,e.CLEAR=`clear`,e.SHOW_CURSOR=`show_cursor`,e.HIDE_CURSOR=`hide_cursor`,e.ENABLE_ALT_SCREEN=`enable_alt_screen`,e.DISABLE_ALT_SCREEN=`disable_alt_screen`,e.CURSOR_UP=`cursor_up`,e.CURSOR_DOWN=`cursor_down`,e.CURSOR_FORWARD=`cursor_forward`,e.CURSOR_BACKWARD=`cursor_backward`,e.CURSOR_MOVE_TO_COLUMN=`cursor_move_to_column`,e.CURSOR_MOVE_TO=`cursor_move_to`,e.ERASE_IN_LINE=`erase_in_line`,e.SET_WINDOW_TITLE=`set_window_title`})(Fu||={});var W=class e{text;style;control;constructor(e,t,n){this.text=e,this.style=t,this.control=n}get cellLength(){return this.control?0:R(this.text)}get hasText(){return this.text.length>0}get isControl(){return this.control!==void 0}splitCells(t){return t>=this.cellLength?[this,new e(``)]:t<=0?[new e(``),this]:this.cutAt([t])}cutAt(t){return ts(this.text,t).map((n,r)=>new e(n,r===0?this.style:this.style?.shiftedBy(t[r-1])))}static _line;static line(){return e._line??=new e(`
41
+ `),_o(a.binPath,i,n),process.stdout.write(ho());let o=Ha(za,Va(qe,await Ba(za,fetch,`https://registry.npmjs.org`)));process[o.stream].write(o.text)}function _o(e,t,n,r){let i=r??Sa(xa(ba(process.env,process.cwd())));p.mkdirSync(s.dirname(i),{recursive:!0});let a=Da(i).statusLine,o=Na(a)?a.command:void 0,c=[e,je(e),Ae(e)],l=typeof o==`string`&&(o.startsWith(`pnpm dlx @promptctl/cc-candybar@`)||c.some(e=>o===e||o.startsWith(`${e} `)));if(o&&!l&&!n){process.stderr.write(`Skipping settings.json update: existing statusLine.command appears customized.\n Current: ${o}\n To overwrite, re-run with --force.\n`);return}let u=qa(e,t);O(i,(Na(a)?[[[`statusLine`,`type`],`command`],[[`statusLine`,`command`],u]]:[[[`statusLine`],{type:`command`,command:u}]]).reduce((e,[t,n])=>Vi(e,t,JSON.stringify(n,null,2),Ei),Ea(i))),process.stdout.write(`Updated ${i}\n`)}function vo(e,t){return e.kind===`owned`?t(e.pid,e.startTime)?{kind:`attach-and-exit`,reason:`live owner pid=${e.pid} holds the socket`}:{kind:`reclaim`,reason:`owner pid=${e.pid} is gone or recycled`}:e.kind===`absent`?{kind:`reclaim`,reason:`no lease — stale socket, no live owner`}:{kind:`reclaim`,reason:`unreadable lease (${e.detail}) — cannot prove a live owner`}}function yo(e){let t;try{t=p.readFileSync(e,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:`read failed: ${e.message}`}}let n;try{n=JSON.parse(t)}catch(e){return{kind:`unreadable`,detail:`bad JSON: ${e.message}`}}let r=n,i=r?.pid;if(typeof i!=`number`||!Number.isInteger(i)||i<=0)return{kind:`unreadable`,detail:`no valid pid (got ${JSON.stringify(i)})`};let a=r?.startTime;return a!=null&&typeof a!=`string`?{kind:`unreadable`,detail:`invalid startTime (got ${JSON.stringify(a)})`}:{kind:`owned`,pid:i,startTime:a??null}}function bo(e,n){let r=`${e}.${t.pid}.tmp`;try{return p.writeFileSync(r,JSON.stringify(n),{mode:384}),p.renameSync(r,e),null}catch(e){let t=e.message;try{p.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`)return`${t}; also failed to remove temp ${r}: ${e.message}`}return t}}function xo(e,t){let n=yo(e);if(n.kind===`owned`&&n.pid===t)try{p.unlinkSync(e)}catch{}}function So(e){try{let t=p.statSync(e);return{kind:`present`,identity:{dev:t.dev,ino:t.ino}}}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:e.message}}}function Co(e,t,n,r){let i=wo(e,t);return i===null?r.kind===`owned`?r.pid===n?{kind:`owned`}:{kind:`displaced`,reason:`lease reassigned (names pid=${r.pid}, we are pid=${n}) — a reclaimer overwrote it`}:{kind:`displaced`,reason:`lease not held (${r.kind}) — no longer the socket owner`}:{kind:`displaced`,reason:i}}function wo(e,t){return t.kind===`present`?t.identity.dev===e.dev&&t.identity.ino===e.ino?null:`socket replaced (bound dev=${e.dev} ino=${e.ino}, now dev=${t.identity.dev} ino=${t.identity.ino})`:t.kind===`absent`?`socket path gone (ENOENT) — unlinked by a reclaimer`:`socket path unreadable (${t.detail}) — cannot prove ownership`}function To(e){let t=!1;function n(){let n=Co(e.bound,e.readIdentity(),e.myPid,e.readLease());return n.kind===`displaced`&&!t&&(t=!0,e.log(`warn`,`ownership self-check: ${n.reason}; shutting down`),e.shutdown(0)),n}function r(t=e.intervalMs??5e3){let r=setInterval(()=>{n().kind===`displaced`&&clearInterval(r)},t);return r.unref(),{disarm:()=>clearInterval(r)}}return{check:n,arm:r}}function Eo(e,t=ut){let n=t({bin:`ps`,args:[`-o`,`lstart=`,`-p`,String(e)],category:`process-fingerprint`,timeoutMs:2e3,env:{...process.env,LC_ALL:`C`,TZ:`UTC`}});if(n.ok){let e=n.stdout.trim();return e.length>0?{kind:`start`,token:e}:{kind:`unavailable`,detail:`ps produced no start-time`}}return{kind:`unavailable`,detail:n.reason===`spawn-error`?n.error??`ps spawn failed`:`ps ${n.reason} (exit ${n.exitCode})`}}function Do(e,t,n){if(t===null)return n.pidAlive(e);let r=n.readStartTime(e);switch(r.kind){case`start`:return r.token===t;case`unavailable`:return n.pidAlive(e)}}function Oo(e,t=Eo){let n=t(e);return n.kind===`start`?n.token:null}const ko=`CC_CANDYBAR_PARENT_PID`;function Ao(e){let t=e[ko];if(t===void 0)return{kind:`outlives-nobody`};let n=Number.parseInt(t,10);if(!Number.isInteger(n)||n<=0)throw Error(`${ko} must be a positive integer pid, got ${JSON.stringify(t)}`);return{kind:`anchored`,pid:n}}function jo(e){if(e.anchor.kind===`outlives-nobody`)return{disarm:()=>{}};let{pid:t}=e.anchor,n=setInterval(()=>{e.isAlive(t)||e.onOrphaned(`spawner pid ${t} gone`)},e.intervalMs??250);return n.unref(),{disarm:()=>clearInterval(n)}}function Mo(e){try{return t.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function No(){let e=Number(process.env.CC_CANDYBAR_DAEMON_CEILING??``);return Number.isInteger(e)&&e>0?e:16}function Po(e,t,n){return e?t>=n?{allow:!1,reason:`${t} live isolated daemons registered >= ceiling ${n}`}:{allow:!0,reason:`${t} live isolated daemons registered < ceiling ${n}`}:{allow:!0,reason:`canonical production socket — exempt (bind() already caps it to one)`}}function Fo(e){try{return p.readdirSync(e).filter(e=>e.endsWith(`.json`)).map(t=>s.join(e,t))}catch{return[]}}function Io(e){let t;try{t=p.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(t),n=e?.pid;return typeof n!=`number`||!Number.isInteger(n)||n<=0?null:{pid:n,startTime:typeof e?.startTime==`string`?e.startTime:null}}catch{return null}}function Lo(e,t,n){let r=0;for(let i of e)t(i.identity.pid,i.identity.startTime)?r++:n(i.path);return r}function Ro(e){if(!e.isolated)return{decision:Po(!1,0,e.ceiling),registryPath:null};e.ensureDirSafe(e.registryDir);let t=[];for(let n of e.listFiles(e.registryDir)){let r=e.readEntry(n);r!==null&&r.pid!==e.pid&&t.push({path:n,identity:r})}let n=Po(!0,Lo(t,e.isSameLiveProcess,e.removeFile),e.ceiling);if(!n.allow)return{decision:n,registryPath:null};let r=s.join(e.registryDir,`pid-${e.pid}.json`);return e.writeEntry(r,{pid:e.pid,startTime:e.startTime}),{decision:n,registryPath:r}}function zo(e,t,n,r){let i=n(e);if(i!==null&&i.pid===t)try{r(e)}catch{}}function Bo(e,t={}){return{isolated:!!process.env.CC_CANDYBAR_SOCKET,registryDir:Et(),ceiling:No(),pid:process.pid,startTime:e,isSameLiveProcess:(e,t)=>Do(e,t,{readStartTime:Eo,pidAlive:Mo}),listFiles:Fo,readEntry:Io,removeFile:e=>{try{p.unlinkSync(e)}catch{}},writeEntry:(e,t)=>{let n=`${e}.${t.pid}.tmp`;try{p.writeFileSync(n,JSON.stringify(t),{mode:384}),p.renameSync(n,e)}catch(e){try{p.unlinkSync(n)}catch(e){e.code}throw e}},ensureDirSafe:process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR?bt:e=>{bt(s.dirname(e)),bt(e)},...t}}const Vo=[[0,0,0],[768,879,0],[1155,1161,0],[1425,1469,0],[1471,1471,0],[1473,1474,0],[1476,1477,0],[1479,1479,0],[1552,1562,0],[1564,1564,0],[1611,1631,0],[1648,1648,0],[1750,1756,0],[1759,1764,0],[1767,1768,0],[1770,1773,0],[1809,1809,0],[1840,1866,0],[1958,1968,0],[2027,2035,0],[2045,2045,0],[2070,2073,0],[2075,2083,0],[2085,2087,0],[2089,2093,0],[2137,2139,0],[2199,2207,0],[2250,2273,0],[2275,2307,0],[2362,2364,0],[2366,2383,0],[2385,2391,0],[2402,2403,0],[2433,2435,0],[2492,2492,0],[2494,2500,0],[2503,2504,0],[2507,2509,0],[2519,2519,0],[2530,2531,0],[2558,2558,0],[2561,2563,0],[2620,2620,0],[2622,2626,0],[2631,2632,0],[2635,2637,0],[2641,2641,0],[2672,2673,0],[2677,2677,0],[2689,2691,0],[2748,2748,0],[2750,2757,0],[2759,2761,0],[2763,2765,0],[2786,2787,0],[2810,2815,0],[2817,2819,0],[2876,2876,0],[2878,2884,0],[2887,2888,0],[2891,2893,0],[2901,2903,0],[2914,2915,0],[2946,2946,0],[3006,3010,0],[3014,3016,0],[3018,3021,0],[3031,3031,0],[3072,3076,0],[3132,3132,0],[3134,3140,0],[3142,3144,0],[3146,3149,0],[3157,3158,0],[3170,3171,0],[3201,3203,0],[3260,3260,0],[3262,3268,0],[3270,3272,0],[3274,3277,0],[3285,3286,0],[3298,3299,0],[3315,3315,0],[3328,3331,0],[3387,3388,0],[3390,3396,0],[3398,3400,0],[3402,3405,0],[3415,3415,0],[3426,3427,0],[3457,3459,0],[3530,3530,0],[3535,3540,0],[3542,3542,0],[3544,3551,0],[3570,3571,0],[3633,3633,0],[3636,3642,0],[3655,3662,0],[3761,3761,0],[3764,3772,0],[3784,3790,0],[3864,3865,0],[3893,3893,0],[3895,3895,0],[3897,3897,0],[3902,3903,0],[3953,3972,0],[3974,3975,0],[3981,3991,0],[3993,4028,0],[4038,4038,0],[4139,4158,0],[4182,4185,0],[4190,4192,0],[4194,4196,0],[4199,4205,0],[4209,4212,0],[4226,4237,0],[4239,4239,0],[4250,4253,0],[4352,4447,2],[4448,4607,0],[4957,4959,0],[5906,5909,0],[5938,5940,0],[5970,5971,0],[6002,6003,0],[6068,6099,0],[6109,6109,0],[6155,6159,0],[6277,6278,0],[6313,6313,0],[6432,6443,0],[6448,6459,0],[6679,6683,0],[6741,6750,0],[6752,6780,0],[6783,6783,0],[6832,6877,0],[6880,6891,0],[6912,6916,0],[6964,6980,0],[7019,7027,0],[7040,7042,0],[7073,7085,0],[7142,7155,0],[7204,7223,0],[7376,7378,0],[7380,7400,0],[7405,7405,0],[7412,7412,0],[7415,7417,0],[7616,7679,0],[8203,8207,0],[8232,8238,0],[8288,8303,0],[8400,8432,0],[8986,8987,2],[9001,9002,2],[9193,9196,2],[9200,9200,2],[9203,9203,2],[9725,9726,2],[9748,9749,2],[9776,9783,2],[9800,9811,2],[9855,9855,2],[9866,9871,2],[9875,9875,2],[9889,9889,2],[9898,9899,2],[9917,9918,2],[9924,9925,2],[9934,9934,2],[9940,9940,2],[9962,9962,2],[9970,9971,2],[9973,9973,2],[9978,9978,2],[9981,9981,2],[9989,9989,2],[9994,9995,2],[10024,10024,2],[10060,10060,2],[10062,10062,2],[10067,10069,2],[10071,10071,2],[10133,10135,2],[10160,10160,2],[10175,10175,2],[11035,11036,2],[11088,11088,2],[11093,11093,2],[11503,11505,0],[11647,11647,0],[11744,11775,0],[11904,11929,2],[11931,12019,2],[12032,12245,2],[12272,12329,2],[12330,12335,0],[12336,12350,2],[12353,12438,2],[12441,12442,0],[12443,12543,2],[12549,12591,2],[12593,12643,2],[12644,12644,0],[12645,12686,2],[12688,12773,2],[12783,12830,2],[12832,12871,2],[12880,42124,2],[42128,42182,2],[42607,42610,0],[42612,42621,0],[42654,42655,0],[42736,42737,0],[43010,43010,0],[43014,43014,0],[43019,43019,0],[43043,43047,0],[43052,43052,0],[43136,43137,0],[43188,43205,0],[43232,43249,0],[43263,43263,0],[43302,43309,0],[43335,43347,0],[43360,43388,2],[43392,43395,0],[43443,43456,0],[43493,43493,0],[43561,43574,0],[43587,43587,0],[43596,43597,0],[43643,43645,0],[43696,43696,0],[43698,43700,0],[43703,43704,0],[43710,43711,0],[43713,43713,0],[43755,43759,0],[43765,43766,0],[44003,44010,0],[44012,44013,0],[44032,55203,2],[55216,55295,0],[63744,64255,2],[64286,64286,0],[65024,65039,0],[65040,65049,2],[65056,65071,0],[65072,65106,2],[65108,65126,2],[65128,65131,2],[65279,65279,0],[65281,65376,2],[65440,65440,0],[65504,65510,2],[65520,65531,0],[66045,66045,0],[66272,66272,0],[66422,66426,0],[68097,68099,0],[68101,68102,0],[68108,68111,0],[68152,68154,0],[68159,68159,0],[68325,68326,0],[68900,68903,0],[68969,68973,0],[69291,69292,0],[69370,69375,0],[69446,69456,0],[69506,69509,0],[69632,69634,0],[69688,69702,0],[69744,69744,0],[69747,69748,0],[69759,69762,0],[69808,69818,0],[69826,69826,0],[69888,69890,0],[69927,69940,0],[69957,69958,0],[70003,70003,0],[70016,70018,0],[70067,70080,0],[70089,70092,0],[70094,70095,0],[70188,70199,0],[70206,70206,0],[70209,70209,0],[70367,70378,0],[70400,70403,0],[70459,70460,0],[70462,70468,0],[70471,70472,0],[70475,70477,0],[70487,70487,0],[70498,70499,0],[70502,70508,0],[70512,70516,0],[70584,70592,0],[70594,70594,0],[70597,70597,0],[70599,70602,0],[70604,70608,0],[70610,70610,0],[70625,70626,0],[70709,70726,0],[70750,70750,0],[70832,70851,0],[71087,71093,0],[71096,71104,0],[71132,71133,0],[71216,71232,0],[71339,71351,0],[71453,71467,0],[71724,71738,0],[71984,71989,0],[71991,71992,0],[71995,71998,0],[72e3,72e3,0],[72002,72003,0],[72145,72151,0],[72154,72160,0],[72164,72164,0],[72193,72202,0],[72243,72249,0],[72251,72254,0],[72263,72263,0],[72273,72283,0],[72330,72345,0],[72544,72551,0],[72751,72758,0],[72760,72767,0],[72850,72871,0],[72873,72886,0],[73009,73014,0],[73018,73018,0],[73020,73021,0],[73023,73029,0],[73031,73031,0],[73098,73102,0],[73104,73105,0],[73107,73111,0],[73459,73462,0],[73472,73473,0],[73475,73475,0],[73524,73530,0],[73534,73538,0],[73562,73562,0],[78896,78912,0],[78919,78933,0],[90398,90415,0],[92912,92916,0],[92976,92982,0],[94031,94031,0],[94033,94087,0],[94095,94098,0],[94176,94179,2],[94180,94180,0],[94192,94193,0],[94194,94198,2],[94208,101589,2],[101631,101662,2],[101760,101874,2],[110576,110579,2],[110581,110587,2],[110589,110590,2],[110592,110882,2],[110898,110898,2],[110928,110930,2],[110933,110933,2],[110948,110951,2],[110960,111355,2],[113821,113822,0],[113824,113827,0],[118528,118573,0],[118576,118598,0],[119141,119145,0],[119149,119170,0],[119173,119179,0],[119210,119213,0],[119362,119364,0],[119552,119638,2],[119648,119670,2],[121344,121398,0],[121403,121452,0],[121461,121461,0],[121476,121476,0],[121499,121503,0],[121505,121519,0],[122880,122886,0],[122888,122904,0],[122907,122913,0],[122915,122916,0],[122918,122922,0],[123023,123023,0],[123184,123190,0],[123566,123566,0],[123628,123631,0],[124140,124143,0],[124398,124399,0],[124643,124643,0],[124646,124646,0],[124654,124655,0],[124661,124661,0],[125136,125142,0],[125252,125258,0],[126980,126980,2],[127183,127183,2],[127374,127374,2],[127377,127386,2],[127488,127490,2],[127504,127547,2],[127552,127560,2],[127568,127569,2],[127584,127589,2],[127744,127776,2],[127789,127797,2],[127799,127868,2],[127870,127891,2],[127904,127946,2],[127951,127955,2],[127968,127984,2],[127988,127988,2],[127992,127994,2],[127995,127999,0],[128e3,128062,2],[128064,128064,2],[128066,128252,2],[128255,128317,2],[128331,128334,2],[128336,128359,2],[128378,128378,2],[128405,128406,2],[128420,128420,2],[128507,128591,2],[128640,128709,2],[128716,128716,2],[128720,128722,2],[128725,128728,2],[128732,128735,2],[128747,128748,2],[128756,128764,2],[128992,129003,2],[129008,129008,2],[129292,129338,2],[129340,129349,2],[129351,129535,2],[129648,129660,2],[129664,129674,2],[129678,129734,2],[129736,129736,2],[129741,129756,2],[129759,129770,2],[129775,129784,2],[131072,196605,2],[196608,262141,2],[917504,921599,0]],Ho=new Set([35,42,48,49,50,51,52,53,54,55,56,57,169,174,8252,8265,8482,8505,8596,8597,8598,8599,8600,8601,8617,8618,9e3,9167,9197,9198,9199,9201,9202,9208,9209,9210,9410,9642,9643,9654,9664,9723,9724,9728,9729,9730,9731,9732,9742,9745,9752,9757,9760,9762,9763,9766,9770,9774,9775,9784,9785,9786,9792,9794,9823,9824,9827,9829,9830,9832,9851,9854,9874,9876,9877,9878,9879,9881,9883,9884,9888,9895,9904,9905,9928,9935,9937,9939,9961,9968,9969,9972,9975,9976,9977,9986,9992,9993,9996,9997,9999,10002,10004,10006,10013,10017,10035,10036,10052,10055,10083,10084,10145,10548,10549,11013,11014,11015,127344,127345,127358,127359,127777,127780,127781,127782,127783,127784,127785,127786,127787,127788,127798,127869,127894,127895,127897,127898,127899,127902,127903,127947,127948,127949,127950,127956,127957,127958,127959,127960,127961,127962,127963,127964,127965,127966,127967,127987,127989,127991,128063,128065,128253,128329,128330,128367,128368,128371,128372,128373,128374,128375,128376,128377,128391,128394,128395,128396,128397,128400,128421,128424,128433,128434,128444,128450,128451,128452,128465,128466,128467,128476,128477,128478,128481,128483,128488,128495,128499,128506,128715,128717,128718,128719,128736,128737,128738,128739,128740,128741,128745,128752,128755]);function Uo(e){if(e<32||e>=127&&e<160)return 0;let t=0,n=Vo.length-1;for(;t<=n;){let r=t+n>>1,[i,a,o]=Vo[r];if(e<i)n=r-1;else if(e>a)t=r+1;else return o}return 1}function Wo(e){return Ho.has(e)}var Go=class{entries=new Map;get size(){return this.entries.size}get(e,t){let n=this.entries.get(e);if(n!==void 0)return n;let r=t(e);return this.entries.size>=4096&&this.entries.clear(),this.entries.set(e,r),r}};const Ko=new Go,qo=/[\u200d\ufe0f]/,Jo=/^[ -~]*$/;function Yo(e){let t=0,n=!1,r=!1;for(let i of e){let e=i.codePointAt(0);if(r)r=!1;else if(e===8205)r=!0;else if(e===65039)t+=+!!n,n=!1;else{let r=Uo(e);t+=r,n=r>0?Wo(e):n}}return t}function Xo(e){if(Jo.test(e))return e.length;if(!qo.test(e))return Yo(e);let t=0;for(let{segment:n}of os().segment(e))t+=Yo(n);return t}function Zo(e){return e.length===0?0:e.length<=64?Ko.get(e,Xo):Xo(e)}function Qo(e){return e}function $o(e){return e}function es(e){return e>0?Math.floor(e):0}function ts(e,t){if(t<=0)return[``,e];if(t>=Zo(e))return[e,``];let n=us(e,t);return[n+` `.repeat(t-Zo(n)),e.slice(n.length)]}function ns(e,t){let n=[],r=0,i=0,a=0,o=0,s=0;for(let c of ls(e,$o(0))){if(s===t.length)break;let l=o+Zo(c),u=o;for(;s<t.length&&t[s]<l;s++){let l=t[s];n.push(` `.repeat(i)+e.slice(r,a)+` `.repeat(l-u)),i=0,r=l===o?a:a+c.length,u=l}u>o&&(i=l-u),a+=c.length,o=l}return n.push(` `.repeat(i)+e.slice(r)),n}function rs(e,t){if(t<=0||e.length===0)return[e];let n=[],r=$o(0);for(;r<e.length;){let i=ms(e,r,t);n.push(e.slice(r,i)),r=i}return n}let is,as;function os(){return is??=new Intl.Segmenter(void 0,{granularity:`grapheme`})}function ss(e){return as?.text!==e&&(as={text:e,segments:os().segment(e)}),as.segments}function cs(e){return Array.from(ls(e,$o(0)))}function*ls(e,t){let n=ss(e);for(let r=t,i=n.containing(r);i;i=n.containing(r)){let t=i.index+i.segment.length;yield e.slice(r,t),r=$o(t)}}function us(e,t){return e.slice(0,fs(ls(e,$o(0)),t))}function ds(e,t){return e.slice(e.length-fs(cs(e).reverse(),t))}function fs(e,t){let n=0,r=0;for(let i of e){let e=Zo(i);if(n+e>t)break;n+=e,r+=i.length}return r}function ps(e,t,n){return $o(t+fs(ls(e,t),n))}function ms(e,t,n){let[r=``]=ls(e,t);return $o(Math.max(ps(e,t,n),t+r.length))}function hs(e){if(!Number.isInteger(e)||e<1)throw RangeError(`tabSize must be a positive integer, got ${e}`);return e}function gs(e,t){let[n,...r]=e.split(` `),i=[],a=[],o=(e,t)=>{let n=e.lastIndexOf(`
42
+ `);return(n<0?t:0)+Zo(e.slice(n+1))},s=n,c=n,l=0,u=n.length,d=0;for(let e of r){l=o(c,l);let n=t-l%t;d+=n-1,i.push(u),a.push(d),s+=` `.repeat(n)+e,l+=n,c=e,u+=1+e.length}return{text:s,offsetOf:e=>{let t=0,n=i.length;for(;t<n;){let r=t+n>>1;i[r]<e?t=r+1:n=r}return e+(t===0?0:a[t-1])}}}var _s=class{name;dark;vars;constructor(e,t,n){this.name=e,this.dark=t;let r=n.get(`background`),i=r===void 0?ys(e):vs(e,r);this.vars=new Map([...n].map(([e,t])=>[e,i(t,e)]))}get(e){return this.vars.get(e)}};function vs(e,t){if(t.alpha!==1)throw RangeError(`palette ${JSON.stringify(e)}: background is the surface its translucent colours are drawn on, so it must be opaque; got ${t.hex}`);return e=>e.alpha===0?e:e.compositeOver(t)}function ys(e){return(t,n)=>{if(t.alpha!==1&&t.alpha!==0)throw RangeError(`palette ${JSON.stringify(e)}: ${n} is translucent (${t.hex}) but the palette has no "background" to draw it on`);return t}}function bs(e){return e.toString(16).padStart(2,`0`)}function xs(e){return Number.isInteger(e)&&e>=0&&e<=255}function Ss(e,t){if(!xs(t))throw RangeError(`ColorRgba.${e} must be an integer in [0, 255]; got ${t}`)}var R=class e{red;green;blue;alpha;constructor(e,t,n,r=1){if(this.red=e,this.green=t,this.blue=n,this.alpha=r,Ss(`red`,e),Ss(`green`,t),Ss(`blue`,n),!Number.isFinite(r)||r<0||r>1)throw RangeError(`ColorRgba.alpha must be a finite number in [0, 1]; got ${r}`)}get hex(){let e=`#`+bs(this.red)+bs(this.green)+bs(this.blue);return this.alpha===1?e:e+bs(Math.round(this.alpha*255))}get rgb(){return this.alpha===1?`rgb(${this.red},${this.green},${this.blue})`:`rgba(${this.red},${this.green},${this.blue},${this.alpha})`}get normalized(){return[this.red/255,this.green/255,this.blue/255,this.alpha]}compositeOver(t){if(this.alpha===1)return this;let n=this.alpha;return new e(Math.round(t.red+(this.red-t.red)*n),Math.round(t.green+(this.green-t.green)*n),Math.round(t.blue+(this.blue-t.blue)*n),1)}};const Cs=new R(0,0,0);function ws(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.red)+.7152*t(e.green)+.0722*t(e.blue)}function Ts(e,t){return Es(ws(e),ws(t))}function Es(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Ds(e,t){let n=e.red-t.red,r=e.green-t.green,i=e.blue-t.blue;return n*n+r*r+i*i}var Os=class{colors;firstIndex;matchMemo=new Go;readableMemo=new Go;constructor(e,t=0){this.colors=e,this.firstIndex=t}get(e){return this.colors[e-this.firstIndex]}luminanceCache;luminances(){return this.luminanceCache??=this.colors.map(ws),this.luminanceCache}get size(){return this.colors.length}match(e){let t=`${e.red},${e.green},${e.blue},${e.alpha}`;return this.matchMemo.get(t,()=>this.nearest(e))}nearest(e){let t=0,n=1/0;for(let r=0;r<this.colors.length;r++){let i=this.colors[r],a=Ds(i,e);a<n&&(n=a,t=r)}return this.firstIndex+t}matchReadable(e,t,n){let r=`${e.red},${e.green},${e.blue}|${t.red},${t.green},${t.blue}|${n}`;return this.readableMemo.get(r,()=>this.nearestReadable(e,t,n))}nearestReadable(e,t,n){let r=ws(t),i=0,a=!1,o=-1/0;for(let t=0;t<this.colors.length;t++){let s=this.colors[t],c=this.luminances()[t],l=Es(c,r),u=l>=n,d=u?-Ds(s,e):l;(u&&!a||u===a&&d>o)&&(i=t,a=u,o=d)}return this.firstIndex+i}matchWhere(e,t){let n=this.colors.map(t=>Ds(t,e)),r=[...n.keys()].sort((e,t)=>n[e]-n[t]).find(e=>t(this.colors[e],this.firstIndex+e));return r===void 0?void 0:this.firstIndex+r}},z;(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.STANDARD=1]=`STANDARD`,e[e.EIGHT_BIT=2]=`EIGHT_BIT`,e[e.TRUECOLOR=3]=`TRUECOLOR`,e[e.WINDOWS=4]=`WINDOWS`})(z||={});function ks(e){switch(e){case z.DEFAULT:return 0;case z.STANDARD:case z.WINDOWS:return 1;case z.EIGHT_BIT:return 2;case z.TRUECOLOR:return 3}}const As={truecolor:z.TRUECOLOR,256:z.EIGHT_BIT,ansi:z.STANDARD,none:null},js=new Map([[`0`,null],[`false`,null],[`1`,z.STANDARD],[`true`,z.STANDARD],[`2`,z.EIGHT_BIT],[`3`,z.TRUECOLOR],[`iTerm.app`,z.TRUECOLOR],[`Apple_Terminal`,z.EIGHT_BIT],[`vscode`,z.TRUECOLOR],[`Tabby`,z.TRUECOLOR],[`xterm-kitty`,z.TRUECOLOR],[`xterm-ghostty`,z.TRUECOLOR],[`wezterm`,z.TRUECOLOR],[`alacritty`,z.TRUECOLOR],[`foot`,z.TRUECOLOR],[`contour`,z.TRUECOLOR]]);function Ms(e={}){let t=Ps(e).NO_COLOR;if(t!==void 0&&t!==``)return null;let n=Ns(Ps(e));return n===void 0?Is(e):n}function Ns(e){let t=e.FORCE_COLOR;if(t===void 0||t===``)return;let n=js.get(t);return n===void 0?z.STANDARD:n}function Ps(e){return e.env??(typeof process<`u`?process.env:{})}function Fs(e){let t=e.TERM;return t===`dumb`||t===`unknown`}function Is(e){let t=Ps(e);if(!(e.isTTY??(typeof process<`u`?process.stdout?.isTTY??!1:!1))||Fs(t))return null;let n=t.TERM??``,r=t.COLORTERM;if(r===`truecolor`||r===`24bit`)return z.TRUECOLOR;let i=js.get(n);if(i!==void 0)return i;let a=t.TERM_PROGRAM;if(a!==void 0){let e=js.get(a);if(e!==void 0)return e}return/-256(color)?$/i.test(n)?z.EIGHT_BIT:/-truecolor$/i.test(n)?z.TRUECOLOR:(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n),z.STANDARD)}function Ls(e,t){return e===`auto`?{colorSystem:Ms(t),hyperlinks:(Ns(Ps(t??{}))??null)!==null||Is(t??{})!==null}:{colorSystem:typeof e==`string`?Rs(e):e,hyperlinks:!0}}function Rs(e,t){if(e===`auto`)return Ms(t);if(Object.hasOwn(As,e))return As[e];throw new zs(`Unknown color system name: ${JSON.stringify(e)} (expected "auto", "truecolor", "256", "ansi", or "none")`)}var zs=class extends Error{constructor(e){super(e),this.name=`ColorParseError`}};const Bs=new Go;var B=class e{name;type;number;value;downgradeCache=new Map;constructor(e,t,n,r){this.name=e,this.type=t,this.number=n,this.value=r}get isDefault(){return this.type===z.DEFAULT}get fixedValue(){switch(this.type){case z.TRUECOLOR:return this.value;case z.EIGHT_BIT:return this.number<16?void 0:uc.get(this.number);case z.DEFAULT:case z.STANDARD:case z.WINDOWS:return}}get isSystemDefined(){return this.type===z.STANDARD||this.type===z.WINDOWS}getAnsiCodes(e=!0){switch(this.type){case z.DEFAULT:return[e?`39`:`49`];case z.STANDARD:{let t=this.number;return e?t<8?[`${30+t}`]:[`${90+t-8}`]:t<8?[`${40+t}`]:[`${100+t-8}`]}case z.EIGHT_BIT:return[e?`38`:`48`,`5`,`${this.number}`];case z.TRUECOLOR:{let t=this.value;return[e?`38`:`48`,`2`,`${t.red}`,`${t.green}`,`${t.blue}`]}case z.WINDOWS:{let t=this.number;return e?t<8?[`${30+t}`]:[`${90+t-8}`]:t<8?[`${40+t}`]:[`${100+t-8}`]}}}flattenAlpha(t){if(this.type!==z.TRUECOLOR||!this.value)return this;let n=this.value.compositeOver(t);return n===this.value?this:e.fromRgba(n)}downgrade(e){if(this.type===z.DEFAULT||this.type===e||ks(this.type)<ks(e))return this;let t=this.downgradeCache.get(e);if(t)return t;let n=this.performDowngrade(e);return this.downgradeCache.set(e,n),n}getTruecolor(e,t=!0){switch(this.type){case z.TRUECOLOR:return this.value;case z.EIGHT_BIT:return this.number<16?hc(e,this.type).ansiColors.get(this.number):uc.get(this.number);case z.STANDARD:case z.WINDOWS:return hc(e,this.type).ansiColors.get(this.number);case z.DEFAULT:{let n=hc(e,this.type);return t?n.foregroundColor:n.backgroundColor}}}static default(){return new e(`default`,z.DEFAULT)}static fromAnsi(t){let n=t<16?z.STANDARD:z.EIGHT_BIT;return new e(`color(${t})`,n,t)}static fromRgba(t){return new e(t.hex,z.TRUECOLOR,void 0,t)}static fromRgb(t,n,r){return e.fromRgba(new R(t,n,r))}static blend(t,n,r){for(let e of[t,n]){if(e.isDefault)throw new zs(`A blend cannot mix "default", which is no colour`);if(e.value!==void 0&&e.value.alpha<1)throw new zs(`A blend's ends are opaque; "${e.name}" is translucent`)}if(!(r>=0&&r<=1))throw new zs(`A blend's fraction is in [0, 1]; got ${r}`);let i=t.fixedValue,a=n.fixedValue;return i!==void 0&&a!==void 0?e.fromRgba(ic(i,a,r)):r===0?t:r===1?n:t.type===n.type&&(t.number===void 0?t.name===n.name:t.number===n.number)?t:new Ks(t,n,r)}static matchOn(t,n,r,i){if(t.alpha<1)throw RangeError(`matchOn rounds an opaque colour; got alpha ${t.alpha}`);if(n===z.TRUECOLOR)return e.fromRgba(t);if(n===z.DEFAULT)return e.default();let a=r.ansiColors.match(t);return[[e.default(),i?r.foregroundColor:r.backgroundColor],[new e(`color(${a})`,n===z.WINDOWS?n:z.STANDARD,a),r.ansiColors.get(a)],...n===z.EIGHT_BIT?[Vs(t)]:[]].reduce((e,n)=>Ds(n[1],t)<Ds(e[1],t)?n:e)[0]}static indexed(e,t){let n=Hs.get(t)??new Map;Hs.set(t,n);let r=n.get(e)??Us(e,t);return n.set(e,r),r}static matchMove(t,n,r,i,a){let o=e.matchOn(n,r,i,a);return Ds(t,n)<=Ds(o.getTruecolor(i,a),n)?void 0:o}static parse(e){return Bs.get(e.toLowerCase().trim(),Zs)}performDowngrade(t){let n=this.getTruecolor(hc(void 0,t));switch(t){case z.EIGHT_BIT:return e.fromAnsi(gc(t).match(n));case z.STANDARD:case z.WINDOWS:{let r=this.number!==void 0&&this.number<16?this.number:gc(t).match(n);return new e(`color(${r})`,t,r)}case z.TRUECOLOR:return this;case z.DEFAULT:return e.default()}}};function Vs(e){let t=dc.match(e);return[B.fromAnsi(t),dc.get(t)]}const Hs=new WeakMap;function Us(e,t){let n=()=>Array.from({length:16},(n,r)=>[new B(`color(${r})`,e===z.WINDOWS?e:z.STANDARD,r),t.ansiColors.get(r)]);switch(e){case z.TRUECOLOR:case z.DEFAULT:return[];case z.STANDARD:case z.WINDOWS:return n();case z.EIGHT_BIT:{let{firstIndex:e,size:t}=dc;return[...n(),...Array.from({length:t},(t,n)=>[B.fromAnsi(e+n),dc.get(e+n)])]}}}function Ws(e,t,n,r){return ic(e.getTruecolor(r),t.getTruecolor(r),n)}function Gs(e){return e.fixedValue?.hex??(e.number===void 0?e.name:`color(${e.number})`)}var Ks=class extends B{from;to;t;constructor(e,t,n){super(`blend(${Gs(e)},${Gs(t)},${n})`,z.TRUECOLOR,void 0,Ws(e,t,n)),this.from=e,this.to=t,this.t=n}get fixedValue(){}getTruecolor(e){return Ws(this.from,this.to,this.t,e)}};const qs=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,Js=/^color\((\d+)\)$/,Ys=/^blend\((.*)\)$/,Xs=/^\s*(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?\s*$/;function Zs(e){if(e===`default`||e===``)return B.default();let t=vc[e];if(t!==void 0)return new B(e,t<16?z.STANDARD:z.EIGHT_BIT,t);if(e.startsWith(`#`))return new B(e,z.TRUECOLOR,void 0,rc(e));let n=qs.exec(e);if(n){let t=$s(e,n[1],`red`),r=$s(e,n[2],`green`),i=$s(e,n[3],`blue`);return new B(e,z.TRUECOLOR,void 0,new R(t,r,i))}let r=Js.exec(e);if(r){let t=$s(e,r[1],`number`);return new B(e,t<16?z.STANDARD:z.EIGHT_BIT,t)}let i=Ys.exec(e);if(i){let t=Qs(i[1]),n=t[2]??``;if(t.length!==3||!Xs.test(n))throw new zs(`ColorSpec "${e}": a blend is blend(<color>,<color>,<fraction>)`);return B.blend(B.parse(t[0]),B.parse(t[1]),Number(n))}throw new zs(`Failed to parse color: "${e}"`)}function Qs(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?n++:a===`)`?n--:a===`,`&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function $s(e,t,n){let r=parseInt(t,10);if(!xs(r))throw new zs(`ColorSpec "${e}": ${n} ${t} is out of range (0-255)`);return r}const ec=/^[0-9a-fA-F]+$/,tc={6:`RRGGBB`,8:`RRGGBBAA`};function nc(e,t,n,r){if(!r.includes(n.length)||!ec.test(n)){let n=r.map(e=>t+tc[e]).join(` or `);throw new zs(`Invalid hex colour ${JSON.stringify(e)} (expected ${n})`)}let i=e=>parseInt(n.slice(e,e+2),16);return new R(i(0),i(2),i(4),n.length===8?i(6)/255:1)}function rc(e){return nc(e,`#`,e.startsWith(`#`)?e.slice(1):``,[6,8])}function ic(e,t,n=.5){return new R(Math.round(e.red+(t.red-e.red)*n),Math.round(e.green+(t.green-e.green)*n),Math.round(e.blue+(t.blue-e.blue)*n),e.alpha+(t.alpha-e.alpha)*n)}var ac=class{backgroundColor;foregroundColor;ansiColors;palette;constructor(e,t,n,r){if(this.backgroundColor=e,this.foregroundColor=t,this.ansiColors=n,this.palette=r,n.firstIndex!==0||n.size!==16)throw RangeError(`a TerminalTheme's ansiColors are the sixteen ANSI colours, indices 0–15; got ${n.size} from index ${n.firstIndex}`)}};function oc(){return[new R(0,0,0),new R(128,0,0),new R(0,128,0),new R(128,128,0),new R(0,0,128),new R(128,0,128),new R(0,128,128),new R(192,192,192),new R(128,128,128),new R(255,0,0),new R(0,255,0),new R(255,255,0),new R(0,0,255),new R(255,0,255),new R(0,255,255),new R(255,255,255)]}function sc(){let e=oc(),t=[0,95,135,175,215,255];for(let n=0;n<6;n++)for(let r=0;r<6;r++)for(let i=0;i<6;i++)e.push(new R(t[n],t[r],t[i]));for(let t=0;t<24;t++){let n=8+10*t;e.push(new R(n,n,n))}return e}function cc(){return[new R(12,12,12),new R(197,15,31),new R(19,161,14),new R(193,156,0),new R(0,55,218),new R(136,23,152),new R(58,150,221),new R(204,204,204),new R(118,118,118),new R(231,72,86),new R(22,198,12),new R(249,241,165),new R(59,120,255),new R(180,0,158),new R(97,214,214),new R(242,242,242)]}const lc=new Os(oc()),uc=new Os(sc()),dc=new Os(sc().slice(16),16),fc=new Os(cc()),pc=new ac(new R(0,0,0),new R(255,255,255),lc,new _s(`default`,!0,new Map)),mc=new ac(fc.get(0),fc.get(7),fc,new _s(`windows`,!0,new Map));function hc(e,t){return e??(t===z.WINDOWS?mc:pc)}function gc(e){switch(e){case z.EIGHT_BIT:return dc;case z.STANDARD:return lc;case z.WINDOWS:return fc}}function _c(e){let t=Object.entries(e).filter(([e])=>e.includes(`grey`)).map(([e,t])=>[e.replace(`grey`,`gray`),t]);return{...e,...Object.fromEntries(t)}}const vc=_c({black:0,red:1,green:2,yellow:3,blue:4,magenta:5,cyan:6,white:7,bright_black:8,bright_red:9,bright_green:10,bright_yellow:11,bright_blue:12,bright_magenta:13,bright_cyan:14,bright_white:15,grey0:16,navy_blue:17,dark_blue:18,blue3:19,blue2:20,blue1:21,dark_green:22,deep_sky_blue4:23,deep_sky_blue5:24,deep_sky_blue6:25,dodger_blue3:26,dodger_blue2:27,green4:28,spring_green4:29,turquoise4:30,deep_sky_blue3:31,deep_sky_blue7:32,dodger_blue1:33,green3:34,spring_green3:35,dark_cyan:36,light_sea_green:37,deep_sky_blue2:38,deep_sky_blue1:39,green5:40,spring_green5:41,spring_green2:42,cyan3:43,dark_turquoise:44,turquoise2:45,green1:46,spring_green6:47,spring_green1:48,medium_spring_green:49,cyan2:50,cyan1:51,dark_red:52,deep_pink4:53,purple4:54,purple5:55,purple3:56,blue_violet:57,orange4:58,grey37:59,medium_purple4:60,slate_blue3:61,slate_blue4:62,royal_blue1:63,chartreuse4:64,dark_sea_green4:65,pale_turquoise4:66,steel_blue:67,steel_blue3:68,cornflower_blue:69,chartreuse3:70,dark_sea_green5:71,cadet_blue:72,cadet_blue2:73,sky_blue3:74,steel_blue1:75,chartreuse5:76,pale_green3:77,sea_green3:78,aquamarine3:79,medium_turquoise:80,steel_blue2:81,chartreuse2:82,sea_green2:83,sea_green1:84,sea_green4:85,aquamarine1:86,dark_slate_gray2:87,dark_red2:88,deep_pink5:89,dark_magenta:90,dark_magenta2:91,dark_violet:92,purple2:93,orange5:94,light_pink4:95,plum4:96,medium_purple3:97,medium_purple5:98,slate_blue1:99,yellow4:100,wheat4:101,grey53:102,light_slate_grey:103,medium_purple:104,light_slate_blue:105,yellow5:106,dark_olive_green3:107,dark_sea_green:108,light_sky_blue3:109,light_sky_blue4:110,sky_blue2:111,chartreuse6:112,dark_olive_green4:113,pale_green4:114,dark_sea_green3:115,dark_slate_gray3:116,sky_blue1:117,chartreuse1:118,light_green:119,light_green2:120,pale_green1:121,aquamarine2:122,dark_slate_gray1:123,red3:124,deep_pink6:125,medium_violet_red:126,magenta3:127,dark_violet2:128,purple:129,dark_orange3:130,indian_red:131,hot_pink3:132,medium_orchid3:133,medium_orchid:134,medium_purple2:135,dark_goldenrod:136,light_salmon3:137,rosy_brown:138,grey63:139,medium_purple6:140,medium_purple1:141,gold3:142,dark_khaki:143,navajo_white3:144,grey69:145,light_steel_blue3:146,light_steel_blue:147,yellow3:148,dark_olive_green5:149,dark_sea_green6:150,dark_sea_green2:151,light_cyan3:152,light_sky_blue1:153,green_yellow:154,dark_olive_green2:155,pale_green2:156,dark_sea_green7:157,dark_sea_green1:158,pale_turquoise1:159,red4:160,deep_pink3:161,deep_pink8:162,magenta4:163,magenta5:164,magenta2:165,dark_orange4:166,indian_red2:167,hot_pink4:168,hot_pink2:169,orchid:170,medium_orchid1:171,orange3:172,light_salmon4:173,light_pink3:174,pink3:175,plum3:176,violet:177,gold4:178,light_goldenrod3:179,tan:180,misty_rose3:181,thistle3:182,plum2:183,yellow6:184,khaki3:185,light_goldenrod2:186,light_yellow3:187,grey84:188,light_steel_blue1:189,yellow2:190,dark_olive_green1:191,dark_olive_green6:192,dark_sea_green8:193,honeydew2:194,light_cyan1:195,red1:196,deep_pink2:197,deep_pink1:198,deep_pink9:199,magenta6:200,magenta1:201,orange_red1:202,indian_red1:203,indian_red3:204,hot_pink5:205,hot_pink:206,medium_orchid2:207,dark_orange:208,salmon1:209,light_coral:210,pale_violet_red1:211,orchid2:212,orchid1:213,orange1:214,sandy_brown:215,light_salmon1:216,light_pink1:217,pink1:218,plum1:219,gold1:220,light_goldenrod4:221,light_goldenrod5:222,navajo_white1:223,misty_rose1:224,thistle1:225,yellow1:226,light_goldenrod1:227,khaki1:228,wheat1:229,cornsilk1:230,grey100:231,grey3:232,grey7:233,grey11:234,grey15:235,grey19:236,grey23:237,grey27:238,grey30:239,grey35:240,grey39:241,grey42:242,grey46:243,grey50:244,grey54:245,grey58:246,grey62:247,grey66:248,grey70:249,grey74:250,grey78:251,grey82:252,grey85:253,grey89:254,grey93:255}),yc=[`default`,...Object.keys(vc)];var bc;const xc=[`l`,`c`,`h`,`alpha`],Sc=Object.freeze({hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0});Object.freeze({hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1});function Cc(e){return e.hueShift%360==0&&e.chromaScale===1&&e.lightnessScale===1&&e.lightnessShift===0}function wc(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Tc(e){return e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055}function Ec(e){return e<0?0:e>1?1:e}const Dc=1e-4,Oc=1e-7,kc=(e,t)=>e<Oc?0:t,Ac=(e,t,n)=>e*(1-n)+t*n,jc=e=>{let t=e%360;return t<0?t+360:t};function Mc(e,t,n){return e>=-Dc&&e<=1+Dc&&t>=-Dc&&t<=1+Dc&&n>=-Dc&&n<=1+Dc}var V=class{l;c;h;alpha;constructor(e,t,n,r=1){if(this.l=e,this.c=t,this.h=n,this.alpha=r,!Number.isFinite(e))throw RangeError(`Oklch.l must be finite; got ${e}`);if(!Number.isFinite(t))throw RangeError(`Oklch.c must be finite; got ${t}`);if(!Number.isFinite(n))throw RangeError(`Oklch.h must be finite; got ${n}`);if(!Number.isFinite(r)||r<0||r>1)throw RangeError(`Oklch.alpha must be a finite number in [0,1]; got ${r}`)}static fromRgba(e){let[t,n,r,i]=e.normalized,a=wc(t),o=wc(n),s=wc(r),c=.4122214708*a+.5363325363*o+.0514459929*s,l=.2119034982*a+.6806995451*o+.1073969566*s,u=.0883024619*a+.2817188376*o+.6299787005*s,d=Math.cbrt(c),f=Math.cbrt(l),p=Math.cbrt(u),m=.2104542553*d+.793617785*f-.0040720468*p,h=1.9779984951*d-2.428592205*f+.4505937099*p,g=.0259040371*d+.7827717662*f-.808675766*p,_=Math.sqrt(h*h+g*g),v=jc(180/Math.PI*Math.atan2(g,h));return new bc(m,_,kc(_,v),i)}toRgba(){let e=Ec(this.l),t=Math.max(0,this.c),n=this.findInGamutChroma(e,t,this.h),{r,g:i,b:a}=this.toLinearRgb(e,n,this.h);return new R(Math.round(Ec(Tc(r))*255),Math.round(Ec(Tc(i))*255),Math.round(Ec(Tc(a))*255),this.alpha)}applyKey(e){if(Cc(e))return this;let t=Ec(this.l*e.lightnessScale+e.lightnessShift),n=Math.max(0,this.c*e.chromaScale),r=jc(this.h+e.hueShift);return new bc(t,n,kc(n,r),this.alpha)}mix(e,t){if(!(t>=0&&t<=1))throw RangeError(`Oklch.mix: t must be in [0, 1]; got ${t}`);return this.#e(e,t,t,t,t)}mixAxes(e,t){for(let e of xc){let n=t[e];if(!(n>=0&&n<=1))throw RangeError(`Oklch.mixAxes: ${e} weight must be in [0, 1]; got ${n}`)}return this.#e(e,t.l,t.c,t.h,t.alpha)}#e(e,t,n,r,i){let a=this.c>=Oc,o=e.c>=Oc,s=jc(a?this.h:o?e.h:0),c=jc(o?e.h:s),l=c-s,u=l<-180?s-360:s,d=l>180?c-360:c,f=Ac(this.c,e.c,n);return new bc(Ac(this.l,e.l,t),f,kc(f,jc(Ac(u,d,r))),Ac(this.alpha,e.alpha,i))}deltaE(e){let t=this.h*Math.PI/180,n=e.h*Math.PI/180;return Math.hypot(this.l-e.l,this.c*Math.cos(t)-e.c*Math.cos(n),this.c*Math.sin(t)-e.c*Math.sin(n))}toLinearRgb(e,t,n){let r=Math.PI/180*n,i=t*Math.cos(r),a=t*Math.sin(r),o=e+.3963377774*i+.2158037573*a,s=e-.1055613458*i-.0638541728*a,c=e-.0894841775*i-1.291485548*a,l=o*o*o,u=s*s*s,d=c*c*c;return{r:4.0767416621*l-3.3077115913*u+.2309699292*d,g:-1.2684380046*l+2.6097574011*u-.3413193965*d,b:-.0041960863*l-.7034186147*u+1.707614701*d}}findInGamutChroma(e,t,n){let r=this.toLinearRgb(e,t,n);if(Mc(r.r,r.g,r.b))return t;let i=0,a=t;for(let t=0;t<24;t++){let t=(i+a)/2,r=this.toLinearRgb(e,t,n);Mc(r.r,r.g,r.b)?i=t:a=t}return i}};bc=V;var Nc=class extends Error{ref;constructor(e,t,n){super(`color reference ${JSON.stringify(e)} did not resolve — ${t}`,n),this.ref=e,this.name=`ColorRefError`}};function Pc(e,t){let n=t.trim();if(n.startsWith(`#`))try{return rc(n)}catch(e){throw e instanceof zs?new Nc(t,e.message,{cause:e}):e}let r=e.get(n);if(r===void 0)throw new Nc(t,`no such variable in palette ${JSON.stringify(e.name)}`+Fc(e,n));return r}function Fc(e,t){let n=t.split(`-`),r=[...e.vars.keys()].filter(e=>n.some(t=>t!==``&&e.includes(t))).slice(0,8);return r.length===0?``:`; did you mean: ${r.join(`, `)}`}function Ic(e){let t=e.red/255,n=e.green/255,r=e.blue/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s=i-a;if(s===0)return{h:0,s:0,l:o};let c=s/(o>.5?2-i-a:i+a),l;return l=i===t?(n-r)/s%6:i===n?(r-t)/s+2:(t-n)/s+4,l=(l*60+360)%360,{h:l,s:c,l:o}}function Lc(e){let t=Math.round(e);return t<0?0:t>255?255:t}function Rc(e){let{h:t,s:n,l:r}=e;if(n===0){let e=Lc(r*255);return new R(e,e,e)}let i=(1-Math.abs(2*r-1))*n,a=t/60,o=i*(1-Math.abs(a%2-1)),s=0,c=0,l=0;a<1?[s,c,l]=[i,o,0]:a<2?[s,c,l]=[o,i,0]:a<3?[s,c,l]=[0,i,o]:a<4?[s,c,l]=[0,o,i]:a<5?[s,c,l]=[o,0,i]:[s,c,l]=[i,0,o];let u=r-i/2;return new R(Lc((s+u)*255),Lc((c+u)*255),Lc((l+u)*255))}function zc(e){return e<0?0:e>1?1:e}function Bc(e,t){let n=Ic(e);return n.l=zc(n.l-.1*t),Rc(n)}function Vc(e,t,n){return ic(t,e,zc(n))}function Hc(e,t=Cs){return ws(qc(e,t))>.179?new R(0,0,0):new R(255,255,255)}function Uc(e,t,n=4.5,r=z.TRUECOLOR,i=Cs,a){let o=qc(t,i),s=Yc(e,o,n,Hc(o)),c=Jc(r,a);if(c===void 0)return s;let l=Kc(c,o);return Ts(Kc(c,s),l)>=n?s:c.written.get(c.shown.matchReadable(e.compositeOver(o),l,n))}function Wc(e,t,n,r=Cs,i){let a=qc(e,r),o=Jc(t,i),s=e=>Kc(o,qc(e,r));if(n(s(a),s))return a;let c=o?.shown.matchWhere(a,e=>n(e,s));return c===void 0?void 0:o.written.get(c)}function Gc(e,t,n=Cs,r){return Kc(Jc(t,r),qc(e,n))}function Kc(e,t){return e===void 0?t:B.fromRgba(t).downgrade(e.depth).getTruecolor(e.terminal)}function qc(e,t){if(t.alpha!==1)throw RangeError(`a contrast substrate is the opaque surface under a translucent background; got ${t.hex}`);return e.compositeOver(t)}function Jc(e,t){let n=hc(t,e);switch(e){case z.EIGHT_BIT:return{depth:e,terminal:n,written:gc(e),shown:gc(e)};case z.STANDARD:case z.WINDOWS:return{depth:e,terminal:n,written:gc(e),shown:n.ansiColors};case z.TRUECOLOR:case z.DEFAULT:return}}function Yc(e,t,n,r){let i=e.compositeOver(t);if(Ts(i,t)>=n)return i;let a=V.fromRgba(i),o=+(ws(r)>.179);if(Ts(new V(o,a.c,a.h,a.alpha).toRgba(),t)<n)return Hc(t);let s=a.l,c=o;for(let e=0;e<20;e++){let e=(s+c)/2;Ts(new V(e,a.c,a.h,a.alpha).toRgba(),t)>=n?c=e:s=e}return new V(c,a.c,a.h,a.alpha).toRgba()}const Xc=.7,Zc=[`primary`,`secondary`,`accent`,`success`,`warning`,`error`];function Qc(e,t,n){let r=vs(e,n.background),i=t=>{let i=n[t];if(i.alpha===0)throw RangeError(`palette ${JSON.stringify(e)}: ${t} is fully transparent (${i.hex}), so there is no colour to derive the palette from`);return r(i)},a={primary:i(`primary`),secondary:i(`secondary`),accent:i(`accent`),success:i(`success`),warning:i(`warning`),error:i(`error`),background:n.background,foreground:i(`foreground`)},o=new Map;o.set(`background`,a.background),o.set(`foreground`,a.foreground);for(let e of Zc)o.set(e,a[e]);o.set(`foreground-muted`,ic(a.foreground,a.background,Xc)),o.set(`background-muted`,ic(a.background,a.foreground,Xc)),o.set(`surface`,ic(a.background,a.foreground,.05));let s=Hc(a.background);for(let e of Zc){let t=a[e],n=ic(t,a.background,Xc);o.set(`${e}-muted`,n),o.set(`text-${e}`,$c(Vc(t,s,.66),n,a.background)),o.set(`on-${e}`,Hc(t))}return new _s(e,t,o)}function $c(e,t,n){return Yc(e,t,4.5,Hc(n))}const el={name:`atom-one-dark`,dark:!0,ansi:{black:`#282C34`,red:`#E06C75`,green:`#98C379`,yellow:`#E5C07B`,blue:`#61AFEF`,magenta:`#C678DD`,cyan:`#56B6C2`,white:`#DCDFE4`,brightBlack:`#5D677A`,brightRed:`#E06C75`,brightGreen:`#98C379`,brightYellow:`#E5C07B`,brightBlue:`#61AFEF`,brightMagenta:`#C678DD`,brightCyan:`#56B6C2`,brightWhite:`#DCDFE4`},vars:{accent:`#A378C2`,"accent-darken-1":`#8E65AD`,"accent-darken-2":`#7A5299`,"accent-darken-3":`#674085`,"accent-lighten-1":`#B78BD6`,"accent-lighten-2":`#CC9FEC`,"accent-lighten-3":`#E2B3FF`,"accent-muted":`#4C425E`,background:`#282C34`,"background-darken-1":`#181C23`,"background-darken-2":`#050A14`,"background-darken-3":`#000000`,"background-lighten-1":`#383C44`,"background-lighten-2":`#494D56`,"background-lighten-3":`#5B5F68`,"block-cursor-background":`#61AFEF`,"block-cursor-blurred-background":`#61AFEF4C`,"block-cursor-blurred-foreground":`#ABB2BF`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#61AFEF`,"border-blurred":`#353B47`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#ABB2BF`,error:`#EF6262`,"error-darken-1":`#D84D50`,"error-darken-2":`#C1373E`,"error-darken-3":`#AA1F2E`,"error-lighten-1":`#FF7674`,"error-lighten-2":`#FF8B87`,"error-lighten-3":`#FFA09B`,"error-muted":`#643C41`,"footer-background":`#4F5666`,"footer-description-background":`#00000000`,"footer-description-foreground":`#ABB2BF`,"footer-foreground":`#ABB2BF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#A378C2`,foreground:`#ABB2BF`,"foreground-darken-1":`#979DAA`,"foreground-darken-2":`#838A96`,"foreground-darken-3":`#707783`,"foreground-disabled":`#ABB2BF60`,"foreground-lighten-1":`#BFC6D3`,"foreground-lighten-2":`#D4DBE8`,"foreground-lighten-3":`#E9F0FE`,"foreground-muted":`#ABB2BF99`,"input-cursor-background":`#ABB2BF`,"input-cursor-foreground":`#282C34`,"input-selection-background":`#77C3FF66`,"link-background":`#00000000`,"link-background-hover":`#61AFEF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#61AFEF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#61AFEF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#61AFEF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#ABB2BF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#ABB2BF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#ABB2BF99`,panel:`#4F5666`,"panel-darken-1":`#3D4453`,"panel-darken-2":`#2C3342`,"panel-darken-3":`#1C2331`,"panel-lighten-1":`#616878`,"panel-lighten-2":`#737A8B`,"panel-lighten-3":`#868E9F`,primary:`#61AFEF`,"primary-background":`#4F5B6A`,"primary-background-darken-1":`#3F4D5D`,"primary-background-darken-2":`#303F50`,"primary-background-darken-3":`#303F50`,"primary-background-lighten-1":`#5E6A77`,"primary-background-lighten-2":`#6E7884`,"primary-background-lighten-3":`#7D8791`,"primary-darken-1":`#489BD9`,"primary-darken-2":`#2C87C4`,"primary-darken-3":`#0074AF`,"primary-lighten-1":`#77C3FF`,"primary-lighten-2":`#8ED8FF`,"primary-lighten-3":`#A4EDFF`,"primary-muted":`#39536C`,scrollbar:`#355674`,"scrollbar-active":`#61AFEF`,"scrollbar-background":`#181C23`,"scrollbar-background-active":`#181C23`,"scrollbar-background-hover":`#181C23`,"scrollbar-corner-color":`#181C23`,"scrollbar-hover":`#3C6589`,secondary:`#C678DD`,"secondary-background":`#5B5567`,"secondary-background-darken-1":`#4D465A`,"secondary-background-darken-2":`#3F374D`,"secondary-background-darken-3":`#3F374D`,"secondary-background-lighten-1":`#6A6475`,"secondary-background-lighten-2":`#787382`,"secondary-background-lighten-3":`#87828F`,"secondary-darken-1":`#B064C7`,"secondary-darken-2":`#9B50B3`,"secondary-darken-3":`#873D9E`,"secondary-lighten-1":`#DB8CF2`,"secondary-lighten-2":`#F1A0FF`,"secondary-lighten-3":`#FFB5FF`,"secondary-muted":`#574266`,success:`#62F062`,"success-darken-1":`#48DA4D`,"success-darken-2":`#29C438`,"success-darken-3":`#00AF22`,"success-lighten-1":`#7AFF76`,"success-lighten-2":`#91FF8A`,"success-lighten-3":`#A8FF9F`,"success-muted":`#396641`,surface:`#3B414D`,"surface-active":`#484E5B`,"surface-darken-1":`#2A303B`,"surface-darken-2":`#1A202B`,"surface-darken-3":`#09101B`,"surface-lighten-1":`#4C525E`,"surface-lighten-2":`#5E6471`,"surface-lighten-3":`#707684`,text:`#FFFFFFDD`,"text-accent":`#C2A5D6`,"text-disabled":`#FFFFFF60`,"text-error":`#F59797`,"text-muted":`#FFFFFF99`,"text-primary":`#96CAF4`,"text-secondary":`#D9A5E8`,"text-success":`#97F597`,"text-warning":`#E9CC92`,warning:`#DDB25B`,"warning-darken-1":`#C79D47`,"warning-darken-2":`#B28A34`,"warning-darken-3":`#9C7721`,"warning-lighten-1":`#F4C66E`,"warning-lighten-2":`#FFDB82`,"warning-lighten-3":`#FFF096`,"warning-muted":`#5E543F`}},tl={name:`atom-one-light`,dark:!1,ansi:{black:`#383A42`,red:`#E45649`,green:`#50A14F`,yellow:`#C18401`,blue:`#0184BC`,magenta:`#A626A4`,cyan:`#0997B3`,white:`#BABABA`,brightBlack:`#4F525E`,brightRed:`#E06C75`,brightGreen:`#98C379`,brightYellow:`#D8B36E`,brightBlue:`#61AFEF`,brightMagenta:`#C678DD`,brightCyan:`#56B6C2`,brightWhite:`#FFFFFF`},vars:{accent:`#BE9232`,"accent-darken-1":`#A97E1D`,"accent-darken-2":`#936B01`,"accent-darken-3":`#7E5900`,"accent-lighten-1":`#D5A545`,"accent-lighten-2":`#EBB959`,"accent-lighten-3":`#FFCE6C`,"accent-muted":`#E8DABE`,background:`#FAFAFA`,"background-darken-1":`#E4E4E4`,"background-darken-2":`#CFCFCF`,"background-darken-3":`#BABABA`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#4078F2`,"block-cursor-blurred-background":`#4078F24C`,"block-cursor-blurred-foreground":`#383A42`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#4078F2`,"border-blurred":`#D8D8D8`,"button-color-foreground":`#000000DD`,"button-foreground":`#383A42`,error:`#F13F3F`,"error-darken-1":`#D9232D`,"error-darken-2":`#C1001D`,"error-darken-3":`#A9000D`,"error-lighten-1":`#FF5650`,"error-lighten-2":`#FF6C62`,"error-lighten-3":`#FF8275`,"error-muted":`#F7C1C1`,"footer-background":`#CCCCCC`,"footer-description-background":`#00000000`,"footer-description-foreground":`#383A42`,"footer-foreground":`#383A42`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#BF9232`,foreground:`#383A42`,"foreground-darken-1":`#272931`,"foreground-darken-2":`#181A21`,"foreground-darken-3":`#040612`,"foreground-disabled":`#383A4260`,"foreground-lighten-1":`#494B53`,"foreground-lighten-2":`#5A5C65`,"foreground-lighten-3":`#6D6F78`,"foreground-muted":`#383A4299`,"input-cursor-background":`#383A42`,"input-cursor-foreground":`#FAFAFA`,"input-selection-background":`#5C8AFF66`,"link-background":`#00000000`,"link-background-hover":`#4078F2`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#4078F2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#4078F2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#4078F2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#383A42`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#383A42`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#383A4299`,panel:`#CCCCCC`,"panel-darken-1":`#B7B7B7`,"panel-darken-2":`#A3A3A3`,"panel-darken-3":`#8F8F8F`,"panel-lighten-1":`#E1E1E1`,"panel-lighten-2":`#F6F6F6`,"panel-lighten-3":`#FFFFFF`,primary:`#4078F2`,"primary-background":`#4078F2`,"primary-background-darken-1":`#1865DC`,"primary-background-darken-2":`#0053C6`,"primary-background-darken-3":`#0043B1`,"primary-background-lighten-1":`#5C8AFF`,"primary-background-lighten-2":`#759EFF`,"primary-background-lighten-3":`#8DB2FF`,"primary-darken-1":`#1865DC`,"primary-darken-2":`#0053C6`,"primary-darken-3":`#0043B1`,"primary-lighten-1":`#5C8AFF`,"primary-lighten-2":`#759EFF`,"primary-lighten-3":`#8DB2FF`,"primary-muted":`#C2D3F7`,scrollbar:`#A2B8E9`,"scrollbar-active":`#4078F2`,"scrollbar-background":`#E4E4E4`,"scrollbar-background-active":`#E4E4E4`,"scrollbar-background-hover":`#E4E4E4`,"scrollbar-corner-color":`#E4E4E4`,"scrollbar-hover":`#92AEEB`,secondary:`#A626A4`,"secondary-background":`#A626A4`,"secondary-background-darken-1":`#90008F`,"secondary-background-darken-2":`#7B007C`,"secondary-background-darken-3":`#670069`,"secondary-background-lighten-1":`#BB3EB8`,"secondary-background-lighten-2":`#D154CD`,"secondary-background-lighten-3":`#E769E2`,"secondary-darken-1":`#90008F`,"secondary-darken-2":`#7B007C`,"secondary-darken-3":`#670069`,"secondary-lighten-1":`#BB3EB8`,"secondary-lighten-2":`#D154CD`,"secondary-lighten-3":`#E769E2`,"secondary-muted":`#E0BAE0`,success:`#6BF23F`,"success-darken-1":`#52DC25`,"success-darken-2":`#36C600`,"success-darken-3":`#05B100`,"success-lighten-1":`#83FF55`,"success-lighten-2":`#9BFF6B`,"success-lighten-3":`#B2FF80`,"success-muted":`#CFF7C1`,surface:`#E0E0E0`,"surface-active":`#F1F1F1`,"surface-darken-1":`#CACACA`,"surface-darken-2":`#B6B6B6`,"surface-darken-3":`#A2A2A2`,"surface-lighten-1":`#F5F5F5`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#7E6021`,"text-disabled":`#00000060`,"text-error":`#9F2929`,"text-muted":`#00000099`,"text-primary":`#2A4F9F`,"text-secondary":`#6D196C`,"text-success":`#479F29`,"text-warning":`#8E8F24`,warning:`#D7D938`,"warning-darken-1":`#C1C41C`,"warning-darken-2":`#ABAF00`,"warning-darken-3":`#969B00`,"warning-lighten-1":`#EEEE4E`,"warning-lighten-2":`#FFFF64`,"warning-lighten-3":`#FFFF79`,"warning-muted":`#EFF0BF`}},nl={name:`catppuccin-frappe`,dark:!0,ansi:{black:`#51576D`,red:`#E78284`,green:`#A6D189`,yellow:`#E5C890`,blue:`#8CAAEE`,magenta:`#F4B8E4`,cyan:`#81C8BE`,white:`#B5BFE2`,brightBlack:`#626880`,brightRed:`#EDA0A2`,brightGreen:`#B9DBA2`,brightYellow:`#ECD7AE`,brightBlue:`#ADC2F3`,brightMagenta:`#F38ED8`,brightCyan:`#98D2CA`,brightWhite:`#A5ADCE`},vars:{accent:`#F4B8E4`,"accent-darken-1":`#DEA3CE`,"accent-darken-2":`#C98FBA`,"accent-darken-3":`#B47BA5`,"accent-lighten-1":`#FFCCF9`,"accent-lighten-2":`#FFE2FF`,"accent-lighten-3":`#FFF7FF`,"accent-muted":`#6A5B75`,background:`#303446`,"background-darken-1":`#1F2435`,"background-darken-2":`#101424`,"background-darken-3":`#000016`,"background-lighten-1":`#404457`,"background-lighten-2":`#525669`,"background-lighten-3":`#64687C`,"block-cursor-background":`#CA9EE6`,"block-cursor-blurred-background":`#CA9EE64C`,"block-cursor-blurred-foreground":`#C6D0F5`,"block-cursor-foreground":`#292C3C`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BABBF1`,"border-blurred":`#838BA7`,"button-color-foreground":`#303446`,"button-foreground":`#C6D0F5`,error:`#E68284`,"error-darken-1":`#D06E71`,"error-darken-2":`#BA5A5E`,"error-darken-3":`#A4474C`,"error-lighten-1":`#FD9697`,"error-lighten-2":`#FFAAAB`,"error-lighten-3":`#FFBFBF`,"error-muted":`#664B58`,"footer-background":`#51576D`,"footer-description-background":`#00000000`,"footer-description-foreground":`#C6D0F5`,"footer-foreground":`#C6D0F5`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#F4B8E4`,foreground:`#C6D0F5`,"foreground-darken-1":`#B1BBDF`,"foreground-darken-2":`#9CA7CA`,"foreground-darken-3":`#8993B5`,"foreground-disabled":`#C6D0F560`,"foreground-lighten-1":`#DBE5FF`,"foreground-lighten-2":`#F0FAFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#C6D0F599`,"input-cursor-background":`#F2D5CF`,"input-cursor-foreground":`#232634`,"input-selection-background":`#949CBB4C`,"link-background":`#00000000`,"link-background-hover":`#CA9EE6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#CA9EE6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#CA9EE6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#CA9EE6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#C6D0F5`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#C6D0F5`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#C6D0F599`,panel:`#51576D`,"panel-darken-1":`#3F455A`,"panel-darken-2":`#2E3448`,"panel-darken-3":`#1D2437`,"panel-lighten-1":`#63697F`,"panel-lighten-2":`#767B93`,"panel-lighten-3":`#898FA7`,primary:`#CA9EE6`,"primary-background":`#625F76`,"primary-background-darken-1":`#54516A`,"primary-background-darken-2":`#47435E`,"primary-background-darken-3":`#47435E`,"primary-background-lighten-1":`#706D82`,"primary-background-lighten-2":`#7E7B8E`,"primary-background-lighten-3":`#8C899A`,"primary-darken-1":`#B58AD0`,"primary-darken-2":`#A076BB`,"primary-darken-3":`#8C63A7`,"primary-lighten-1":`#DFB2FB`,"primary-lighten-2":`#F4C7FF`,"primary-lighten-3":`#FFDCFF`,"primary-muted":`#5E5376`,scrollbar:`#63547B`,"scrollbar-active":`#CA9EE6`,"scrollbar-background":`#1F2435`,"scrollbar-background-active":`#1F2435`,"scrollbar-background-hover":`#1F2435`,"scrollbar-corner-color":`#1F2435`,"scrollbar-hover":`#74618D`,secondary:`#EE9F76`,"secondary-background":`#666067`,"secondary-background-darken-1":`#59525A`,"secondary-background-darken-2":`#4C444D`,"secondary-background-darken-3":`#4C444D`,"secondary-background-lighten-1":`#746E75`,"secondary-background-lighten-2":`#817C82`,"secondary-background-lighten-3":`#8F8A8F`,"secondary-darken-1":`#D88B63`,"secondary-darken-2":`#C27750`,"secondary-darken-3":`#AC643E`,"secondary-lighten-1":`#FFB389`,"secondary-lighten-2":`#FFC89D`,"secondary-lighten-3":`#FFDDB1`,"secondary-muted":`#695454`,success:`#A6D189`,"success-darken-1":`#91BC75`,"success-darken-2":`#7DA762`,"success-darken-3":`#6A9350`,"success-lighten-1":`#BAE69C`,"success-lighten-2":`#CFFBB1`,"success-lighten-3":`#E5FFC5`,"success-muted":`#53635A`,surface:`#414559`,"surface-active":`#4F5267`,"surface-darken-1":`#303447`,"surface-darken-2":`#1F2436`,"surface-darken-3":`#101526`,"surface-lighten-1":`#52566B`,"surface-lighten-2":`#64687E`,"surface-lighten-3":`#777B91`,text:`#FFFFFFDD`,"text-accent":`#F7D0ED`,"text-disabled":`#FFFFFF60`,"text-error":`#EFACAD`,"text-muted":`#FFFFFF99`,"text-primary":`#DCBEEE`,"text-secondary":`#F4BFA4`,"text-success":`#C4E0B1`,"text-warning":`#EDDAB5`,warning:`#E4C890`,"warning-darken-1":`#CFB37C`,"warning-darken-2":`#BA9F69`,"warning-darken-3":`#A58B56`,"warning-lighten-1":`#FADCA4`,"warning-lighten-2":`#FFF2B8`,"warning-lighten-3":`#FFFFCD`,"warning-muted":`#66605C`}},rl={name:`catppuccin-latte`,dark:!1,ansi:{black:`#BCC0CC`,red:`#D20F39`,green:`#40A02B`,yellow:`#DF8E1D`,blue:`#1E66F5`,magenta:`#EA76CB`,cyan:`#179299`,white:`#5C5F77`,brightBlack:`#ACB0BE`,brightRed:`#E7103F`,brightGreen:`#46B02F`,brightYellow:`#E49931`,brightBlue:`#3878F6`,brightMagenta:`#EF95D7`,brightCyan:`#19A1A8`,brightWhite:`#6C6F85`},vars:{accent:`#FD640B`,"accent-darken-1":`#E54F00`,"accent-darken-2":`#CC3900`,"accent-darken-3":`#B42200`,"accent-lighten-1":`#FF7825`,"accent-lighten-2":`#FF8D3A`,"accent-lighten-3":`#FFA24F`,"accent-muted":`#F3C6AE`,background:`#EFF1F5`,"background-darken-1":`#D9DBDF`,"background-darken-2":`#C4C6CA`,"background-darken-3":`#B0B2B5`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#8839EF`,"block-cursor-blurred-background":`#8839EF4C`,"block-cursor-blurred-foreground":`#4C4F69`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#8839EF`,"border-blurred":`#DEE1E7`,"button-color-foreground":`#EFF1F5`,"button-foreground":`#4C4F69`,error:`#D10F39`,"error-darken-1":`#BA0028`,"error-darken-2":`#A20019`,"error-darken-3":`#8A0008`,"error-lighten-1":`#EA324A`,"error-lighten-2":`#FF4B5B`,"error-lighten-3":`#FF626E`,"error-muted":`#E6ADBC`,"footer-background":`#CCD0DA`,"footer-description-background":`#00000000`,"footer-description-foreground":`#4C4F69`,"footer-foreground":`#4C4F69`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FE640B`,foreground:`#4C4F69`,"foreground-darken-1":`#3A3D56`,"foreground-darken-2":`#292D45`,"foreground-darken-3":`#191D34`,"foreground-disabled":`#4C4F6960`,"foreground-lighten-1":`#5E607B`,"foreground-lighten-2":`#70738F`,"foreground-lighten-3":`#8386A2`,"foreground-muted":`#4C4F6999`,"input-cursor-background":`#4C4F69`,"input-cursor-foreground":`#EFF1F5`,"input-selection-background":`#9E4DFF66`,"link-background":`#00000000`,"link-background-hover":`#8839EF`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#8839EF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#8839EF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#8839EF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#4C4F69`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#4C4F69`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#4C4F6999`,panel:`#CCD0DA`,"panel-darken-1":`#B7BBC5`,"panel-darken-2":`#A3A6B0`,"panel-darken-3":`#8F939C`,"panel-lighten-1":`#E1E5EF`,"panel-lighten-2":`#F6FAFF`,"panel-lighten-3":`#FFFFFF`,primary:`#8839EF`,"primary-background":`#8839EF`,"primary-background-darken-1":`#7122D9`,"primary-background-darken-2":`#5901C3`,"primary-background-darken-3":`#4000AE`,"primary-background-lighten-1":`#9E4DFF`,"primary-background-lighten-2":`#B562FF`,"primary-background-lighten-3":`#CC76FF`,"primary-darken-1":`#7122D9`,"primary-darken-2":`#5901C3`,"primary-darken-3":`#4000AE`,"primary-lighten-1":`#9E4DFF`,"primary-lighten-2":`#B562FF`,"primary-lighten-3":`#CC76FF`,"primary-muted":`#D0B9F3`,scrollbar:`#B89AE5`,"scrollbar-active":`#8839EF`,"scrollbar-background":`#D9DBDF`,"scrollbar-background-active":`#D9DBDF`,"scrollbar-background-hover":`#D9DBDF`,"scrollbar-corner-color":`#D9DBDF`,"scrollbar-hover":`#B08AE7`,secondary:`#DB8A78`,"secondary-background":`#DB8A78`,"secondary-background-darken-1":`#C57665`,"secondary-background-darken-2":`#B06353`,"secondary-background-darken-3":`#9A5041`,"secondary-background-lighten-1":`#F29D8B`,"secondary-background-lighten-2":`#FFB29E`,"secondary-background-lighten-3":`#FFC7B3`,"secondary-darken-1":`#C57665`,"secondary-darken-2":`#B06353`,"secondary-darken-3":`#9A5041`,"secondary-lighten-1":`#F29D8B`,"secondary-lighten-2":`#FFB29E`,"secondary-lighten-3":`#FFC7B3`,"secondary-muted":`#E9D2CF`,success:`#40A02B`,"success-darken-1":`#278B14`,"success-darken-2":`#007800`,"success-darken-3":`#006400`,"success-lighten-1":`#56B43F`,"success-lighten-2":`#6BC952`,"success-lighten-3":`#81DE66`,"success-muted":`#BAD8B8`,surface:`#E6E9EF`,"surface-active":`#F7FAFF`,"surface-darken-1":`#D0D3D9`,"surface-darken-2":`#BCBFC4`,"surface-darken-3":`#A7AAB0`,"surface-lighten-1":`#FBFEFF`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#A74207`,"text-disabled":`#00000060`,"text-error":`#8A0925`,"text-muted":`#00000099`,"text-primary":`#59259D`,"text-secondary":`#915B4F`,"text-success":`#2A691C`,"text-warning":`#935D13`,warning:`#DE8E1D`,"warning-darken-1":`#C77A00`,"warning-darken-2":`#B06700`,"warning-darken-3":`#9A5500`,"warning-lighten-1":`#F6A134`,"warning-lighten-2":`#FFB648`,"warning-lighten-3":`#FFCA5D`,"warning-muted":`#EAD3B4`}},il={name:`catppuccin-macchiato`,dark:!0,ansi:{black:`#494D64`,red:`#ED8796`,green:`#A6DA95`,yellow:`#EED49F`,blue:`#8AADF4`,magenta:`#F5BDE6`,cyan:`#8BD5CA`,white:`#B8C0E0`,brightBlack:`#5B6078`,brightRed:`#F2A7B2`,brightGreen:`#BDE3B0`,brightYellow:`#F4E3C1`,brightBlue:`#ADC5F7`,brightMagenta:`#F493DA`,brightCyan:`#A5DED6`,brightWhite:`#A5ADCB`},vars:{accent:`#F5BDE6`,"accent-darken-1":`#DFA8D0`,"accent-darken-2":`#CA94BC`,"accent-darken-3":`#B580A7`,"accent-lighten-1":`#FFD1FB`,"accent-lighten-2":`#FFE7FF`,"accent-lighten-3":`#FFFCFF`,"accent-muted":`#62546D`,background:`#24273A`,"background-darken-1":`#141729`,"background-darken-2":`#00021A`,"background-darken-3":`#000007`,"background-lighten-1":`#34374B`,"background-lighten-2":`#45485C`,"background-lighten-3":`#57596F`,"block-cursor-background":`#C6A0F6`,"block-cursor-blurred-background":`#C6A0F64C`,"block-cursor-blurred-foreground":`#CAD3F5`,"block-cursor-foreground":`#1E2030`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#B7BDF8`,"border-blurred":`#737994`,"button-color-foreground":`#24273A`,"button-foreground":`#CAD3F5`,error:`#ED8796`,"error-darken-1":`#D67382`,"error-darken-2":`#C05F6F`,"error-darken-3":`#AB4C5D`,"error-lighten-1":`#FF9BA9`,"error-lighten-2":`#FFAFBE`,"error-lighten-3":`#FFC4D3`,"error-muted":`#604355`,"footer-background":`#494D64`,"footer-description-background":`#00000000`,"footer-description-foreground":`#CAD3F5`,"footer-foreground":`#CAD3F5`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#F5BDE6`,foreground:`#CAD3F5`,"foreground-darken-1":`#B5BEDF`,"foreground-darken-2":`#A0A9CA`,"foreground-darken-3":`#8C95B5`,"foreground-disabled":`#CAD3F560`,"foreground-lighten-1":`#DFE8FF`,"foreground-lighten-2":`#F4FDFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#CAD3F599`,"input-cursor-background":`#F4DBD6`,"input-cursor-foreground":`#181926`,"input-selection-background":`#838BA74C`,"link-background":`#00000000`,"link-background-hover":`#C6A0F6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C6A0F6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C6A0F6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C6A0F6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#CAD3F5`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#CAD3F5`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#CAD3F599`,panel:`#494D64`,"panel-darken-1":`#373B51`,"panel-darken-2":`#262B40`,"panel-darken-3":`#161C2F`,"panel-lighten-1":`#5A5E76`,"panel-lighten-2":`#6D7189`,"panel-lighten-3":`#80849D`,primary:`#C6A0F6`,"primary-background":`#59566F`,"primary-background-darken-1":`#4A4762`,"primary-background-darken-2":`#3C3956`,"primary-background-darken-3":`#3C3956`,"primary-background-lighten-1":`#67657C`,"primary-background-lighten-2":`#767488`,"primary-background-lighten-3":`#858395`,"primary-darken-1":`#B08CE0`,"primary-darken-2":`#9C78CB`,"primary-darken-3":`#8865B6`,"primary-lighten-1":`#DBB4FF`,"primary-lighten-2":`#F1C9FF`,"primary-lighten-3":`#FFDEFF`,"primary-muted":`#544B72`,scrollbar:`#5B4D7B`,"scrollbar-active":`#C6A0F6`,"scrollbar-background":`#141729`,"scrollbar-background-active":`#141729`,"scrollbar-background-hover":`#141729`,"scrollbar-corner-color":`#141729`,"scrollbar-hover":`#6D5B8F`,secondary:`#F4A97F`,"secondary-background":`#5F5760`,"secondary-background-darken-1":`#514852`,"secondary-background-darken-2":`#433A44`,"secondary-background-darken-3":`#433A44`,"secondary-background-lighten-1":`#6D666E`,"secondary-background-lighten-2":`#7B757C`,"secondary-background-lighten-3":`#89838A`,"secondary-darken-1":`#DE946B`,"secondary-darken-2":`#C88159`,"secondary-darken-3":`#B26E47`,"secondary-lighten-1":`#FFBD92`,"secondary-lighten-2":`#FFD2A6`,"secondary-lighten-3":`#FFE7BB`,"secondary-muted":`#624E4E`,success:`#A6DA95`,"success-darken-1":`#91C481`,"success-darken-2":`#7DB06E`,"success-darken-3":`#6A9C5B`,"success-lighten-1":`#BAEFA9`,"success-lighten-2":`#CFFFBD`,"success-lighten-3":`#E5FFD2`,"success-muted":`#4B5C55`,surface:`#363A4F`,"surface-active":`#43475D`,"surface-darken-1":`#25293D`,"surface-darken-2":`#151A2D`,"surface-darken-3":`#03061D`,"surface-lighten-1":`#474B60`,"surface-lighten-2":`#595C73`,"surface-lighten-3":`#6B6F86`,text:`#FFFFFFDD`,"text-accent":`#F8D3EE`,"text-disabled":`#FFFFFF60`,"text-error":`#F3AFB9`,"text-muted":`#FFFFFF99`,"text-primary":`#D9C0F9`,"text-secondary":`#F8C6AA`,"text-success":`#C4E6B9`,"text-warning":`#F3E2BF`,warning:`#EED49F`,"warning-darken-1":`#D8BF8B`,"warning-darken-2":`#C3AA77`,"warning-darken-3":`#AE9664`,"warning-lighten-1":`#FFE9B3`,"warning-lighten-2":`#FFFEC7`,"warning-lighten-3":`#FFFFDD`,"warning-muted":`#605A58`}},al={name:`catppuccin-mocha`,dark:!0,ansi:{black:`#45475A`,red:`#F38BA8`,green:`#A6E3A1`,yellow:`#F9E2AF`,blue:`#89B4FA`,magenta:`#F5C2E7`,cyan:`#94E2D5`,white:`#BAC2DE`,brightBlack:`#585B70`,brightRed:`#F7AEC2`,brightGreen:`#C2ECBF`,brightYellow:`#FCD682`,brightBlue:`#AECCFC`,brightMagenta:`#F398DA`,brightCyan:`#B1EAE1`,brightWhite:`#A6ADC8`},vars:{accent:`#F9B387`,"accent-darken-1":`#E39E73`,"accent-darken-2":`#CD8A60`,"accent-darken-3":`#B7774E`,"accent-lighten-1":`#FFC79A`,"accent-lighten-2":`#FFDCAE`,"accent-lighten-3":`#FFF2C3`,"accent-muted":`#5B4642`,background:`#181825`,"background-darken-1":`#040216`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#272735`,"background-lighten-2":`#373746`,"background-lighten-3":`#484857`,"block-cursor-background":`#F5C2E7`,"block-cursor-blurred-background":`#F5C2E74C`,"block-cursor-blurred-foreground":`#CDD6F4`,"block-cursor-foreground":`#1E1E2E`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#B4BEFE`,"border-blurred":`#585B70`,"button-color-foreground":`#181825`,"button-foreground":`#CDD6F4`,error:`#F28FAD`,"error-darken-1":`#DB7A99`,"error-darken-2":`#C66785`,"error-darken-3":`#B05372`,"error-lighten-1":`#FFA3C1`,"error-lighten-2":`#FFB8D6`,"error-lighten-3":`#FFCDEB`,"error-muted":`#593B4D`,"footer-background":`#45475A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#CDD6F4`,"footer-foreground":`#CDD6F4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FAB387`,foreground:`#CDD6F4`,"foreground-darken-1":`#B8C1DE`,"foreground-darken-2":`#A3ACC9`,"foreground-darken-3":`#8F98B4`,"foreground-disabled":`#CDD6F460`,"foreground-lighten-1":`#E2EBFF`,"foreground-lighten-2":`#F7FFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#CDD6F499`,"input-cursor-background":`#F5E0DC`,"input-cursor-foreground":`#11111B`,"input-selection-background":`#9399B24C`,"link-background":`#00000000`,"link-background-hover":`#F5C2E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#F5C2E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#F5C2E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#F5C2E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#CDD6F4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#CDD6F4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#CDD6F499`,panel:`#45475A`,"panel-darken-1":`#333648`,"panel-darken-2":`#232637`,"panel-darken-3":`#131627`,"panel-lighten-1":`#56586C`,"panel-lighten-2":`#696A7F`,"panel-lighten-3":`#7B7D92`,primary:`#F5C2E7`,"primary-background":`#564F5E`,"primary-background-darken-1":`#474050`,"primary-background-darken-2":`#393142`,"primary-background-darken-3":`#393142`,"primary-background-lighten-1":`#655F6C`,"primary-background-lighten-2":`#746E7A`,"primary-background-lighten-3":`#837E88`,"primary-darken-1":`#DFADD1`,"primary-darken-2":`#CA99BD`,"primary-darken-3":`#B585A8`,"primary-lighten-1":`#FFD6FC`,"primary-lighten-2":`#FFECFF`,"primary-lighten-3":`#FFFFFF`,"primary-muted":`#5A4B5F`,scrollbar:`#644E69`,"scrollbar-active":`#F5C2E7`,"scrollbar-background":`#040216`,"scrollbar-background-active":`#040216`,"scrollbar-background-hover":`#040216`,"scrollbar-corner-color":`#040216`,"scrollbar-hover":`#7C627E`,secondary:`#CBA6F7`,"secondary-background":`#504C60`,"secondary-background-darken-1":`#413C52`,"secondary-background-darken-2":`#322D44`,"secondary-background-darken-3":`#322D44`,"secondary-background-lighten-1":`#605C6E`,"secondary-background-lighten-2":`#6F6C7C`,"secondary-background-lighten-3":`#7E7B8A`,"secondary-darken-1":`#B592E1`,"secondary-darken-2":`#A17ECC`,"secondary-darken-3":`#8C6BB7`,"secondary-lighten-1":`#E0BAFF`,"secondary-lighten-2":`#F6CFFF`,"secondary-lighten-3":`#FFE4FF`,"secondary-muted":`#4D4264`,success:`#ABE9B3`,"success-darken-1":`#96D39E`,"success-darken-2":`#82BE8B`,"success-darken-3":`#6EAA77`,"success-lighten-1":`#BFFEC7`,"success-lighten-2":`#D5FFDC`,"success-lighten-3":`#EAFFF2`,"success-muted":`#44564F`,surface:`#313244`,"surface-active":`#3E3F51`,"surface-darken-1":`#202233`,"surface-darken-2":`#111223`,"surface-darken-3":`#000014`,"surface-lighten-1":`#414255`,"surface-lighten-2":`#535467`,"surface-lighten-3":`#65667A`,text:`#FFFFFFDD`,"text-accent":`#FBCCAF`,"text-disabled":`#FFFFFF60`,"text-error":`#F6B5C8`,"text-muted":`#FFFFFF99`,"text-primary":`#F8D6EF`,"text-secondary":`#DCC4F9`,"text-success":`#C7F0CC`,"text-warning":`#FBECCA`,warning:`#FAE3B0`,"warning-darken-1":`#E4CD9B`,"warning-darken-2":`#CEB988`,"warning-darken-3":`#B9A574`,"warning-lighten-1":`#FFF8C4`,"warning-lighten-2":`#FFFFD9`,"warning-lighten-3":`#FFFFEF`,"warning-muted":`#5B544E`}},ol=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],sl=Object.fromEntries(ol.map((e,t)=>[e,lc.get(t).hex])),cl={black:`#1A1A1A`,red:`#F4005F`,green:`#98E024`,yellow:`#FD971F`,blue:`#9D65FF`,magenta:`#F4005F`,cyan:`#58D1EB`,white:`#C4C5B5`,brightBlack:`#625E4C`,brightRed:`#F4005F`,brightGreen:`#98E024`,brightYellow:`#E0D561`,brightBlue:`#9D65FF`,brightMagenta:`#F4005F`,brightCyan:`#58D1EB`,brightWhite:`#F6F6EF`},ll={"atom-one-dark":el,"atom-one-light":tl,"catppuccin-frappe":nl,"catppuccin-latte":rl,"catppuccin-macchiato":il,"catppuccin-mocha":al,cyberpunk:{name:`cyberpunk`,dark:!0,ansi:cl,vars:{background:`#070714`,"background-darken-1":`#03030A`,"background-darken-2":`#000003`,"background-darken-3":`#000000`,"background-lighten-1":`#11111E`,"background-lighten-2":`#1A1A2B`,"background-lighten-3":`#25253A`,foreground:`#E2E2FF`,"foreground-darken-1":`#CACAE4`,"foreground-darken-2":`#B3B3CC`,"foreground-darken-3":`#9C9CB5`,"foreground-disabled":`#E2E2FF60`,"foreground-lighten-1":`#EEEEFF`,"foreground-lighten-2":`#F6F6FF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E2E2FF99`,primary:`#00E5FFD9`,"primary-darken-1":`#00CCE6D9`,"primary-darken-2":`#00B2CCD9`,"primary-darken-3":`#0099B3D9`,"primary-lighten-1":`#1AF0FFD9`,"primary-lighten-2":`#33F5FFD9`,"primary-lighten-3":`#4DFAFFD9`,"primary-muted":`#054A5BF4`,"primary-background":`#0A3340`,"primary-background-darken-1":`#072833`,"primary-background-darken-2":`#051E27`,"primary-background-darken-3":`#051E27`,"primary-background-lighten-1":`#0F404F`,"primary-background-lighten-2":`#154E5F`,"primary-background-lighten-3":`#1A5C6F`,secondary:`#FF1E8ECC`,"secondary-darken-1":`#E60A76CC`,"secondary-darken-2":`#CC005FCC`,"secondary-darken-3":`#B20048CC`,"secondary-lighten-1":`#FF3CA2CC`,"secondary-lighten-2":`#FF5AB6CC`,"secondary-lighten-3":`#FF78CACC`,"secondary-muted":`#510E39EF`,"secondary-background":`#3A0A28`,"secondary-background-darken-1":`#2E071F`,"secondary-background-darken-2":`#220517`,"secondary-background-darken-3":`#220517`,"secondary-background-lighten-1":`#470D33`,"secondary-background-lighten-2":`#54103F`,"secondary-background-lighten-3":`#61134B`,accent:`#EEFF00CC`,"accent-darken-1":`#D6E600CC`,"accent-darken-2":`#BECC00CC`,"accent-darken-3":`#A5B200CC`,"accent-lighten-1":`#FFFF26CC`,"accent-lighten-2":`#FFFF4DCC`,"accent-lighten-3":`#FFFF73CC`,"accent-muted":`#4C510EEF`,success:`#39FF14BF`,"success-darken-1":`#23E60ABF`,"success-darken-2":`#0FCC00BF`,"success-darken-3":`#00B200BF`,"success-lighten-1":`#4DFF32BF`,"success-lighten-2":`#69FF5ABF`,"success-lighten-3":`#87FF82BF`,"success-muted":`#164D14F0`,warning:`#FF6E00CC`,"warning-darken-1":`#E65800CC`,"warning-darken-2":`#CC4300CC`,"warning-darken-3":`#B23000CC`,"warning-lighten-1":`#FF8C26CC`,"warning-lighten-2":`#FFA54DCC`,"warning-lighten-3":`#FFBE73CC`,"warning-muted":`#51260EEF`,error:`#FF1133BF`,"error-darken-1":`#E6051EBF`,"error-darken-2":`#CC000CBF`,"error-darken-3":`#B20000BF`,"error-lighten-1":`#FF3758BF`,"error-lighten-2":`#FF5A78BF`,"error-lighten-3":`#FF7D96BF`,"error-muted":`#510A1DF0`,surface:`#0F0F22`,"surface-active":`#161630`,"surface-darken-1":`#08081A`,"surface-darken-2":`#040411`,"surface-darken-3":`#020209`,"surface-lighten-1":`#17172E`,"surface-lighten-2":`#1F1F3C`,"surface-lighten-3":`#28284A`,panel:`#0C0C1E`,"panel-darken-1":`#060614`,"panel-darken-2":`#03030C`,"panel-darken-3":`#010108`,"panel-lighten-1":`#14142C`,"panel-lighten-2":`#1C1C3A`,"panel-lighten-3":`#242448`,scrollbar:`#151535`,"scrollbar-active":`#00E5FFD9`,"scrollbar-background":`#040412`,"scrollbar-background-active":`#040412`,"scrollbar-background-hover":`#040412`,"scrollbar-corner-color":`#040412`,"scrollbar-hover":`#1F1F48`,"block-cursor-background":`#00E5FF`,"block-cursor-blurred-background":`#00E5FF4C`,"block-cursor-blurred-foreground":`#E2E2FF`,"block-cursor-foreground":`#070714`,"block-hover-background":`#00E5FF19`,boost:`#00E5FF0A`,"boost-darken-1":`#00CCE60A`,"boost-darken-2":`#00B2CC0A`,"boost-darken-3":`#0099B30A`,"boost-lighten-1":`#00E5FF0A`,"boost-lighten-2":`#00E5FF0A`,"boost-lighten-3":`#00E5FF0A`,border:`#00E5FFD9`,"border-blurred":`#1A1A35`,"button-color-foreground":`#070714`,"button-foreground":`#E2E2FF`,"footer-background":`#0C0C1E`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E2E2FF`,"footer-foreground":`#E2E2FF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#00E5FFD9`,"input-cursor-background":`#E2E2FF`,"input-cursor-foreground":`#070714`,"input-selection-background":`#00E5FF40`,"link-background":`#00000000`,"link-background-hover":`#00E5FFD9`,"link-color":`#E2E2FFDD`,"link-color-hover":`#070714`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#00E5FFD9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#00E5FFD9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#FF1E8ECC`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E2E2FF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E2E2FF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E2E2FF99`,text:`#E2E2FFDD`,"text-accent":`#F4FF66CC`,"text-disabled":`#E2E2FF60`,"text-error":`#FF6677BF`,"text-muted":`#E2E2FF99`,"text-primary":`#66F0FFD9`,"text-secondary":`#FF80B0CC`,"text-success":`#80FF55BF`,"text-warning":`#FFB055CC`}},default:{name:`default`,dark:!0,ansi:sl,vars:{accent:`#006FB8`,"accent-darken-1":`#005CA3`,"accent-darken-2":`#004B8F`,"accent-darken-3":`#003A7B`,"accent-lighten-1":`#3081CC`,"accent-lighten-2":`#4C95E2`,"accent-lighten-3":`#64A8F7`,"accent-muted":`#002137`,background:`#000000`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#161616`,"background-lighten-2":`#252525`,"background-lighten-3":`#353535`,"block-cursor-background":`#006FB8`,"block-cursor-blurred-background":`#006FB84C`,"block-cursor-blurred-foreground":`#FFFFFF`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#006FB8`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#FFFFFF`,error:`#7F0000`,"error-darken-1":`#6A0000`,"error-darken-2":`#560000`,"error-darken-3":`#450000`,"error-lighten-1":`#961E12`,"error-lighten-2":`#AD3423`,"error-lighten-3":`#C44934`,"error-muted":`#260000`,"footer-background":`#242E35`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FFFFFF`,"footer-foreground":`#FFFFFF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#006FB8`,foreground:`#FFFFFF`,"foreground-darken-1":`#E9E9E9`,"foreground-darken-2":`#D4D4D4`,"foreground-darken-3":`#BFBFBF`,"foreground-disabled":`#FFFFFF60`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FFFFFF99`,"input-cursor-background":`#FFFFFF`,"input-cursor-foreground":`#000000`,"input-selection-background":`#3081CC66`,"link-background":`#00000000`,"link-background-hover":`#006FB8`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#006FB8`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#006FB8`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#006FB8`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FFFFFF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FFFFFF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FFFFFF99`,panel:`#242E35`,"panel-darken-1":`#141E24`,"panel-darken-2":`#000D15`,"panel-darken-3":`#000000`,"panel-lighten-1":`#343E45`,"panel-lighten-2":`#454F57`,"panel-lighten-3":`#566169`,primary:`#006FB8`,"primary-background":`#26333D`,"primary-background-darken-1":`#13212C`,"primary-background-darken-2":`#00101B`,"primary-background-darken-3":`#00101B`,"primary-background-lighten-1":`#39454E`,"primary-background-lighten-2":`#4C575F`,"primary-background-lighten-3":`#5F6970`,"primary-darken-1":`#005CA3`,"primary-darken-2":`#004B8F`,"primary-darken-3":`#003A7B`,"primary-lighten-1":`#3081CC`,"primary-lighten-2":`#4C95E2`,"primary-lighten-3":`#64A8F7`,"primary-muted":`#002137`,scrollbar:`#002C49`,"scrollbar-active":`#006FB8`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#00375C`,secondary:`#762671`,"secondary-background":`#342A33`,"secondary-background-darken-1":`#221721`,"secondary-background-darken-2":`#110510`,"secondary-background-darken-3":`#110510`,"secondary-background-lighten-1":`#463D45`,"secondary-background-lighten-2":`#585057`,"secondary-background-lighten-3":`#6A6269`,"secondary-darken-1":`#620F5E`,"secondary-darken-2":`#4E004C`,"secondary-darken-3":`#3B003A`,"secondary-lighten-1":`#8A3984`,"secondary-lighten-2":`#9E4C97`,"secondary-lighten-3":`#B360AB`,"secondary-muted":`#230B21`,success:`#008000`,"success-darken-1":`#006C00`,"success-darken-2":`#005900`,"success-darken-3":`#004600`,"success-lighten-1":`#29931C`,"success-lighten-2":`#42A832`,"success-lighten-3":`#58BD46`,"success-muted":`#002600`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#569FD0`,"text-disabled":`#FFFFFF60`,"text-error":`#AB5656`,"text-muted":`#FFFFFF99`,"text-primary":`#569FD0`,"text-secondary":`#A46FA1`,"text-success":`#56AB56`,"text-warning":`#ABAB56`,warning:`#7F8000`,"warning-darken-1":`#6B6D00`,"warning-darken-2":`#575A00`,"warning-darken-3":`#454900`,"warning-lighten-1":`#94931E`,"warning-lighten-2":`#A9A734`,"warning-lighten-3":`#BFBB48`,"warning-muted":`#262600`}},dracula:{name:`dracula`,dark:!0,ansi:{black:`#21222C`,red:`#FF5555`,green:`#50FA7B`,yellow:`#F1FA8C`,blue:`#BD93F9`,magenta:`#FF79C6`,cyan:`#8BE9FD`,white:`#F8F8F2`,brightBlack:`#6272A4`,brightRed:`#FF6E6E`,brightGreen:`#69FF94`,brightYellow:`#FFFFA5`,brightBlue:`#D6ACFF`,brightMagenta:`#FF92DF`,brightCyan:`#A4FFFF`,brightWhite:`#FFFFFF`},vars:{accent:`#FF79C6`,"accent-darken-1":`#E864B1`,"accent-darken-2":`#D24F9D`,"accent-darken-3":`#BC3989`,"accent-lighten-1":`#FF8DDA`,"accent-lighten-2":`#FFA3F0`,"accent-lighten-3":`#FFB8FF`,"accent-muted":`#684161`,background:`#282A36`,"background-darken-1":`#181A25`,"background-darken-2":`#050716`,"background-darken-3":`#000000`,"background-lighten-1":`#383A46`,"background-lighten-2":`#494B58`,"background-lighten-3":`#5B5D6A`,"block-cursor-background":`#BD93F9`,"block-cursor-blurred-background":`#BD93F94C`,"block-cursor-blurred-foreground":`#F8F8F2`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BD93F9`,"border-blurred":`#252835`,"button-color-foreground":`#282A36`,"button-foreground":`#F8F8F2`,error:`#FE5555`,"error-darken-1":`#E63E43`,"error-darken-2":`#CE2332`,"error-darken-3":`#B70022`,"error-lighten-1":`#FF6A67`,"error-lighten-2":`#FF807A`,"error-lighten-3":`#FF958D`,"error-muted":`#68363F`,"footer-background":`#313442`,"footer-description-background":`#00000000`,"footer-description-foreground":`#F8F8F2`,"footer-foreground":`#F8F8F2`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FF79C6`,foreground:`#F8F8F2`,"foreground-darken-1":`#E2E2DC`,"foreground-darken-2":`#CDCDC7`,"foreground-darken-3":`#B8B8B3`,"foreground-disabled":`#F8F8F260`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#F8F8F299`,"input-cursor-background":`#F8F8F2`,"input-cursor-foreground":`#282A36`,"input-selection-background":`#D2A7FF66`,"link-background":`#00000000`,"link-background-hover":`#BD93F9`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#BD93F9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#BD93F9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#BD93F9`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#F8F8F2`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#F8F8F2`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#F8F8F299`,panel:`#313442`,"panel-darken-1":`#202431`,"panel-darken-2":`#111421`,"panel-darken-3":`#000012`,"panel-lighten-1":`#414453`,"panel-lighten-2":`#535665`,"panel-lighten-3":`#656878`,primary:`#BD93F9`,"primary-background":`#5A566C`,"primary-background-darken-1":`#4C475F`,"primary-background-darken-2":`#3E3953`,"primary-background-darken-3":`#3E3953`,"primary-background-lighten-1":`#696579`,"primary-background-lighten-2":`#777486`,"primary-background-lighten-3":`#868393`,"primary-darken-1":`#A77FE3`,"primary-darken-2":`#936CCE`,"primary-darken-3":`#7E59B9`,"primary-lighten-1":`#D2A7FF`,"primary-lighten-2":`#E8BBFF`,"primary-lighten-3":`#FED0FF`,"primary-muted":`#544970`,scrollbar:`#5A4A79`,"scrollbar-active":`#BD93F9`,"scrollbar-background":`#181A25`,"scrollbar-background-active":`#181A25`,"scrollbar-background-hover":`#181A25`,"scrollbar-corner-color":`#181A25`,"scrollbar-hover":`#6A568F`,secondary:`#6272A4`,"secondary-background":`#4F5261`,"secondary-background-darken-1":`#3F4353`,"secondary-background-darken-2":`#303446`,"secondary-background-darken-3":`#303446`,"secondary-background-lighten-1":`#5E616F`,"secondary-background-lighten-2":`#6E707D`,"secondary-background-lighten-3":`#7D808B`,"secondary-darken-1":`#4E5F90`,"secondary-darken-2":`#3B4D7C`,"secondary-darken-3":`#283C69`,"secondary-lighten-1":`#7584B8`,"secondary-lighten-2":`#8998CD`,"secondary-lighten-3":`#9DACE2`,"secondary-muted":`#393F57`,success:`#50FA7B`,"success-darken-1":`#2FE467`,"success-darken-2":`#00CE53`,"success-darken-3":`#00B83F`,"success-lighten-1":`#6AFF8F`,"success-lighten-2":`#83FFA3`,"success-lighten-3":`#9BFFB8`,"success-muted":`#34684A`,surface:`#2B2E3B`,"surface-active":`#383B48`,"surface-darken-1":`#1B1E2A`,"surface-darken-2":`#0A0D1B`,"surface-darken-3":`#000009`,"surface-lighten-1":`#3B3E4C`,"surface-lighten-2":`#4C4F5D`,"surface-lighten-3":`#5E6170`,text:`#FFFFFFDD`,"text-accent":`#FFA6D9`,"text-disabled":`#FFFFFF60`,"text-error":`#FF8E8E`,"text-muted":`#FFFFFF99`,"text-primary":`#D3B7FB`,"text-secondary":`#97A1C2`,"text-success":`#8BFBA7`,"text-warning":`#FFD09D`,warning:`#FEB86C`,"warning-darken-1":`#E8A358`,"warning-darken-2":`#D18F45`,"warning-darken-3":`#BB7C33`,"warning-lighten-1":`#FFCC7F`,"warning-lighten-2":`#FFE193`,"warning-lighten-3":`#FFF7A7`,"warning-muted":`#685446`}},flexoki:{name:`flexoki`,dark:!0,ansi:{black:`#100F0F`,red:`#D14D41`,green:`#879A39`,yellow:`#D0A215`,blue:`#4385BE`,magenta:`#CE5D97`,cyan:`#3AA99F`,white:`#878580`,brightBlack:`#575653`,brightRed:`#AF3029`,brightGreen:`#66800B`,brightYellow:`#AD8301`,brightBlue:`#205EA6`,brightMagenta:`#A02F6F`,brightCyan:`#24837B`,brightWhite:`#CECDC3`},vars:{accent:`#9B76C8`,"accent-darken-1":`#8663B3`,"accent-darken-2":`#72509E`,"accent-darken-3":`#5F3E8B`,"accent-lighten-1":`#AF89DD`,"accent-lighten-2":`#C49DF2`,"accent-lighten-3":`#D9B1FF`,"accent-muted":`#392D46`,background:`#100F0F`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#1F1F1F`,"background-lighten-2":`#2F2E2E`,"background-lighten-3":`#403F3F`,"block-cursor-background":`#205EA6`,"block-cursor-blurred-background":`#205EA64C`,"block-cursor-blurred-foreground":`#FFFCF0`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#205EA6`,"border-blurred":`#171614`,"button-color-foreground":`#FFFCF0`,"button-foreground":`#FFFCF0`,error:`#AE3029`,"error-darken-1":`#981818`,"error-darken-2":`#810007`,"error-darken-3":`#6B0000`,"error-lighten-1":`#C64539`,"error-lighten-2":`#DD594B`,"error-lighten-3":`#F46D5D`,"error-muted":`#3F1816`,"footer-background":`#282726`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FFFCF0`,"footer-foreground":`#FFFCF0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#9B76C8`,foreground:`#FFFCF0`,"foreground-darken-1":`#E9E6DA`,"foreground-darken-2":`#D4D1C5`,"foreground-darken-3":`#BFBCB1`,"foreground-disabled":`#FFFCF060`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FFFCF099`,"input-cursor-background":`#FFFCF0`,"input-cursor-foreground":`#5E409D`,"input-selection-background":`#6F6E6959`,"link-background":`#00000000`,"link-background-hover":`#205EA6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#205EA6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#205EA6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#205EA6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FFFCF0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FFFCF0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FFFCF099`,panel:`#282726`,"panel-darken-1":`#181716`,"panel-darken-2":`#040200`,"panel-darken-3":`#000000`,"panel-lighten-1":`#383736`,"panel-lighten-2":`#494846`,"panel-lighten-3":`#5A5958`,primary:`#205EA6`,"primary-background":`#353C45`,"primary-background-darken-1":`#232B35`,"primary-background-darken-2":`#121A25`,"primary-background-darken-3":`#121A25`,"primary-background-lighten-1":`#474D56`,"primary-background-lighten-2":`#595E66`,"primary-background-lighten-3":`#6A6F76`,"primary-darken-1":`#004C91`,"primary-darken-2":`#003B7E`,"primary-darken-3":`#002B6B`,"primary-lighten-1":`#3C70BA`,"primary-lighten-2":`#5383CF`,"primary-lighten-3":`#6996E4`,"primary-muted":`#14263C`,scrollbar:`#0C2542`,"scrollbar-active":`#205EA6`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#102F53`,secondary:`#24837B`,"secondary-background":`#364140`,"secondary-background-darken-1":`#24302F`,"secondary-background-darken-2":`#13201F`,"secondary-background-darken-3":`#13201F`,"secondary-background-lighten-1":`#485251`,"secondary-background-lighten-2":`#596262`,"secondary-background-lighten-3":`#6B7373`,"secondary-darken-1":`#006F68`,"secondary-darken-2":`#005D56`,"secondary-darken-3":`#004A44`,"secondary-lighten-1":`#3C968E`,"secondary-lighten-2":`#52AAA1`,"secondary-lighten-3":`#67BFB6`,"secondary-muted":`#16312F`,success:`#65800B`,"success-darken-1":`#526D00`,"success-darken-2":`#3E5A00`,"success-darken-3":`#2D4800`,"success-lighten-1":`#7A9324`,"success-lighten-2":`#8EA738`,"success-lighten-3":`#A3BB4C`,"success-muted":`#29300D`,surface:`#1C1B1A`,"surface-active":`#282726`,"surface-darken-1":`#0A0806`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2B2A29`,"surface-lighten-2":`#3B3A39`,"surface-lighten-3":`#4D4B4A`,text:`#FFFFFFDD`,"text-accent":`#BDA4DA`,"text-disabled":`#FFFFFF60`,"text-error":`#CA7671`,"text-muted":`#FFFFFF99`,"text-primary":`#6B94C4`,"text-secondary":`#6EADA7`,"text-success":`#9AAB5D`,"text-warning":`#C8AD57`,warning:`#AC8301`,"warning-darken-1":`#977000`,"warning-darken-2":`#815D00`,"warning-darken-3":`#6C4C00`,"warning-lighten-1":`#C39621`,"warning-lighten-2":`#D9AA37`,"warning-lighten-3":`#F0BE4B`,"warning-muted":`#3F310A`}},gruvbox:{name:`gruvbox`,dark:!0,ansi:{black:`#282828`,red:`#CC241D`,green:`#98971A`,yellow:`#D79921`,blue:`#458588`,magenta:`#B16286`,cyan:`#689D6A`,white:`#A89984`,brightBlack:`#928374`,brightRed:`#FB4934`,brightGreen:`#B8BB26`,brightYellow:`#FABD2F`,brightBlue:`#83A598`,brightMagenta:`#D3869B`,brightCyan:`#8EC07C`,brightWhite:`#EBDBB2`},vars:{accent:`#F9BD2F`,"accent-darken-1":`#E2A811`,"accent-darken-2":`#CB9400`,"accent-darken-3":`#B48100`,"accent-lighten-1":`#FFD146`,"accent-lighten-2":`#FFE65B`,"accent-lighten-3":`#FFFC70`,"accent-muted":`#67542A`,background:`#282828`,"background-darken-1":`#181818`,"background-darken-2":`#040404`,"background-darken-3":`#000000`,"background-lighten-1":`#383838`,"background-lighten-2":`#494949`,"background-lighten-3":`#5A5A5A`,"block-cursor-background":`#85A598`,"block-cursor-blurred-background":`#85A5984C`,"block-cursor-blurred-foreground":`#FBF1C7`,"block-cursor-foreground":`#FBF1C7`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#85A598`,"border-blurred":`#363230`,"button-color-foreground":`#282828`,"button-foreground":`#FBF1C7`,error:`#FA4934`,"error-darken-1":`#E23022`,"error-darken-2":`#C90D10`,"error-darken-3":`#B10000`,"error-lighten-1":`#FF5F45`,"error-lighten-2":`#FF7558`,"error-lighten-3":`#FF8B6B`,"error-muted":`#67312B`,"footer-background":`#504945`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FBF1C7`,"footer-foreground":`#FBF1C7`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FABD2F`,foreground:`#FBF1C7`,"foreground-darken-1":`#E5DBB2`,"foreground-darken-2":`#D0C69E`,"foreground-darken-3":`#BBB28A`,"foreground-disabled":`#FBF1C760`,"foreground-lighten-1":`#FFFFDC`,"foreground-lighten-2":`#FFFFF1`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FBF1C799`,"input-cursor-background":`#FBF1C7`,"input-cursor-foreground":`#282828`,"input-selection-background":`#689D6A40`,"link-background":`#00000000`,"link-background-hover":`#85A598`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#85A598`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#85A598`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#85A598`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FBF1C7`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FBF1C7`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FBF1C799`,panel:`#504945`,"panel-darken-1":`#3E3834`,"panel-darken-2":`#2E2724`,"panel-darken-3":`#1E1815`,"panel-lighten-1":`#615A56`,"panel-lighten-2":`#746C68`,"panel-lighten-3":`#877F7B`,primary:`#85A598`,"primary-background":`#535755`,"primary-background-darken-1":`#444846`,"primary-background-darken-2":`#353A38`,"primary-background-darken-3":`#353A38`,"primary-background-lighten-1":`#626664`,"primary-background-lighten-2":`#717573`,"primary-background-lighten-3":`#808382`,"primary-darken-1":`#719184`,"primary-darken-2":`#5F7D71`,"primary-darken-3":`#4C6A5F`,"primary-lighten-1":`#98B9AB`,"primary-lighten-2":`#ACCEC0`,"primary-lighten-3":`#C1E3D5`,"primary-muted":`#434D49`,scrollbar:`#43504B`,"scrollbar-active":`#85A598`,"scrollbar-background":`#181818`,"scrollbar-background-active":`#181818`,"scrollbar-background-hover":`#181818`,"scrollbar-corner-color":`#181818`,"scrollbar-hover":`#4E5E58`,secondary:`#A89A85`,"secondary-background":`#585653`,"secondary-background-darken-1":`#494744`,"secondary-background-darken-2":`#3B3935`,"secondary-background-darken-3":`#3B3935`,"secondary-background-lighten-1":`#676562`,"secondary-background-lighten-2":`#757471`,"secondary-background-lighten-3":`#848380`,"secondary-darken-1":`#938671`,"secondary-darken-2":`#80735F`,"secondary-darken-3":`#6D604D`,"secondary-lighten-1":`#BCAE98`,"secondary-lighten-2":`#D1C2AC`,"secondary-lighten-3":`#E6D7C1`,"secondary-muted":`#4E4A43`,success:`#B7BB26`,"success-darken-1":`#A2A601`,"success-darken-2":`#8C9300`,"success-darken-3":`#777F00`,"success-lighten-1":`#CDCF3D`,"success-lighten-2":`#E4E453`,"success-lighten-3":`#FAFA68`,"success-muted":`#535427`,surface:`#3C3836`,"surface-active":`#494543`,"surface-darken-1":`#2B2725`,"surface-darken-2":`#1C1816`,"surface-darken-3":`#0A0300`,"surface-lighten-1":`#4D4846`,"surface-lighten-2":`#5F5A58`,"surface-lighten-3":`#716C6A`,text:`#FFFFFFDD`,"text-accent":`#FBD375`,"text-disabled":`#FFFFFF60`,"text-error":`#FC8679`,"text-muted":`#FFFFFF99`,"text-primary":`#AEC3BB`,"text-secondary":`#C5BCAE`,"text-success":`#D0D26F`,"text-warning":`#FEAB67`,warning:`#FD8019`,"warning-darken-1":`#E56C00`,"warning-darken-2":`#CD5800`,"warning-darken-3":`#B54500`,"warning-lighten-1":`#FF9430`,"warning-lighten-2":`#FFA845`,"warning-lighten-3":`#FFBD5A`,"warning-muted":`#684223`}},monokai:{name:`monokai`,dark:!0,ansi:{black:`#333333`,red:`#C4265E`,green:`#86B42B`,yellow:`#B3B42B`,blue:`#6A7EC8`,magenta:`#8C6BC8`,cyan:`#56ADBC`,white:`#E3E3DD`,brightBlack:`#666666`,brightRed:`#F92672`,brightGreen:`#A6E22E`,brightYellow:`#E2E22E`,brightBlue:`#819AFF`,brightMagenta:`#AE81FF`,brightCyan:`#66D9EF`,brightWhite:`#F8F8F2`},vars:{accent:`#66D9EF`,"accent-darken-1":`#4DC3D9`,"accent-darken-2":`#31AFC4`,"accent-darken-3":`#009BB0`,"accent-lighten-1":`#7DEEFF`,"accent-lighten-2":`#94FFFF`,"accent-lighten-3":`#AAFFFF`,"accent-muted":`#395D5F`,background:`#272822`,"background-darken-1":`#171812`,"background-darken-2":`#020400`,"background-darken-3":`#000000`,"background-lighten-1":`#373831`,"background-lighten-2":`#484942`,"background-lighten-3":`#595A54`,"block-cursor-background":`#AE81FF`,"block-cursor-blurred-background":`#AE81FF4C`,"block-cursor-blurred-foreground":`#D6D6D6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#AE81FF`,"border-blurred":`#282828`,"button-color-foreground":`#272822`,"button-foreground":`#D6D6D6`,error:`#F82672`,"error-darken-1":`#E1005F`,"error-darken-2":`#C9004E`,"error-darken-3":`#B1003D`,"error-lighten-1":`#FF4484`,"error-lighten-2":`#FF5D98`,"error-lighten-3":`#FF75AC`,"error-muted":`#66273A`,"footer-background":`#3E3D32`,"footer-description-background":`#00000000`,"footer-description-foreground":`#D6D6D6`,"footer-foreground":`#D6D6D6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#66D9EF`,foreground:`#D6D6D6`,"foreground-darken-1":`#C1C1C1`,"foreground-darken-2":`#ACACAC`,"foreground-darken-3":`#989898`,"foreground-disabled":`#D6D6D660`,"foreground-lighten-1":`#EBEBEB`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#797979`,"input-cursor-background":`#D6D6D6`,"input-cursor-foreground":`#272822`,"input-selection-background":`#575B6190`,"link-background":`#00000000`,"link-background-hover":`#AE81FF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#AE81FF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#AE81FF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#AE81FF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#D6D6D6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#D6D6D6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#797979`,panel:`#3E3D32`,"panel-darken-1":`#2D2C22`,"panel-darken-2":`#1D1C12`,"panel-darken-3":`#0D0B00`,"panel-lighten-1":`#4F4E42`,"panel-lighten-2":`#616054`,"panel-lighten-3":`#737266`,primary:`#AE81FF`,"primary-background":`#58535F`,"primary-background-darken-1":`#494451`,"primary-background-darken-2":`#3B3543`,"primary-background-darken-3":`#3B3543`,"primary-background-lighten-1":`#67626D`,"primary-background-lighten-2":`#75717B`,"primary-background-lighten-3":`#848089`,"primary-darken-1":`#986DE9`,"primary-darken-2":`#835AD3`,"primary-darken-3":`#6E48BE`,"primary-lighten-1":`#C394FF`,"primary-lighten-2":`#D9A9FF`,"primary-lighten-3":`#EFBDFF`,"primary-muted":`#4F4264`,scrollbar:`#534270`,"scrollbar-active":`#AE81FF`,"scrollbar-background":`#171812`,"scrollbar-background-active":`#171812`,"scrollbar-background-hover":`#171812`,"scrollbar-corner-color":`#171812`,"scrollbar-hover":`#624C88`,secondary:`#F82672`,"secondary-background":`#61474D`,"secondary-background-darken-1":`#53373D`,"secondary-background-darken-2":`#46272E`,"secondary-background-darken-3":`#46272E`,"secondary-background-lighten-1":`#6F575D`,"secondary-background-lighten-2":`#7D676C`,"secondary-background-lighten-3":`#8B787C`,"secondary-darken-1":`#E1005F`,"secondary-darken-2":`#C9004E`,"secondary-darken-3":`#B1003D`,"secondary-lighten-1":`#FF4484`,"secondary-lighten-2":`#FF5D98`,"secondary-lighten-3":`#FF75AC`,"secondary-muted":`#66273A`,success:`#A5E22E`,"success-darken-1":`#90CC09`,"success-darken-2":`#7AB700`,"success-darken-3":`#64A300`,"success-lighten-1":`#BBF746`,"success-lighten-2":`#D2FF5D`,"success-lighten-3":`#E8FF72`,"success-muted":`#4D5F25`,surface:`#2E2E2E`,"surface-active":`#3B3B3B`,"surface-darken-1":`#1E1E1E`,"surface-darken-2":`#0D0D0D`,"surface-darken-3":`#000000`,"surface-lighten-1":`#3E3E3E`,"surface-lighten-2":`#4F4F4F`,"surface-lighten-3":`#616161`,text:`#FFFFFFDD`,"text-accent":`#9AE5F4`,"text-disabled":`#FFFFFF60`,"text-error":`#FB6FA1`,"text-muted":`#FFFFFF99`,"text-primary":`#C9ABFF`,"text-secondary":`#FB6FA1`,"text-success":`#C4EB75`,"text-warning":`#FDBA6B`,warning:`#FC971F`,"warning-darken-1":`#E58300`,"warning-darken-2":`#CD6F00`,"warning-darken-3":`#B65D00`,"warning-lighten-1":`#FFAB36`,"warning-lighten-2":`#FFBF4C`,"warning-lighten-3":`#FFD460`,"warning-muted":`#674921`}},nord:{name:`nord`,dark:!0,ansi:{black:`#3B4252`,red:`#BF616A`,green:`#A3BE8C`,yellow:`#EBCB8B`,blue:`#81A1C1`,magenta:`#B48EAD`,cyan:`#88C0D0`,white:`#E5E9F0`,brightBlack:`#596377`,brightRed:`#BF616A`,brightGreen:`#A3BE8C`,brightYellow:`#EBCB8B`,brightBlue:`#81A1C1`,brightMagenta:`#B48EAD`,brightCyan:`#8FBCBB`,brightWhite:`#ECEFF4`},vars:{accent:`#B48EAD`,"accent-darken-1":`#9F7A98`,"accent-darken-2":`#8B6785`,"accent-darken-3":`#785572`,"accent-lighten-1":`#C8A1C1`,"accent-lighten-2":`#DDB6D6`,"accent-lighten-3":`#F3CAEB`,"accent-muted":`#564F60`,background:`#2E3440`,"background-darken-1":`#1E242F`,"background-darken-2":`#0E141F`,"background-darken-3":`#000010`,"background-lighten-1":`#3E4451`,"background-lighten-2":`#505663`,"background-lighten-3":`#626875`,"block-cursor-background":`#88C0D0`,"block-cursor-blurred-background":`#88C0D04C`,"block-cursor-blurred-foreground":`#D8DEE9`,"block-cursor-foreground":`#2E3440`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#88C0D0`,"border-blurred":`#353C4C`,"button-color-foreground":`#2E3440`,"button-foreground":`#D8DEE9`,error:`#BE616A`,"error-darken-1":`#A94D57`,"error-darken-2":`#933A46`,"error-darken-3":`#7E2735`,"error-lighten-1":`#D4747C`,"error-lighten-2":`#EB8890`,"error-lighten-3":`#FF9CA3`,"error-muted":`#59414C`,"footer-background":`#434C5E`,"footer-description-background":`#00000000`,"footer-description-foreground":`#D8DEE9`,"footer-foreground":`#D8DEE9`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#88C0D0`,foreground:`#D8DEE9`,"foreground-darken-1":`#C3C9D3`,"foreground-darken-2":`#AEB4BF`,"foreground-darken-3":`#9AA0AA`,"foreground-disabled":`#D8DEE960`,"foreground-lighten-1":`#EDF3FE`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#D8DEE999`,"input-cursor-background":`#D8DEE9`,"input-cursor-foreground":`#2E3440`,"input-selection-background":`#81A1C159`,"link-background":`#00000000`,"link-background-hover":`#88C0D0`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#88C0D0`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#88C0D0`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#88C0D0`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#D8DEE9`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#D8DEE9`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#D8DEE999`,panel:`#434C5E`,"panel-darken-1":`#313A4C`,"panel-darken-2":`#212A3A`,"panel-darken-3":`#111B2A`,"panel-lighten-1":`#545D70`,"panel-lighten-2":`#677083`,"panel-lighten-3":`#798396`,primary:`#88C0D0`,"primary-background":`#58646E`,"primary-background-darken-1":`#495661`,"primary-background-darken-2":`#3B4955`,"primary-background-darken-3":`#3B4955`,"primary-background-lighten-1":`#67717B`,"primary-background-lighten-2":`#757F88`,"primary-background-lighten-3":`#848D94`,"primary-darken-1":`#73ABBB`,"primary-darken-2":`#5F97A6`,"primary-darken-3":`#4B8393`,"primary-lighten-1":`#9CD4E5`,"primary-lighten-2":`#B1EAFA`,"primary-lighten-3":`#C6FFFF`,"primary-muted":`#495E6B`,scrollbar:`#48626F`,"scrollbar-active":`#88C0D0`,"scrollbar-background":`#1E242F`,"scrollbar-background-active":`#1E242F`,"scrollbar-background-hover":`#1E242F`,"scrollbar-corner-color":`#1E242F`,"scrollbar-hover":`#53727F`,secondary:`#81A1C1`,"secondary-background":`#57606C`,"secondary-background-darken-1":`#48525F`,"secondary-background-darken-2":`#3A4453`,"secondary-background-darken-3":`#3A4453`,"secondary-background-lighten-1":`#666E79`,"secondary-background-lighten-2":`#757C86`,"secondary-background-lighten-3":`#838A93`,"secondary-darken-1":`#6D8DAC`,"secondary-darken-2":`#597A98`,"secondary-darken-3":`#466784`,"secondary-lighten-1":`#95B5D5`,"secondary-lighten-2":`#A9C9EB`,"secondary-lighten-3":`#BEDEFF`,"secondary-muted":`#465466`,success:`#A3BE8C`,"success-darken-1":`#8FA978`,"success-darken-2":`#7B9565`,"success-darken-3":`#688253`,"success-lighten-1":`#B7D29F`,"success-lighten-2":`#CCE8B4`,"success-lighten-3":`#E1FDC8`,"success-muted":`#515D56`,surface:`#3B4252`,"surface-active":`#484F60`,"surface-darken-1":`#2A3140`,"surface-darken-2":`#1A212F`,"surface-darken-3":`#0A1120`,"surface-lighten-1":`#4C5364`,"surface-lighten-2":`#5E6576`,"surface-lighten-3":`#707889`,text:`#FFFFFFDD`,"text-accent":`#CDB4C8`,"text-disabled":`#FFFFFF60`,"text-error":`#D4969C`,"text-muted":`#FFFFFF99`,"text-primary":`#B0D5DF`,"text-secondary":`#ABC0D6`,"text-success":`#C2D4B3`,"text-warning":`#F1DCB2`,warning:`#EACB8B`,"warning-darken-1":`#D5B677`,"warning-darken-2":`#BFA264`,"warning-darken-3":`#AA8E51`,"warning-lighten-1":`#FFE09E`,"warning-lighten-2":`#FFF5B3`,"warning-lighten-3":`#FFFFC8`,"warning-muted":`#666156`}},"rose-pine":{name:`rose-pine`,dark:!0,ansi:{black:`#26233A`,red:`#EB6F92`,green:`#31748F`,yellow:`#F6C177`,blue:`#9CCFD8`,magenta:`#C4A7E7`,cyan:`#EBBCBA`,white:`#E0DEF4`,brightBlack:`#6E6A86`,brightRed:`#EB6F92`,brightGreen:`#31748F`,brightYellow:`#F6C177`,brightBlue:`#9CCFD8`,brightMagenta:`#C4A7E7`,brightCyan:`#EBBCBA`,brightWhite:`#E0DEF4`},vars:{accent:`#EBBCBA`,"accent-darken-1":`#D5A7A5`,"accent-darken-2":`#C09391`,"accent-darken-3":`#AB807E`,"accent-lighten-1":`#FFD0CE`,"accent-lighten-2":`#FFE5E3`,"accent-lighten-3":`#FFFBF9`,"accent-muted":`#584851`,background:`#191724`,"background-darken-1":`#060015`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#282634`,"background-lighten-2":`#383644`,"background-lighten-3":`#4A4756`,"block-cursor-background":`#C4A7E7`,"block-cursor-blurred-background":`#C4A7E74C`,"block-cursor-blurred-foreground":`#E0DEF4`,"block-cursor-foreground":`#191724`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#524F67`,"border-blurred":`#6E6A86`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0DEF4`,error:`#EA6F92`,"error-darken-1":`#D45A7E`,"error-darken-2":`#BE466B`,"error-darken-3":`#A83159`,"error-lighten-1":`#FF83A5`,"error-lighten-2":`#FF98BA`,"error-lighten-3":`#FFADCE`,"error-muted":`#583145`,"footer-background":`#26233A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0DEF4`,"footer-foreground":`#E0DEF4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#EBBCBA`,foreground:`#E0DEF4`,"foreground-darken-1":`#CAC9DE`,"foreground-darken-2":`#B6B4C9`,"foreground-darken-3":`#A2A0B4`,"foreground-disabled":`#E0DEF460`,"foreground-lighten-1":`#F5F3FF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0DEF499`,"input-cursor-background":`#F4EDE8`,"input-cursor-foreground":`#191724`,"input-selection-background":`#403D52`,"link-background":`#00000000`,"link-background-hover":`#C4A7E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C4A7E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C4A7E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C4A7E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0DEF4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0DEF4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0DEF499`,panel:`#26233A`,"panel-darken-1":`#161329`,"panel-darken-2":`#04001A`,"panel-darken-3":`#000008`,"panel-lighten-1":`#36324B`,"panel-lighten-2":`#47435D`,"panel-lighten-3":`#59556F`,primary:`#C4A7E7`,"primary-background":`#504B5D`,"primary-background-darken-1":`#413B4F`,"primary-background-darken-2":`#322C41`,"primary-background-darken-3":`#322C41`,"primary-background-lighten-1":`#605B6B`,"primary-background-lighten-2":`#6F6B7A`,"primary-background-lighten-3":`#7E7B88`,"primary-darken-1":`#AF93D1`,"primary-darken-2":`#9A7FBC`,"primary-darken-3":`#866CA8`,"primary-lighten-1":`#D9BBFC`,"primary-lighten-2":`#EED0FF`,"primary-lighten-3":`#FFE5FF`,"primary-muted":`#4C425E`,scrollbar:`#524269`,"scrollbar-active":`#C4A7E7`,"scrollbar-background":`#060015`,"scrollbar-background-active":`#060015`,"scrollbar-background-hover":`#060015`,"scrollbar-corner-color":`#060015`,"scrollbar-hover":`#65537E`,secondary:`#31748F`,"secondary-background":`#3E4452`,"secondary-background-darken-1":`#2D3443`,"secondary-background-darken-2":`#1C2434`,"secondary-background-darken-3":`#1C2434`,"secondary-background-lighten-1":`#4F5561`,"secondary-background-lighten-2":`#606570`,"secondary-background-lighten-3":`#717680`,"secondary-darken-1":`#17617B`,"secondary-darken-2":`#004F68`,"secondary-darken-3":`#003E56`,"secondary-lighten-1":`#4687A2`,"secondary-lighten-2":`#5B9AB7`,"secondary-lighten-3":`#70AECB`,"secondary-muted":`#203244`,success:`#9CCFD8`,"success-darken-1":`#87BAC3`,"success-darken-2":`#73A5AE`,"success-darken-3":`#60929A`,"success-lighten-1":`#B0E4ED`,"success-lighten-2":`#C5F9FF`,"success-lighten-3":`#DAFFFF`,"success-muted":`#404E5A`,surface:`#1F1D2E`,"surface-active":`#2B293B`,"surface-darken-1":`#100B1E`,"surface-darken-2":`#00000E`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2F2C3E`,"surface-lighten-2":`#3F3D4F`,"surface-lighten-3":`#514E61`,text:`#FFFFFFDD`,"text-accent":`#F1D2D1`,"text-disabled":`#FFFFFF60`,"text-error":`#F19FB7`,"text-muted":`#FFFFFF99`,"text-primary":`#D8C4EF`,"text-secondary":`#77A3B5`,"text-success":`#BDDFE5`,"text-warning":`#F9D6A5`,warning:`#F5C177`,"warning-darken-1":`#DFAC63`,"warning-darken-2":`#C99850`,"warning-darken-3":`#B3853E`,"warning-lighten-1":`#FFD58A`,"warning-lighten-2":`#FFEB9E`,"warning-lighten-3":`#FFFFB3`,"warning-muted":`#5B4A3C`}},"rose-pine-dawn":{name:`rose-pine-dawn`,dark:!1,ansi:{black:`#F2E9E1`,red:`#B4637A`,green:`#286983`,yellow:`#EA9D34`,blue:`#56949F`,magenta:`#907AA9`,cyan:`#D7827E`,white:`#575279`,brightBlack:`#9893A5`,brightRed:`#B4637A`,brightGreen:`#286983`,brightYellow:`#EA9D34`,brightBlue:`#56949F`,brightMagenta:`#907AA9`,brightCyan:`#D7827E`,brightWhite:`#575279`},vars:{accent:`#D6827E`,"accent-darken-1":`#C16E6B`,"accent-darken-2":`#AB5B58`,"accent-darken-3":`#964847`,"accent-lighten-1":`#ED9591`,"accent-lighten-2":`#FFAAA5`,"accent-lighten-3":`#FFBEB9`,"accent-muted":`#EFD1CB`,background:`#FAF4ED`,"background-darken-1":`#E4DED7`,"background-darken-2":`#CFC9C2`,"background-darken-3":`#BAB5AE`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#575279`,"block-cursor-blurred-background":`#907AA94C`,"block-cursor-blurred-foreground":`#575279`,"block-cursor-foreground":`#FAF4ED`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#CECACD`,"border-blurred":`#9893A5`,"button-color-foreground":`#000000DD`,"button-foreground":`#575279`,error:`#B4637A`,"error-darken-1":`#9E5067`,"error-darken-2":`#8A3D55`,"error-darken-3":`#752A43`,"error-lighten-1":`#C9768D`,"error-lighten-2":`#DF8AA0`,"error-lighten-3":`#F59EB5`,"error-muted":`#E5C8CA`,"footer-background":`#F2E9E1`,"footer-description-background":`#00000000`,"footer-description-foreground":`#575279`,"footer-foreground":`#575279`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#D7827E`,foreground:`#575279`,"foreground-darken-1":`#444066`,"foreground-darken-2":`#332F53`,"foreground-darken-3":`#222042`,"foreground-disabled":`#57527960`,"foreground-lighten-1":`#69648C`,"foreground-lighten-2":`#7C76A0`,"foreground-lighten-3":`#9089B4`,"foreground-muted":`#57527999`,"input-cursor-background":`#575279`,"input-cursor-foreground":`#FAF4ED`,"input-selection-background":`#DFDAD9`,"link-background":`#00000000`,"link-background-hover":`#907AA9`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#907AA9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#907AA9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#907AA9`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#575279`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#575279`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#57527999`,panel:`#F2E9E1`,"panel-darken-1":`#DCD3CB`,"panel-darken-2":`#C7BFB7`,"panel-darken-3":`#B3AAA3`,"panel-lighten-1":`#FFFEF6`,"panel-lighten-2":`#FFFFFF`,"panel-lighten-3":`#FFFFFF`,primary:`#907AA9`,"primary-background":`#907AA9`,"primary-background-darken-1":`#7C6795`,"primary-background-darken-2":`#695481`,"primary-background-darken-3":`#56436E`,"primary-background-lighten-1":`#A48DBD`,"primary-background-lighten-2":`#B8A1D2`,"primary-background-lighten-3":`#CDB5E7`,"primary-darken-1":`#7C6795`,"primary-darken-2":`#695481`,"primary-darken-3":`#56436E`,"primary-lighten-1":`#A48DBD`,"primary-lighten-2":`#B8A1D2`,"primary-lighten-3":`#CDB5E7`,"primary-muted":`#DACFD8`,scrollbar:`#C2B6C4`,"scrollbar-active":`#907AA9`,"scrollbar-background":`#E4DED7`,"scrollbar-background-active":`#E4DED7`,"scrollbar-background-hover":`#E4DED7`,"scrollbar-corner-color":`#E4DED7`,"scrollbar-hover":`#BAACC0`,secondary:`#286983`,"secondary-background":`#286983`,"secondary-background-darken-1":`#0A566F`,"secondary-background-darken-2":`#00455D`,"secondary-background-darken-3":`#00344B`,"secondary-background-lighten-1":`#3E7B96`,"secondary-background-lighten-2":`#538FAA`,"secondary-background-lighten-3":`#67A2BE`,"secondary-darken-1":`#0A566F`,"secondary-darken-2":`#00455D`,"secondary-darken-3":`#00344B`,"secondary-lighten-1":`#3E7B96`,"secondary-lighten-2":`#538FAA`,"secondary-lighten-3":`#67A2BE`,"secondary-muted":`#BBCACD`,success:`#56949F`,"success-darken-1":`#41808B`,"success-darken-2":`#2D6D78`,"success-darken-3":`#155B65`,"success-lighten-1":`#6AA7B3`,"success-lighten-2":`#7EBCC7`,"success-lighten-3":`#92D1DC`,"success-muted":`#C8D7D5`,surface:`#FFFAF3`,"surface-active":`#FFFFFF`,"surface-darken-1":`#E9E4DD`,"surface-darken-2":`#D4CFC8`,"surface-darken-3":`#BFBAB4`,"surface-lighten-1":`#FFFFFF`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#8D5553`,"text-disabled":`#00000060`,"text-error":`#764150`,"text-muted":`#00000099`,"text-primary":`#5F506F`,"text-secondary":`#1A4556`,"text-success":`#386168`,"text-warning":`#9A6722`,warning:`#E99D34`,"warning-darken-1":`#D2891D`,"warning-darken-2":`#BC7600`,"warning-darken-3":`#A56300`,"warning-lighten-1":`#FFB148`,"warning-lighten-2":`#FFC55C`,"warning-lighten-3":`#FFDA70`,"warning-muted":`#F5D9B5`}},"rose-pine-moon":{name:`rose-pine-moon`,dark:!0,ansi:{black:`#393552`,red:`#EB6F92`,green:`#3E8FB0`,yellow:`#F6C177`,blue:`#9CCFD8`,magenta:`#C4A7E7`,cyan:`#EA9A97`,white:`#E0DEF4`,brightBlack:`#6E6A86`,brightRed:`#EB6F92`,brightGreen:`#3E8FB0`,brightYellow:`#F6C177`,brightBlue:`#9CCFD8`,brightMagenta:`#C4A7E7`,brightCyan:`#EA9A97`,brightWhite:`#E0DEF4`},vars:{accent:`#EA9A97`,"accent-darken-1":`#D48683`,"accent-darken-2":`#BE7270`,"accent-darken-3":`#A95F5E`,"accent-lighten-1":`#FFAEAA`,"accent-lighten-2":`#FFC3BF`,"accent-lighten-3":`#FFD8D4`,"accent-muted":`#5E4553`,background:`#232136`,"background-darken-1":`#131125`,"background-darken-2":`#000017`,"background-darken-3":`#000001`,"background-lighten-1":`#333046`,"background-lighten-2":`#444158`,"background-lighten-3":`#56526A`,"block-cursor-background":`#C4A7E7`,"block-cursor-blurred-background":`#C4A7E74C`,"block-cursor-blurred-foreground":`#E0DEF4`,"block-cursor-foreground":`#232136`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#56526E`,"border-blurred":`#6E6A86`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0DEF4`,error:`#EA6F92`,"error-darken-1":`#D45A7E`,"error-darken-2":`#BE466B`,"error-darken-3":`#A83159`,"error-lighten-1":`#FF83A5`,"error-lighten-2":`#FF98BA`,"error-lighten-3":`#FFADCE`,"error-muted":`#5F3851`,"footer-background":`#393552`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0DEF4`,"footer-foreground":`#E0DEF4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#EA9A97`,foreground:`#E0DEF4`,"foreground-darken-1":`#CAC9DE`,"foreground-darken-2":`#B6B4C9`,"foreground-darken-3":`#A2A0B4`,"foreground-disabled":`#E0DEF460`,"foreground-lighten-1":`#F5F3FF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0DEF499`,"input-cursor-background":`#F4EDE8`,"input-cursor-foreground":`#232136`,"input-selection-background":`#44415A`,"link-background":`#00000000`,"link-background-hover":`#C4A7E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C4A7E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C4A7E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C4A7E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0DEF4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0DEF4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0DEF499`,panel:`#393552`,"panel-darken-1":`#282440`,"panel-darken-2":`#17152F`,"panel-darken-3":`#080020`,"panel-lighten-1":`#4A4564`,"panel-lighten-2":`#5C5776`,"panel-lighten-3":`#6F6989`,primary:`#C4A7E7`,"primary-background":`#58536A`,"primary-background-darken-1":`#49445D`,"primary-background-darken-2":`#3B3550`,"primary-background-darken-3":`#3B3550`,"primary-background-lighten-1":`#676277`,"primary-background-lighten-2":`#757184`,"primary-background-lighten-3":`#848091`,"primary-darken-1":`#AF93D1`,"primary-darken-2":`#9A7FBC`,"primary-darken-3":`#866CA8`,"primary-lighten-1":`#D9BBFC`,"primary-lighten-2":`#EED0FF`,"primary-lighten-3":`#FFE5FF`,"primary-muted":`#53496B`,scrollbar:`#594D72`,"scrollbar-active":`#C4A7E7`,"scrollbar-background":`#131125`,"scrollbar-background-active":`#131125`,"scrollbar-background-hover":`#131125`,"scrollbar-corner-color":`#131125`,"scrollbar-hover":`#6B5C86`,secondary:`#3E8FB0`,"secondary-background":`#474F63`,"secondary-background-darken-1":`#374055`,"secondary-background-darken-2":`#273148`,"secondary-background-darken-3":`#273148`,"secondary-background-lighten-1":`#575F71`,"secondary-background-lighten-2":`#676E7E`,"secondary-background-lighten-3":`#787E8C`,"secondary-darken-1":`#237B9B`,"secondary-darken-2":`#006888`,"secondary-darken-3":`#005674`,"secondary-lighten-1":`#54A2C4`,"secondary-lighten-2":`#6AB7D9`,"secondary-lighten-3":`#80CBEE`,"secondary-muted":`#2B425A`,success:`#9CCFD8`,"success-darken-1":`#87BAC3`,"success-darken-2":`#73A5AE`,"success-darken-3":`#60929A`,"success-lighten-1":`#B0E4ED`,"success-lighten-2":`#C5F9FF`,"success-lighten-3":`#DAFFFF`,"success-muted":`#475566`,surface:`#2A273F`,"surface-active":`#37334C`,"surface-darken-1":`#19172E`,"surface-darken-2":`#0A021E`,"surface-darken-3":`#00000F`,"surface-lighten-1":`#3A3750`,"surface-lighten-2":`#4C4862`,"surface-lighten-3":`#5E5975`,text:`#FFFFFFDD`,"text-accent":`#F1BCBA`,"text-disabled":`#FFFFFF60`,"text-error":`#F19FB7`,"text-muted":`#FFFFFF99`,"text-primary":`#D8C4EF`,"text-secondary":`#7FB5CA`,"text-success":`#BDDFE5`,"text-warning":`#F9D6A5`,warning:`#F5C177`,"warning-darken-1":`#DFAC63`,"warning-darken-2":`#C99850`,"warning-darken-3":`#B3853E`,"warning-lighten-1":`#FFD58A`,"warning-lighten-2":`#FFEB9E`,"warning-lighten-3":`#FFFFB3`,"warning-muted":`#625149`}},"solarized-dark":{name:`solarized-dark`,dark:!0,ansi:{black:`#073642`,red:`#DC322F`,green:`#859900`,yellow:`#B58900`,blue:`#268BD2`,magenta:`#D33682`,cyan:`#2AA198`,white:`#EEE8D5`,brightBlack:`#335E69`,brightRed:`#CB4B16`,brightGreen:`#586E75`,brightYellow:`#657B83`,brightBlue:`#839496`,brightMagenta:`#6C71C4`,brightCyan:`#93A1A1`,brightWhite:`#FDF6E3`},vars:{accent:`#6C71C4`,"accent-darken-1":`#575EAF`,"accent-darken-2":`#424C9A`,"accent-darken-3":`#2D3B87`,"accent-lighten-1":`#8083D9`,"accent-lighten-2":`#9597EE`,"accent-lighten-3":`#AAABFF`,"accent-muted":`#204060`,background:`#002B36`,"background-darken-1":`#001B25`,"background-darken-2":`#000A17`,"background-darken-3":`#000000`,"background-lighten-1":`#143B46`,"background-lighten-2":`#274C58`,"background-lighten-3":`#3A5E6A`,"block-cursor-background":`#268BD2`,"block-cursor-blurred-background":`#268BD24C`,"block-cursor-blurred-foreground":`#839496`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#268BD2`,"border-blurred":`#00303C`,"button-color-foreground":`#FDF6E3`,"button-foreground":`#839496`,error:`#DB322F`,"error-darken-1":`#C3121E`,"error-darken-2":`#AB000D`,"error-darken-3":`#940000`,"error-lighten-1":`#F44940`,"error-lighten-2":`#FF6052`,"error-lighten-3":`#FF7564`,"error-muted":`#422D33`,"footer-background":`#268BD2`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FDF6E3`,"footer-foreground":`#839496`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FDF6E3`,foreground:`#839496`,"foreground-darken-1":`#6F8082`,"foreground-darken-2":`#5D6D6F`,"foreground-darken-3":`#4B5B5D`,"foreground-disabled":`#83949660`,"foreground-lighten-1":`#96A7A9`,"foreground-lighten-2":`#AABCBE`,"foreground-lighten-3":`#BED0D3`,"foreground-muted":`#83949699`,"input-cursor-background":`#839496`,"input-cursor-foreground":`#002B36`,"input-selection-background":`#073642`,"link-background":`#00000000`,"link-background-hover":`#268BD2`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#268BD2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#268BD2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#268BD2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#839496`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#839496`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#83949699`,panel:`#073642`,"panel-darken-1":`#002531`,"panel-darken-2":`#001721`,"panel-darken-3":`#000112`,"panel-lighten-1":`#1D4653`,"panel-lighten-2":`#305865`,"panel-lighten-3":`#436A78`,primary:`#268BD2`,"primary-background":`#2A5667`,"primary-background-darken-1":`#17475A`,"primary-background-darken-2":`#05394D`,"primary-background-darken-3":`#05394D`,"primary-background-lighten-1":`#3D6575`,"primary-background-lighten-2":`#507482`,"primary-background-lighten-3":`#62838F`,"primary-darken-1":`#0077BD`,"primary-darken-2":`#0065A8`,"primary-darken-3":`#005394`,"primary-lighten-1":`#459EE7`,"primary-lighten-2":`#5FB2FD`,"primary-lighten-3":`#77C7FF`,"primary-muted":`#0B4764`,scrollbar:`#0F476A`,"scrollbar-active":`#268BD2`,"scrollbar-background":`#001B25`,"scrollbar-background-active":`#001B25`,"scrollbar-background-hover":`#001B25`,"scrollbar-corner-color":`#001B25`,"scrollbar-hover":`#13537B`,secondary:`#2AA198`,"secondary-background":`#2B5960`,"secondary-background-darken-1":`#184A52`,"secondary-background-darken-2":`#063C44`,"secondary-background-darken-3":`#063C44`,"secondary-background-lighten-1":`#3E676E`,"secondary-background-lighten-2":`#50767C`,"secondary-background-lighten-3":`#63858A`,"secondary-darken-1":`#008C84`,"secondary-darken-2":`#007971`,"secondary-darken-3":`#00665F`,"secondary-lighten-1":`#44B5AB`,"secondary-lighten-2":`#5BCAC0`,"secondary-lighten-3":`#72DFD5`,"secondary-muted":`#0C4E53`,success:`#849900`,"success-darken-1":`#708500`,"success-darken-2":`#5B7200`,"success-darken-3":`#485F00`,"success-lighten-1":`#99AC22`,"success-lighten-2":`#AFC139`,"success-lighten-3":`#C4D64E`,"success-muted":`#274C25`,surface:`#073642`,"surface-active":`#19434F`,"surface-darken-1":`#002531`,"surface-darken-2":`#001721`,"surface-darken-3":`#000112`,"surface-lighten-1":`#1D4653`,"surface-lighten-2":`#305865`,"surface-lighten-3":`#436A78`,text:`#FFFFFFDD`,"text-accent":`#9DA1D8`,"text-disabled":`#FFFFFF60`,"text-error":`#E77775`,"text-muted":`#FFFFFF99`,"text-primary":`#6FB2E1`,"text-secondary":`#72C0BB`,"text-success":`#AEBB56`,"text-warning":`#DC8865`,warning:`#CA4B16`,"warning-darken-1":`#B33600`,"warning-darken-2":`#9C2000`,"warning-darken-3":`#850100`,"warning-lighten-1":`#E25F29`,"warning-lighten-2":`#FA733C`,"warning-lighten-3":`#FF874E`,"warning-muted":`#3C342C`}},"solarized-light":{name:`solarized-light`,dark:!1,ansi:{black:`#073642`,red:`#DC322F`,green:`#859900`,yellow:`#B58900`,blue:`#268BD2`,magenta:`#D33682`,cyan:`#2AA198`,white:`#BBB5A2`,brightBlack:`#002B36`,brightRed:`#CB4B16`,brightGreen:`#586E75`,brightYellow:`#657B83`,brightBlue:`#839496`,brightMagenta:`#6C71C4`,brightCyan:`#93A1A1`,brightWhite:`#FDF6E3`},vars:{accent:`#6C71C4`,"accent-darken-1":`#575EAF`,"accent-darken-2":`#424C9A`,"accent-darken-3":`#2D3B87`,"accent-lighten-1":`#8083D9`,"accent-lighten-2":`#9597EE`,"accent-lighten-3":`#AAABFF`,"accent-muted":`#D1CED9`,background:`#FDF6E3`,"background-darken-1":`#E7E0CD`,"background-darken-2":`#D2CBB9`,"background-darken-3":`#BDB6A4`,"background-lighten-1":`#FFFFF8`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#268BD2`,"block-cursor-blurred-background":`#268BD24C`,"block-cursor-blurred-foreground":`#586E75`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#268BD2`,"border-blurred":`#E6E0CE`,"button-color-foreground":`#FDF6E3`,"button-foreground":`#586E75`,error:`#DB322F`,"error-darken-1":`#C3121E`,"error-darken-2":`#AB000D`,"error-darken-3":`#940000`,"error-lighten-1":`#F44940`,"error-lighten-2":`#FF6052`,"error-lighten-3":`#FF7564`,"error-muted":`#F3BBAD`,"footer-background":`#268BD2`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FDF6E3`,"footer-foreground":`#586E75`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FDF6E3`,foreground:`#586E75`,"foreground-darken-1":`#465B62`,"foreground-darken-2":`#344950`,"foreground-darken-3":`#23383F`,"foreground-disabled":`#586E7560`,"foreground-lighten-1":`#6A8088`,"foreground-lighten-2":`#7D949B`,"foreground-lighten-3":`#91A8AF`,"foreground-muted":`#586E7599`,"input-cursor-background":`#586E75`,"input-cursor-foreground":`#FDF6E3`,"input-selection-background":`#459EE766`,"link-background":`#00000000`,"link-background-hover":`#268BD2`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#268BD2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#268BD2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#268BD2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#586E75`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#586E75`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#586E7599`,panel:`#EEE8D5`,"panel-darken-1":`#D8D2C0`,"panel-darken-2":`#C3BEAB`,"panel-darken-3":`#AFA997`,"panel-lighten-1":`#FFFDEA`,"panel-lighten-2":`#FFFFFF`,"panel-lighten-3":`#FFFFFF`,primary:`#268BD2`,"primary-background":`#268BD2`,"primary-background-darken-1":`#0077BD`,"primary-background-darken-2":`#0065A8`,"primary-background-darken-3":`#005394`,"primary-background-lighten-1":`#459EE7`,"primary-background-lighten-2":`#5FB2FD`,"primary-background-lighten-3":`#77C7FF`,"primary-darken-1":`#0077BD`,"primary-darken-2":`#0065A8`,"primary-darken-3":`#005394`,"primary-lighten-1":`#459EE7`,"primary-lighten-2":`#5FB2FD`,"primary-lighten-3":`#77C7FF`,"primary-muted":`#BCD5DD`,scrollbar:`#99BECF`,"scrollbar-active":`#268BD2`,"scrollbar-background":`#E7E0CD`,"scrollbar-background-active":`#E7E0CD`,"scrollbar-background-hover":`#E7E0CD`,"scrollbar-corner-color":`#E7E0CD`,"scrollbar-hover":`#86B5CF`,secondary:`#2AA198`,"secondary-background":`#2AA198`,"secondary-background-darken-1":`#008C84`,"secondary-background-darken-2":`#007971`,"secondary-background-darken-3":`#00665F`,"secondary-background-lighten-1":`#44B5AB`,"secondary-background-lighten-2":`#5BCAC0`,"secondary-background-lighten-3":`#72DFD5`,"secondary-darken-1":`#008C84`,"secondary-darken-2":`#007971`,"secondary-darken-3":`#00665F`,"secondary-lighten-1":`#44B5AB`,"secondary-lighten-2":`#5BCAC0`,"secondary-lighten-3":`#72DFD5`,"secondary-muted":`#BDDCCC`,success:`#849900`,"success-darken-1":`#708500`,"success-darken-2":`#5B7200`,"success-darken-3":`#485F00`,"success-lighten-1":`#99AC22`,"success-lighten-2":`#AFC139`,"success-lighten-3":`#C4D64E`,"success-muted":`#D9DA9E`,surface:`#EEE8D5`,"surface-active":`#FFF9E5`,"surface-darken-1":`#D8D2C0`,"surface-darken-2":`#C3BEAB`,"surface-darken-3":`#AFA997`,"surface-lighten-1":`#FFFDEA`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#474A81`,"text-disabled":`#00000060`,"text-error":`#91211F`,"text-muted":`#00000099`,"text-primary":`#195B8A`,"text-secondary":`#1B6A64`,"text-success":`#576400`,"text-warning":`#85310E`,warning:`#CA4B16`,"warning-darken-1":`#B33600`,"warning-darken-2":`#9C2000`,"warning-darken-3":`#850100`,"warning-lighten-1":`#E25F29`,"warning-lighten-2":`#FA733C`,"warning-lighten-3":`#FF874E`,"warning-muted":`#EEC2A5`}},"svg-export":{name:`svg-export`,dark:!0,ansi:{black:`#4B4E55`,red:`#CC555A`,green:`#98A84B`,yellow:`#D0B344`,blue:`#608AB1`,magenta:`#98729F`,cyan:`#68A0B3`,white:`#C5C8C6`,brightBlack:`#9A9B99`,brightRed:`#FF2627`,brightGreen:`#00823D`,brightYellow:`#D08442`,brightBlue:`#1984E9`,brightMagenta:`#FF2C7A`,brightCyan:`#398280`,brightWhite:`#FDFDC5`},vars:{accent:`#56B6C2`,"accent-darken-1":`#3EA1AD`,"accent-darken-2":`#238D99`,"accent-darken-3":`#007A85`,"accent-lighten-1":`#6CCAD6`,"accent-lighten-2":`#81DFEC`,"accent-lighten-3":`#97F5FF`,"accent-muted":`#365356`,background:`#292929`,"background-darken-1":`#191919`,"background-darken-2":`#050505`,"background-darken-3":`#000000`,"background-lighten-1":`#393939`,"background-lighten-2":`#4A4A4A`,"background-lighten-3":`#5C5C5C`,"block-cursor-background":`#61AFEF`,"block-cursor-blurred-background":`#61AFEF4C`,"block-cursor-blurred-foreground":`#C5C8C6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#61AFEF`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#C5C8C6`,error:`#CB555A`,"error-darken-1":`#B54048`,"error-darken-2":`#9F2C37`,"error-darken-3":`#891427`,"error-lighten-1":`#E2686C`,"error-lighten-2":`#F97D7F`,"error-lighten-3":`#FF9192`,"error-muted":`#593637`,"footer-background":`#2C343A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#C5C8C6`,"footer-foreground":`#C5C8C6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#56B6C2`,foreground:`#C5C8C6`,"foreground-darken-1":`#B0B3B1`,"foreground-darken-2":`#9C9F9D`,"foreground-darken-3":`#888B89`,"foreground-disabled":`#C5C8C660`,"foreground-lighten-1":`#D9DCDA`,"foreground-lighten-2":`#EFF2F0`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#C5C8C699`,"input-cursor-background":`#C5C8C6`,"input-cursor-foreground":`#292929`,"input-selection-background":`#77C3FF66`,"link-background":`#00000000`,"link-background-hover":`#61AFEF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#61AFEF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#61AFEF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#61AFEF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#C5C8C6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#C5C8C6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#C5C8C699`,panel:`#2C343A`,"panel-darken-1":`#1C2429`,"panel-darken-2":`#0C141A`,"panel-darken-3":`#000007`,"panel-lighten-1":`#3C444B`,"panel-lighten-2":`#4D565C`,"panel-lighten-3":`#5F686F`,primary:`#61AFEF`,"primary-background":`#4F5A61`,"primary-background-darken-1":`#404B53`,"primary-background-darken-2":`#313D46`,"primary-background-darken-3":`#313D46`,"primary-background-lighten-1":`#5F686F`,"primary-background-lighten-2":`#6E777D`,"primary-background-lighten-3":`#7E858B`,"primary-darken-1":`#489BD9`,"primary-darken-2":`#2C87C4`,"primary-darken-3":`#0074AF`,"primary-lighten-1":`#77C3FF`,"primary-lighten-2":`#8ED8FF`,"primary-lighten-3":`#A4EDFF`,"primary-muted":`#395164`,scrollbar:`#35556E`,"scrollbar-active":`#61AFEF`,"scrollbar-background":`#191919`,"scrollbar-background-active":`#191919`,"scrollbar-background-hover":`#191919`,"scrollbar-corner-color":`#191919`,"scrollbar-hover":`#3D6484`,secondary:`#C678DD`,"secondary-background":`#5C5260`,"secondary-background-darken-1":`#4E4352`,"secondary-background-darken-2":`#403444`,"secondary-background-darken-3":`#403444`,"secondary-background-lighten-1":`#6A616E`,"secondary-background-lighten-2":`#79707C`,"secondary-background-lighten-3":`#87808A`,"secondary-darken-1":`#B064C7`,"secondary-darken-2":`#9B50B3`,"secondary-darken-3":`#873D9E`,"secondary-lighten-1":`#DB8CF2`,"secondary-lighten-2":`#F1A0FF`,"secondary-lighten-3":`#FFB5FF`,"secondary-muted":`#58405F`,success:`#98C379`,"success-darken-1":`#83AE65`,"success-darken-2":`#709A53`,"success-darken-3":`#5C8641`,"success-lighten-1":`#ACD78C`,"success-lighten-2":`#C1EDA0`,"success-lighten-3":`#D6FFB4`,"success-muted":`#4A5741`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#8FCED6`,"text-disabled":`#FFFFFF60`,"text-error":`#DD8E92`,"text-muted":`#FFFFFF99`,"text-primary":`#96CAF4`,"text-secondary":`#D9A5E8`,"text-success":`#BBD7A6`,"text-warning":`#EDD5A7`,warning:`#E4C07B`,"warning-darken-1":`#CFAB67`,"warning-darken-2":`#B99754`,"warning-darken-3":`#A48442`,"warning-lighten-1":`#FBD48E`,"warning-lighten-2":`#FFE9A2`,"warning-lighten-3":`#FFFFB7`,"warning-muted":`#615641`}},"textual-ansi":{name:`textual-ansi`,dark:!0,ansi:sl,vars:{accent:`#0000FF`,"accent-darken-1":`#0000FF`,"accent-darken-2":`#0000FF`,"accent-darken-3":`#0000FF`,"accent-lighten-1":`#0000FF`,"accent-lighten-2":`#0000FF`,"accent-lighten-3":`#0000FF`,"accent-muted":`#0178D4`,background:`#121212`,"background-darken-1":`#121212`,"background-darken-2":`#121212`,"background-darken-3":`#121212`,"background-lighten-1":`#121212`,"background-lighten-2":`#121212`,"background-lighten-3":`#121212`,"block-cursor-background":`#000080`,"block-cursor-blurred-background":`#0000804C`,"block-cursor-blurred-foreground":`#E0E0E0`,"block-cursor-foreground":`#E0E0E0`,"block-hover-background":`#00000019`,boost:`#0178D4`,"boost-darken-1":`#0178D4`,"boost-darken-2":`#0178D4`,"boost-darken-3":`#0178D4`,"boost-lighten-1":`#0178D4`,"boost-lighten-2":`#0178D4`,"boost-lighten-3":`#0178D4`,border:`#0000FF`,"border-blurred":`#000080`,"button-color-foreground":`#E0E0E0`,"button-foreground":`#E0E0E0`,error:`#800000`,"error-darken-1":`#800000`,"error-darken-2":`#800000`,"error-darken-3":`#800000`,"error-lighten-1":`#800000`,"error-lighten-2":`#800000`,"error-lighten-3":`#800000`,"error-muted":`#0178D4`,"footer-background":`#121212`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0E0E0`,"footer-foreground":`#E0E0E0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#0000FF`,foreground:`#E0E0E0`,"foreground-darken-1":`#E0E0E0`,"foreground-darken-2":`#E0E0E0`,"foreground-darken-3":`#E0E0E0`,"foreground-disabled":`#00000060`,"foreground-lighten-1":`#E0E0E0`,"foreground-lighten-2":`#E0E0E0`,"foreground-lighten-3":`#E0E0E0`,"foreground-muted":`#00000099`,"input-cursor-background":`#121212`,"input-cursor-foreground":`#E0E0E0`,"input-selection-background":`#000080`,"link-background":`#00000000`,"link-background-hover":`#000080`,"link-color":`#E0E0E0`,"link-color-hover":`#0178D4`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#000080`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#000080`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#000080`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0E0E0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0E0E0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#00000099`,panel:`#121212`,"panel-darken-1":`#121212`,"panel-darken-2":`#121212`,"panel-darken-3":`#121212`,"panel-lighten-1":`#121212`,"panel-lighten-2":`#121212`,"panel-lighten-3":`#121212`,primary:`#000080`,"primary-background":`#000080`,"primary-background-darken-1":`#000080`,"primary-background-darken-2":`#000080`,"primary-background-darken-3":`#000080`,"primary-background-lighten-1":`#000080`,"primary-background-lighten-2":`#000080`,"primary-background-lighten-3":`#000080`,"primary-darken-1":`#000080`,"primary-darken-2":`#000080`,"primary-darken-3":`#000080`,"primary-lighten-1":`#000080`,"primary-lighten-2":`#000080`,"primary-lighten-3":`#000080`,"primary-muted":`#0178D4`,scrollbar:`#000080`,"scrollbar-active":`#000080`,"scrollbar-background":`#121212`,"scrollbar-background-active":`#121212`,"scrollbar-background-hover":`#121212`,"scrollbar-corner-color":`#E0E0E0`,"scrollbar-hover":`#000040`,secondary:`#008080`,"secondary-background":`#008080`,"secondary-background-darken-1":`#008080`,"secondary-background-darken-2":`#008080`,"secondary-background-darken-3":`#008080`,"secondary-background-lighten-1":`#008080`,"secondary-background-lighten-2":`#008080`,"secondary-background-lighten-3":`#008080`,"secondary-darken-1":`#008080`,"secondary-darken-2":`#008080`,"secondary-darken-3":`#008080`,"secondary-lighten-1":`#008080`,"secondary-lighten-2":`#008080`,"secondary-lighten-3":`#008080`,"secondary-muted":`#0178D4`,success:`#008000`,"success-darken-1":`#008000`,"success-darken-2":`#008000`,"success-darken-3":`#008000`,"success-lighten-1":`#008000`,"success-lighten-2":`#008000`,"success-lighten-3":`#008000`,"success-muted":`#0178D4`,surface:`#121212`,"surface-active":`#131313`,"surface-darken-1":`#121212`,"surface-darken-2":`#121212`,"surface-darken-3":`#121212`,"surface-lighten-1":`#121212`,"surface-lighten-2":`#121212`,"surface-lighten-3":`#121212`,text:`#E0E0E0`,"text-accent":`#5656FF`,"text-disabled":`#E0E0E0`,"text-error":`#AB5656`,"text-muted":`#E0E0E0`,"text-primary":`#5656AB`,"text-secondary":`#56ABAB`,"text-success":`#56AB56`,"text-warning":`#ABAB56`,warning:`#808000`,"warning-darken-1":`#808000`,"warning-darken-2":`#808000`,"warning-darken-3":`#808000`,"warning-lighten-1":`#808000`,"warning-lighten-2":`#808000`,"warning-lighten-3":`#808000`,"warning-muted":`#0178D4`}},"textual-dark":{name:`textual-dark`,dark:!0,ansi:cl,vars:{accent:`#FEA62B`,"accent-darken-1":`#E7920D`,"accent-darken-2":`#CF7E00`,"accent-darken-3":`#B86B00`,"accent-lighten-1":`#FFBA41`,"accent-lighten-2":`#FFCF56`,"accent-lighten-3":`#FFE46B`,"accent-muted":`#593E19`,background:`#121212`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#212121`,"background-lighten-2":`#313131`,"background-lighten-3":`#414141`,"block-cursor-background":`#0178D4`,"block-cursor-blurred-background":`#0178D44C`,"block-cursor-blurred-foreground":`#E0E0E0`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#0178D4`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0E0E0`,error:`#B93C5B`,"error-darken-1":`#A32549`,"error-darken-2":`#8D0638`,"error-darken-3":`#780028`,"error-lighten-1":`#D0506D`,"error-lighten-2":`#E76580`,"error-lighten-3":`#FE7993`,"error-muted":`#441E27`,"footer-background":`#242F38`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0E0E0`,"footer-foreground":`#E0E0E0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FFA62B`,foreground:`#E0E0E0`,"foreground-darken-1":`#CACACA`,"foreground-darken-2":`#B6B6B6`,"foreground-darken-3":`#A2A2A2`,"foreground-disabled":`#E0E0E060`,"foreground-lighten-1":`#F5F5F5`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0E0E099`,"input-cursor-background":`#E0E0E0`,"input-cursor-foreground":`#121212`,"input-selection-background":`#368AE966`,"link-background":`#00000000`,"link-background-hover":`#0178D4`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#0178D4`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#0178D4`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#0178D4`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0E0E0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0E0E0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0E0E099`,panel:`#242F38`,"panel-darken-1":`#141F27`,"panel-darken-2":`#000F18`,"panel-darken-3":`#000003`,"panel-lighten-1":`#343F49`,"panel-lighten-2":`#45505A`,"panel-lighten-3":`#57626D`,primary:`#0178D4`,"primary-background":`#33424E`,"primary-background-darken-1":`#21313E`,"primary-background-darken-2":`#0F212F`,"primary-background-darken-3":`#0F212F`,"primary-background-lighten-1":`#45525D`,"primary-background-lighten-2":`#57636D`,"primary-background-lighten-3":`#69747D`,"primary-darken-1":`#0065BE`,"primary-darken-2":`#0053AA`,"primary-darken-3":`#004295`,"primary-lighten-1":`#368AE9`,"primary-lighten-2":`#539EFF`,"primary-lighten-3":`#6DB2FF`,"primary-muted":`#0C304C`,scrollbar:`#003054`,"scrollbar-active":`#0178D4`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#003C6A`,secondary:`#004578`,"secondary-background":`#333B42`,"secondary-background-darken-1":`#212A31`,"secondary-background-darken-2":`#0F1921`,"secondary-background-darken-3":`#0F1921`,"secondary-background-lighten-1":`#454C52`,"secondary-background-lighten-2":`#575E63`,"secondary-background-lighten-3":`#696F74`,"secondary-darken-1":`#003465`,"secondary-darken-2":`#002452`,"secondary-darken-3":`#001541`,"secondary-lighten-1":`#23568B`,"secondary-lighten-2":`#3B689F`,"secondary-lighten-3":`#507BB3`,"secondary-muted":`#0C2130`,success:`#4EBF71`,"success-darken-1":`#36AA5E`,"success-darken-2":`#18954B`,"success-darken-3":`#008139`,"success-lighten-1":`#64D484`,"success-lighten-2":`#7AE998`,"success-lighten-3":`#8FFFAC`,"success-muted":`#24452E`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#FFC473`,"text-disabled":`#FFFFFF60`,"text-error":`#D17E92`,"text-muted":`#FFFFFF99`,"text-primary":`#57A5E2`,"text-secondary":`#5684A5`,"text-success":`#8AD4A1`,"text-warning":`#FFC473`,warning:`#FEA62B`,"warning-darken-1":`#E7920D`,"warning-darken-2":`#CF7E00`,"warning-darken-3":`#B86B00`,"warning-lighten-1":`#FFBA41`,"warning-lighten-2":`#FFCF56`,"warning-lighten-3":`#FFE46B`,"warning-muted":`#593E19`}},"textual-light":{name:`textual-light`,dark:!1,ansi:{black:`#000000`,red:`#AA3731`,green:`#448C27`,yellow:`#CB9000`,blue:`#325CC0`,magenta:`#7A3E9D`,cyan:`#0083B2`,white:`#F7F7F7`,brightBlack:`#777777`,brightRed:`#F05050`,brightGreen:`#60CB00`,brightYellow:`#FFBC5D`,brightBlue:`#007ACC`,brightMagenta:`#E64CE6`,brightCyan:`#00AACB`,brightWhite:`#F7F7F7`},vars:{accent:`#FEA62B`,"accent-darken-1":`#E7920D`,"accent-darken-2":`#CF7E00`,"accent-darken-3":`#B86B00`,"accent-lighten-1":`#FFBA41`,"accent-lighten-2":`#FFCF56`,"accent-lighten-3":`#FFE46B`,"accent-muted":`#E9CEA9`,background:`#E0E0E0`,"background-darken-1":`#CACACA`,"background-darken-2":`#B6B6B6`,"background-darken-3":`#A2A2A2`,"background-lighten-1":`#F5F5F5`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#004578`,"block-cursor-blurred-background":`#0045784C`,"block-cursor-blurred-foreground":`#1F1F1F`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#004578`,"border-blurred":`#D0D1D0`,"button-color-foreground":`#000000DD`,"button-foreground":`#1F1F1F`,error:`#B93C5B`,"error-darken-1":`#A32549`,"error-darken-2":`#8D0638`,"error-darken-3":`#780028`,"error-lighten-1":`#D0506D`,"error-lighten-2":`#E76580`,"error-lighten-3":`#FE7993`,"error-muted":`#D4AEB8`,"footer-background":`#D0D0D0`,"footer-description-background":`#00000000`,"footer-description-foreground":`#1F1F1F`,"footer-foreground":`#1F1F1F`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#0178D4`,foreground:`#1F1F1F`,"foreground-darken-1":`#0E0E0E`,"foreground-darken-2":`#000000`,"foreground-darken-3":`#000000`,"foreground-disabled":`#1F1F1F60`,"foreground-lighten-1":`#2E2E2E`,"foreground-lighten-2":`#3F3F3F`,"foreground-lighten-3":`#505050`,"foreground-muted":`#1F1F1F99`,"input-cursor-background":`#1F1F1F`,"input-cursor-foreground":`#E0E0E0`,"input-selection-background":`#23568B66`,"link-background":`#00000000`,"link-background-hover":`#004578`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#004578`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#004578`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#004578`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#1F1F1F`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#1F1F1F`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#1F1F1F99`,panel:`#D0D0D0`,"panel-darken-1":`#BBBBBB`,"panel-darken-2":`#A6A6A6`,"panel-darken-3":`#939393`,"panel-lighten-1":`#E5E5E5`,"panel-lighten-2":`#FAFAFA`,"panel-lighten-3":`#FFFFFF`,primary:`#004578`,"primary-background":`#004578`,"primary-background-darken-1":`#003465`,"primary-background-darken-2":`#002452`,"primary-background-darken-3":`#001541`,"primary-background-lighten-1":`#23568B`,"primary-background-lighten-2":`#3B689F`,"primary-background-lighten-3":`#507BB3`,"primary-darken-1":`#003465`,"primary-darken-2":`#002452`,"primary-darken-3":`#001541`,"primary-lighten-1":`#23568B`,"primary-lighten-2":`#3B689F`,"primary-lighten-3":`#507BB3`,"primary-muted":`#9CB1C0`,scrollbar:`#7994A9`,"scrollbar-active":`#004578`,"scrollbar-background":`#CACACA`,"scrollbar-background-active":`#CACACA`,"scrollbar-background-hover":`#CACACA`,"scrollbar-corner-color":`#CACACA`,"scrollbar-hover":`#6587A1`,secondary:`#0178D4`,"secondary-background":`#0178D4`,"secondary-background-darken-1":`#0065BE`,"secondary-background-darken-2":`#0053AA`,"secondary-background-darken-3":`#004295`,"secondary-background-lighten-1":`#368AE9`,"secondary-background-lighten-2":`#539EFF`,"secondary-background-lighten-3":`#6DB2FF`,"secondary-darken-1":`#0065BE`,"secondary-darken-2":`#0053AA`,"secondary-darken-3":`#004295`,"secondary-lighten-1":`#368AE9`,"secondary-lighten-2":`#539EFF`,"secondary-lighten-3":`#6DB2FF`,"secondary-muted":`#9DC0DC`,success:`#4EBF71`,"success-darken-1":`#36AA5E`,"success-darken-2":`#18954B`,"success-darken-3":`#008139`,"success-lighten-1":`#64D484`,"success-lighten-2":`#7AE998`,"success-lighten-3":`#8FFFAC`,"success-muted":`#B4D6BE`,surface:`#D8D8D8`,"surface-active":`#E8E8E8`,"surface-darken-1":`#C3C3C3`,"surface-darken-2":`#AEAEAE`,"surface-darken-3":`#9A9A9A`,"surface-lighten-1":`#EDEDED`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#A86D1C`,"text-disabled":`#00000060`,"text-error":`#7A273C`,"text-muted":`#00000099`,"text-primary":`#002D4F`,"text-secondary":`#004F8B`,"text-success":`#337E4A`,"text-warning":`#A86D1C`,warning:`#FEA62B`,"warning-darken-1":`#E7920D`,"warning-darken-2":`#CF7E00`,"warning-darken-3":`#B86B00`,"warning-lighten-1":`#FFBA41`,"warning-lighten-2":`#FFCF56`,"warning-lighten-3":`#FFE46B`,"warning-muted":`#E9CEA9`}},"tokyo-night":{name:`tokyo-night`,dark:!0,ansi:{black:`#15161E`,red:`#F7768E`,green:`#9ECE6A`,yellow:`#E0AF68`,blue:`#7AA2F7`,magenta:`#BB9AF7`,cyan:`#7DCFFF`,white:`#A9B1D6`,brightBlack:`#414868`,brightRed:`#F7768E`,brightGreen:`#9ECE6A`,brightYellow:`#E0AF68`,brightBlue:`#7AA2F7`,brightMagenta:`#BB9AF7`,brightCyan:`#7DCFFF`,brightWhite:`#C0CAF5`},vars:{accent:`#FE9E64`,"accent-darken-1":`#E78A51`,"accent-darken-2":`#D0763E`,"accent-darken-3":`#BA632C`,"accent-lighten-1":`#FFB277`,"accent-lighten-2":`#FFC78A`,"accent-lighten-3":`#FFDC9E`,"accent-muted":`#5E4238`,background:`#1A1B26`,"background-darken-1":`#070817`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#292A36`,"background-lighten-2":`#3A3A47`,"background-lighten-3":`#4B4B58`,"block-cursor-background":`#BB9AF7`,"block-cursor-blurred-background":`#BB9AF74C`,"block-cursor-blurred-foreground":`#A9B1D6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BB9AF7`,"border-blurred":`#1E2235`,"button-color-foreground":`#24283B`,"button-foreground":`#A9B1D6`,error:`#F6768E`,"error-darken-1":`#E0617A`,"error-darken-2":`#C94D68`,"error-darken-3":`#B33856`,"error-lighten-1":`#FF8AA1`,"error-lighten-2":`#FF9FB5`,"error-lighten-3":`#FFB4CA`,"error-muted":`#5C3645`,"footer-background":`#414868`,"footer-description-background":`#00000000`,"footer-description-foreground":`#A9B1D6`,"footer-foreground":`#A9B1D6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FF9E64`,foreground:`#A9B1D6`,"foreground-darken-1":`#949CC1`,"foreground-darken-2":`#8189AC`,"foreground-darken-3":`#6D7698`,"foreground-disabled":`#A9B1D660`,"foreground-lighten-1":`#BDC5EB`,"foreground-lighten-2":`#D2DAFF`,"foreground-lighten-3":`#E7EFFF`,"foreground-muted":`#A9B1D699`,"input-cursor-background":`#A9B1D6`,"input-cursor-foreground":`#1A1B26`,"input-selection-background":`#D0AEFF66`,"link-background":`#00000000`,"link-background-hover":`#BB9AF7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#BB9AF7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#BB9AF7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#BB9AF7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#A9B1D6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#A9B1D6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#A9B1D699`,panel:`#414868`,"panel-darken-1":`#2F3755`,"panel-darken-2":`#1E2744`,"panel-darken-3":`#0C1733`,"panel-lighten-1":`#53597A`,"panel-lighten-2":`#656B8E`,"panel-lighten-3":`#787EA1`,primary:`#BB9AF7`,"primary-background":`#504D60`,"primary-background-darken-1":`#413D52`,"primary-background-darken-2":`#322E45`,"primary-background-darken-3":`#322E45`,"primary-background-lighten-1":`#605D6E`,"primary-background-lighten-2":`#6F6C7C`,"primary-background-lighten-3":`#7E7C8A`,"primary-darken-1":`#A686E1`,"primary-darken-2":`#9173CC`,"primary-darken-3":`#7D60B7`,"primary-lighten-1":`#D0AEFF`,"primary-lighten-2":`#E5C2FF`,"primary-lighten-3":`#FBD7FF`,"primary-muted":`#4A4164`,scrollbar:`#4F4270`,"scrollbar-active":`#BB9AF7`,"scrollbar-background":`#070817`,"scrollbar-background-active":`#070817`,"scrollbar-background-hover":`#070817`,"scrollbar-corner-color":`#070817`,"scrollbar-hover":`#615187`,secondary:`#7AA2F7`,"secondary-background":`#484E60`,"secondary-background-darken-1":`#383E52`,"secondary-background-darken-2":`#282F45`,"secondary-background-darken-3":`#282F45`,"secondary-background-lighten-1":`#585D6E`,"secondary-background-lighten-2":`#686D7C`,"secondary-background-lighten-3":`#787D8A`,"secondary-darken-1":`#648EE1`,"secondary-darken-2":`#4D7BCC`,"secondary-darken-3":`#3468B7`,"secondary-lighten-1":`#8FB6FF`,"secondary-lighten-2":`#A5CAFF`,"secondary-lighten-3":`#BBDFFF`,"secondary-muted":`#364364`,success:`#9ECE6A`,"success-darken-1":`#89B956`,"success-darken-2":`#75A443`,"success-darken-3":`#619030`,"success-lighten-1":`#B2E37D`,"success-lighten-2":`#C8F891`,"success-lighten-3":`#DDFFA6`,"success-muted":`#41503A`,surface:`#24283B`,"surface-active":`#313448`,"surface-darken-1":`#14182A`,"surface-darken-2":`#00031B`,"surface-darken-3":`#000009`,"surface-lighten-1":`#34384C`,"surface-lighten-2":`#45495E`,"surface-lighten-3":`#575A70`,text:`#FFFFFFDD`,"text-accent":`#FFBE98`,"text-disabled":`#FFFFFF60`,"text-error":`#F9A4B4`,"text-muted":`#FFFFFF99`,"text-primary":`#D2BCF9`,"text-secondary":`#A7C1F9`,"text-success":`#BEDE9C`,"text-warning":`#EACA9B`,warning:`#DFAF68`,"warning-darken-1":`#C99A55`,"warning-darken-2":`#B48742`,"warning-darken-3":`#9E7430`,"warning-lighten-1":`#F6C37B`,"warning-lighten-2":`#FFD88F`,"warning-lighten-3":`#FFEDA3`,"warning-muted":`#554739`}}},ul=Object.freeze(Object.keys(ll).sort()),dl=new Map;function fl(){return ul}function pl(e){if(!ml(e))return null;let t=dl.get(e);if(t!==void 0)return t;let n=_l(ll[e]);return dl.set(e,n),n}function ml(e){return Object.hasOwn(ll,e)}function hl(e){let t=ll[e],n=gl(t,`background`),r=vs(t.name,n),i=e=>r(gl(t,e));return{name:t.name,dark:t.dark,bg:n,fg:i(`foreground`),primary:i(`primary`),secondary:i(`secondary`),accent:i(`accent`),success:i(`success`),warning:i(`warning`),error:i(`error`),ansi:new Os(ol.map(e=>yl(t.ansi[e],t.name,`ansi.${e}`)))}}function gl(e,t){let n=e.vars[t];if(n===void 0)throw Error(`Theme ${e.name}: required base var "${t}" missing from data file`);return vl(n,e.name,t)}function _l(e){let t=new Map;for(let[n,r]of Object.entries(e.vars))t.set(n,vl(r,e.name,`var ${n}`));for(let n of Zc){let r=gl(e,`text-${n}`);t.set(`text-${n}`,$c(r,gl(e,`${n}-muted`),gl(e,`background`)))}return new _s(e.name,e.dark,t)}function vl(e,t,n){try{return rc(e)}catch(e){throw e instanceof zs?Error(`Theme ${t}: ${n}: ${e.message}`,{cause:e}):e}}function yl(e,t,n){let r=vl(e,t,n);if(r.alpha!==1)throw Error(`Theme ${t}: ${n} has alpha in ${JSON.stringify(e)} (expected #RRGGBB)`);return r}function bl(e){return new ac(e.bg,e.fg,e.ansi,Qc(e.name,e.dark,{primary:e.primary,secondary:e.secondary,accent:e.accent,success:e.success,warning:e.warning,error:e.error,background:e.bg,foreground:e.fg}))}const xl=bl(hl(`default`));bl(hl(`svg-export`)),bl(hl(`monokai`)),bl(hl(`nord`)),bl(hl(`gruvbox`)),bl(hl(`dracula`)),bl(hl(`tokyo-night`)),bl(hl(`flexoki`)),bl(hl(`cyberpunk`)),bl(hl(`catppuccin-mocha`)),bl(hl(`catppuccin-latte`)),bl(hl(`catppuccin-frappe`)),bl(hl(`catppuccin-macchiato`)),bl(hl(`solarized-dark`)),bl(hl(`solarized-light`)),bl(hl(`rose-pine`)),bl(hl(`rose-pine-moon`)),bl(hl(`rose-pine-dawn`)),bl(hl(`atom-one-dark`)),bl(hl(`atom-one-light`)),bl(hl(`textual-dark`)),bl(hl(`textual-light`)),bl(hl(`textual-ansi`));const Sl=new Set([`error`,`success`,`warning`]);function Cl(e){let t=e.indexOf(`-`);return t===-1?e:e.slice(0,t)}function wl(e){return Sl.has(Cl(e))}function Tl(e,t,n){if(Cc(t))return new _s(n??e.name,e.dark,e.vars);let r={...t,hueShift:0},i=new Map;for(let[n,a]of e.vars){let e=wl(n)?r:t;i.set(n,V.fromRgba(a).applyKey(e).toRgba())}let a=i.get(`background`);if(a===void 0)throw Error(`transposePalette: palette "${e.name}" has no "background" var; cannot derive the dark flag without a background color.`);let o=V.fromRgba(a).l<.5;return new _s(n??e.name,o,i)}function El(e,t,n,r){for(let[i,a]of[[`x1`,e],[`y1`,t],[`x2`,n],[`y2`,r]])if(!Number.isFinite(a))throw RangeError(`cubicBezier ${i} must be finite, got ${a}`);if(e<0||e>1||n<0||n>1)throw RangeError(`cubicBezier x1 and x2 must lie in [0, 1], got ${e} and ${n}`);let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=1e-9,m=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<p)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;for(t=e;r-n>p;)u(t)<e?n=t:r=t,t=(n+r)/2;return t};return Ol(e=>d(m(e)))}function Dl(e,t=`jump-end`){let n=t===`jump-none`?2:1;if(!Number.isInteger(e)||e<n)throw RangeError(`steps(${e}, "${t}") needs a whole number of steps ≥ ${n}`);let r=t===`jump-start`||t===`start`||t===`jump-both`,i={"jump-start":e,start:e,"jump-end":e,end:e,"jump-both":e+1,"jump-none":e-1}[t],a=+!!r;return Ol(t=>Math.min(i,Math.floor(t*e)+a)/i)}const Ol=e=>t=>{let n=Math.min(1,Math.max(0,t));return n===1?1:e(n)},kl=Ol(e=>e),Al=Dl(1,`jump-end`),jl=Ol(e=>(1-Math.cos(Math.PI*e))/2),Ml=.001,Nl={stiffness:100,damping:10,mass:1};function Pl(e={}){let{stiffness:t,damping:n,mass:r}={...Nl,...e};for(let[e,i]of[[`stiffness`,t],[`damping`,n],[`mass`,r]])Yl(`spring ${e}`,i);let i=Math.sqrt(t/r),a=n/(2*Math.sqrt(t*r)),o=a*i,{displacement:s,seconds:c}=a<1?Il(i,a,o):Ll(i,a,o);return{seconds:c,ease:Ol(e=>1-s(e*c))}}function Fl(e,t,n){for(let r=0;r<64;r++){let r=(t+n)/2;Math.abs(e(r))>.001?t=r:n=r}return n}function Il(e,t,n){let r=e*Math.sqrt(1-t*t),i=n/r,a=e=>Math.exp(-n*e)*(Math.cos(r*e)+i*Math.sin(r*e)),o=Math.ceil(Math.log(1/Ml)/(n*Math.PI/r));return{displacement:a,seconds:Fl(a,(o-1)*Math.PI/r,(o*Math.PI-Math.atan(1/i))/r)}}function Ll(e,t,n){let{displacement:r,far:i}=t===1?Rl(e):zl(e,t,n);return{displacement:r,seconds:Fl(r,0,i)}}function Rl(e){return{displacement:t=>Math.exp(-e*t)*(1+e*t),far:10/e}}function zl(e,t,n){let r=Math.sqrt(t*t-1),i=e*r,a=e/(t+r),o=n+i,s=n/i;return{displacement:e=>((1+s)*Math.exp(-a*e)+(1-s)*Math.exp(-o*e))/2,far:Math.log((1+s)/(2*Ml))/a}}const Bl=[{until:1/2.75,centre:0,floor:0},{until:2/2.75,centre:1.5/2.75,floor:.75},{until:2.5/2.75,centre:2.25/2.75,floor:.9375},{until:1/0,centre:2.625/2.75,floor:.984375}],Vl=Ol(e=>{let t=Bl.find(({until:t})=>e<t);return 7.5625*(e-t.centre)**2+t.floor}),Hl=1.70158,Ul=Ol(e=>e**3+Hl*e**2*(e-1)),Wl=Ol(e=>{let t=e-1;return 1+t**3+Hl*t**2*(t+1)}),Gl=2*Math.PI/3,Kl=Ol(e=>2**(-10*e)*Math.sin((10*e-.75)*Gl)+1),ql={linear:kl,ease:El(.25,.1,.25,1),"ease-in":El(.42,0,1,1),"ease-out":El(0,0,.58,1),"ease-in-out":El(.42,0,.58,1),"step-start":Dl(1,`jump-start`),"step-end":Al,step:Al,sine:jl,spring:Pl().ease,bounce:Vl,"back-in":Ul,"back-out":Wl,elastic:Kl};function Jl(e){if(!Object.hasOwn(ql,e))throw RangeError(`unknown ease ${JSON.stringify(e)}; expected one of `+Object.keys(ql).map(e=>JSON.stringify(e)).join(`, `));return ql[e]}function Yl(e,t,n=``){if(!(Number.isFinite(t)&&t>0))throw RangeError(`${e} must be a positive number${n}, got ${t}`)}function Xl(e,t){Yl(e,t,` of seconds`)}function Zl(e,t,n){if(!Number.isFinite(t))throw RangeError(`${e} needs a finite t, got ${t}`);let r=t%n;if(r>=0)return r;let i=r+n;return i>=n?0:i}function Ql(e){return e===0?Number.MIN_VALUE:($l[0]=e,eu[0]+=e>0?1n:-1n,$l[0])}const $l=new Float64Array(1),eu=new BigUint64Array($l.buffer);function tu(e,t,n){let r=e;for(let e=0;!t(r);e++){if(e===8)throw RangeError(n());r=Ql(r)}return r}function nu(e,t){if(!Number.isFinite(e))throw RangeError(`firstReaching needs a finite guess, got ${e}`);let n=e,r=e;for(let i=Ql(Math.abs(e))-Math.abs(e);t(n);i*=2){if(n===-Number.MAX_VALUE)return-1/0;r=n,n=Math.max(e-i,-Number.MAX_VALUE)}for(let i=Ql(Math.abs(e))-Math.abs(e);!t(r);i*=2){if(r===Number.MAX_VALUE)return 1/0;n=r,r=Math.min(e+i,Number.MAX_VALUE)}for(;;){let e=n+(r-n)/2;if(e<=n||e>=r)return r;t(e)?r=e:n=e}}function ru(e){if(e.length===0)throw RangeError(`a beat needs at least one hold`);e.forEach((e,t)=>Xl(`beat hold ${t}`,e));let t=e.reduce((e,t)=>e+t,0),n=[],r=0;for(let t of e)n.push(r),r+=t;let i=[...e],a=e=>{let t=i.length-1;for(;n[t]>e;)t--;return t},o=(e,r,o,s)=>tu(r*t+n[o],n=>a(Zl(e,n,t))===o,()=>`${e}: hold ${o} (${i[o]} s) is finer than time resolves near t = ${s}`),s=(e,n)=>Math.round((e-n)/t);return{holds:i,period:t,at(e){return a(Zl(`Beat.at`,e,t))},lastChange(e){let n=Zl(`Beat.lastChange`,e,t);return o(`Beat.lastChange`,s(e,n),a(n),e)},nextChange(e){let n=Zl(`Beat.nextChange`,e,t),r=a(n),c=r===i.length-1;return o(`Beat.nextChange`,s(e,n)+ +!!c,c?0:r+1,e)}}}const iu={once(e,t){if(!Number.isFinite(e))throw RangeError(`Phase.once start must be finite, got ${e}`);return Xl(`Phase.once duration`,t),n=>Math.min(1,Math.max(0,(n-e)/t))},loop(e){return Xl(`Phase.loop period`,e),t=>Zl(`Phase.loop`,t,e)/e},pingPong(e){Xl(`Phase.pingPong period`,e);let t=iu.loop(e);return e=>1-Math.abs(2*t(e)-1)}},au={constant(e){return{at:()=>e,nextChange:()=>1/0,lastChange:()=>-1/0}},continuous(e){return{at:e,nextChange:e=>e,lastChange:e=>e}},map(e,t){return{at:n=>t(e.at(n)),nextChange:t=>e.nextChange(t),lastChange:t=>e.lastChange(t)}},all(e){return{at:t=>e.map(e=>e.at(t)),nextChange:t=>Math.min(...e.map(e=>e.nextChange(t))),lastChange:t=>Math.max(...e.map(e=>e.lastChange(t)))}},sequence(e,t,n){Xl(`Animation.sequence seconds`,t);let r=e=>Number.isFinite(e)?nu(e+t,n=>n-t>=e):e;return{at:r=>r-t>=0?n.at(r-t):e.at(r),nextChange(i){let a=i-t;return a<0?Math.min(e.nextChange(i),t):Math.max(i,r(n.nextChange(a)))},lastChange(i){let a=i-t;return a<0?e.lastChange(i):Math.min(i,Math.max(t,r(n.lastChange(a))))}}}};function ou(e,t,n){for(let[n,r]of[[`from`,e],[`to`,t]])if(!Number.isFinite(r))throw RangeError(`tween ${n} must be finite, got ${r}`);let{ease:r,seconds:i}=n,a=iu.once(0,i);return e===t?au.constant(e):{at(n){let i=r(a(n));return(1-i)*e+i*t},nextChange:e=>e<0?0:e<i?e:1/0,lastChange:e=>e<0?-1/0:e<i?e:i}}var su=class{ease;stops;constructor(e,t){if(this.ease=e,this.stops=t,t.length===0)throw RangeError(`a ColorRamp needs at least one stop`);for(let[e,n]of t.entries()){if(!Number.isFinite(n.at))throw RangeError(`ColorRamp stop ${e} has a non-finite position ${n.at}`);let r=t[e-1];if(r!==void 0&&n.at<r.at)throw RangeError(`ColorRamp stops must be in ascending position order; stop ${e} at ${n.at} follows stop ${e-1} at ${r.at}`)}}at(e){if(!Number.isFinite(e))throw RangeError(`ColorRamp.at needs a finite value, got ${e}`);let t=this.stops,n=-1;for(;n+1<t.length&&t[n+1].at<=e;)n++;if(n<0)return t[0].color;let r=t[n];if(n===t.length-1)return r.color;let i=t[n+1],a=this.ease((e-r.at)/(i.at-r.at));return a<=0?r.color:a>=1?i.color:V.fromRgba(r.color).mix(V.fromRgba(i.color),a).toRgba()}over(e){let t=this.stops[0].at,n=this.stops[this.stops.length-1].at;return au.map(ou(t,n,{seconds:e,ease:ql.linear}),e=>this.at(e))}};function cu(e,t){if(!Number.isFinite(t))throw RangeError(`${e} must be a finite number of seconds, got ${t}`);return t}const lu=e=>cu(`Timeline host time`,e);function uu(e){if(!Number.isFinite(e)||e===0)throw RangeError(`Timeline rate must be finite and not zero, got ${e}`);return e}function du(e,t,n,r){let i=lu(t);return e.playing?{playing:!0,origin:i,time:n,rate:r}:{playing:!1,time:n,rate:r}}function fu(e,{origin:t,time:n,rate:r}){let i=e=>n+r*(e-t),a=r>0,o=a?t=>e.nextChange(t):t=>e.lastChange(t),s=a?t=>e.lastChange(t):t=>e.nextChange(t),c=a?(e,t)=>e>=t:(e,t)=>e<t,l=e=>{let a=t+(e-n)/r;return Number.isFinite(a)?nu(a,t=>c(i(t),e)):a};return{at:t=>e.at(i(lu(t))),nextChange(e){let t=lu(e),n=i(t),r=o(n);return r===n?t:Math.max(t,l(r))},lastChange(e){let t=lu(e),n=i(t),r=s(n);return r===n?t:Math.min(t,l(r))}}}const pu={play(e,t=1){return{playing:!0,origin:cu(`Timeline.play origin`,e),time:0,rate:uu(t)}},at(e,t){let n=lu(t);return e.playing?e.time+e.rate*(n-e.origin):e.time},pause(e,t){return{playing:!1,time:pu.at(e,t),rate:e.rate}},resume(e,t){return{playing:!0,origin:lu(t),time:pu.at(e,t),rate:e.rate}},seek(e,t,n){return du(e,t,cu(`Timeline.seek time`,n),e.rate)},withRate(e,t,n){return du(e,t,pu.at(e,t),uu(n))},run(e,t){return e.playing?fu(t,e):{at:n=>t.at(pu.at(e,n)),nextChange:e=>(lu(e),1/0),lastChange:e=>(lu(e),-1/0)}}};function mu(e,t){return{owner:e.owner,row:e.row,col:e.col+t,inner:e.inner&&mu(e.inner,t)}}function hu(e,t){for(let n=e;n;n=n.inner)if(n.owner===t)return!0;return!1}const gu=[`bold`,`dim`,`italic`,`underline`,`blink`,`blink2`,`reverse`,`conceal`,`strike`,`underline2`,`frame`,`encircle`,`overline`],_u={bold:1,dim:2,italic:3,underline:4,blink:5,blink2:6,reverse:7,conceal:8,strike:9,underline2:21,frame:51,encircle:52,overline:53},vu={b:`bold`,d:`dim`,i:`italic`,u:`underline`,s:`strike`,r:`reverse`,o:`overline`,uu:`underline2`};var yu=class extends Error{constructor(e,t){super(e,t),this.name=`StyleSyntaxError`}};const bu=new Go;var H=class e{color;bgcolor;bold;dim;italic;underline;blink;blink2;reverse;conceal;strike;underline2;frame;encircle;overline;link;meta;anchor;nextChange;constructor(e={}){let t=e.nextChange??1/0;if(!(t>-1/0))throw RangeError(`Style nextChange must be a time in seconds or Infinity, got ${t}`);this.nextChange=t,this.color=Au(e.color),this.bgcolor=ju(e.bgcolor),this.bold=e.bold,this.dim=e.dim,this.italic=e.italic,this.underline=e.underline,this.blink=e.blink,this.blink2=e.blink2,this.reverse=e.reverse,this.conceal=e.conceal,this.strike=e.strike,this.underline2=e.underline2,this.frame=e.frame,this.encircle=e.encircle,this.overline=e.overline,this.link=e.link||void 0,this.meta=e.meta,this.anchor=e.anchor}get isNull(){return this.color===void 0&&this.bgcolor===void 0&&this.bold===void 0&&this.dim===void 0&&this.italic===void 0&&this.underline===void 0&&this.blink===void 0&&this.blink2===void 0&&this.reverse===void 0&&this.conceal===void 0&&this.strike===void 0&&this.underline2===void 0&&this.frame===void 0&&this.encircle===void 0&&this.overline===void 0&&this.link===void 0&&this.meta===void 0&&this.anchor===void 0&&this.nextChange===1/0}get transparentBackground(){return this.bgcolor===void 0||this.bgcolor.isDefault}get backgroundStyle(){return new e({bgcolor:this.bgcolor})}with(t){return new e({...this,...t})}get withoutColor(){return this.with({color:void 0,bgcolor:void 0})}withLink(e){return this.with({link:e})}clearMetaAndLinks(){return this.with({link:void 0,meta:void 0})}withAnchor(e){return this.with({anchor:e})}shiftedBy(e){return this.anchor?this.withAnchor(mu(this.anchor,e)):this}add(t){return!t||t.isNull?this:this.isNull?t:new e({color:t.color??this.color,bgcolor:t.bgcolor??this.bgcolor,bold:t.bold??this.bold,dim:t.dim??this.dim,italic:t.italic??this.italic,underline:t.underline??this.underline,blink:t.blink??this.blink,blink2:t.blink2??this.blink2,reverse:t.reverse??this.reverse,conceal:t.conceal??this.conceal,strike:t.strike??this.strike,underline2:t.underline2??this.underline2,frame:t.frame??this.frame,encircle:t.encircle??this.encircle,overline:t.overline??this.overline,link:t.link??this.link,meta:t.meta&&this.meta?{...this.meta,...t.meta}:t.meta??this.meta,anchor:t.anchor??this.anchor,nextChange:Math.min(this.nextChange,t.nextChange)})}equals(e){return this===e?!0:this.color?.name===e.color?.name&&this.bgcolor?.name===e.bgcolor?.name&&this.bold===e.bold&&this.dim===e.dim&&this.italic===e.italic&&this.underline===e.underline&&this.blink===e.blink&&this.blink2===e.blink2&&this.reverse===e.reverse&&this.conceal===e.conceal&&this.strike===e.strike&&this.underline2===e.underline2&&this.frame===e.frame&&this.encircle===e.encircle&&this.overline===e.overline&&this.link===e.link&&Pu(this.anchor,e.anchor)&&this.nextChange===e.nextChange}drawnColors(e){let t=Cs,n=this.bgcolor?.flattenAlpha(t),r=n?.getTruecolor(void 0,!1)??t,i=this.color?.flattenAlpha(r),a=t=>e===void 0?t:t.downgrade(e);return{color:i===void 0?void 0:a(i),bgcolor:n===void 0?void 0:a(n)}}toSgrCodes(e){if(this.isNull)return``;let t=this.drawnColors(e);return[...gu.filter(e=>this[e]===!0).map(e=>`${_u[e]}`),...t.color?.getAnsiCodes(!0)??[],...t.bgcolor?.getAnsiCodes(!1)??[]].join(`;`)}toString(){if(this.isNull)return`none`;let e=[];for(let t of gu)this[t]===!1&&e.push(`not ${t}`);for(let t of gu)this[t]===!0&&e.push(t);return this.color&&e.push(this.color.name),this.bgcolor&&e.push(`on ${this.bgcolor.name}`),this.link&&e.push(`link ${this.link}`),e.join(` `)||`none`}static null(){return U}static fromColor(t,n){return new e({color:t,bgcolor:n})}static fromMeta(t){return new e({meta:t})}static pickFirst(...e){for(let t of e)if(t!==void 0)return t;throw Error(`All arguments are undefined`)}static combine(e){let t=U;for(let n of e)n&&(t=t.add(n));return t}static chain(...t){return e.combine(t)}static normalize(e){return e.trim().replace(/\s+/g,` `)}static parse(t){let n=e.normalize(t);return n===``||n===`none`?U:bu.get(n,ku)}};const U=new H,xu=/^[a-z][a-z0-9._-]*$/;function Su(e,t){return e instanceof H?e.add(t):e===``?t:typeof e==`string`?{under:e,over:t}:{under:e.under,over:e.over.add(t)}}var Cu=class{styles;constructor(e={},t){if(this.styles=new Map,t?.inherit!==!1)for(let[e,t]of Object.entries(Mu))this.styles.set(e,t);for(let[t,n]of Object.entries(e)){if(!xu.test(t))throw Error(`Invalid style name: "${t}" (must be lowercase, start with letter, contain only letters, digits, ".", "-", "_")`);this.styles.set(t,H.parse(n))}}get(e){return this.styles.get(e)}resolve(e){return e instanceof H?e:typeof e==`string`?this.styles.get(e)??H.parse(e):this.resolve(e.under).add(e.over)}has(e){return this.styles.has(e)}};const wu=new Set(gu),Tu=[`not`,`on`,`link`,...gu,...yc];function Eu(e,t){let n=[],r=Array.from({length:t.length+1},(e,t)=>t);for(let i=1;i<=e.length;i++){let a=[i];for(let o=1;o<=t.length;o++){let s=i>1&&o>1&&e[i-1]===t[o-2]&&e[i-2]===t[o-1];a[o]=Math.min(r[o]+1,a[o-1]+1,r[o-1]+Number(e[i-1]!==t[o-1]),s?n[o-2]+1:1/0)}[n,r]=[r,a]}return r[t.length]}function Du(e,t){let n=e.toLowerCase(),r=Math.max(1,Math.floor(n.length/3)),i=t.filter(e=>Math.abs(e.length-n.length)<=r).map(e=>({name:e,distance:Eu(n,e)})),a=Math.min(r,...i.map(e=>e.distance)),o=i.filter(e=>e.distance===a).map(e=>`"${e.name}"`).sort();return o.length===0?``:` (did you mean ${o.join(` or `)}?)`}function Ou(e,t,n){try{return B.parse(e)}catch(r){throw new yu(`${t} "${e}"${Du(e,n)}: ${String(r)}`,{cause:r})}}function ku(e){let t=e.split(/\s+/),n={},r=0;for(;r<t.length;){let e=t[r];if(e===`not`){r++;let e=t[r];if(!e)throw new yu(`Expected attribute after "not" in style definition`);let i=vu[e]??e;if(!wu.has(i))throw new yu(`Invalid attribute: "${e}"${Du(e,gu)}`);n[i]=!1,r++;continue}if(e===`on`){r++;let e=t[r];if(!e)throw new yu(`Expected color after "on" in style definition`);n.bgcolor=Ou(e,`Invalid background color`,yc),r++;continue}if(e===`link`){r++;let e=t[r];e&&(n.link=e),r++;continue}let i=vu[e]??e;if(wu.has(i)){n[i]=!0,r++;continue}n.color=Ou(e,`Invalid style definition`,Tu),r++}return new H(n)}function Au(e){if(e!==void 0)return e instanceof B?e:B.parse(e)}function ju(e){let t=Au(e);return t?.value?.alpha===0?void 0:t}const Mu={none:U,reset:new H({color:B.default(),bgcolor:B.default(),bold:!1,dim:!1,italic:!1,underline:!1,blink:!1,blink2:!1,reverse:!1,conceal:!1,strike:!1,underline2:!1,frame:!1,encircle:!1,overline:!1}),bold:new H({bold:!0}),dim:new H({dim:!0}),italic:new H({italic:!0}),underline:new H({underline:!0}),blink:new H({blink:!0}),blink2:new H({blink2:!0}),reverse:new H({reverse:!0}),conceal:new H({conceal:!0}),strike:new H({strike:!0}),underline2:new H({underline2:!0}),frame:new H({frame:!0}),encircle:new H({encircle:!0}),overline:new H({overline:!0}),"table.header":new H({bold:!0}),"table.footer":new H({bold:!0}),"table.cell":U,"table.title":new H({italic:!0}),"table.caption":new H({italic:!0,dim:!0}),"repr.ellipsis":H.parse(`yellow`),"repr.indent":H.parse(`dim green`),"repr.error":H.parse(`bold red`),"repr.str":H.parse(`not bold not italic green`),"repr.brace":H.parse(`bold`),"repr.comma":H.parse(`bold`),"repr.ipv4":H.parse(`bold bright_green`),"repr.ipv6":H.parse(`bold bright_green`),"repr.eui48":H.parse(`bold bright_green`),"repr.eui64":H.parse(`bold bright_green`),"repr.tag_start":H.parse(`bold`),"repr.tag_name":H.parse(`bold bright_magenta`),"repr.tag_contents":H.parse(`default`),"repr.tag_end":H.parse(`bold`),"repr.attrib_name":H.parse(`not italic yellow`),"repr.attrib_equal":H.parse(`bold`),"repr.attrib_value":H.parse(`not italic magenta`),"repr.number":H.parse(`bold not italic cyan`),"repr.number_complex":H.parse(`bold not italic cyan`),"repr.bool_true":H.parse(`italic bright_green`),"repr.bool_false":H.parse(`italic bright_red`),"repr.none":H.parse(`italic magenta`),"repr.url":H.parse(`not bold not italic underline bright_blue`),"repr.uuid":H.parse(`not bold bright_yellow`),"repr.call":H.parse(`bold magenta`),"repr.path":H.parse(`magenta`),"repr.filename":H.parse(`bright_magenta`),"log.time":H.parse(`cyan dim`),"log.message":U,"log.path":H.parse(`dim`),"log.line_no":H.parse(`cyan`),"log.level":U,"rule.line":H.parse(`bright_green`),"rule.text":U,"strip.separator":H.parse(`bright_black`),"strip.rail":H.parse(`bright_black`),"json.brace":H.parse(`bold`),"json.bool_true":H.parse(`italic bright_green`),"json.bool_false":H.parse(`italic bright_red`),"json.key":H.parse(`bold blue`),"json.null":H.parse(`italic magenta`),"json.number":H.parse(`bold not italic cyan`),"json.str":H.parse(`not bold not italic green`),"syntax.keyword":H.parse(`bold magenta`),"syntax.constant":H.parse(`italic bright_magenta`),"syntax.string":H.parse(`green`),"syntax.number":H.parse(`cyan`),"syntax.comment":H.parse(`dim italic`),"syntax.line_number":H.parse(`dim`),"syntax.line_number.highlight":H.parse(`bold grey93 on grey27`),"markdown.h1":H.parse(`bold underline`),"markdown.h2":H.parse(`underline magenta`),"markdown.h3":H.parse(`bold magenta`),"markdown.h4":H.parse(`italic magenta`),"markdown.h5":H.parse(`italic`),"markdown.h6":H.parse(`dim`),"markdown.code":H.parse(`bold dark_turquoise on grey11`),"markdown.em":H.parse(`italic`),"markdown.strong":H.parse(`bold`),"markdown.s":H.parse(`strike`),"markdown.kbd":H.parse(`bold bright_yellow`),"markdown.block_quote":H.parse(`magenta`),"markdown.hr":H.parse(`dim`),"markdown.item":U,"markdown.item.bullet":H.parse(`bold`),"markdown.item.number":H.parse(`cyan`),"markdown.link":H.parse(`bright_blue`),"markdown.link_url":H.parse(`underline blue`),"markdown.table.border":H.parse(`cyan`),"markdown.table.header":H.parse(`not bold cyan`),"progress.description":U,"progress.percentage":H.parse(`magenta`),"progress.remaining":H.parse(`cyan`),"progress.elapsed":H.parse(`yellow`),"progress.spinner":H.parse(`green`),"progress.download":H.parse(`green`),"progress.filesize":H.parse(`green`),"progress.filesize.total":H.parse(`green`),"progress.data.speed":H.parse(`red`),"bar.back":H.parse(`grey23`),"bar.complete":H.parse(`rgb(249,38,114)`),"bar.finished":H.parse(`rgb(114,156,31)`),"bar.pulse":H.parse(`rgb(249,38,114)`),"scrollbar.thumb":U,"scrollbar.track":H.parse(`grey37`),tree:U,"tree.guide":U,"status.spinner":H.parse(`green`),"status.message":U,prompt:U,"prompt.choices":H.parse(`bold magenta`),"prompt.default":H.parse(`bold cyan`),"prompt.invalid":H.parse(`red`),"prompt.invalid.choice":H.parse(`red`),"inspect.attr":H.parse(`yellow italic`),"inspect.attr.dunder":H.parse(`yellow italic dim`),"inspect.callable":H.parse(`bold magenta`),"inspect.error":H.parse(`bold red`),"inspect.help":H.parse(`cyan`),"inspect.doc":H.parse(`dim`),"inspect.value.border":H.parse(`green`),"traceback.border":H.parse(`red`),"traceback.text":H.parse(`red`),"traceback.title":H.parse(`bold red`),"traceback.exc_type":H.parse(`bold bright_red`),"traceback.exc_value":U,"traceback.offset":H.parse(`bold bright_red`),"scope.border":H.parse(`blue`),"scope.key":H.parse(`italic`),"scope.key.special":H.parse(`dim italic`),pretty:U,"iso8601.date":H.parse(`blue`),"iso8601.time":H.parse(`magenta`),"iso8601.timezone":H.parse(`yellow`),"iso8601.year":U,"iso8601.month":U,"iso8601.day":U,"iso8601.week":U,"iso8601.hour":U,"iso8601.minute":U,"iso8601.second":U,"iso8601.frac":U,"iso8601.ms":U,"iso8601.hyphen":U},Nu=new Cu;function Pu(e,t){return e===t?!0:!e||!t?!1:e.owner===t.owner&&e.row===t.row&&e.col===t.col&&Pu(e.inner,t.inner)}var Fu;(function(e){e.BELL=`bell`,e.CARRIAGE_RETURN=`carriage_return`,e.HOME=`home`,e.CLEAR=`clear`,e.SHOW_CURSOR=`show_cursor`,e.HIDE_CURSOR=`hide_cursor`,e.ENABLE_ALT_SCREEN=`enable_alt_screen`,e.DISABLE_ALT_SCREEN=`disable_alt_screen`,e.CURSOR_UP=`cursor_up`,e.CURSOR_DOWN=`cursor_down`,e.CURSOR_FORWARD=`cursor_forward`,e.CURSOR_BACKWARD=`cursor_backward`,e.CURSOR_MOVE_TO_COLUMN=`cursor_move_to_column`,e.CURSOR_MOVE_TO=`cursor_move_to`,e.ERASE_IN_LINE=`erase_in_line`,e.SET_WINDOW_TITLE=`set_window_title`})(Fu||={});var W=class e{text;style;control;constructor(e,t,n){this.text=e,this.style=t,this.control=n}get cellLength(){return this.control?0:Zo(this.text)}get hasText(){return this.text.length>0}get isControl(){return this.control!==void 0}splitCells(t){return t>=this.cellLength?[this,new e(``)]:t<=0?[new e(``),this]:this.cutAt([t])}cutAt(t){return ns(this.text,t).map((n,r)=>new e(n,r===0?this.style:this.style?.shiftedBy(t[r-1])))}static _line;static line(){return e._line??=new e(`
43
43
  `)}static anchorLines(t,n,r=0){return t.map((t,i)=>{let a=r+i,o=0;return t.map(t=>{if(t.isControl)return t;let r=t.style??H.null(),i=new e(t.text,r.withAnchor({owner:n,row:a,col:o,inner:r.anchor}));return o+=t.cellLength,i})})}static nextChange(e){let t=1/0;for(let n of e)t=Math.min(t,n.style?.nextChange??1/0);return t}static anchorAt(e,t,n){if(!Number.isInteger(t)||t<0)return;let r=0;for(let i of e[n]??[]){let e=r+i.cellLength;if(t<e){let e=i.style?.anchor;return e&&mu(e,t-r)}r=e}}static*applyStyle(t,n,r){let i=n?.isNull?void 0:n,a=r?.isNull?void 0:r;if(!i&&!a){yield*t;return}for(let n of t){if(n.isControl){yield n;continue}let t=n.style;i&&(t=i.add(t)),a&&(t=t?t.add(a):a),yield new e(n.text,t,n.control)}}static*filterControl(e,t){for(let n of e)n.isControl===t&&(yield n)}static splitLines(t){let n=[],r=[];for(let i of t){if(i.isControl){r.push(i);continue}let t=i.text;if(!t.includes(`
44
44
  `)){r.push(i);continue}let a=t.split(`
45
- `);for(let t=0;t<a.length;t++){t>0&&(n.push(r),r=[]);let o=a[t];o.length>0&&r.push(new e(o,i.style))}}return r.length>0&&n.push(r),n}static adjustLineLength(t,n,r,i=!0){let a=e.getLineLength(t);if(a===n)return t;if(a<n)return i?[...t,new e(` `.repeat(n-a),r)]:t;let o=[],s=n;for(let e of t){if(e.isControl){o.push(e);continue}let t=e.cellLength;if(t<=s)o.push(e),s-=t;else{let[t]=e.splitCells(Zo(s));o.push(t),s=0;break}}return o}static*cropLines(t,n){let r=Math.max(0,n),i=0;for(let n of t){if(n.isControl){yield n;continue}let t=n.text.split(`
46
- `);for(let e=0;e<t.length;e++){e>0&&(i=0);let[n]=es(t[e],Zo(r-i));i+=R(n),t[e]=n}let a=t.join(`
47
- `);yield a===n.text?n:new e(a,n.style)}}static splitAndCropLines(t,n){return e.splitLines(t).map(t=>e.adjustLineLength(t,n))}static getLineLength(e){let t=0;for(let n of e)n.isControl||(t+=n.cellLength);return t}static getShape(t){if(t.length===0)return[0,0];let n=0;for(let r of t){let t=e.getLineLength(r);t>n&&(n=t)}return[n,t.length]}static*mergeHorizontal(t,n=0){let r=0;for(let e of t)e.lines.length>r&&(r=e.lines.length);let i=n>0?[new e(` `.repeat(n))]:[];for(let n=0;n<r;n++){for(let r=0;r<t.length;r++){r>0&&(yield*i);let a=t[r];yield*e.adjustLineLength(a.lines[n]??[],a.width)}yield e.line()}}static*simplify(t){let n;for(let r of t){if(!n){n=r;continue}Iu(n.style,r.style)&&!r.isControl&&!n.isControl?n=new e(n.text+r.text,n.style):(yield n,n=r)}n&&(yield n)}static*stripLinks(t){for(let n of t)n.style?.link?yield new e(n.text,n.style.clearMetaAndLinks(),n.control):yield n}static*stripStyles(t){for(let n of t)yield new e(n.text,void 0,n.control)}static*removeColor(t){for(let n of t)n.style?yield new e(n.text,n.style.withoutColor,n.control):yield n}static divide(e,t){if(t.length===0)return[e];let n=[[]],r=0,i=0;for(let a of e){let e=r+a.cellLength,o=[];for(;i<t.length&&t[i]<e;i++){let e=t[i];e<=r?n.push([]):o.push(Zo(e-r))}let[s,...c]=o.length===0?[a]:a.cutAt(o);n[n.length-1].push(s);for(let e of c)n.push(e.hasText?[e]:[]);r=e}for(;i<t.length;i++)n.push([]);return n[n.length-1].length===0&&n.pop(),n}static alignTop(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)];for(;a.length<r;)a.push([...o]);return a.slice(0,r)}static alignBottom(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)],s=Math.max(0,r-a.length),c=[];for(let e=0;e<s;e++)c.push([...o]);return c.push(...a),c.slice(0,r)}static alignMiddle(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)],s=Math.max(0,Math.floor((r-a.length)/2)),c=[];for(let e=0;e<s;e++)c.push([...o]);for(c.push(...a);c.length<r;)c.push([...o]);return c.slice(0,r)}static setShape(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)];for(;a.length<r;)a.push([...o]);return a.slice(0,r)}};function Iu(e,t){return e===t?!0:!e||!t?!1:e.equals(t)}const Lu=e=>/^[\x00-\x7F]*$/.test(e);function Ru(e,t,n,r=String){return e.asciiOnly===!0&&!Lu(r(t))?n:t}function zu(e,t){return(e.theme??Nu).resolve(t)}H.parse(`default on default`);function Bu(e){return{...e,maxWidth:$o(e.maxWidth)}}function Vu(e){return $o(e.maxWidth)<1}function Hu(e,t){let n=Vu(t)?`held`:`drawn`;if(t.onPresent?.(e,n),n===`drawn`)return e.render(t);if(Ku(e))for(let n of e.contents())Hu(n,t);return[]}function Uu(e){return{...e,onPresent:void 0}}function Wu(e,t){let n=Bu(e);if(Number.isFinite(n.maxWidth))return n;let r=t.measure(Uu(n)).maximum;if(!Number.isFinite(r))throw RangeError(`maxWidth is unbounded and this renderable has no natural width to fall back on: its content does not implement measure(), or something inside it asked for an unbounded width of its own. Render it at a finite width, or give the content a measure() that reports a finite maximum.`);return{...n,maxWidth:$o(r)}}function Gu(e){return typeof e==`object`&&!!e&&`measure`in e&&typeof e.measure==`function`}function Ku(e){return`contents`in e&&typeof e.contents==`function`}var qu=class e{minimum;maximum;constructor(e,t){this.minimum=e,this.maximum=t}get span(){return this.maximum-this.minimum}normalize(){let t=e=>Number.isNaN(e)?0:e;return new e(Math.max(0,Math.min(t(this.minimum),t(this.maximum))),Math.max(0,t(this.maximum)))}withMaximum(t){return new e(Math.min(this.minimum,t),Math.min(this.maximum,t))}withMinimum(t){let n=Math.max(this.minimum,t);return new e(n,Math.max(this.maximum,n))}clamp(t,n){return new e(Math.min(Math.max(this.minimum,t),n),Math.min(Math.max(this.maximum,t),n))}static get(t,n){if(Vu(t))return new e(0,0);if(!Gu(n))return new e(0,t.maxWidth);let{minimum:r,maximum:i}=n.measure(Uu(t));return new e(r,Math.min(i,t.maxWidth)).normalize()}};function*Ju(e){let t=/\s*\S+\s*/y;for(let n=t.exec(e);n!==null;n=t.exec(e))yield n[0]}function Yu(e){return R(e.trimEnd())}function Xu(e){return Array.from(Ju(e),Yu)}function Zu(e,t){let n=ns(e,t);return R(n[0])>t?[``,...n]:n}function Qu(e,t,n){if(t<=0)return[];let r=[],i=e=>{e>0&&r.push(Zo(e))},a=0,o=0;for(let r of Ju(e)){let e=Yu(r);if(t-a>=e)a+=R(r);else if(n.fold&&e>t){let e=Zu(r,t),n=o;for(let t=0;t<e.length;t+=1){i(n);let r=e[t];t===e.length-1?a=R(r):n+=R(r)}}else i(o),a=R(r);o+=R(r)}return r}const $u=new TextEncoder;function ed(e){let t=2166136261;for(let n of $u.encode(e))t=Math.imul(t^n,16777619);return(t>>>0).toString(16).padStart(8,`0`)}const td=`\\x1b\\x07\\x9c`,nd=RegExp(`[${td}]`,`g`);function rd(e){return e.replace(nd,``)}function id(e){let t=rd(e);return`\x1b]8;id=${ed(t)};${t}\x1b\\`}const ad=RegExp(`\\x1b\\]8;([^;${td}]*);([^${td}]*)(?:\\x1b\\\\|\\x07|\\x9c)`),od=new RegExp(ad.source,`g`);function sd(e){return[...e.matchAll(od)].map(e=>({index:e.index,length:e[0].length,params:e[1],uri:e[2]}))}const cd=/[\x00-\x08\x0B-\x1F\x7F-\x9F\u202A-\u202E\u2066-\u206F]/g;function ld(e){return e.replace(cd,``)}const ud=/\s+$/;function dd(e){return e.map(e=>e.text).join(``)}function fd(e){return R(ud.exec(dd(e))?.[0]??``)}function pd(e){let t=e.link;if(!t)return e;let n=rd(t);return n===t?e:e.withLink(n)}function md(e){return typeof e==`string`?e:e instanceof H?hd(e):{under:e.under,over:hd(e.over)}}function hd(e){return pd(e.anchor?e.withAnchor(void 0):e)}function gd(e){return e instanceof H?e.isNull:e===``}function _d(e,t){return pd(t instanceof H?t:typeof t==`string`?vd(e,t):vd(e,t.under).add(t.over))}function vd(e,t){try{return zu(e,t)}catch(n){if(!(n instanceof yu))throw n;return e.onStyleError?.(n,t),U}}var yd=class e{start;end;style;constructor(e,t,n){this.start=e,this.end=t,this.style=n}get hasLength(){return this.end>this.start}toString(){return`Span(${this.start}, ${this.end})`}split(t){return t<=this.start||t>=this.end?[this,void 0]:[new e(this.start,t,this.style),new e(t,this.end,this.style)]}move(t){return new e(this.start+t,this.end+t,this.style)}rightCrop(t){return t>=this.end?this:new e(this.start,Math.min(this.end,t),this.style)}extend(t){return new e(this.start,this.end+t,this.style)}},G=class e{_text;_spans;_style;_justify;_overflow;_end;_tabSize;_noWrap;constructor(e,t){this._text=e?ld(e):``,this._spans=[],this._style=md(t?.style??U),this._justify=t?.justify,this._overflow=t?.overflow,this._end=t?.end??`
48
- `,this._tabSize=ms(t?.tabSize??8),this._noWrap=t?.noWrap??!1}get plain(){return this._text}set plain(e){let t=ld(e);this._text=t;let n=t.length;this._spans=this._spans.map(e=>e.end>n?new yd(e.start,Math.min(e.end,n),e.style):e).filter(e=>e.start<n)}get length(){return this._text.length}get cellLength(){return R(hs(this._text,this._tabSize).text)}get hasContent(){return this._text.length>0}get style(){return this._style}set style(e){this._style=md(e)}get justify(){return this._justify}set justify(e){this._justify=e}get overflow(){return this._overflow}set overflow(e){this._overflow=e}get end(){return this._end}set end(e){this._end=e}get noWrap(){return this._noWrap}set noWrap(e){this._noWrap=e}get spans(){return this._spans}resolvedStyle(e){return _d(e,this._style)}edgeStyle(e,t){let n=this.resolvedStyle(t);if(this._text.length===0)return n;let r=e===`left`?0:this._text.length-1,i=n;for(let e of this._spans)e.start<=r&&r<e.end&&(i=i.add(_d(t,e.style)));return i}append(t,n){if(t instanceof e){if(n!==void 0)throw Error(`Style argument must not be provided when appending RichText`);let e=this._text.length;this._text+=t._text,this._addSpan(e,this._text.length,t._style);for(let n of t._spans)this._spans.push(n.move(e));return this}let r=ld(t),i=this._text.length;return this._text+=r,this._addSpan(i,this._text.length,n??``),this}contains(t){let n=t instanceof e?t._text:t;return this._text.includes(n)}at(t){let n=t<0?this._text.length+t:t;return this._text[n]===void 0?new e(``):this.slice(n,n+1)}slice(e,t){let n=this._text,r=n.length,i=e??0,a=t??r,o=i<0?Math.max(0,r+i):Math.min(i,r),s=a<0?Math.max(0,r+a):Math.min(a,r);if(o>=s)return this.blankCopy();let c=n.slice(o,s),l=this.blankCopy(c);for(let e of this._spans){let t=Math.max(e.start,o)-o,n=Math.min(e.end,s)-o;t<n&&l._spans.push(new yd(t,n,e.style))}return l}_addSpan(e,t,n){let r=md(n);gd(r)||this._spans.push(new yd(e,t,r))}stylize(e,t,n){let r=this._text.length,i=t===void 0?0:t<0?r+t:t,a=n===void 0?r:n<0?r+n:n;if(i>=a||i>=r||a<=0)return this;let o=Math.max(0,i),s=Math.min(r,a);return this._addSpan(o,s,e),this}highlightRegex(e,t){let n=this._text,r=0,i=e.flags.includes(`g`)?e.flags:e.flags+`g`,a=new RegExp(e.source,i),o;for(;(o=a.exec(n))!==null;){if(o[0].length===0){a.lastIndex++;continue}if(o.groups){let e=0;for(let[t,n]of Object.entries(o.groups))if(n!==void 0){let r=o[0].indexOf(n,e);if(r>=0){let i=o.index+r;this._addSpan(i,i+n.length,t),e=r+n.length}}r++;continue}this._addSpan(o.index,o.index+o[0].length,t??``),r++}return r}highlightWords(e,t,n){let r=n?.caseSensitive!==!1,i=0;for(let n of e){if(n.length===0)continue;let e=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=r?`g`:`gi`,o=RegExp(`\\b${e}\\b`,a),s;for(;(s=o.exec(this._text))!==null;)this._addSpan(s.index,s.index+s[0].length,t),i++}return i}copy(){let t=new e(this._text,{style:this._style,justify:this._justify,overflow:this._overflow,end:this._end,tabSize:this._tabSize,noWrap:this._noWrap});return t._spans=this._spans.slice(),t}blankCopy(t){return new e(t??``,{style:this._style,justify:this._justify,overflow:this._overflow,end:this._end,tabSize:this._tabSize,noWrap:this._noWrap})}split(e){let t=e??`
49
- `,n=this._text,r=[],i=0;for(;;){let e=n.indexOf(t,i);if(e===-1){r.push(this.slice(i));break}r.push(this.slice(i,e)),i=e+t.length}return r}divide(e){if(e.length===0)return[this.copy()];let t=[],n=0;for(let r of e)t.push(this.slice(n,r)),n=r;return t.push(this.slice(n)),t}rstrip(){let e=this._text.replace(/\s+$/,``);return e.length<this._text.length&&(this.plain=e),this}pad(e,t){let n=ld(t??` `).repeat(e);return this._spans=this._spans.map(e=>e.move(n.length)),this._text=n+this._text+n,this}expandTabs(){let e=hs(this._text,this._tabSize);return this._spans=this._spans.map(t=>new yd(e.offsetOf(t.start),e.offsetOf(t.end),t.style)),this._text=e.text,this}padLeft(e,t){let n=ld(t??` `).repeat(e);return this._spans=this._spans.map(e=>e.move(n.length)),this._text=n+this._text,this}padRight(e,t){return this._text+=ld(t??` `).repeat(e),this}setLength(e){return this._text.length<e?this._text+=` `.repeat(e-this._text.length):this._text.length>e&&(this.plain=this._text.slice(0,e)),this}extendStyle(e){let t=this._text.length;return this._text+=` `.repeat(e),this._spans=this._spans.map(n=>n.end===t?n.extend(e):n),this}truncate(e,t){if(this.cellLength<=e)return this;this.expandTabs();let n=t?.mode??`right`,r=$o(e),i=ls(ld(t?.marker??`…`),r),a=Zo(r-R(i));if(n===`right`)return this._cropRightTo(a),i&&(this._text+=i),this;if(n===`left`)return this._cropLeftTo(a),i&&(this._spans=this._spans.map(e=>e.move(i.length)),this._text=i+this._text),this;let o=Zo(Math.floor(a/2)),s=Zo(a-o),c=ls(this._text,o).length,l=this._text.length-us(this._text,s).length,u=this._text.slice(0,c),d=this._text.slice(l),f=c,p=l,m=i.length-(p-f),h=[];for(let e of this._spans)e.end<=f?h.push(e):e.start>=p?h.push(e.move(m)):(e.start<f&&h.push(new yd(e.start,f,e.style)),e.end>p&&h.push(new yd(p+m,e.end+m,e.style)));return this._text=u+i+d,this._spans=h,this}_cropRightTo(e){this.plain=ls(this._text,e)}_cropLeftTo(e){let t=this._text.length-us(this._text,e).length,n=-t;this._spans=this._spans.map(e=>{if(!(e.end<=t))return new yd(Math.max(0,e.start+n),e.end+n,e.style)}).filter(e=>e!==void 0),this._text=this._text.slice(t)}align(e,t){let n=this.cellLength;if(n>=t)return this;this.expandTabs();let r=t-n;switch(e){case`left`:this.padRight(r);break;case`right`:this.padLeft(r);break;case`center`:{let e=Math.floor(r/2),t=r-e;this.padLeft(e),this.padRight(t);break}}return this}removeSuffix(e){return this._text.endsWith(e)&&(this.plain=this._text.slice(0,-e.length)),this}appendTokens(e){for(let[t,n]of e)this.append(t,n);return this}static assemble(t,n){let r=new e(``,{style:n?.style});for(let n of t)if(typeof n==`string`)r.append(n);else if(n instanceof e)r.append(n);else{let[e,t]=n;r.append(e,t)}return r}static styled(t,n){let r=new e(t);return r.stylize(n),r}static fromFragments(t,n){let r=new e(``,{end:n?.end??``});for(let e of t)r.append(e);return r}*render(e){let t=hs(this._text,this._tabSize),n=this.resolvedStyle(e),{segments:r,covered:i}=this._buildSegments(t,n,e),a=bd(r,i);r.push(W.line());let o=W.splitLines(r),s=$o(Wu(e,this).maxWidth),c=this._overflow??e.overflow??`fold`,l=this._noWrap||(e.noWrap??!1),u=c===`ignore`?$o(1/0):s,d=l?$o(1/0):u,f=c===`ignore`?void 0:this._justify??e.justify,p=Ru(e,`…`,`.`);for(let e=0;e<o.length;e+=1){let t=o[e],r=a[e],i=e<o.length-1,l=Qu(dd(t),d,{fold:c===`fold`}),m=W.divide(t,l),h=this._justifyLines(m.map((e,t)=>({segments:[...this._fitLine(e,u,c,p)],free:e=>r(t===0?e:l[t-1]+e)})),s,n,f);for(let e=0;e<h.length;e+=1)yield*h[e],(e<h.length-1||i)&&(yield W.line())}this._end&&(yield new W(this._end))}measure(e){let t=hs(this._text,this._tabSize).text.split(`
50
- `),n=t.reduce((e,t)=>Math.max(e,R(t)),0),r=t.flatMap(Xu),i=r.length>0?r.reduce((e,t)=>Math.max(e,t),0):n,a=$o(e.maxWidth);return{minimum:Math.min(i,a),maximum:Math.min(n,a)}}_buildSegments({text:e,offsetOf:t},n,r){let i=n=>Math.max(0,Math.min(t(n),e.length)),a=new Set;for(let e of this._spans)a.add(i(e.start)),a.add(i(e.end));a.delete(0),a.delete(e.length);let o=[0,...[...a].sort((e,t)=>e-t),e.length],s=new Map(o.map((e,t)=>[e,t]).reverse()),c=o.slice(0,-1).map(()=>n),l=c.map(()=>!1);for(let e of this._spans){let t=i(e.end),n=_d(r,e.style),a=s.get(i(e.start));for(let e=a;o[e]<t;e++)c[e]=c[e].add(n),l[e]=!0}return{segments:c.map((t,n)=>new W(e.slice(o[n],o[n+1]),t.isNull?void 0:t)),covered:l}}_justifyLines(e,t,n,r){return r===`full`?e.map(({segments:r},i)=>i===e.length-1?r:this._fillLine(r,t,n)):e.map(e=>[...this._justifyLine(e,t,n,r)])}*_justifyLine({segments:e,free:t},n,r,i){let a=r.isNull?void 0:r;switch(i){case`center`:case`right`:{let r=W.adjustLineLength(e,W.getLineLength(e)-fd(e),void 0,!1),o=Math.max(n-W.getLineLength(r),0),s=i===`center`?Math.floor(o/2):o;yield*xd(r,t,s,o-s,a);break}case`left`:yield*xd(e,t,0,Math.max(n-W.getLineLength(e),0),a);break;default:yield*e;break}}_fillLine(e,t,n){let r=dd(e),i=r.split(` `);r.endsWith(` `)&&i.pop();let a=i.length-1,o=Array(a).fill(1),s=i.reduce((e,t)=>e+R(t),0)+a;for(let e=0;s<t&&a>0;e=(e+1)%a)o[a-1-e]+=1,s+=1;let c=[],l=0;for(let e=0;e<i.length;e+=1)l+=R(i[e]),c.push(l),l+=1,e<a&&c.push(l);let u=W.divide(e,c),d=(e,t)=>e.filter(e=>e.hasText).at(t)?.style??n,f=[];for(let e=0;e<i.length;e+=1)if(f.push(...u[e*2]),e<a){let t=d(u[e*2],-1),r=d(u[e*2+2],0),i=t.equals(r)?t:n;f.push(new W(` `.repeat(o[e]),i.isNull?void 0:i))}return f}*_fitLine(e,t,n,r){let i=W.getLineLength(e);if(i-fd(e)<=t){yield*W.adjustLineLength(e,Math.min(i,t),void 0,!1);return}if(n===`ellipsis`&&t>0){yield*W.adjustLineLength(e,t-1,void 0,!1),yield new W(r);return}yield*W.adjustLineLength(e,t,void 0,!1)}};function bd(e,t){let n=[[]];return e.forEach((e,r)=>{e.text.split(`
51
- `).forEach((e,i)=>{i>0&&n.push([]);let a=n.at(-1);a.push({end:(a.at(-1)?.end??0)+R(e),free:!t[r]})})}),n.map(e=>t=>{let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i].end<=t?n=i+1:r=i}return e[n].free})}function*xd(e,t,n,r,i){if(n+r===0)return yield*e;let a=e.filter(e=>e.text!==``),o=e=>` `.repeat(e),s=W.getLineLength(a);if(s===0)return yield new W(o(n+r),i);let c=a.length-1,l=n>0&&a[0].cellLength>0&&t(0),u=r>0&&a[c].cellLength>0&&t(s-1),d=+!!l,f=u?c:c+1;if(d>f){yield new W(o(n)+a[0].text+o(r),i);return}n>0&&(yield new W(o(n)+(l?a[0].text:``),i)),yield*a.slice(d,f),r>0&&(yield new W((u?a[c].text:``)+o(r),i))}const Sd=Object.freeze({name:`join`});var Cd=class{fg;bg;constructor(e,t){this.fg=e,this.bg=t}};function wd(e,t){for(let n=e;n;n=n.inner){if(t.has(n.owner))return{fg:!0,bg:!0};if(n.owner instanceof Cd){let{fg:e,bg:r}=n.owner;return{fg:e!==null&&t.has(e),bg:r!==null&&t.has(r)}}}return{fg:!1,bg:!1}}function Td(e,t,n,r){let i=e.join(t,n,r);return{render:e=>W.anchorLines([[...Hu(i,e)]],Sd)[0]}}function Ed(e){return{render:t=>W.anchorLines([[...Hu(e,t)]],e)[0]}}var Dd=class{items;joiner;constructor(e,t){this.items=e,this.joiner=t}*render(e){let t=this.items;if(t.length===0)return;let n={...e,justify:void 0};yield*Hu(Td(this.joiner,null,t[0],{index:0}),n);for(let e=0;e<t.length;e++){let r=t[e];yield*Hu(Ed(r),n);let i=e+1<t.length?t[e+1]:null;yield*Hu(Td(this.joiner,r,i,{index:e+1}),n)}yield W.line()}contents(){return this.items}measure(e){let t=0;for(let n of Hu(this,e))t+=n.cellLength;return{minimum:t,maximum:t}}};const Od=[`seam`,`divider`,`lead`,`tail`];function*kd(e){yield e,`mix`in e&&(yield*kd(e.mix[0]),yield*kd(e.mix[1]))}const Ad=e=>typeof e.glyph==`string`?[e.glyph]:e.glyph.oneOf,jd=(e,t,n,r)=>{let i=Ad(e);return i[Math.floor(parseInt(ed(`${t}:${n}:${r}`),16)/2**32*i.length)]},Md=e=>R(Ad(e)[0]??``),Nd=e=>e.reduce((e,t)=>e+Md(t),0);function Pd(e,t,n){if(e===`ground`)return n(`mixes ground, whose colour is unknown`);let r=typeof e==`object`&&e?e:{};if((r.edge===`left`||r.edge===`right`)&&(r.part===`bg`||r.part===`fg`))return r.edge===t&&n(`names the ${t} neighbour, which this part is drawn without`),Object.freeze({edge:r.edge,part:r.part});if(typeof r.role==`string`)return Object.freeze({role:r.role});if(Array.isArray(r.mix)&&r.mix.length===3){let[e,i,a]=r.mix;return(typeof a!=`number`||!(a>=0&&a<=1))&&n(`mixes at ${String(a)}, outside 0..1`),Object.freeze({mix:Object.freeze([Pd(e,t,n),Pd(i,t,n),a])})}return n(`has a colour that is not a Paint: ${JSON.stringify(e)}`)}const Fd=(e,t,n)=>e===`ground`?e:Pd(e,t,n),Id={seam:void 0,divider:void 0,lead:`left`,tail:`right`},Ld={seam:`seam`,divider:`seam`,lead:`caps`,tail:`caps`};function Rd(e,t,n,r){let i=e.glyph,a=typeof i==`object`&&i?i.oneOf:void 0;typeof i!=`string`&&!(Array.isArray(a)&&a.every(e=>typeof e==`string`))&&r(`has a glyph that is neither a string nor a oneOf of strings: ${JSON.stringify(i)}`),e.fg===`ground`&&e.bg===`ground`&&r(`has ground on both sides`);let o=Ad(e);return o.length===0&&r(`has an empty oneOf`),o.some(t=>R(t)!==Md(e))&&r(`has oneOf members of different widths`),t===`ascii`&&!o.every(Lu)&&r(`is not ASCII`),Object.freeze({glyph:typeof e.glyph==`string`?e.glyph:Object.freeze({oneOf:Object.freeze([...o])}),fg:Fd(e.fg,Id[n],r),bg:Fd(e.bg,Id[n],r)})}function zd(e,t,n,r){let i=e,a=Ld[n];if(typeof i?.[t]!=`object`||i[t]===null)throw Error(`${a}: has no ${t} form`);let o=i[t][n];if(!Array.isArray(o))throw Error(`${a}: ${t} ${n} is not a list of cells`);return Object.freeze(o.map((e,i)=>{let o=e=>{throw Error(`${a}: ${t} ${n}[${i}] ${e}`)};return typeof e==`object`&&e?r(e,o):o(`is not a cell`)}))}const Bd=(e,t)=>(n,r)=>Rd(n,e,t,r),Vd=(e,t)=>(n,r)=>{if(!(`cap`in n))return Rd(n,e,t,r);let{cap:i}=n;return Object.keys(n).length!==1&&r(`names a cap and draws cells of its own; a cell is one or the other`),i===`lead`||i===`tail`?Object.freeze({cap:i}):r(`names a cap that is neither lead nor tail: ${JSON.stringify(i)}`)},Hd=e=>[Nd(e.filter(e=>!(`cap`in e))),e.filter(e=>`cap`in e&&e.cap===`lead`).length,e.filter(e=>`cap`in e&&e.cap===`tail`).length];function Ud(e){let t=t=>{let n=zd(e,t,`seam`,Vd(t,`seam`)),r=e[t].divider===e[t].seam?n:zd(e,t,`divider`,Vd(t,`divider`)),[i,a]=[Hd(n),Hd(r)];if(i.some((e,t)=>e!==a[t]))throw Error(`seam: ${t} divider is not the width of the seam under every caps`);return Object.freeze({seam:n,divider:r})};return Object.freeze({glyph:t(`glyph`),ascii:t(`ascii`)})}function Wd(e){let t=t=>Object.freeze({lead:zd(e,t,`lead`,Bd(t,`lead`)),tail:zd(e,t,`tail`,Bd(t,`tail`))});return Object.freeze({glyph:t(`glyph`),ascii:t(`ascii`)})}function Gd(e,t){let n=e=>e.flatMap(e=>`cap`in e?t[e.cap]:[e]),r=n(e.seam);return{seam:r,divider:e.divider===e.seam?r:n(e.divider),lead:t.lead,tail:t.tail}}const Kd=(e,t)=>e.some(e=>[e.fg,e.bg].some(e=>e!==`ground`&&[...kd(e)].some(e=>`edge`in e&&e.edge===t&&e.part===`bg`)));function qd(e){let t=[...e.seam,...e.divider];return{shape:e,reads:{seam:{left:Kd(t,`left`),right:Kd(t,`right`)},lead:Kd(e.lead,`right`),tail:Kd(e.tail,`left`)}}}function Jd(e){return e!==void 0&&!e.isDefault?e:void 0}function Yd(e){return e.flattenAlpha(Ss)}function Xd(e,t){if(e.reverse)return!1;let{color:n,bgcolor:r}=e.drawnColors(t??B.TRUECOLOR);if(n===void 0||r===void 0)return!1;let i=n.fixedValue,a=r.fixedValue;return i!==void 0&&a!==void 0?Mc.fromRgba(i).deltaE(Mc.fromRgba(a))<.04:n.number===void 0?n.name===r.name:n.number===r.number}function Zd(e,t,n){if(`edge`in e){let n=t[e.edge];if(e.part===`fg`)return n?.color;let r=Jd(n?.bgcolor);return r&&Yd(r)}if(`role`in e)return zu(n,e.role).color;let[r,i,a]=e.mix,o=Zd(r,t,n),s=Zd(i,t,n);return o&&s&&V.blend(o,s,a)}function Qd(e,t,n){return e.fg===`ground`?new H({color:e.bg===`ground`?void 0:Zd(e.bg,t,n),reverse:!0}):new H({color:Zd(e.fg,t,n),bgcolor:e.bg===`ground`?void 0:Zd(e.bg,t,n)})}const $d=e=>Od.flatMap(t=>e[t].flatMap(Ad)).join(``);var ef=class{seam;caps;_forms;constructor(e,t){this.seam=Ud(e),this.caps=Wd(t),this._forms={glyph:qd(Gd(this.seam.glyph,this.caps.glyph)),ascii:qd(Gd(this.seam.ascii,this.caps.ascii))}}join(e,t,{index:n}){let r=this._forms;return{*render(i){let{shape:a,reads:o}=Ru(i,r.glyph,r.ascii,e=>$d(e.shape)),s={left:e?.edgeStyle(`right`,i),right:t?.edgeStyle(`left`,i)},c=Jd(s.left?.bgcolor),l=Jd(s.right?.bgcolor),u=e!==null&&(!o.seam.left||c!==void 0),d=t!==null&&(!o.seam.right||l!==void 0),f=d&&(!o.lead||l!==void 0),p=u&&(!o.tail||c!==void 0),m={left:e,right:t},h=e=>e!==`ground`&&`edge`in e?m[e.edge]:null,g=e=>a[e].map((t,r)=>{let a=new Cd(h(t.fg),h(t.bg));return new W(jd(t,e,n,r),Qd(t,s,i).withAnchor({owner:a,row:0,col:0,inner:void 0}))});if(!u||!d){(f||p)&&(yield*g(f?`lead`:`tail`));return}let _=g(`seam`);yield*a.divider!==a.seam&&_.every(e=>e.style!==void 0&&Xd(e.style,i.colorSystem))?g(`divider`):_}}}};const tf={edge:`left`,part:`bg`},nf={edge:`right`,part:`bg`},rf={edge:`left`,part:`fg`},af={mix:[tf,nf,1/2]},of=`ground`,sf={cap:`lead`},cf={cap:`tail`},lf=(e,t)=>({glyph:e,ascii:t}),uf={glyph:``,thin:``,ascii:`>`,asciiThin:`>`},df={glyph:``,thin:``,ascii:`/`,asciiThin:`/`},ff={glyph:``,thin:``,ascii:`\\`,asciiThin:`\\`},pf={glyph:``,thin:``,ascii:`}`,asciiThin:`}`},mf={glyph:``,thin:``,ascii:`#`,asciiThin:`>`},hf={glyph:``,thin:``,ascii:`]`,asciiThin:`>`},gf={glyph:``,thin:``,ascii:`)`,asciiThin:`)`},_f=(e,t)=>({seam:[{glyph:e,fg:tf,bg:nf}],divider:[{glyph:t,fg:rf,bg:tf}]}),vf=e=>lf(_f(e.glyph,e.thin),_f(e.ascii,e.asciiThin));function yf(e,t){let n=e=>({mix:[tf,nf,e]}),r={glyph:` `,fg:rf,bg:tf};return{seam:[{glyph:e,fg:tf,bg:n(1/3)},{glyph:e,fg:n(1/3),bg:n(2/3)},{glyph:e,fg:n(2/3),bg:nf}],divider:[r,{glyph:t,fg:rf,bg:tf},r]}}function bf(e){let t=[cf,...e,sf];return{seam:t,divider:t}}function xf(e,t){let n=[{glyph:e,fg:t,bg:af}];return{seam:n,divider:n}}function Sf(e){return{seam:xf({oneOf:e},tf).seam,divider:[{glyph:{oneOf:e},fg:rf,bg:af}]}}const Cf=[{glyph:` | `,fg:{role:`strip.separator`},bg:of}],wf={seam:Cf,divider:Cf},Tf={glyph:` `,fg:rf,bg:of},Ef=e=>({glyph:e,fg:{role:`strip.rail`},bg:of}),Df=Object.freeze({powerline:Ud(vf(uf)),prism:Ud(lf(yf(uf.glyph,uf.thin),yf(uf.ascii,uf.asciiThin))),slant:Ud(vf(df)),backslant:Ud(vf(ff)),flame:Ud(vf(pf)),pixel:Ud(vf(mf)),ice:Ud(vf(hf)),bubble:Ud(vf(gf)),capsule:Ud(lf(bf([Tf]),bf([Tf]))),wrapper:Ud(lf(bf([]),bf([]))),metro:Ud(lf(bf([Ef(`──`)]),bf([Ef(`--`)]))),stitch:Ud(lf(xf(`┊`,rf),xf(`:`,rf))),torn:Ud(lf(Sf([`▚▞`,`▞▚`,`▘▗`,`▝▖`,`▖▝`,`▗▘`]),Sf([`/\\`,`\\/`]))),plain:Ud(lf(wf,wf))}),Of=e=>lf({lead:[{glyph:e.glyph,fg:of,bg:nf}],tail:[{glyph:e.glyph,fg:tf,bg:of}]},{lead:[],tail:[{glyph:e.ascii,fg:tf,bg:of}]}),kf=(e,t)=>({lead:[{glyph:e,fg:nf,bg:of}],tail:[{glyph:t,fg:tf,bg:of}]}),Af={lead:[],tail:[]},jf=Object.freeze({powerline:Wd(Of(uf)),slant:Wd(Of(df)),backslant:Wd(Of(ff)),flame:Wd(Of(pf)),pixel:Wd(Of(mf)),ice:Wd(Of(hf)),bubble:Wd(Of(gf)),capsule:Wd(lf(kf(``,``),kf(`(`,`)`))),wrapper:Wd(lf(kf(``,``),kf(`<`,`>`))),flat:Wd(lf(Af,Af))}),Mf=Object.freeze({powerline:new ef(Df.powerline,jf.powerline),prism:new ef(Df.prism,jf.powerline),slant:new ef(Df.slant,jf.slant),backslant:new ef(Df.backslant,jf.backslant),flame:new ef(Df.flame,jf.flame),pixel:new ef(Df.pixel,jf.pixel),ice:new ef(Df.ice,jf.ice),bubble:new ef(Df.bubble,jf.bubble),capsule:new ef(Df.capsule,jf.capsule),wrapper:new ef(Df.wrapper,jf.wrapper),metro:new ef(Df.metro,jf.capsule),stitch:new ef(Df.stitch,jf.flat),torn:new ef(Df.torn,jf.flat),plain:new ef(Df.plain,jf.flat)});function Nf(e,t){if(e.isControl)return``;let{text:n,style:r}=e;if(n.length===0||r===void 0)return n;let i=t.colorSystem===null?``:r.toSgrCodes(t.colorSystem),a=i.length>0?`\x1b[${i}m${n}\x1b[0m`:n,o=t.hyperlinks?r.link:void 0;return o===void 0?a:`${id(o)}${a}]8;;\\`}function Pf(e,t){let n=[];for(let r of e)n.push(Nf(r,t));return n.join(``)}const Ff=/\r|\x1b\[([0-9;:]*)m|\x1b\[([012]?)K|\x1b\[[0-?]*[ -/]*[@-~]|\x1b[\]P_^X][\s\S]*?(?:\x07|\x1b\\|\x9c|$)|\x1b[ -/]*[0-~]/g;function*If(e){let t=0;for(let n of e.matchAll(Ff))n.index>t&&(yield{kind:`text`,text:e.slice(t,n.index)}),n[0]===`\r`&&(yield{kind:`return`}),n[1]!==void 0&&(yield{kind:`sgr`,params:n[1]}),n[2]!==void 0&&(yield{kind:`erase`,mode:n[2]||`0`}),t=n.index+n[0].length;t<e.length&&(yield{kind:`text`,text:e.slice(t)})}function*Lf(e){let t=0;for(let n of sd(e))yield*If(e.slice(t,n.index)),yield{kind:`link`,uri:n.uri},t=n.index+n.length;yield*If(e.slice(t))}function Rf(e){let t=new H(e);return e=>e.add(t)}function zf(e){let t=e.next();return t.done?void 0:t.value}function Bf(e){let t=zf(e);if(t===5){let t=zf(e);return t===void 0?void 0:V.fromAnsi(t)}if(t===2){let[t,n,r]=[zf(e),zf(e),zf(e)];return r===void 0?void 0:V.fromRgb(t,n,r)}}const Vf=new Map([[0,()=>U],...gu.map(e=>[_u[e],Rf({[e]:!0})]),[22,Rf({bold:!1,dim:!1})],[23,Rf({italic:!1})],[24,Rf({underline:!1,underline2:!1})],[25,Rf({blink:!1,blink2:!1})],[27,Rf({reverse:!1})],[28,Rf({conceal:!1})],[29,Rf({strike:!1})],[38,(e,t)=>e.add(new H({color:Bf(t)}))],[39,Rf({color:V.default()})],[48,(e,t)=>e.add(new H({bgcolor:Bf(t)}))],[49,Rf({bgcolor:V.default()})],[58,(e,t)=>(Bf(t),e)],[54,Rf({frame:!1,encircle:!1})],[55,Rf({overline:!1})],...Array.from({length:8},(e,t)=>[[30+t,Rf({color:V.fromAnsi(t)})],[40+t,Rf({bgcolor:V.fromAnsi(t)})],[90+t,Rf({color:V.fromAnsi(t+8)})],[100+t,Rf({bgcolor:V.fromAnsi(t+8)})]]).flat()]),Hf=e=>e;function Uf(e,t){let n=t.split(`;`).filter(e=>/^\d*$/.test(e)).map(e=>Math.min(255,Number(e))).values(),r=e;for(let e of n)r=(Vf.get(e)??Hf)(r,n);return r}const Wf=[` `,U];function Gf(e,t,n){n!==`0`&&e.fill(Wf,0,Math.min(t+1,e.length)),n!==`1`&&(e.length=Math.min(t,e.length))}var Kf=class{sgr=U;link=void 0;decode(e){return(e.match(/[^\n]*\n|[^\n]+/g)??[]).map(e=>this.decodeLine(e.replace(/\r?\n$/,``)))}decodeLine(e){let t=[],n=0;for(let r of Lf(e))switch(r.kind){case`text`:{let e=this.sgr.withLink(this.link);for(let i of r.text)t[n++]=[i,e];break}case`return`:n=0;break;case`erase`:Gf(t,n,r.mode);break;case`sgr`:this.sgr=Uf(this.sgr,r.params);break;case`link`:this.link=r.uri===``?void 0:r.uri;break}let r=[];for(let[e,n]of t){let t=r.at(-1);t?.[1].equals(n)?t[0]+=e:r.push([e,n])}return G.assemble(r)}};function qf(e){return e.end=``,e.plain=e.plain.replaceAll(`
52
- `,` `),e.expandTabs()}var Jf=class{renderable;effect;t;key;theme;constructor(e,t,n){if(this.renderable=e,this.effect=t,!Number.isFinite(n.t))throw RangeError(`Effected needs a finite t, got ${n.t}`);this.t=n.t,this.key=n.key,this.theme=n.theme}render(e){let t=Hu(this.renderable,e);return e.colorSystem===null?t:this._moved(t,e)}*contents(){yield this.renderable}*_moved(e,t){let n=t.colorSystem??B.TRUECOLOR,r=Xf(e,n,this.theme),i=Zf(r),a=this.effect($f(r,()=>i,n,this.theme));yield*W.applyStyle(this._recolored(i,a.at(this.t),n),new H({nextChange:a.nextChange(this.t)}))}*_recolored(e,t,n){for(let{segment:r,look:i,glyphs:a}of e){if(i===void 0){yield r;continue}let{style:e,wire:o,slots:s,pair:c}=i,{terminal:l}=c,u={fg:c.fg,bg:c.bg},d=[];for(let{glyph:e,cell:r}of a){let i=r===void 0?s:tp(t(u,{...r,seed:this.seed(r.row,r.col),terminal:l,reverse:c.reverse}),c.reverse),a=d[d.length-1],f=a!==void 0&&op(a.colors,i)?a.drawn:this.respec(o,s,i,n);a!==void 0&&rp(a.drawn,f)?(a.text+=e,a.cells+=R(e),a.colors=i):d.push({text:e,cells:R(e),colors:i,drawn:f})}if(d.every(e=>rp(e.drawn,o))){yield r;continue}let f=0;for(let t of d){let n=e.shiftedBy(f),r=rp(t.drawn,o)?n:n.add(H.fromColor(t.drawn.color,t.drawn.bgcolor));yield new W(t.text,r),f+=t.cells}}}measure(e){return qu.get(e,this.renderable)}static shows(e,t,n,r){let i=tp(e,e.reverse),a=np(i,tp(t,e.reverse),n,r);return tp({fg:a.fg?.getTruecolor(r,!0)??i.fg,bg:a.bg?.getTruecolor(r,!1)??i.bg},e.reverse)}respec(e,t,n,r){let i=np(t,n,r,this.theme);return{color:i.fg??e.color,bgcolor:i.bg??e.bgcolor}}seed(e,t){return Number.parseInt(ed(`${this.key}:${e}:${t}`),16)/4294967296}};const Yf=V.default();function Xf(e,t,n){return[...e].map(e=>{if(e.isControl)return{segment:e,look:void 0};let r=e.style??H.null(),i=r.drawnColors(t),a={fg:(i.color??Yf).getTruecolor(n,!0),bg:(i.bgcolor??Yf).getTruecolor(n,!1)},o=r.reverse===!0,s=tp({fg:i.color?.isDefault??!0,bg:i.bgcolor?.isDefault??!0},o);return{segment:e,look:{style:r,wire:i,slots:a,pair:{...tp(a,o),terminal:s,reverse:o}}}})}function Zf(e){let t=0,n=0;return e.map(({segment:e,look:r})=>{if(r===void 0)return{segment:e,look:r,glyphs:[]};let i=r.style.anchor,a=0;return{segment:e,look:r,glyphs:[...ss(e.text)].map(e=>{let r=e===`
45
+ `);for(let t=0;t<a.length;t++){t>0&&(n.push(r),r=[]);let o=a[t];o.length>0&&r.push(new e(o,i.style))}}return r.length>0&&n.push(r),n}static adjustLineLength(t,n,r,i=!0){let a=e.getLineLength(t);if(a===n)return t;if(a<n)return i?[...t,new e(` `.repeat(n-a),r)]:t;let o=[],s=n;for(let e of t){if(e.isControl){o.push(e);continue}let t=e.cellLength;if(t<=s)o.push(e),s-=t;else{let[t]=e.splitCells(Qo(s));o.push(t),s=0;break}}return o}static*cropLines(t,n){let r=Math.max(0,n),i=0;for(let n of t){if(n.isControl){yield n;continue}let t=n.text.split(`
46
+ `);for(let e=0;e<t.length;e++){e>0&&(i=0);let[n]=ts(t[e],Qo(r-i));i+=Zo(n),t[e]=n}let a=t.join(`
47
+ `);yield a===n.text?n:new e(a,n.style)}}static splitAndCropLines(t,n){return e.splitLines(t).map(t=>e.adjustLineLength(t,n))}static getLineLength(e){let t=0;for(let n of e)n.isControl||(t+=n.cellLength);return t}static getShape(t){if(t.length===0)return[0,0];let n=0;for(let r of t){let t=e.getLineLength(r);t>n&&(n=t)}return[n,t.length]}static*mergeHorizontal(t,n=0){let r=0;for(let e of t)e.lines.length>r&&(r=e.lines.length);let i=n>0?[new e(` `.repeat(n))]:[];for(let n=0;n<r;n++){for(let r=0;r<t.length;r++){r>0&&(yield*i);let a=t[r];yield*e.adjustLineLength(a.lines[n]??[],a.width)}yield e.line()}}static*simplify(t){let n;for(let r of t){if(!n){n=r;continue}Iu(n.style,r.style)&&!r.isControl&&!n.isControl?n=new e(n.text+r.text,n.style):(yield n,n=r)}n&&(yield n)}static*stripLinks(t){for(let n of t)n.style?.link?yield new e(n.text,n.style.clearMetaAndLinks(),n.control):yield n}static*stripStyles(t){for(let n of t)yield new e(n.text,void 0,n.control)}static*removeColor(t){for(let n of t)n.style?yield new e(n.text,n.style.withoutColor,n.control):yield n}static divide(e,t){if(t.length===0)return[e];let n=[[]],r=0,i=0;for(let a of e){let e=r+a.cellLength,o=[];for(;i<t.length&&t[i]<e;i++){let e=t[i];e<=r?n.push([]):o.push(Qo(e-r))}let[s,...c]=o.length===0?[a]:a.cutAt(o);n[n.length-1].push(s);for(let e of c)n.push(e.hasText?[e]:[]);r=e}for(;i<t.length;i++)n.push([]);return n[n.length-1].length===0&&n.pop(),n}static alignTop(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)];for(;a.length<r;)a.push([...o]);return a.slice(0,r)}static alignBottom(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)],s=Math.max(0,r-a.length),c=[];for(let e=0;e<s;e++)c.push([...o]);return c.push(...a),c.slice(0,r)}static alignMiddle(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)],s=Math.max(0,Math.floor((r-a.length)/2)),c=[];for(let e=0;e<s;e++)c.push([...o]);for(c.push(...a);c.length<r;)c.push([...o]);return c.slice(0,r)}static setShape(t,n,r,i){let a=t.map(t=>e.adjustLineLength(t,n,i)),o=[new e(` `.repeat(n),i)];for(;a.length<r;)a.push([...o]);return a.slice(0,r)}};function Iu(e,t){return e===t?!0:!e||!t?!1:e.equals(t)}const Lu=e=>/^[\x00-\x7F]*$/.test(e);function Ru(e,t,n,r=String){return e.asciiOnly===!0&&!Lu(r(t))?n:t}function zu(e,t){return(e.theme??Nu).resolve(t)}H.parse(`default on default`);function Bu(e){return{...e,maxWidth:es(e.maxWidth)}}function Vu(e){return es(e.maxWidth)<1}function Hu(e,t){let n=Vu(t)?`held`:`drawn`;if(t.onPresent?.(e,n),n===`drawn`)return e.render(t);if(Ku(e))for(let n of e.contents())Hu(n,t);return[]}function Uu(e){return{...e,onPresent:void 0}}function Wu(e,t){let n=Bu(e);if(Number.isFinite(n.maxWidth))return n;let r=t.measure(Uu(n)).maximum;if(!Number.isFinite(r))throw RangeError(`maxWidth is unbounded and this renderable has no natural width to fall back on: its content does not implement measure(), or something inside it asked for an unbounded width of its own. Render it at a finite width, or give the content a measure() that reports a finite maximum.`);return{...n,maxWidth:es(r)}}function Gu(e){return typeof e==`object`&&!!e&&`measure`in e&&typeof e.measure==`function`}function Ku(e){return`contents`in e&&typeof e.contents==`function`}var qu=class e{minimum;maximum;constructor(e,t){this.minimum=e,this.maximum=t}get span(){return this.maximum-this.minimum}normalize(){let t=e=>Number.isNaN(e)?0:e;return new e(Math.max(0,Math.min(t(this.minimum),t(this.maximum))),Math.max(0,t(this.maximum)))}withMaximum(t){return new e(Math.min(this.minimum,t),Math.min(this.maximum,t))}withMinimum(t){let n=Math.max(this.minimum,t);return new e(n,Math.max(this.maximum,n))}clamp(t,n){return new e(Math.min(Math.max(this.minimum,t),n),Math.min(Math.max(this.maximum,t),n))}static get(t,n){if(Vu(t))return new e(0,0);if(!Gu(n))return new e(0,t.maxWidth);let{minimum:r,maximum:i}=n.measure(Uu(t));return new e(r,Math.min(i,t.maxWidth)).normalize()}};function*Ju(e){let t=/\s*\S+\s*/y;for(let n=t.exec(e);n!==null;n=t.exec(e))yield n[0]}function Yu(e){return Zo(e.trimEnd())}function Xu(e){return Array.from(Ju(e),Yu)}function Zu(e,t){let n=rs(e,t);return Zo(n[0])>t?[``,...n]:n}function Qu(e,t,n){if(t<=0)return[];let r=[],i=e=>{e>0&&r.push(Qo(e))},a=0,o=0;for(let r of Ju(e)){let e=Yu(r);if(t-a>=e)a+=Zo(r);else if(n.fold&&e>t){let e=Zu(r,t),n=o;for(let t=0;t<e.length;t+=1){i(n);let r=e[t];t===e.length-1?a=Zo(r):n+=Zo(r)}}else i(o),a=Zo(r);o+=Zo(r)}return r}const $u=new TextEncoder;function ed(e){let t=2166136261;for(let n of $u.encode(e))t=Math.imul(t^n,16777619);return(t>>>0).toString(16).padStart(8,`0`)}const td=`\\x1b\\x07\\x9c`,nd=RegExp(`[${td}]`,`g`);function rd(e){return e.replace(nd,``)}function id(e){let t=rd(e);return`\x1b]8;id=${ed(t)};${t}\x1b\\`}const ad=RegExp(`\\x1b\\]8;([^;${td}]*);([^${td}]*)(?:\\x1b\\\\|\\x07|\\x9c)`),od=new RegExp(ad.source,`g`);function sd(e){return[...e.matchAll(od)].map(e=>({index:e.index,length:e[0].length,params:e[1],uri:e[2]}))}const cd=/[\x00-\x08\x0B-\x1F\x7F-\x9F\u202A-\u202E\u2066-\u206F]/g;function ld(e){return e.replace(cd,``)}const ud=/\s+$/;function dd(e){return e.map(e=>e.text).join(``)}function fd(e){return Zo(ud.exec(dd(e))?.[0]??``)}function pd(e){let t=e.link;if(!t)return e;let n=rd(t);return n===t?e:e.withLink(n)}function md(e){return typeof e==`string`?e:e instanceof H?hd(e):{under:e.under,over:hd(e.over)}}function hd(e){return pd(e.anchor?e.withAnchor(void 0):e)}function gd(e){return e instanceof H?e.isNull:e===``}function _d(e,t){return pd(t instanceof H?t:typeof t==`string`?vd(e,t):vd(e,t.under).add(t.over))}function vd(e,t){try{return zu(e,t)}catch(n){if(!(n instanceof yu))throw n;return e.onStyleError?.(n,t),U}}var yd=class e{start;end;style;constructor(e,t,n){this.start=e,this.end=t,this.style=n}get hasLength(){return this.end>this.start}toString(){return`Span(${this.start}, ${this.end})`}split(t){return t<=this.start||t>=this.end?[this,void 0]:[new e(this.start,t,this.style),new e(t,this.end,this.style)]}move(t){return new e(this.start+t,this.end+t,this.style)}rightCrop(t){return t>=this.end?this:new e(this.start,Math.min(this.end,t),this.style)}extend(t){return new e(this.start,this.end+t,this.style)}},G=class e{_text;_spans;_style;_justify;_overflow;_end;_tabSize;_noWrap;constructor(e,t){this._text=e?ld(e):``,this._spans=[],this._style=md(t?.style??U),this._justify=t?.justify,this._overflow=t?.overflow,this._end=t?.end??`
48
+ `,this._tabSize=hs(t?.tabSize??8),this._noWrap=t?.noWrap??!1}get plain(){return this._text}set plain(e){let t=ld(e);this._text=t;let n=t.length;this._spans=this._spans.map(e=>e.end>n?new yd(e.start,Math.min(e.end,n),e.style):e).filter(e=>e.start<n)}get length(){return this._text.length}get cellLength(){return Zo(gs(this._text,this._tabSize).text)}get hasContent(){return this._text.length>0}get style(){return this._style}set style(e){this._style=md(e)}get justify(){return this._justify}set justify(e){this._justify=e}get overflow(){return this._overflow}set overflow(e){this._overflow=e}get end(){return this._end}set end(e){this._end=e}get noWrap(){return this._noWrap}set noWrap(e){this._noWrap=e}get spans(){return this._spans}resolvedStyle(e){return _d(e,this._style)}edgeStyle(e,t){let n=this.resolvedStyle(t);if(this._text.length===0)return n;let r=e===`left`?0:this._text.length-1,i=n;for(let e of this._spans)e.start<=r&&r<e.end&&(i=i.add(_d(t,e.style)));return i}append(t,n){if(t instanceof e){if(n!==void 0)throw Error(`Style argument must not be provided when appending RichText`);let e=this._text.length;this._text+=t._text,this._addSpan(e,this._text.length,t._style);for(let n of t._spans)this._spans.push(n.move(e));return this}let r=ld(t),i=this._text.length;return this._text+=r,this._addSpan(i,this._text.length,n??``),this}contains(t){let n=t instanceof e?t._text:t;return this._text.includes(n)}at(t){let n=t<0?this._text.length+t:t;return this._text[n]===void 0?new e(``):this.slice(n,n+1)}slice(e,t){let n=this._text,r=n.length,i=e??0,a=t??r,o=i<0?Math.max(0,r+i):Math.min(i,r),s=a<0?Math.max(0,r+a):Math.min(a,r);if(o>=s)return this.blankCopy();let c=n.slice(o,s),l=this.blankCopy(c);for(let e of this._spans){let t=Math.max(e.start,o)-o,n=Math.min(e.end,s)-o;t<n&&l._spans.push(new yd(t,n,e.style))}return l}_addSpan(e,t,n){let r=md(n);gd(r)||this._spans.push(new yd(e,t,r))}stylize(e,t,n){let r=this._text.length,i=t===void 0?0:t<0?r+t:t,a=n===void 0?r:n<0?r+n:n;if(i>=a||i>=r||a<=0)return this;let o=Math.max(0,i),s=Math.min(r,a);return this._addSpan(o,s,e),this}highlightRegex(e,t){let n=this._text,r=0,i=e.flags.includes(`g`)?e.flags:e.flags+`g`,a=new RegExp(e.source,i),o;for(;(o=a.exec(n))!==null;){if(o[0].length===0){a.lastIndex++;continue}if(o.groups){let e=0;for(let[t,n]of Object.entries(o.groups))if(n!==void 0){let r=o[0].indexOf(n,e);if(r>=0){let i=o.index+r;this._addSpan(i,i+n.length,t),e=r+n.length}}r++;continue}this._addSpan(o.index,o.index+o[0].length,t??``),r++}return r}highlightWords(e,t,n){let r=n?.caseSensitive!==!1,i=0;for(let n of e){if(n.length===0)continue;let e=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=r?`g`:`gi`,o=RegExp(`\\b${e}\\b`,a),s;for(;(s=o.exec(this._text))!==null;)this._addSpan(s.index,s.index+s[0].length,t),i++}return i}copy(){let t=new e(this._text,{style:this._style,justify:this._justify,overflow:this._overflow,end:this._end,tabSize:this._tabSize,noWrap:this._noWrap});return t._spans=this._spans.slice(),t}blankCopy(t){return new e(t??``,{style:this._style,justify:this._justify,overflow:this._overflow,end:this._end,tabSize:this._tabSize,noWrap:this._noWrap})}split(e){let t=e??`
49
+ `,n=this._text,r=[],i=0;for(;;){let e=n.indexOf(t,i);if(e===-1){r.push(this.slice(i));break}r.push(this.slice(i,e)),i=e+t.length}return r}divide(e){if(e.length===0)return[this.copy()];let t=[],n=0;for(let r of e)t.push(this.slice(n,r)),n=r;return t.push(this.slice(n)),t}rstrip(){let e=this._text.replace(/\s+$/,``);return e.length<this._text.length&&(this.plain=e),this}pad(e,t){let n=ld(t??` `).repeat(e);return this._spans=this._spans.map(e=>e.move(n.length)),this._text=n+this._text+n,this}expandTabs(){let e=gs(this._text,this._tabSize);return this._spans=this._spans.map(t=>new yd(e.offsetOf(t.start),e.offsetOf(t.end),t.style)),this._text=e.text,this}padLeft(e,t){let n=ld(t??` `).repeat(e);return this._spans=this._spans.map(e=>e.move(n.length)),this._text=n+this._text,this}padRight(e,t){return this._text+=ld(t??` `).repeat(e),this}setLength(e){return this._text.length<e?this._text+=` `.repeat(e-this._text.length):this._text.length>e&&(this.plain=this._text.slice(0,e)),this}extendStyle(e){let t=this._text.length;return this._text+=` `.repeat(e),this._spans=this._spans.map(n=>n.end===t?n.extend(e):n),this}truncate(e,t){if(this.cellLength<=e)return this;this.expandTabs();let n=t?.mode??`right`,r=es(e),i=us(ld(t?.marker??`…`),r),a=Qo(r-Zo(i));if(n===`right`)return this._cropRightTo(a),i&&(this._text+=i),this;if(n===`left`)return this._cropLeftTo(a),i&&(this._spans=this._spans.map(e=>e.move(i.length)),this._text=i+this._text),this;let o=Qo(Math.floor(a/2)),s=Qo(a-o),c=us(this._text,o).length,l=this._text.length-ds(this._text,s).length,u=this._text.slice(0,c),d=this._text.slice(l),f=c,p=l,m=i.length-(p-f),h=[];for(let e of this._spans)e.end<=f?h.push(e):e.start>=p?h.push(e.move(m)):(e.start<f&&h.push(new yd(e.start,f,e.style)),e.end>p&&h.push(new yd(p+m,e.end+m,e.style)));return this._text=u+i+d,this._spans=h,this}_cropRightTo(e){this.plain=us(this._text,e)}_cropLeftTo(e){let t=this._text.length-ds(this._text,e).length,n=-t;this._spans=this._spans.map(e=>{if(!(e.end<=t))return new yd(Math.max(0,e.start+n),e.end+n,e.style)}).filter(e=>e!==void 0),this._text=this._text.slice(t)}align(e,t){let n=this.cellLength;if(n>=t)return this;this.expandTabs();let r=t-n;switch(e){case`left`:this.padRight(r);break;case`right`:this.padLeft(r);break;case`center`:{let e=Math.floor(r/2),t=r-e;this.padLeft(e),this.padRight(t);break}}return this}removeSuffix(e){return this._text.endsWith(e)&&(this.plain=this._text.slice(0,-e.length)),this}appendTokens(e){for(let[t,n]of e)this.append(t,n);return this}static assemble(t,n){let r=new e(``,{style:n?.style});for(let n of t)if(typeof n==`string`)r.append(n);else if(n instanceof e)r.append(n);else{let[e,t]=n;r.append(e,t)}return r}static styled(t,n){let r=new e(t);return r.stylize(n),r}static fromFragments(t,n){let r=new e(``,{end:n?.end??``});for(let e of t)r.append(e);return r}*render(e){let t=gs(this._text,this._tabSize),n=this.resolvedStyle(e),{segments:r,covered:i}=this._buildSegments(t,n,e),a=bd(r,i);r.push(W.line());let o=W.splitLines(r),s=es(Wu(e,this).maxWidth),c=this._overflow??e.overflow??`fold`,l=this._noWrap||(e.noWrap??!1),u=c===`ignore`?es(1/0):s,d=l?es(1/0):u,f=c===`ignore`?void 0:this._justify??e.justify,p=Ru(e,`…`,`.`);for(let e=0;e<o.length;e+=1){let t=o[e],r=a[e],i=e<o.length-1,l=Qu(dd(t),d,{fold:c===`fold`}),m=W.divide(t,l),h=this._justifyLines(m.map((e,t)=>({segments:[...this._fitLine(e,u,c,p)],free:e=>r(t===0?e:l[t-1]+e)})),s,n,f);for(let e=0;e<h.length;e+=1)yield*h[e],(e<h.length-1||i)&&(yield W.line())}this._end&&(yield new W(this._end))}measure(e){let t=gs(this._text,this._tabSize).text.split(`
50
+ `),n=t.reduce((e,t)=>Math.max(e,Zo(t)),0),r=t.flatMap(Xu),i=r.length>0?r.reduce((e,t)=>Math.max(e,t),0):n,a=es(e.maxWidth);return{minimum:Math.min(i,a),maximum:Math.min(n,a)}}_buildSegments({text:e,offsetOf:t},n,r){let i=n=>Math.max(0,Math.min(t(n),e.length)),a=new Set;for(let e of this._spans)a.add(i(e.start)),a.add(i(e.end));a.delete(0),a.delete(e.length);let o=[0,...[...a].sort((e,t)=>e-t),e.length],s=new Map(o.map((e,t)=>[e,t]).reverse()),c=o.slice(0,-1).map(()=>n),l=c.map(()=>!1);for(let e of this._spans){let t=i(e.end),n=_d(r,e.style),a=s.get(i(e.start));for(let e=a;o[e]<t;e++)c[e]=c[e].add(n),l[e]=!0}return{segments:c.map((t,n)=>new W(e.slice(o[n],o[n+1]),t.isNull?void 0:t)),covered:l}}_justifyLines(e,t,n,r){return r===`full`?e.map(({segments:r},i)=>i===e.length-1?r:this._fillLine(r,t,n)):e.map(e=>[...this._justifyLine(e,t,n,r)])}*_justifyLine({segments:e,free:t},n,r,i){let a=r.isNull?void 0:r;switch(i){case`center`:case`right`:{let r=W.adjustLineLength(e,W.getLineLength(e)-fd(e),void 0,!1),o=Math.max(n-W.getLineLength(r),0),s=i===`center`?Math.floor(o/2):o;yield*xd(r,t,s,o-s,a);break}case`left`:yield*xd(e,t,0,Math.max(n-W.getLineLength(e),0),a);break;default:yield*e;break}}_fillLine(e,t,n){let r=dd(e),i=r.split(` `);r.endsWith(` `)&&i.pop();let a=i.length-1,o=Array(a).fill(1),s=i.reduce((e,t)=>e+Zo(t),0)+a;for(let e=0;s<t&&a>0;e=(e+1)%a)o[a-1-e]+=1,s+=1;let c=[],l=0;for(let e=0;e<i.length;e+=1)l+=Zo(i[e]),c.push(l),l+=1,e<a&&c.push(l);let u=W.divide(e,c),d=(e,t)=>e.filter(e=>e.hasText).at(t)?.style??n,f=[];for(let e=0;e<i.length;e+=1)if(f.push(...u[e*2]),e<a){let t=d(u[e*2],-1),r=d(u[e*2+2],0),i=t.equals(r)?t:n;f.push(new W(` `.repeat(o[e]),i.isNull?void 0:i))}return f}*_fitLine(e,t,n,r){let i=W.getLineLength(e);if(i-fd(e)<=t){yield*W.adjustLineLength(e,Math.min(i,t),void 0,!1);return}if(n===`ellipsis`&&t>0){yield*W.adjustLineLength(e,t-1,void 0,!1),yield new W(r);return}yield*W.adjustLineLength(e,t,void 0,!1)}};function bd(e,t){let n=[[]];return e.forEach((e,r)=>{e.text.split(`
51
+ `).forEach((e,i)=>{i>0&&n.push([]);let a=n.at(-1);a.push({end:(a.at(-1)?.end??0)+Zo(e),free:!t[r]})})}),n.map(e=>t=>{let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i].end<=t?n=i+1:r=i}return e[n].free})}function*xd(e,t,n,r,i){if(n+r===0)return yield*e;let a=e.filter(e=>e.text!==``),o=e=>` `.repeat(e),s=W.getLineLength(a);if(s===0)return yield new W(o(n+r),i);let c=a.length-1,l=n>0&&a[0].cellLength>0&&t(0),u=r>0&&a[c].cellLength>0&&t(s-1),d=+!!l,f=u?c:c+1;if(d>f){yield new W(o(n)+a[0].text+o(r),i);return}n>0&&(yield new W(o(n)+(l?a[0].text:``),i)),yield*a.slice(d,f),r>0&&(yield new W((u?a[c].text:``)+o(r),i))}const Sd=Object.freeze({name:`join`});var Cd=class{fg;bg;constructor(e,t){this.fg=e,this.bg=t}};function wd(e,t){for(let n=e;n;n=n.inner){if(t.has(n.owner))return{fg:!0,bg:!0};if(n.owner instanceof Cd){let{fg:e,bg:r}=n.owner;return{fg:e!==null&&t.has(e),bg:r!==null&&t.has(r)}}}return{fg:!1,bg:!1}}function Td(e,t,n,r){let i=e.join(t,n,r);return{render:e=>W.anchorLines([[...Hu(i,e)]],Sd)[0]}}function Ed(e){return{render:t=>W.anchorLines([[...Hu(e,t)]],e)[0]}}var Dd=class{items;joiner;constructor(e,t){this.items=e,this.joiner=t}*render(e){let t=this.items;if(t.length===0)return;let n={...e,justify:void 0};yield*Hu(Td(this.joiner,null,t[0],{index:0}),n);for(let e=0;e<t.length;e++){let r=t[e];yield*Hu(Ed(r),n);let i=e+1<t.length?t[e+1]:null;yield*Hu(Td(this.joiner,r,i,{index:e+1}),n)}yield W.line()}contents(){return this.items}measure(e){let t=0;for(let n of Hu(this,e))t+=n.cellLength;return{minimum:t,maximum:t}}};const Od=[`seam`,`divider`,`lead`,`tail`];function*kd(e){yield e,`mix`in e&&(yield*kd(e.mix[0]),yield*kd(e.mix[1]))}const Ad=e=>typeof e.glyph==`string`?[e.glyph]:e.glyph.oneOf,jd=(e,t,n,r)=>{let i=Ad(e);return i[Math.floor(parseInt(ed(`${t}:${n}:${r}`),16)/2**32*i.length)]},Md=e=>Zo(Ad(e)[0]??``),Nd=e=>e.reduce((e,t)=>e+Md(t),0);function Pd(e,t,n){if(e===`ground`)return n(`mixes ground, whose colour is unknown`);let r=typeof e==`object`&&e?e:{};if((r.edge===`left`||r.edge===`right`)&&(r.part===`bg`||r.part===`fg`))return r.edge===t&&n(`names the ${t} neighbour, which this part is drawn without`),Object.freeze({edge:r.edge,part:r.part});if(typeof r.role==`string`)return Object.freeze({role:r.role});if(Array.isArray(r.mix)&&r.mix.length===3){let[e,i,a]=r.mix;return(typeof a!=`number`||!(a>=0&&a<=1))&&n(`mixes at ${String(a)}, outside 0..1`),Object.freeze({mix:Object.freeze([Pd(e,t,n),Pd(i,t,n),a])})}return n(`has a colour that is not a Paint: ${JSON.stringify(e)}`)}const Fd=(e,t,n)=>e===`ground`?e:Pd(e,t,n),Id={seam:void 0,divider:void 0,lead:`left`,tail:`right`},Ld={seam:`seam`,divider:`seam`,lead:`caps`,tail:`caps`};function Rd(e,t,n,r){let i=e.glyph,a=typeof i==`object`&&i?i.oneOf:void 0;typeof i!=`string`&&!(Array.isArray(a)&&a.every(e=>typeof e==`string`))&&r(`has a glyph that is neither a string nor a oneOf of strings: ${JSON.stringify(i)}`),e.fg===`ground`&&e.bg===`ground`&&r(`has ground on both sides`);let o=Ad(e);return o.length===0&&r(`has an empty oneOf`),o.some(t=>Zo(t)!==Md(e))&&r(`has oneOf members of different widths`),t===`ascii`&&!o.every(Lu)&&r(`is not ASCII`),Object.freeze({glyph:typeof e.glyph==`string`?e.glyph:Object.freeze({oneOf:Object.freeze([...o])}),fg:Fd(e.fg,Id[n],r),bg:Fd(e.bg,Id[n],r)})}function zd(e,t,n,r){let i=e,a=Ld[n];if(typeof i?.[t]!=`object`||i[t]===null)throw Error(`${a}: has no ${t} form`);let o=i[t][n];if(!Array.isArray(o))throw Error(`${a}: ${t} ${n} is not a list of cells`);return Object.freeze(o.map((e,i)=>{let o=e=>{throw Error(`${a}: ${t} ${n}[${i}] ${e}`)};return typeof e==`object`&&e?r(e,o):o(`is not a cell`)}))}const Bd=(e,t)=>(n,r)=>Rd(n,e,t,r),Vd=(e,t)=>(n,r)=>{if(!(`cap`in n))return Rd(n,e,t,r);let{cap:i}=n;return Object.keys(n).length!==1&&r(`names a cap and draws cells of its own; a cell is one or the other`),i===`lead`||i===`tail`?Object.freeze({cap:i}):r(`names a cap that is neither lead nor tail: ${JSON.stringify(i)}`)},Hd=e=>[Nd(e.filter(e=>!(`cap`in e))),e.filter(e=>`cap`in e&&e.cap===`lead`).length,e.filter(e=>`cap`in e&&e.cap===`tail`).length];function Ud(e){let t=t=>{let n=zd(e,t,`seam`,Vd(t,`seam`)),r=e[t].divider===e[t].seam?n:zd(e,t,`divider`,Vd(t,`divider`)),[i,a]=[Hd(n),Hd(r)];if(i.some((e,t)=>e!==a[t]))throw Error(`seam: ${t} divider is not the width of the seam under every caps`);return Object.freeze({seam:n,divider:r})};return Object.freeze({glyph:t(`glyph`),ascii:t(`ascii`)})}function Wd(e){let t=t=>Object.freeze({lead:zd(e,t,`lead`,Bd(t,`lead`)),tail:zd(e,t,`tail`,Bd(t,`tail`))});return Object.freeze({glyph:t(`glyph`),ascii:t(`ascii`)})}function Gd(e,t){let n=e=>e.flatMap(e=>`cap`in e?t[e.cap]:[e]),r=n(e.seam);return{seam:r,divider:e.divider===e.seam?r:n(e.divider),lead:t.lead,tail:t.tail}}const Kd=(e,t)=>e.some(e=>[e.fg,e.bg].some(e=>e!==`ground`&&[...kd(e)].some(e=>`edge`in e&&e.edge===t&&e.part===`bg`)));function qd(e){let t=[...e.seam,...e.divider];return{shape:e,reads:{seam:{left:Kd(t,`left`),right:Kd(t,`right`)},lead:Kd(e.lead,`right`),tail:Kd(e.tail,`left`)}}}function Jd(e){return e!==void 0&&!e.isDefault?e:void 0}function Yd(e){return e.flattenAlpha(Cs)}function Xd(e,t){if(e.reverse)return!1;let{color:n,bgcolor:r}=e.drawnColors(t??z.TRUECOLOR);if(n===void 0||r===void 0)return!1;let i=n.fixedValue,a=r.fixedValue;return i!==void 0&&a!==void 0?V.fromRgba(i).deltaE(V.fromRgba(a))<.04:n.number===void 0?n.name===r.name:n.number===r.number}function Zd(e,t,n){if(`edge`in e){let n=t[e.edge];if(e.part===`fg`)return n?.color;let r=Jd(n?.bgcolor);return r&&Yd(r)}if(`role`in e)return zu(n,e.role).color;let[r,i,a]=e.mix,o=Zd(r,t,n),s=Zd(i,t,n);return o&&s&&B.blend(o,s,a)}function Qd(e,t,n){return e.fg===`ground`?new H({color:e.bg===`ground`?void 0:Zd(e.bg,t,n),reverse:!0}):new H({color:Zd(e.fg,t,n),bgcolor:e.bg===`ground`?void 0:Zd(e.bg,t,n)})}const $d=e=>Od.flatMap(t=>e[t].flatMap(Ad)).join(``);var ef=class{seam;caps;_forms;constructor(e,t){this.seam=Ud(e),this.caps=Wd(t),this._forms={glyph:qd(Gd(this.seam.glyph,this.caps.glyph)),ascii:qd(Gd(this.seam.ascii,this.caps.ascii))}}join(e,t,{index:n}){let r=this._forms;return{*render(i){let{shape:a,reads:o}=Ru(i,r.glyph,r.ascii,e=>$d(e.shape)),s={left:e?.edgeStyle(`right`,i),right:t?.edgeStyle(`left`,i)},c=Jd(s.left?.bgcolor),l=Jd(s.right?.bgcolor),u=e!==null&&(!o.seam.left||c!==void 0),d=t!==null&&(!o.seam.right||l!==void 0),f=d&&(!o.lead||l!==void 0),p=u&&(!o.tail||c!==void 0),m={left:e,right:t},h=e=>e!==`ground`&&`edge`in e?m[e.edge]:null,g=e=>a[e].map((t,r)=>{let a=new Cd(h(t.fg),h(t.bg));return new W(jd(t,e,n,r),Qd(t,s,i).withAnchor({owner:a,row:0,col:0,inner:void 0}))});if(!u||!d){(f||p)&&(yield*g(f?`lead`:`tail`));return}let _=g(`seam`);yield*a.divider!==a.seam&&_.every(e=>e.style!==void 0&&Xd(e.style,i.colorSystem))?g(`divider`):_}}}};const tf={edge:`left`,part:`bg`},nf={edge:`right`,part:`bg`},rf={edge:`left`,part:`fg`},af={mix:[tf,nf,1/2]},of=`ground`,sf={cap:`lead`},cf={cap:`tail`},lf=(e,t)=>({glyph:e,ascii:t}),uf={glyph:``,thin:``,ascii:`>`,asciiThin:`>`},df={glyph:``,thin:``,ascii:`/`,asciiThin:`/`},ff={glyph:``,thin:``,ascii:`\\`,asciiThin:`\\`},pf={glyph:``,thin:``,ascii:`}`,asciiThin:`}`},mf={glyph:``,thin:``,ascii:`#`,asciiThin:`>`},hf={glyph:``,thin:``,ascii:`]`,asciiThin:`>`},gf={glyph:``,thin:``,ascii:`)`,asciiThin:`)`},_f=(e,t)=>({seam:[{glyph:e,fg:tf,bg:nf}],divider:[{glyph:t,fg:rf,bg:tf}]}),vf=e=>lf(_f(e.glyph,e.thin),_f(e.ascii,e.asciiThin));function yf(e,t){let n=e=>({mix:[tf,nf,e]}),r={glyph:` `,fg:rf,bg:tf};return{seam:[{glyph:e,fg:tf,bg:n(1/3)},{glyph:e,fg:n(1/3),bg:n(2/3)},{glyph:e,fg:n(2/3),bg:nf}],divider:[r,{glyph:t,fg:rf,bg:tf},r]}}function bf(e){let t=[cf,...e,sf];return{seam:t,divider:t}}function xf(e,t){let n=[{glyph:e,fg:t,bg:af}];return{seam:n,divider:n}}function Sf(e){return{seam:xf({oneOf:e},tf).seam,divider:[{glyph:{oneOf:e},fg:rf,bg:af}]}}const Cf=[{glyph:` | `,fg:{role:`strip.separator`},bg:of}],wf={seam:Cf,divider:Cf},Tf={glyph:` `,fg:rf,bg:of},Ef=e=>({glyph:e,fg:{role:`strip.rail`},bg:of}),Df=Object.freeze({powerline:Ud(vf(uf)),prism:Ud(lf(yf(uf.glyph,uf.thin),yf(uf.ascii,uf.asciiThin))),slant:Ud(vf(df)),backslant:Ud(vf(ff)),flame:Ud(vf(pf)),pixel:Ud(vf(mf)),ice:Ud(vf(hf)),bubble:Ud(vf(gf)),capsule:Ud(lf(bf([Tf]),bf([Tf]))),wrapper:Ud(lf(bf([]),bf([]))),metro:Ud(lf(bf([Ef(`──`)]),bf([Ef(`--`)]))),stitch:Ud(lf(xf(`┊`,rf),xf(`:`,rf))),torn:Ud(lf(Sf([`▚▞`,`▞▚`,`▘▗`,`▝▖`,`▖▝`,`▗▘`]),Sf([`/\\`,`\\/`]))),plain:Ud(lf(wf,wf))}),Of=e=>lf({lead:[{glyph:e.glyph,fg:of,bg:nf}],tail:[{glyph:e.glyph,fg:tf,bg:of}]},{lead:[],tail:[{glyph:e.ascii,fg:tf,bg:of}]}),kf=(e,t)=>({lead:[{glyph:e,fg:nf,bg:of}],tail:[{glyph:t,fg:tf,bg:of}]}),Af={lead:[],tail:[]},jf=Object.freeze({powerline:Wd(Of(uf)),slant:Wd(Of(df)),backslant:Wd(Of(ff)),flame:Wd(Of(pf)),pixel:Wd(Of(mf)),ice:Wd(Of(hf)),bubble:Wd(Of(gf)),capsule:Wd(lf(kf(``,``),kf(`(`,`)`))),wrapper:Wd(lf(kf(``,``),kf(`<`,`>`))),flat:Wd(lf(Af,Af))}),Mf=Object.freeze({powerline:new ef(Df.powerline,jf.powerline),prism:new ef(Df.prism,jf.powerline),slant:new ef(Df.slant,jf.slant),backslant:new ef(Df.backslant,jf.backslant),flame:new ef(Df.flame,jf.flame),pixel:new ef(Df.pixel,jf.pixel),ice:new ef(Df.ice,jf.ice),bubble:new ef(Df.bubble,jf.bubble),capsule:new ef(Df.capsule,jf.capsule),wrapper:new ef(Df.wrapper,jf.wrapper),metro:new ef(Df.metro,jf.capsule),stitch:new ef(Df.stitch,jf.flat),torn:new ef(Df.torn,jf.flat),plain:new ef(Df.plain,jf.flat)});function Nf(e,t){if(e.isControl)return``;let{text:n,style:r}=e;if(n.length===0||r===void 0)return n;let i=t.colorSystem===null?``:r.toSgrCodes(t.colorSystem),a=i.length>0?`\x1b[${i}m${n}\x1b[0m`:n,o=t.hyperlinks?r.link:void 0;return o===void 0?a:`${id(o)}${a}]8;;\\`}function Pf(e,t){let n=[];for(let r of e)n.push(Nf(r,t));return n.join(``)}const Ff=/\r|\x1b\[([0-9;:]*)m|\x1b\[([012]?)K|\x1b\[[0-?]*[ -/]*[@-~]|\x1b[\]P_^X][\s\S]*?(?:\x07|\x1b\\|\x9c|$)|\x1b[ -/]*[0-~]/g;function*If(e){let t=0;for(let n of e.matchAll(Ff))n.index>t&&(yield{kind:`text`,text:e.slice(t,n.index)}),n[0]===`\r`&&(yield{kind:`return`}),n[1]!==void 0&&(yield{kind:`sgr`,params:n[1]}),n[2]!==void 0&&(yield{kind:`erase`,mode:n[2]||`0`}),t=n.index+n[0].length;t<e.length&&(yield{kind:`text`,text:e.slice(t)})}function*Lf(e){let t=0;for(let n of sd(e))yield*If(e.slice(t,n.index)),yield{kind:`link`,uri:n.uri},t=n.index+n.length;yield*If(e.slice(t))}function Rf(e){let t=new H(e);return e=>e.add(t)}function zf(e){let t=e.next();return t.done?void 0:t.value}function Bf(e){let t=zf(e);if(t===5){let t=zf(e);return t===void 0?void 0:B.fromAnsi(t)}if(t===2){let[t,n,r]=[zf(e),zf(e),zf(e)];return r===void 0?void 0:B.fromRgb(t,n,r)}}const Vf=new Map([[0,()=>U],...gu.map(e=>[_u[e],Rf({[e]:!0})]),[22,Rf({bold:!1,dim:!1})],[23,Rf({italic:!1})],[24,Rf({underline:!1,underline2:!1})],[25,Rf({blink:!1,blink2:!1})],[27,Rf({reverse:!1})],[28,Rf({conceal:!1})],[29,Rf({strike:!1})],[38,(e,t)=>e.add(new H({color:Bf(t)}))],[39,Rf({color:B.default()})],[48,(e,t)=>e.add(new H({bgcolor:Bf(t)}))],[49,Rf({bgcolor:B.default()})],[58,(e,t)=>(Bf(t),e)],[54,Rf({frame:!1,encircle:!1})],[55,Rf({overline:!1})],...Array.from({length:8},(e,t)=>[[30+t,Rf({color:B.fromAnsi(t)})],[40+t,Rf({bgcolor:B.fromAnsi(t)})],[90+t,Rf({color:B.fromAnsi(t+8)})],[100+t,Rf({bgcolor:B.fromAnsi(t+8)})]]).flat()]),Hf=e=>e;function Uf(e,t){let n=t.split(`;`).filter(e=>/^\d*$/.test(e)).map(e=>Math.min(255,Number(e))).values(),r=e;for(let e of n)r=(Vf.get(e)??Hf)(r,n);return r}const Wf=[` `,U];function Gf(e,t,n){n!==`0`&&e.fill(Wf,0,Math.min(t+1,e.length)),n!==`1`&&(e.length=Math.min(t,e.length))}var Kf=class{sgr=U;link=void 0;decode(e){return(e.match(/[^\n]*\n|[^\n]+/g)??[]).map(e=>this.decodeLine(e.replace(/\r?\n$/,``)))}decodeLine(e){let t=[],n=0;for(let r of Lf(e))switch(r.kind){case`text`:{let e=this.sgr.withLink(this.link);for(let i of r.text)t[n++]=[i,e];break}case`return`:n=0;break;case`erase`:Gf(t,n,r.mode);break;case`sgr`:this.sgr=Uf(this.sgr,r.params);break;case`link`:this.link=r.uri===``?void 0:r.uri;break}let r=[];for(let[e,n]of t){let t=r.at(-1);t?.[1].equals(n)?t[0]+=e:r.push([e,n])}return G.assemble(r)}};function qf(e){return e.end=``,e.plain=e.plain.replaceAll(`
52
+ `,` `),e.expandTabs()}var Jf=class{renderable;effect;t;key;theme;constructor(e,t,n){if(this.renderable=e,this.effect=t,!Number.isFinite(n.t))throw RangeError(`Effected needs a finite t, got ${n.t}`);this.t=n.t,this.key=n.key,this.theme=n.theme}render(e){let t=Hu(this.renderable,e);return e.colorSystem===null?t:this._moved(t,e)}*contents(){yield this.renderable}*_moved(e,t){let n=t.colorSystem??z.TRUECOLOR,r=Xf(e,n,this.theme),i=Zf(r),a=this.effect($f(r,()=>i,n,this.theme));yield*W.applyStyle(this._recolored(i,a.at(this.t),n),new H({nextChange:a.nextChange(this.t)}))}*_recolored(e,t,n){for(let{segment:r,look:i,glyphs:a}of e){if(i===void 0){yield r;continue}let{style:e,wire:o,slots:s,pair:c}=i,{terminal:l}=c,u={fg:c.fg,bg:c.bg},d=[];for(let{glyph:e,cell:r}of a){let i=r===void 0?s:tp(t(u,{...r,seed:this.seed(r.row,r.col),terminal:l,reverse:c.reverse}),c.reverse),a=d[d.length-1],f=a!==void 0&&op(a.colors,i)?a.drawn:this.respec(o,s,i,n);a!==void 0&&rp(a.drawn,f)?(a.text+=e,a.cells+=Zo(e),a.colors=i):d.push({text:e,cells:Zo(e),colors:i,drawn:f})}if(d.every(e=>rp(e.drawn,o))){yield r;continue}let f=0;for(let t of d){let n=e.shiftedBy(f),r=rp(t.drawn,o)?n:n.add(H.fromColor(t.drawn.color,t.drawn.bgcolor));yield new W(t.text,r),f+=t.cells}}}measure(e){return qu.get(e,this.renderable)}static shows(e,t,n,r){let i=tp(e,e.reverse),a=np(i,tp(t,e.reverse),n,r);return tp({fg:a.fg?.getTruecolor(r,!0)??i.fg,bg:a.bg?.getTruecolor(r,!1)??i.bg},e.reverse)}respec(e,t,n,r){let i=np(t,n,r,this.theme);return{color:i.fg??e.color,bgcolor:i.bg??e.bgcolor}}seed(e,t){return Number.parseInt(ed(`${this.key}:${e}:${t}`),16)/4294967296}};const Yf=B.default();function Xf(e,t,n){return[...e].map(e=>{if(e.isControl)return{segment:e,look:void 0};let r=e.style??H.null(),i=r.drawnColors(t),a={fg:(i.color??Yf).getTruecolor(n,!0),bg:(i.bgcolor??Yf).getTruecolor(n,!1)},o=r.reverse===!0,s=tp({fg:i.color?.isDefault??!0,bg:i.bgcolor?.isDefault??!0},o);return{segment:e,look:{style:r,wire:i,slots:a,pair:{...tp(a,o),terminal:s,reverse:o}}}})}function Zf(e){let t=0,n=0;return e.map(({segment:e,look:r})=>{if(r===void 0)return{segment:e,look:r,glyphs:[]};let i=r.style.anchor,a=0;return{segment:e,look:r,glyphs:[...cs(e.text)].map(e=>{let r=e===`
53
53
  `?void 0:{row:t,col:n,anchor:i&&mu(i,a)};return[t,n]=e===`
54
- `?[t+1,0]:[t,n+R(e)],a+=R(e),{glyph:e,cell:r}})}})}function Qf(e){return[e.underline,e.underline2,e.strike,e.overline,e.frame,e.encircle].some(e=>e===!0)}function $f(e,t,n,r){let i=r.backgroundColor.hex,a,o=()=>t().flatMap(({look:e,glyphs:t})=>{if(e===void 0)return[];let n=e.pair.bg.hex!==i||Qf(e.style);return t.flatMap(({glyph:e,cell:t})=>t!==void 0&&(e.trim()!==``||n)?[t]:[])}),s=e.flatMap(({segment:e,look:t})=>t!==void 0&&e.text.trim()!==``&&!hu(t.style.anchor,Sd)?[t.pair]:[]),c=[...new Map(s.map(e=>[`${e.fg.hex}/${e.bg.hex}/${e.terminal.fg}/${e.terminal.bg}/${e.reverse}`,e])).values()],l=e=>c.flatMap(t=>t.terminal[e]?[]:[t[e].hex]);return{cells:()=>a??=o(),pairs:c,colors:new Set([...l(`fg`),...l(`bg`)]),fills:new Set(l(`bg`)),depth:n,theme:r}}function ep(e,...t){let n=new Set(t),r=e=>wd(e.anchor,n),i=({fg:e,bg:t})=>e||t,a=e=>({...e,cells:()=>e.cells().filter(e=>i(r(e)))});return t=>au.map(e(a(t)),e=>(t,n)=>{let a=r(n);if(!i(a))return t;let o=e(t,n);return{fg:a.fg?o.fg:t.fg,bg:a.bg?o.bg:t.bg}})}function tp(e,t){return t?{fg:e.bg,bg:e.fg}:e}function np(e,t,n,r){let i=t.bg.compositeOver(Ss),a=t.fg.compositeOver(i);return{fg:V.matchMove(e.fg,a,n,r,!0),bg:V.matchMove(e.bg,i,n,r,!1)}}function rp(e,t){return ip(e.color,t.color,!0)&&ip(e.bgcolor,t.bgcolor,!1)}function ip(e,t,n){return e===t||ap(e,n)===ap(t,n)}function ap(e,t){return e?.getAnsiCodes(t).join(`;`)??``}function op(e,t){return sp(e.fg,t.fg)&&sp(e.bg,t.bg)}function sp(e,t){return e.red===t.red&&e.green===t.green&&e.blue===t.blue&&e.alpha===t.alpha}const cp=(()=>{let e=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];return[...e,...e]})(),lp=e=>e*e*e*(e*(e*6-15)+10),up=(e,t,n)=>e+n*(t-e);function dp(e,t,n,r){let i=e&15,a=i<8?t:n,o=i<4?n:i===12||i===14?t:r;return(i&1?-a:a)+(i&2?-o:o)}function fp(e,t,n){let r=Math.floor(e),i=Math.floor(t),a=Math.floor(n),o=r&255,s=i&255,c=a&255;e-=r,t-=i,n-=a;let l=lp(e),u=lp(t),d=lp(n),f=cp[o]+s,p=cp[f]+c,m=cp[f+1]+c,h=cp[o+1]+s,g=cp[h]+c,_=cp[h+1]+c;return up(up(up(dp(cp[p],e,t,n),dp(cp[g],e-1,t,n),l),up(dp(cp[m],e,t-1,n),dp(cp[_],e-1,t-1,n),l),u),up(up(dp(cp[p+1],e,t,n-1),dp(cp[g+1],e-1,t,n-1),l),up(dp(cp[m+1],e,t-1,n-1),dp(cp[_+1],e-1,t-1,n-1),l),u),d)}function pp(e,t,n,r){let i=0,a=1,o=0;for(let s=0;s<r;s++){let r=2**s;i+=a*fp(e*r,t*r,n*r),o+=a,a/=2}return i/o}function mp(e,t){let n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)}function hp(e,t,n){let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)}const gp=Array.from({length:48},(e,t)=>(t+1)/48);function _p(e,t){return Math.min(ws(e.fg,e.bg),4.5)-(t===B.TRUECOLOR?.01:0)}const vp=[`fg`,`bg`];function yp({pairs:e,depth:t,theme:n},r,i){let a=(e,t)=>e.terminal[t]?void 0:e[t].hex,o=new Map(e.flatMap(e=>vp.flatMap(t=>{let n=a(e,t);return n===void 0?[]:[[n,e[t]]]}))),s=new Map([...r].filter(e=>!o.has(e)).map(e=>[e,1])),c=e=>Mc.fromRgba(o.get(e)).l;for(let l of[...r].filter(e=>o.has(e)).sort((e,t)=>c(t)-c(e))){let r=e.flatMap(e=>{let t=vp.find(t=>a(e,t)===l);if(t===void 0)return[];let n=a(e,t===`fg`?`bg`:`fg`);return[[e,t,n===void 0?0:s.get(n)??0]]}),o=e=>r.every(([r,a,o])=>{let s=_p(r,t),c=(t,n)=>Ep(i,r[t],(t===a?e:o)*n);return gp.every(e=>{let i=Jf.shows(r,{fg:c(`fg`,e),bg:c(`bg`,e)},t,n);return ws(i.fg,i.bg)>=s})}),[c,u]=o(1)?[1,1]:[0,1];for(let e=0;e<20&&u-c>.001;e++){let e=(c+u)/2;[c,u]=o(e)?[e,u]:[c,e]}s.set(l,c)}return s}function bp(e,t){let n=new WeakMap;return wp(Cp(e,r=>{let i=t??r.colors,a=[xp(r),`|`,...i].join(` `),o=n.get(r.theme)??new Go;return n.set(r.theme,o),o.get(a,()=>yp(r,i,e.touch))}))}function xp({depth:e,pairs:t}){return[e,...t.map(Sp)].join(` `)}function Sp({fg:e,bg:t,terminal:n,reverse:r}){return`${e.hex}/${t.hex}/${n.fg}/${n.bg}/${r}`}function Cp(e,t){return n=>{let r=t(n);return au.continuous(t=>{let i=e.field(t,n);return({fg:t,bg:n},a)=>{let o=Math.round(Ap(i(a))*48)/48,s=(t,n)=>Ep(e.touch,t,(n?0:r.get(t.hex)??0)*o);return{fg:s(t,a.terminal.fg),bg:s(n,a.terminal.bg)}}})}}function wp(e){return t=>Tp(t.depth)?au.constant(e=>e):e(t)}function Tp(e){switch(e){case B.DEFAULT:case B.STANDARD:case B.WINDOWS:return!0;case B.EIGHT_BIT:case B.TRUECOLOR:return!1}}function Ep(e,t,n){return n===0?t:e(t,n)}function Dp(e){if(!(Number.isFinite(e.seconds)&&e.seconds>0))throw RangeError(`curve: seconds must be a positive number of seconds, got ${e.seconds}`);if(!(e.swing>=0&&e.swing<=1))throw RangeError(`curve: swing must be in [0, 1], got ${e.swing}`)}const Op={shimmer:{seconds:109,ease:ql.linear,swing:.9},pulse:{seconds:43,ease:ql.linear,swing:.85},sparkle:{seconds:139,ease:ql.linear,swing:.95},wheel:{seconds:907,ease:ql.linear,swing:1},fade:{seconds:20,ease:ql[`ease-in-out`],swing:1},dissolve:{seconds:30,ease:ql[`ease-in-out`],swing:1}},kp={sun:new z(255,228,176),firefly:new z(222,245,140)},Ap=e=>Math.min(1,Math.max(0,e));function jp(e,t,n){if(!(n>=0&&n<=1))throw RangeError(`blend: w must be in [0, 1]; got ${n}`);let r=Math.PI/180,i=(1-n)*e.c*Math.cos(e.h*r)+n*t.c*Math.cos(t.h*r),a=(1-n)*e.c*Math.sin(e.h*r)+n*t.c*Math.sin(t.h*r);return new Mc((1-n)*e.l+n*t.l,Math.hypot(i,a),Math.atan2(a,i)/r,e.alpha)}function Mp(e){let t=Mc.fromRgba(e);return(e,n)=>{let r=Mc.fromRgba(e);return jp(r,new Mc(Math.max(r.l,t.l),t.c,t.h,t.alpha),n).toRgba()}}const Np=(e,t)=>t*e[e.length-1][0];function Pp(e,t,n){let r=t/n,i=e.findIndex(([e])=>r<e);if(!(r>0)||i<0)return 0;let[a,o]=i===0?[0,0]:e[i-1],[s,c]=e[i];return n*(o+(c-o)*(1-Math.cos(Math.PI*(r-a)/(s-a)))/2)}function Fp(e,t,n){let r=Np(e,n),i=t=>{let r=0;for(let i=0;i<24;i++)r+=Pp(e,(i+.5)/24*t,n);return r*t};return i(Math.min(Math.max(t,0),r))/i(r)}const Ip=[[.24,1],[.6,0]];function Lp(e,t,n){Dp(e);let r=.9+.2*mp(n,3.1),i=t=>.1*fp(t/(3*e.seconds),.5,.5+n),a=i(0);return{touch:Mp(t),field:t=>{let o=r*t/e.seconds+i(t)-a,s=Math.floor(o),c=.7+.3*hp(-.5,.5,fp(s*.37,2.1,n)),l=.5-.5*Math.cos(2*Math.PI*(o-s)),u=e.swing*e.ease(c*l);return()=>u}}}const Rp=e=>Math.abs(e)>=1?0:(1-e*e)**3;function zp(e,t,n,r){Dp(e);let i=e.seconds,a=i/2,o=e=>hp(-.4,.4,fp(e/7,3.3,5.5+r)),s=.7,c=.51,l=.4,u=(e,n,u)=>{let d=o(e),f=(mp(e,7.5+r)<.35+.6*d)*(.3+.7*d*(.6+.4*mp(e,8.5+r))),p=i*u/80*(c+l*mp(e,5.5+r)),m=Ap((n-(e+s*mp(e,6.5+r))*a)/p);return{strength:f,centre:m*u-t+.06*u*Math.sin(Math.PI*m)*fp(m,2.7,e+r)}},d=(e,t)=>{let n=s+(c+l)*i*t/80/a,r=Math.floor(e/a),o=[];for(let i=Math.max(0,Math.ceil(r-n));i<=r;i++)o.push(u(i,e,t));return o},f=(e,t,n)=>Math.exp(-((fp(e,t,n)/.8)**2));return{touch:Mp(n),field:(n,i)=>{let[a,o]=Gp(i.cells().map(e=>e.col)),s=d(n,o-a+1+2*t);return i=>{let o=0;for(let{strength:e,centre:n}of s)o=Math.max(o,e*Rp((i.col-a-n)/t));let c=i.row+r,l=.8*fp(i.col*.05,c*.3+1.3,n*.02),u=(f(i.col*.21+l,c*.9,n*.022)*f(i.col*.33+9.1-l,c*.7,n*.018+4.2))**2;return e.swing*e.ease(o*(.1+.6*u))}}}}function Bp(e,t,n){Dp(e);let r=e.seconds,i=22.1,a=3.1,o=(e,t,i,a,o)=>{let s=e*4.9+t*31.7+.3+n,c=e+.5+.7*fp(e*1.7+.2,.3+t*2.9,.5+n),l=i+mp(e+t*1013,.7+n)*r,u=Math.floor(l/r),d=mp(u,s+1)<.15?0:1,f=.5+.5*mp(u,s+2),p=mp(u,s+3)*(1-Np(Ip,f)),m=l/r-u-p;return{x:a+c*8+5*(2*mp(u,s+4)-1)+5*f*(2*mp(u,s+5)-1)*Fp(Ip,m,f)+1.5*fp(s,.1,i*.035),y:o+t*3+.6*fp(s,2.2,i*.035),glow:d*Pp(Ip,m,f)}};return{touch:Mp(t),field:(t,n)=>{let r=n.cells(),[s,c]=Gp(r.map(e=>e.col)),[l,u]=Gp(r.map(e=>e.row)),d=e=>(e-s)/8-.5,f=e=>(e-l)/3,[p,m]=[Math.ceil(d(s-i)),Math.floor(d(c+i))],[h,g]=[Math.ceil(f(l-a)),Math.floor(f(u+a))],_=Array.from({length:g-h+1},(e,n)=>Array.from({length:m-p+1},(e,r)=>o(p+r,h+n,t,s,l)));return t=>{let n=0,[r,o]=[Math.max(p,Math.ceil(d(t.col-i))),Math.min(m,Math.floor(d(t.col+i)))],[s,c]=[Math.max(h,Math.ceil(f(t.row-a))),Math.min(g,Math.floor(f(t.row+a)))];for(let e=s;e<=c;e++)for(let i=r;i<=o;i++){let r=_[e-h][i-p];n=Math.max(n,r.glow*Rp(Math.hypot(t.col-r.x,2*(t.row-r.y))/5))}return e.swing*e.ease(n)}}}}function Vp(e,t){return n=>{let r=Mc.fromRgba(n.theme.backgroundColor);return au.continuous(i=>{let a=e(i,n);return(e,n)=>{let i=t*(1-Ap(a(n)));if(i===0)return e;let o=jp(Mc.fromRgba(e.bg),r,i);return{fg:jp(Mc.fromRgba(e.fg),o,i).toRgba(),bg:o.toRgba()}}})}}function Hp(e){let t=new Map;return n=>{let r=`${n.row}:${n.col}`,i=t.get(r)??Ap(.5+1.1*pp(n.col*.09+1.4*fp(n.col*.035,n.row*.2+2.6,e+.5),n.row*.45,e,3));return t.set(r,i),i}}function Up(e,t){let n=t=>t>=e.seconds;return{effect:r=>{let i=t(r);return{at:e=>i.at(e),nextChange:e=>n(e)?1/0:i.nextChange(e),lastChange:t=>n(t)?e.seconds:i.lastChange(t)}},done:n}}function Wp(e,t){let n=new Map,r=e=>`${e.row}:${e.col}`;return i=>{let[a,o]=Gp(i.map(t)),s=(o>a?.55:0)*e.seconds,c=iu.once(0,e.seconds-s),l=e=>{let n=o>a?Ap((t(e)-a)/(o-a)):0;return{along:n,progress:e=>c(e-n*s)}};for(let e of i){let t=r(e);n.set(t,n.get(t)??l(e))}return e=>n.get(r(e))??l(e)}}function Gp(e){let t=e[0]??0,n=t;for(let r of e)t=Math.min(t,r),n=Math.max(n,r);return[t,n]}function Kp(e,t){Dp(e);let n=Wp(e,Hp(1.7+t));return Up(e,Vp((t,r)=>{let i=n(r.cells());return n=>e.ease(i(n).progress(t))},e.swing))}const qp={depth:.4,from:.5,to:.95,maskFrom:.35,maskTo:.75,late:.6};function Jp(e,t){Dp(e);let n=Hp(9.3+t),r=Wp(e,Hp(4.2+t)),{depth:i,from:a,to:o,maskFrom:s,maskTo:c,late:l}=qp;return Up(e,Vp((t,u)=>{let d=r(u.cells());return r=>{let{along:u,progress:f}=d(r),p=e.ease(f(t)),m=Ap((p-a)/(o-a)),h=i*hp(s,c,n(r))*(1-l+l*u)*Math.sin(Math.PI*m)**2;return 1-p+h}},e.swing))}const Yp=[211,337];function Xp(e,t){Dp(e);let n=e.seconds,r=e=>mp(Number.parseInt(e.slice(1),16)*1e-4,17.3+t),i=(e,n)=>fp(n/Yp[0],5.9+97*e,t)+.5*fp(n/Yp[1],2.3+89*e,t+7.1),a=(t,a)=>{let o=r(t);return 360*a/n+e.swing*180*((i(o,a)-i(o,0))/1.5)},o=new WeakMap;return wp(e=>{let{colors:t,fills:n,depth:r,theme:i}=e,s=(e,n)=>!e&&t.has(n.hex),c=(e,t,r)=>n.has(e.hex)||!r?e.hex:t.hex,l=(e,t)=>`${e.hex} ${t}`,u=o.get(i)??new Go;o.set(i,u);let d=u.get(xp(e),()=>nm(e.pairs,r,(e,t)=>{let n=t===`fg`?`bg`:`fg`;return s(e.terminal[t],e[t])?l(e[t],c(e[t],e[n],s(e.terminal[n],e[n]))):void 0})),f=am(r,i);return au.continuous(e=>{let t=new Map,n=(t,n)=>{let i=Zp(t,a(n,e));return om(i.looks,t,r===B.TRUECOLOR?i.either.map(rm):f,d.get(l(t,n))??$p)},i=(e,r)=>{let i=t.get(l(e,r))??n(e,r);return t.set(l(e,r),i),i};return(e,t)=>{let n={fg:s(t.terminal.fg,e.fg),bg:s(t.terminal.bg,e.bg)},r=(e,t,n,r)=>t?i(e,c(e,n,r)):e;return{fg:r(e.fg,n.fg,e.bg,n.bg),bg:r(e.bg,n.bg,e.fg,n.fg)}}})})}function Zp(e,t){if(t===0)return{looks:e,either:[e]};let n=Mc.fromRgba(e),r=Cs(e),i=e=>new Mc(e,n.c,n.h+t,n.alpha).toRgba(),[a,o]=[0,1];for(let e=0;e<24;e++){let e=(a+o)/2;[a,o]=Cs(i(e))<r?[e,o]:[a,e]}return{looks:i(o),either:[i(a),i(o)]}}const Qp=e=>Math.log(ws(e,new z(0,0,0))),$p={lo:-1/0,hi:1/0},em={lo:1/0,hi:-1/0},tm=Math.log(1.031);function nm(e,t,n){let r=new Map;for(let i of e.filter(e=>_p(e,t)>1)){let e=(Math.log(ws(i.fg,i.bg))-Math.log(_p(i,t)))/vp.filter(e=>n(i,e)!==void 0).length;for(let t of vp){let a=n(i,t);if(a===void 0)continue;let[o,s]=[Qp(i[t]),Qp(i[t===`fg`?`bg`:`fg`])],{lo:c,hi:l}=r.get(a)??$p;r.set(a,o>=s?{lo:Math.max(c,o-e),hi:l}:{lo:c,hi:Math.min(l,o+e)})}}return new Map([...r].map(([e,{lo:t,hi:n}])=>[e,n-t<tm?em:{lo:t,hi:n}]))}const rm=e=>({color:e,looks:Mc.fromRgba(e),stop:Qp(e)}),im=new WeakMap;function am(e,t){let n=V.indexed(e,t),r=im.get(n)??n.map(([,e])=>rm(e));return im.set(n,r),r}function om(e,t,n,{lo:r,hi:i}){return sm(e,[rm(t),...n.filter(({stop:e})=>e>=r&&e<=i)]).color}function sm(e,t){let n=Mc.fromRgba(e),r;for(let e of t){let t=n.deltaE(e.looks);(r===void 0||t<r[1])&&(r=[e,t])}return r?.[0]}const cm={loops:{shimmer:(e,t=Op.shimmer)=>bp(zp(t,24,kp.sun,e.z)),pulse:(e,t=Op.pulse)=>bp(Lp(t,kp.sun,e.z)),sparkle:(e,t=Op.sparkle)=>bp(Bp(t,kp.firefly,e.z)),wheel:(e,t=Op.wheel)=>Xp(t,e.z)},transitions:{fade:(e,t=Op.fade)=>Kp(t,e.z),dissolve:(e,t=Op.dissolve)=>Jp(t,e.z)}};var lm=class{beat;width;_shown;constructor(e){this.beat=ru(e.map(e=>e.seconds));let t=e.map(e=>qf(e.text.copy())),n=t.map(e=>e.cellLength);this.width=Math.max(...n),this._shown=t.map((e,t)=>(e.noWrap=!0,e.overflow=`crop`,e.padRight(this.width-n[t])))}at(e){return this._shown[this.beat.at(e)].copy()}nextChange(e){return this.beat.nextChange(e)}lastChange(e){return this.beat.lastChange(e)}};function um(e,t){return e.at(t).copy().stylize(new H({nextChange:e.nextChange(t)}))}function dm(e,t){let n=[...Hu(e,t)],r=0;for(let e of n)r+=e.cellLength;return{segments:n,width:r}}const fm={segments:[],width:0},pm={left:()=>0,justify:()=>0,center:e=>Math.floor(e/2),right:e=>e};function mm(e,t){return pm[e](t)}function hm(e,t,n,r){let i=Math.max(0,r-1),a=e===`justify`&&!t&&i>0&&n>0?n:0,o=i>0?Math.floor(a/i):0,s=a-o*i;return Array.from({length:i},(e,t)=>o+ +(t<s))}var gm=class{items;joiner;gap;align;constructor(e,t){this.items=e,this.joiner=t?.joiner,this.gap=t?.gap??0,this.align=t?.align??`left`}contents(){return this.items}*render(e){let t=this.items;if(t.length===0)return;let n=Math.max(1,e.maxWidth),r=this.gap,i=this.joiner,a=t.map(t=>dm(Ed(t),e)),o=n=>i?dm(Td(i,null,t[n],{index:n}),e):fm,s=n=>i?dm(Td(i,t[n],null,{index:n+1}),e):fm,c=(n,r)=>i?dm(Td(i,t[n],t[r],{index:r}),e):fm,l=[],u=null,d=r>0?{segments:[new W(` `.repeat(r))],width:r}:fm;for(let e=0;e<t.length;e++){let t=a[e];if(u===null){let n=o(e),r=s(e),i=n.width>0?[n,t]:[t],a=[i.length-1];u={blocks:i,width:n.width+t.width,lastIndex:e,itemBlockIndices:a},u.endCap=r;continue}let i=u.lastIndex,f=c(i,e),p=s(e),m=(r>0?r:0)+f.width+(r>0?r:0)+t.width;if(u.width+m+p.width<=n)r>0&&u.blocks.push(d),f.width>0&&u.blocks.push(f),r>0&&u.blocks.push(d),u.blocks.push(t),u.itemBlockIndices.push(u.blocks.length-1),u.width+=m,u.lastIndex=e,u.endCap=p;else{let n=u.endCap;n.width>0&&u.blocks.push(n),u.width+=n.width,l.push(u);let r=o(e),i=s(e),a=r.width>0?[r,t]:[t],c=[a.length-1];u={blocks:a,width:r.width+t.width,lastIndex:e,itemBlockIndices:c},u.endCap=i}}let f=u;{let e=f.endCap;e.width>0&&f.blocks.push(e),f.width+=e.width,l.push(f)}let p=this.align;for(let e=0;e<l.length;e++){let t=l[e],r=e===l.length-1,i=Math.max(0,n-t.width),a=mm(p,i),o=hm(p,r,i,t.itemBlockIndices.length),s=new Map;t.itemBlockIndices.forEach((e,t)=>s.set(e,t)),a>0&&(yield new W(` `.repeat(a)));for(let e=0;e<t.blocks.length;e++){let n=s.get(e);if(n!==void 0&&n>0){let e=o[n-1];e>0&&(yield new W(` `.repeat(e)))}yield*t.blocks[e].segments}yield W.line()}}measure(e){let t=this.items;if(t.length===0)return{minimum:0,maximum:0};let n=0,r=0;for(let i=0;i<t.length;i++){let a=dm(t[i],e).width,o=this.joiner?dm(Td(this.joiner,null,t[i],{index:i}),e).width:0,s=this.joiner?dm(Td(this.joiner,t[i],null,{index:i+1}),e).width:0;n=Math.max(n,a+o+s),r+=a,i>0&&(r+=this.gap*2,this.joiner&&(r+=dm(Td(this.joiner,t[i-1],t[i],{index:i}),e).width))}return this.joiner&&(r+=dm(Td(this.joiner,null,t[0],{index:0}),e).width,r+=dm(Td(this.joiner,t[t.length-1],null,{index:t.length}),e).width),{minimum:n,maximum:r}}};function _m(){let e=new WeakMap;return(t,n,r)=>{let i=e.get(t);i===void 0&&(i=new Map,e.set(t,i));let a=i.get(n);if(a!==void 0)return a;let o=r();return i.set(n,o),o}}const vm=[`primary`,`secondary`,`accent`],ym=[`darken-3`,`darken-2`,`darken-1`,`base`,`lighten-1`,`lighten-2`,`lighten-3`],bm={"darken-3":`-darken-3`,"darken-2":`-darken-2`,"darken-1":`-darken-1`,base:``,"lighten-1":`-lighten-1`,"lighten-2":`-lighten-2`,"lighten-3":`-lighten-3`,muted:`-muted`},xm=(e,t)=>`${e}${bm[t]}`,Sm=(e,t,n,r)=>th(e,n,r),Cm=(e,t,n,r)=>rh(e,Gm(e,`text-${t}`),n,r),wm=e=>({tones:[ym[e],ym[e+2],ym[e+1]],text:Sm}),Tm={muted:{tones:[`muted`],text:Cm},deepest:wm(0),deeper:wm(1),middle:wm(2),brighter:wm(3),brightest:wm(4)},Em=1/0,Dm={accent:{hues:[`secondary`,`accent`],run:Em},duo:{hues:[`primary`,`secondary`],run:Em},mono:{hues:[`primary`],run:Em},alt:{hues:[`secondary`,`accent`],run:3}},Om=e=>e.variation.hues.flatMap(t=>e.shade.tones.map(e=>({hue:t,shade:e}))),km=e=>{let t=0,n=.5;for(let r=e;r>0;r>>=1,n/=2)t+=n*(r&1);return t},Am=[`van-der-corput`,`golden-angle`,`ends-interleaved`,`monotonic`,`uniform`],jm=e=>typeof e==`string`&&Am.includes(e),Mm={"van-der-corput":km,"golden-angle":e=>e*.6180339887498949%1,"ends-interleaved":(e,t)=>((e%2==0?e/2:t-1-(e-1)/2)+.5)/t,monotonic:(e,t)=>(e+.5)/t,uniform:()=>.5},Nm=e=>Mm[e??`van-der-corput`];function Pm(e){let t=0,n=1;for(let{index:r,count:i,distribution:a}of e)t+=a(r,i)*n,n*=.37;return t%1}const Fm=(e,t)=>Math.floor(e*t),Im=(e,t)=>Math.round(e*t)%t;function Lm(e){return e===void 0?0:e.distribution(e.index,e.count)}function Rm(e,t,n){let r=e[n(Lm(t),e.length)];if(r===void 0)throw Error(`vocabularySelect: empty vocabulary`);return r}function zm(e){let t=e.findIndex(e=>e.axis===`cell`),n=t===-1?e:e.slice(0,t);return{row:n.at(-1),cell:e[n.length]}}const Bm=(e,t)=>Fm(Lm(t),e.hues.length);function Vm(e,t){let{row:n,cell:r}=zm(t);return Hm(e,n,r)}function Hm(e,t,n){let{hues:r,run:i}=e.variation,a=n===void 0?0:Math.floor(n.index/i),o=r[(Bm(e.variation,t)+a)%r.length];if(o===void 0)throw Error(`decorEntryFor: empty variation`);return{hue:o,shade:Rm(e.shade.tones,n,Im)}}function Um(e,t){let{row:n,cell:r}=zm(t),i=r===void 0?[void 0]:Array.from({length:r.count},(e,t)=>({...r,index:t}));return[...new Map(i.map(t=>Hm(e,n,t)).map(e=>[xm(e.hue,e.shade),e])).values()].sort((e,t)=>vm.indexOf(e.hue)-vm.indexOf(t.hue)||Wm.indexOf(e.shade)-Wm.indexOf(t.shade))}const Wm=[...ym,`muted`];function Gm(e,t){let n=e.get(t);if(n===void 0)throw Error(`palette "${e.name}" has no "${t}" role; decoration needs it`);return n}const Km=(e,t)=>Gm(e,xm(t.hue,t.shade)),qm=2.2,Jm=(e,t)=>t.map(t=>Km(e,t)),Ym=e=>t=>Gc(t,e),Xm=Ym(B.TRUECOLOR);function Zm(e,t,n,r){return Qm(e,`${t}|${n.map(e=>e.hex).join(`+`)}|${r}`,()=>$m(e,t,n,r))}const Qm=_m();function $m(e,t,n,r){let i=n.map(Xm),a=Gm(e,t),o=new z(0,0,0),s=new z(255,255,255),c=(e,t)=>Mc.fromRgba(a).mixAxes(Mc.fromRgba(e),{l:t,c:0,h:0,alpha:0}).toRgba(),l=e=>Array.from({length:12},(t,n)=>c(e,(n+1)/12)),u=l(o),d=[a,...l(s).flatMap((e,t)=>[e,u[t]])],f=e=>{let t=Ym(e),n=i.map(t);return e=>Math.min(1/0,...n.map(n=>ws(t(e),n)))},p=f(B.TRUECOLOR),m=f(r),h=e=>Wc(e,r,(e,t)=>i.every(n=>ws(e,t(n))>=qm)),g=e=>p(e)>=2.2&&h(e)!==void 0,_=(e,t)=>{let n=n=>ws(Xm(n),e)-ws(Xm(n),t),r=n(a)<0?o:s,i=r===o?1:-1,[l,u]=[0,1];for(let e=0;e<40;e++){let e=(l+u)/2;i*n(c(r,e))>0?u=e:l=e}return[c(r,l),c(r,u)]},v=()=>{let e=[...i].sort((e,t)=>Cs(e)-Cs(t));return e.slice(1).flatMap((t,n)=>_(t,e[n]))},y=d.find(g)??[...d,...v()].reduce((e,t)=>m(t)>m(e)?t:e),b=h(y)??y,ee=m(b);return{anchor:y,state:b,short:ee>=2.2?null:ee}}const eh=4.5;function th(e,t,n){return nh(e,`${t.hex}|${n}`,()=>{let r=Hc(t);return rh(e,[`background`,`foreground`].map(t=>Gm(e,t)).reduce((e,t)=>ws(r,t)<ws(r,e)?t:e),t,n)})}const nh=_m();function rh(e,t,n,r){return ih(e,`${t.hex}|${n.hex}|${r}`,()=>Uc(t,n,eh,r))}const ih=_m();function ah(e,t,n){return t.depth===0?Jm(e,t.ground):oh(e,t,n)}const oh=(e,t,n)=>t.depth===0?[]:[_h(e,{...t,depth:t.depth-1},n).plane],sh=(e,{short:t},n)=>t===null?[]:[`theme "${e.name}": no open-trigger colour stands ${qm}:1 off every cell beside it — the nearest stands ${t.toFixed(2)}:1 as drawn at depth ${B[n]}; another shade or variation clears it`],ch=(e,t,n)=>t>=fh.triggerPlane?[]:[`theme "${e.name}": an open band's plane stands ΔE ${t.toFixed(3)} off the trigger that opened it as drawn at depth ${B[n]}, under the ${fh.triggerPlane} that tells them apart; another style clears it`],lh={base:.42,perDepth:.14,cap:.75},uh={floor:.12,span:.8};function dh(e,t){return vm[(vm.indexOf(e)+t)%vm.length]}const fh={triggerPlane:.1,nestedPlane:.035};function ph(e,t,n){return mh(e,`${hh(t)}|${n}`,()=>{let r=Zm(e,dh(t.hue,t.depth),ah(e,t,n),n),{state:i}=r,a=xh(e,t,i,n),o=Wc(_h(e,t,n).plane,n,(e,t)=>a.every(n=>n(e,t)));if(o===void 0)throw Error(`palette "${e.name}": the ${t.hue} band at depth ${t.depth} cannot keep its floors on the colours drawn at depth ${B[n]}`);let s=Ym(n);return{state:i,plane:o,shortfalls:n===B.DEFAULT?[]:[...sh(e,r,n),...ch(e,gh(s(i),s(o)),n)]}})}const mh=_m(),hh=({hue:e,depth:t,ground:n})=>`${e}|${t}|${n.map(e=>xm(e.hue,e.shade)).join(`+`)}`,gh=(e,t)=>Mc.fromRgba(e).deltaE(Mc.fromRgba(t));function _h(e,t,n){return vh(e,`${hh(t)}|${n}`,()=>yh(e,t,n))}const vh=_m();function yh(e,t,n){let{anchor:r}=Zm(e,dh(t.hue,t.depth),ah(e,t,n),n),i=Math.min(lh.cap,lh.base+lh.perDepth*t.depth),a=(t,n)=>rc(r,Gm(e,t),n),o=oh(e,t,n),s=e=>gh(Xm(r),Xm(e))>=fh.triggerPlane&&o.every(t=>gh(Xm(t),Xm(e))>=fh.nestedPlane),c=a(`background`,i);return{state:r,plane:[c,a(`foreground`,i),a(`background`,lh.cap),a(`foreground`,lh.cap),...bh.toSorted((e,t)=>Math.abs(e-i)-Math.abs(t-i)).flatMap(e=>[a(`background`,e),a(`foreground`,e)])].find(s)??c}}const bh=Array.from({length:12},(e,t)=>(t+1)/12);function xh(e,t,n,r){let{hue:i,depth:a,ground:o}=t,s=t=>_h(e,{hue:i,depth:t,ground:o},r).state,c=t=>_h(e,{hue:i,depth:t,ground:o},r).plane,l=c(a),u=(e,t)=>gh(Xm(l),Xm(t))>=e?e:0,d=Zm(e,dh(i,a+1),ah(e,{hue:i,depth:a+1,ground:o},r),r),f=ws(Xm(l),Xm(d.anchor))>=2.2?qm:0,p=(e,t)=>(n,r)=>gh(n,r(e))>=t;return[p(n,u(fh.triggerPlane,s(a))),(e,t)=>ws(e,t(d.state))>=f,...a>0?[p(ph(e,{hue:i,depth:a-1,ground:o},r).plane,u(fh.nestedPlane,c(a-1)))]:[]]}function Sh(e,t,n,r){let i=ph(e,t,r),a=_h(e,t,r),o=e=>rc(a.plane,a.state,e),s=uh.floor+uh.span*Pm(n),c=uh.floor+uh.span/2,l=(e,t)=>e.hex!==t(i.plane).hex&&e.hex!==t(i.state).hex;for(let e=0;e<=12;e++){let t=Wc(o(s+(c-s)*e/12),r,l);if(t!==void 0)return t}return o(s)}const Ch=e=>({kind:`bar`,decor:e,address:[]}),wh=(e,t)=>({...e,address:[...e.address,t]}),Th=e=>({kind:`band`,band:e,address:[]});function Eh(e,t,n){switch(t.kind){case`bar`:{let{decor:r,address:i}=t,a=Vm(r,i),o=Km(e,a),s;return{tint:o,text:r.shade.text(e,a.hue,o,n),disclosure:{hue:`accent`,depth:0,get ground(){return s??=Um(r,i)}}}}case`band`:{let{band:r,address:i}=t,a=Sh(e,r,i,n);return{tint:a,text:th(e,a,n),disclosure:{...r,depth:r.depth+1}}}}}const Dh=new Map([[`dark`,`textual-dark`],[`light`,`textual-light`]]);function Oh(e){let t=typeof e==`string`?Dh.get(e):void 0;return t===void 0?``:` — "${e}" was retired; write "${t}", the same palette`}const kh=`textual-dark`;function Ah(e,t,n,r,i){let a=t===null?null:i(t);return e??a??n??r}function jh(){return fl()}function Mh(){return[`bar`,...jh()]}let Nh;function Ph(e){return Nh??=new Set(Mh()),Nh.has(e)}function Fh(e,t,n,r,i){let a=e=>Object.prototype.hasOwnProperty.call(i,e)?e:null;return Ah(e===void 0?null:a(e),t,a(n??r),r,a)}const Ih=[`style`,`palette`,`effect`];function Lh(e){return e!==void 0&&e.includes(`{{`)}function Rh(e,t,n,r,i){let a=Lh(n)?{kind:`expression`,source:n}:i(n??r.name);return Ah(e===void 0?null:i(e),t,a,r,i)}function zh(e,t){return e.kind===`decided`?e:t(e.source)}const Bh=`none`;function Vh(e,t){let n=t[e];return n===void 0?null:{kind:`decided`,name:e,value:n}}function Hh(e,t){return Vh(e,t)??Vh(`none`,t)??{kind:`decided`,name:`none`,value:xc}}function Uh(e,t,n,r){return Rh(e,t,n,Hh(Bh,r),e=>Vh(e,r))}const Wh=`none`,Gh={style:Bh,palette:kh,effect:Wh};function Kh(e,t,n){return`${e} rendered "${Gh[t]}": ${n}`}const qh=Object.freeze([Wh,...Object.keys(cm.loops)]),Jh=Object.freeze([`bar`,...qh]);function Yh(e){let t=qh.find(t=>t===e);return t===void 0?null:{kind:`decided`,name:e,value:t}}function Xh(e){return Yh(e)??{kind:`decided`,name:`none`,value:`none`}}function Zh(e,t,n){return Rh(e,t,n,Xh(Wh),Yh)}const Qh=Object.freeze(Object.keys(Mf)),$h=[`powerline`,`capsule`,`plain`];function eg(e){return $h.includes(e)}const tg=[`truecolor`,`256`,`ansi`,`none`];function ng(e){return Ls(e)??B.DEFAULT}const rg=Object.keys(Dm),ig=Object.keys(Tm),ag=`true`,og=`false`,sg=[ag,og],cg={min:0,max:16};function lg(e){return e===`true`?!0:e===`false`?!1:null}function ug(e,t){let n=Number(e);return Number.isInteger(n)&&String(n)===e&&n>=t.min&&n<=t.max?n:null}const dg=[`vertical`,`horizontal`],fg={vertical:`row`,horizontal:`cell`};function pg(e){return e.id??e.name}function mg(e){return[..._g(e)].flatMap(e=>e.kind===`segment`?[pg(e)]:[])}function hg(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function gg(e,t){return e.opens===void 0?e:{...e,opens:{...e.opens,body:t(e.opens.body)}}}function*_g(e){yield e;for(let t of xg(e))yield*_g(t)}const vg=(e,t)=>`${e}.children[${t}]`,yg=e=>`${e}.opens.body`;function*bg(e,t){if(yield[e,t],e.kind===`container`)for(let[n,r]of e.children.entries())yield*bg(r,vg(t,n));else e.opens!==void 0&&(yield*bg(e.opens.body,yg(t)))}function xg(e){return e.kind===`container`?e.children:e.opens===void 0?[]:[e.opens.body]}function Sg(e){return e===void 0||`text`in e?`text`:`regex`in e?`regex`:`json`}const Cg=[`ttl`,`watch_file`,`depends_on`,`key`,`never`];function wg(e){return e.kind===`file`||e.kind===`shell`}const Tg=[`branch`,`sha`,`dirty`,`ahead`,`behind`,`stash`],Eg=[`fail`,`ignore`];function Dg(e){return e.missingData??`fail`}function*Og(e){for(let[t,n]of Object.entries(e.variables))n.kind===`state`&&(yield[t,n]);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))r.kind===`state`&&(yield[`${t}.${e}`,r])}const kg=`theme`,Ag=`effect`,jg=[kg,Ag];function Mg(e){return{...e.settings,[kg]:{label:kg,domain:`theme`,default:e.palette??`bar`},[Ag]:{label:Ag,domain:Jh,default:`bar`}}}function Ng(e){let t=e?.domain;return typeof t==`object`&&`min`in t?t:void 0}function Pg(e,t){return Object.entries(e).flatMap(([n,r])=>{let i=Ng(r)?.atLeast;if(i===void 0)return[];let a=t[n],o=t[i];return a>=o?[]:[{setting:n,message:`"${n}" (${a}) is below "${i}" (${o}) — ${r.label} must be at least ${e[i].label}`}]})}function Fg(e,t){let{domain:n}=e;return n===`bool`?typeof t==`boolean`:n===`theme`?typeof t==`string`&&Ph(t):`min`in n?typeof t==`number`&&Number.isInteger(t)&&t>=n.min&&t<=n.max:typeof t==`string`&&n.includes(t)}function Ig(e){return String(e)}function Lg(e,t){let{domain:n}=e;if(typeof n==`object`&&`min`in n)return ug(t,n)??void 0;let r=n===`bool`?t===`true`?!0:t===`false`?!1:t:t;return Fg(e,r)?r:void 0}function Rg(e,t,n,r){let i=e.settings?.[t]??n.default,a=e.drafts?.[t],o=a===void 0?null:r(a);return(o===null?void 0:Lg(n,o))??i}function zg(e){let{domain:t}=e;return t===`bool`?`true or false`:t===`theme`?`"bar" (the bar's own theme) or an installed theme name`:`min`in t?`an integer from ${t.min} to ${t.max}`:`one of ${t.map(e=>JSON.stringify(e)).join(`, `)}`}const Bg=[`left`,`center`,`right`],Vg=[`right`,`left`,`middle`];var Hg=class extends Error{file;issues;warnings;constructor(e,t,n=[]){super(Kg(e,t)),this.name=`ConfigError`,this.file=e,this.issues=t,this.warnings=n}};function K(e,t){let n=0,r;for(let i of t){if(i===``||/^\d+$/.test(i))continue;let t=Ug(e,n,i);if(t===-1)return r===void 0?void 0:Wg(e,r);n=t,r=t}return r===void 0?void 0:Wg(e,r)}function Ug(e,t,n){let r=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),i=RegExp(`(?:["']${r}["']|\\b${r}\\b)\\s*:`,`g`);i.lastIndex=t;let a=i.exec(e);return a?a.index:-1}function Wg(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function Gg(e,t){try{return _i(t),null}catch(n){if(!(n instanceof di))throw n;return`${e}:${Wg(t,n.offset)}: ${n.reason} — the settings menu cannot edit this file until it is fixed`}}function Kg(e,t){if(t.length===0)return`${e}: invalid config (no details)`;let n=[`Invalid config in ${e} (${t.length} issue${t.length===1?``:`s`}):`];for(let e of t){let t=[];e.line!==void 0&&t.push(`line ${e.line}${e.col===void 0?``:`:${e.col}`}`),e.path&&t.push(e.path);let r=t.length>0?`[${t.join(` • `)}] `:``;n.push(` ${r}${e.message}`)}return n.join(`
55
- `)}function qg(e,t,n,r){let i=n[r];return typeof i==`string`?i:(e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),r])}),null)}function Jg(e,t,n,r){let i=n.default;if(i!==void 0){if(!(r===`string`&&typeof i==`string`||r===`number`&&typeof i==`number`||r===`boolean`&&typeof i==`boolean`)){e.issues.push({path:`${t}.default`,message:`default must be a ${r}, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),`default`])});return}return i}}function Yg(e,t,n,r){let i=n[r];if(i!==void 0){if(typeof i!=`string`){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),r])});return}return i}}function Xg(e,t,n){let r=Yg(e,t,n,`palette`);if(r!==void 0){if(!e.allowedPalettes.has(r)){e.issues.push({path:`${t}.palette`,message:`Unknown palette "${r}"${Oh(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:K(e.source,[...t.split(`.`),`palette`])});return}return r}}function Zg(e,t,n,r,i){let a=n[r];if(a!==void 0){if(typeof a!=`string`||!i.includes(a)){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be one of: ${i.join(`, `)}; got ${q(a)}`,line:K(e.source,[...t.split(`.`),r])});return}return a}}function Qg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $g(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function q(e){return typeof e==`string`?JSON.stringify(e):e===void 0?`undefined`:String(e)}function e_(e,t,n,r){return Qg(r)?(i_(e,n,r,t.noun,new Set(Object.keys(t.fields)),t_(e,t.removed??{},n,r)),n_(e,t.fields,n,r)):(e.issues.push({path:n,message:`${n} must be an object, got ${$g(r)}`,line:K(e.source,n.split(`.`))}),null)}function t_(e,t,n,r){let i=Object.entries(t).filter(([e])=>r[e]!==void 0);for(let[t,r]of i)a_(e,`${n}.${t}`,`${n}.${t} was removed: ${r}`);return new Set(i.map(([e])=>`${n}.${e}`))}function n_(e,t,n,r){let i=t,a={},o=!0;for(let[t,s]of Object.entries(i)){let i=s.parse(e,n,t,r);i===void 0?s.required&&(o=!1):a[t]=i}return o?a:null}const r_=new Set;function i_(e,t,n,r,i,a=r_){for(let o of Object.keys(n))!i.has(o)&&!a.has(`${t}.${o}`)&&e.issues.push({path:`${t}.${o}`,message:`Unknown ${r} "${o}". Expected one of: ${[...i].join(`, `)}`,line:K(e.source,[...t.split(`.`),o])})}function a_(e,t,n){return e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))}),null}function o_(e,t,n,r){if(!Qg(r))return e.issues.push({path:n,message:`${t.noun} must be an object, got ${$g(r)}`,line:K(e.source,n.split(`.`))}),null;let i=t.arms,a=Object.keys(i),o=Object.keys(r).filter(e=>e in i),s=Object.keys(r).filter(e=>!(e in i));for(let r of s)e.issues.push({path:`${n}.${r}`,message:`Unknown ${t.noun} key "${r}". Expected exactly one of: ${a.join(`, `)}`,line:K(e.source,[...n.split(`.`),r])});if(o.length===0)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)}`,line:K(e.source,n.split(`.`))}),null;if(o.length>1)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)} (found: ${o.join(`, `)})`,line:K(e.source,n.split(`.`))}),null;let c=o[0];return i[c].parse(e,`${n}.${c}`,r[c])}function s_(e,t,n,r){if(!Qg(r))return e.issues.push({path:n,message:`${n} must be an object, got ${$g(r)}`,line:K(e.source,n.split(`.`))}),null;let i=r[t.tag];if(typeof i!=`string`)return e.issues.push({path:`${n}.${t.tag}`,message:`${n}.${t.tag} must be a string, got ${$g(i)}`,line:K(e.source,n.split(`.`))}),null;let a=t.arms;if(!(i in a))return e.issues.push({path:`${n}.${t.tag}`,message:`Unknown ${t.noun} "${i}". Expected one of: ${Object.keys(a).join(`, `)}`,line:K(e.source,[...n.split(`.`),t.tag])}),null;let o=a[i],s=e.issues.length,c=o.parse(e,n,r),l=new Set(e.issues.slice(s).map(e=>e.path));return i_(e,n,r,`${i} ${t.memberNoun} key`,o.keys,l),c}function c_(e,t,n){return{json:S_(b_(n),e,t),keys:new Set([e,...Object.keys(n)])}}function l_(e){return(...t)=>e()(...t)}function u_(e,...t){return(n,r,i)=>{let a=e(n,r,i);if(a===null)return null;for(let e of t){if(e.ok(a))continue;let{field:t,message:i}=e.issue(a),o=t===``?r:`${r}.${t}`;return n.issues.push({path:o,message:i,line:K(n.source,o.split(`.`))}),null}return a}}function d_(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>Yg(e,t,r,n)}}function f_(){return{required:!1,json:{type:`boolean`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`boolean`){e.issues.push({path:`${t}.${n}`,message:`${n} must be a boolean, got ${$g(i)}`,line:K(e.source,[n])});return}return i}}}}function p_(e){let{min:t,max:n}=e;return{required:!1,json:{type:`integer`,minimum:t,maximum:n},parse:(e,r,i,a)=>{let o=a[i];if(o!==void 0){if(typeof o!=`number`||!Number.isInteger(o)||o<t||o>n){e.issues.push({path:`${r}.${i}`,message:`${i} must be an integer between ${t} and ${n}, got ${q(o)}`,line:K(e.source,[i])});return}return o}}}}function m_(e={}){let{min:t}=e;return{required:!1,json:{type:`number`,...t!==void 0&&{minimum:t}},parse:(e,n,r,i)=>{let a=i[r];if(a!==void 0){if(typeof a!=`number`||!Number.isFinite(a)||t!==void 0&&a<t){let i=t===void 0?`a finite number`:`a finite number >= ${t}`;e.issues.push({path:`${n}.${r}`,message:`${r} must be ${i}, got ${q(a)}`,line:K(e.source,[r])});return}return a}}}}function h_(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>Xg(e,t,r)}}function g_(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>qg(e,t,r,n)??void 0}}function __(e,t){return u(t)?null:`${e} must be an absolute path (\`~\` and relative paths are not expanded), got ${JSON.stringify(t)}`}function v_(){return{required:!0,json:{type:`string`,pattern:`^/`},parse:(e,t,n,r)=>{let i=qg(e,t,r,n);if(i===null)return;let a=__(`${t}.${n}`,i);return a===null?i:a_(e,`${t}.${n}`,a)??void 0}}}function y_(e){return{required:!1,json:{enum:[...e]},parse:(t,n,r,i)=>Zg(t,n,i,r,e)}}function b_(e,t={closed:!0}){let n=e,r={},i=[];for(let[e,t]of Object.entries(n))r[e]=t.json,t.required&&i.push(e);return{type:`object`,properties:r,...i.length>0&&{required:i},...t.closed&&{additionalProperties:!1}}}function x_(e){return b_(e.fields)}function S_(e,t,n){let r=e,i={[t]:{const:n},...r.properties},a=[t,...r.required??[]];return{...r,properties:i,required:a}}function C_(e){let t=e.arms;return{anyOf:Object.values(t).map(e=>e.json)}}function w_(e){let t=e.arms;return{anyOf:Object.entries(t).map(([e,t])=>({type:`object`,properties:{[e]:t.json},required:[e],additionalProperties:!1}))}}const T_={band:{setting:`experimentalBand`,label:`🧪 band (A)`,elsewhere:`the band above the prompt`},statusline:{setting:`experimentalStatusline`,label:`🧪 statusline (B)`,elsewhere:null},pane:{setting:`experimentalPane`,label:`🧪 tmux pane (C)`,elsewhere:`a tmux pane below`},tmuxStatus:{setting:`experimentalTmuxStatus`,label:`🧪 tmux status line (C)`,elsewhere:`the tmux status line`}},E_=Object.keys(T_),D_={by:`request`},O_=e=>`drawing.${e}`,k_={subscribers:0,fps:0,shown:!0},A_=(e,t)=>`feeds.${e}.${t}`;function j_(e){return Object.fromEntries(E_.map(t=>[t,e(t)]))}const M_=j_(()=>k_);function N_(e){return typeof e==`string`&&Object.hasOwn(T_,e)?e:null}const P_=(e,t,n=[])=>({label:e,place:t,previews:n}),F_=(e,t)=>({spec:y_(e),domain:{from:e},parse:t=>e.includes(t)?t:null,...t!==void 0&&{optionDomain:{name:t,members:e}}}),I_={spec:f_(),domain:`bool`,parse:lg},L_=e=>({spec:p_(e),domain:e,parse:t=>ug(t,e)});function R_(e,t,n,r={}){return{kind:`session`,...F_(e,r.optionDomain),floor:t,control:n,themeDefault:r.themeDefault??!1}}function z_(e,t){return{kind:`session`,...I_,floor:e,control:t,themeDefault:!1}}function B_(e,t,n){return{kind:`session`,...L_(e),floor:t,control:n,themeDefault:!1}}function V_(e,t,n,r,i={}){return{kind:`selection`,sessionKey:e,spec:t,domain:n,control:r,themeDefault:i.themeDefault??!1}}const H_=e=>({kind:`text`,spec:e}),U_={required:!1,json:{enum:[...tg]},parse:(e,t,n,r)=>{if(r[n]===`auto`){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: "auto" is not supported — the render daemon runs detached, so terminal detection would read the daemon's environment, not your terminal's. Pick an explicit depth: ${tg.join(`, `)}`,line:K(e.source,[...t.split(`.`),n])});return}return Zg(e,t,r,n,tg)}},W_={required:!1,json:{type:`string`},parse:(e,t,n,r)=>{let i=Yg(e,t,r,n);return Lh(i)?i:Xg(e,t,r)}},G_={required:!1,json:{anyOf:[{enum:[...qh]},{type:`string`,pattern:`\\{\\{`}]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&Lh(i)?i:Zg(e,t,r,n,qh)}},K_=/^[^\r\n]*\S[^\r\n]*$/u,q_=RegExp(`^(?:✖|✕)[\\uFE0E\\uFE0F]?$`,`u`),J_={required:!1,json:{type:`string`,pattern:K_.source,not:{pattern:q_.source}},parse:(e,t,n,r)=>{let i=Yg(e,t,r,n);if(i===void 0||K_.test(i)&&!q_.test(i))return i;e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: must be one line of visible text other than a close glyph ("✖", "✕") — the settings menu needs a glyph to click`,line:K(e.source,[...t.split(`.`),n])})}},Y_=Object.fromEntries(E_.map(e=>[T_[e].setting,z_(!1,P_(T_[e].label,`toggles`))])),X_={palette:V_(`theme`,W_,{themes:`themes`},P_(`🎨 theme`,`look`)),preset:V_(`preset`,d_(),{from:`presets`},P_(`▦`,`door`,[`layout`,`presetDelete`])),style:V_(`style`,d_(),{from:`styles`},P_(`◐`,`gear`,[`palette`]),{themeDefault:!0}),effect:V_(`effect`,G_,{from:qh},P_(`✨`,`look`)),endcaps:R_(Qh,`powerline`,P_(`✦`,`look`),{optionDomain:`endcaps`}),variation:R_(rg,`accent`,P_(`🎼`,`gear`,[`layout`]),{optionDomain:`variations`,themeDefault:!0}),shade:R_(ig,`middle`,P_(`🔆`,`gear`,[`layout`]),{optionDomain:`shades`,themeDefault:!0}),transitions:z_(!1,P_(`fade in/out`,`look`)),autoWrap:z_(!0,P_(`wrap`,`layout`)),padding:B_({...cg,step:1},1,P_(`padding`,`layout`)),updateNotice:z_(!0,P_(`update notice`,`config`)),...Y_,colorCompatibility:{kind:`config`,...F_(tg,`colorCompatibilities`),spec:U_,floor:`truecolor`},default_empty_value:H_(d_()),default_separator:H_(d_()),menuGlyph:H_(J_)},Z_=Object.entries(X_),Q_=Z_.filter(([,e])=>e.kind===`session`||e.kind===`config`).map(([e])=>e),$_=Z_.filter(([,e])=>e.kind===`session`||e.kind===`selection`).map(([e])=>e),ev=Z_.filter(([,e])=>(e.kind===`session`||e.kind===`selection`)&&e.themeDefault).map(([e])=>e),tv=Z_.flatMap(([,e])=>`optionDomain`in e&&e.optionDomain!==void 0?[e.optionDomain]:[]);function nv(e){return X_[e]}const rv=e=>nv(e).floor;function iv(e){let t=X_[e];if(t.kind===`text`)return`string`;let{domain:n}=t;return n===`bool`?`boolean`:typeof n==`object`&&`min`in n?`number`:`string`}const av=e=>`${e}.effective`,ov=e=>{let t=X_[e];return t.kind===`selection`?t.sessionKey:e},sv=Object.fromEntries($_.map(e=>{let t=ov(e);return[t,{configKey:e,sessionKey:t,effectiveVar:av(t),...X_[e].control}]})),cv=Object.keys(sv),lv=Object.values(sv),uv=Q_.filter(e=>X_[e].kind===`config`).map(e=>({configKey:e,effectiveVar:av(e)})),dv=new Set(uv.map(e=>e.configKey)),fv=new Map([...lv,...uv].map(e=>[e.configKey,e.effectiveVar])),pv=new Map(lv.map(e=>[e.sessionKey,e.effectiveVar]));function mv(e){return Object.fromEntries(cv.map(t=>[t,e(t)]))}const hv=new Map(cv.map(e=>[sv[e].sessionKey,e])),gv=[[0,31],[127,159],[8234,8238],[8294,8303]];function _v(e){return gv.some(([t,n])=>e>=t&&e<=n)}function vv(e){let t=``;for(let n of e)t+=_v(n.codePointAt(0)??0)?` `:n;return t.replace(/\s+/g,` `).trim()}function yv(e,t){let n=vv(e),r=``,i=0;for(let e of n){if(i===t)return r.replace(/.$/u,`…`);r+=e,i++}return r}const bv=`\x1B[38;2;255;255;255m`,xv=`\x1B[48;2;200;40;40m`,Sv=`\x1B[0m`;function Cv(e){let t=/;2;(\d+);(\d+);(\d+)m$/.exec(e);if(t===null)throw Error(`diagnostic-style: not a 24-bit SGR: ${e}`);return`#`+t.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}const wv={fg:Cv(bv),bg:Cv(xv)},Tv={fg:Cv(`\x1B[38;2;0;0;0m`),bg:Cv(`\x1B[48;2;220;160;40m`)},Ev=new Cu({"strip.separator":`default`,"strip.rail":`default`});function Dv(e){return Ev.resolve(e)}const Ov={kind:`still`},kv=Symbol(`bar`);function Av(e){return e.name!==Wh}function jv(e,t){return n=>au.map(au.all(t.map(({t,effect:r})=>pu.run(pu.play(e-t),r(n)))),e=>(t,n)=>e.reduce((e,t)=>t(e,n),t))}const Mv=xl;function Nv(e,t){let n=new ic(t,Mv.foregroundColor,Mv.ansiColors,Mv.palette);return t=>e({...t,theme:n})}function Pv(e,t){return n=>ep(()=>e(n),...t)(n)}function Fv(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t/4294967296}const Iv=4096;var Lv=class{inForce=null;placements=new Map;made=new Map;drawn=null;frame={effect:Wh,t:0,made:0,reused:0,own:[],basis:`off`,revision:0,fades:[],leaves:[]};constructor(e){this.key=e}lastFrame(){return this.frame}get heldCount(){let e=[...this.drawn?.placements.values()??[]].filter(({passage:e})=>e!==null).length;return[...this.made.values()].reduce((e,t)=>e+t.size,e)}motion(e,t,n){let r=this.inForce?.name===e?this.inForce:{name:e,since:t},i={scope:kv,name:e,t:t-r.since},a=this.placements,o=new Map,s=this.made,c=new Map,l=[],u=this.drawn,d=n.transitions?u!==null&&u.source.config===n.source.config&&u.source.preset===n.source.preset&&u.source.revision===n.source.revision&&u.source.width===n.source.width?`compared`:`fresh`:`off`,f=d===`compared`?u.placements:null,p=new Map,m=[],h=[],g={effect:e,t:i.t,made:0,reused:0,own:l,basis:d,revision:n.source.revision,fades:m,leaves:h},_=(e,n,{ground:r})=>{let i=cm.transitions[e]({z:Fv(`${this.key}@${n}`)*Iv});return{name:e,since:t,transition:{effect:Nv(i.effect,r),done:e=>i.done(e)}}},v=({since:e,transition:n})=>n.done(t-e),y=(e,t,n)=>({drawing:t,passage:f===null?null:n===void 0||n.passage?.name===`dissolve`?_(`fade`,e,t):n.passage!==null&&!v(n.passage)?n.passage:null}),b=(e,t)=>{if(t===void 0||t.drawing.own.length===0)return;if(t.passage?.name===`dissolve`)return v(t.passage)?void 0:t;let r={...t.drawing,own:t.drawing.own.map(n.hold)};return{drawing:r,passage:_(`dissolve`,e,r)}},ee=(e,r)=>{if(p.has(e))throw Error(`placement "${e}" was reached twice in one frame`);let i=f?.get(e),{drawing:a,deeper:o}=n.returned(e,r),s=a===null?b(e,i):y(e,a,i);return s===void 0?r:(p.set(e,s),s.passage!==null&&(s.passage.name===`fade`?m:h).push({placement:e,t:t-s.passage.since}),a===null?[...s.drawing.own,...o]:r)},x=(e,n)=>{let r=o.get(e)??a.get(e),i=r?.name===n?r:{name:n,since:t},s=t-i.since;return o.has(e)||(o.set(e,i),l.push({placement:e,effect:n,t:s})),{scope:e,name:n,t:s}},S=(e,t)=>{let n=c.get(e)??new Map;c.set(e,n);let r=n.get(t.scope);if(r!==void 0)return r.effect;let i=s.get(e)?.get(t.scope),a=i?.name===t.name,o=Fv(t.scope===kv?e:`${e}@${t.scope}`),l=a?i.effect:cm.loops[t.name]({z:o*Iv});return g[a?`reused`:`made`]++,n.set(t.scope,{name:t.name,effect:l}),l},te=e=>{let t=new Map;for(let{owner:n,placement:r}of e){let e=r.effect===`bar`?i:x(r.id,r.effect),a=t.get(e.scope);a===void 0?t.set(e.scope,{...e,owners:[n]}):a.owners.push(n)}return[...t.values()]},ne=e=>{let n=new Map;for(let{owner:t,placement:r}of e){let e=n.get(r.id);e===void 0?n.set(r.id,[t]):e.push(t)}return[...n].flatMap(([e,n])=>{let r=p.get(e)?.passage??null;return r===null?[]:[{t:t-r.since,effect:ep(r.transition.effect,...n)}]})};return{placed:d===`off`?(e,t)=>t:ee,row:(e,t)=>{let n=(t.some(e=>e.placement.effect!==`bar`)?te(t):[{...i,owners:void 0}]).filter(Av),r=ne(t);if(n.length===0&&r.length===0)return Ov;let a=`${this.key}#${e}`;return{kind:`moving`,wrap:e=>new Jf(e,jv(i.t,[...n.map(e=>{let t=S(a,e);return{t:e.t,effect:e.owners===void 0?t:Pv(t,e.owners)}}),...r]),{t:i.t,key:a,theme:Mv})}},drawn:()=>{this.inForce=r,this.placements=o,this.made=c,this.drawn=d===`off`?null:{source:n.source,placements:p},this.frame=g}}}},Rv=class{sessions=new Map;constructor(e=256){this.maxSessions=e}of(e){let t=this.sessions.get(e)??new Lv(e);this.sessions.delete(e),this.sessions.set(e,t);for(let e of this.sessions.keys()){if(this.sessions.size<=this.maxSessions)break;this.sessions.delete(e)}return t}getStats(){let e=0;for(let t of this.sessions.values())e+=t.heldCount;return{sessions:this.sessions.size,effects:e}}};function zv(e,t){let n=Is(t.colorSystem),r=[...Hu(e,{maxWidth:t.width??80,isTerminal:!1,asciiOnly:!1,theme:Ev,colorSystem:n.colorSystem,onStyleError:e=>{throw e}})];return{text:Pf(r,n),moves:Number.isFinite(W.nextChange(r))}}const Bv=new Map;function Vv(e){let t=Bv.get(e);if(t!==void 0)return t;let n=t=>{let n=t.seam.map(t=>`cap`in t?t:{...t,glyph:e});return{seam:n,divider:n}},{seam:r,caps:i}=Mf.plain,a=new ef({glyph:n(r.glyph),ascii:r.ascii},i);return Bv.set(e,a),a}function Hv(e,t){return e===`plain`&&t!==void 0?Vv(t):Mf[e]}const Uv=new Map;function Wv(e){let t=JSON.stringify([e.endcaps,e.separator??null]),n=Uv.get(t);if(n!==void 0)return n;let r=Hv(e.endcaps,e.separator),i=e=>new G(`x`,{end:``,overflow:`ignore`,style:new H({bgcolor:e})}),a=e=>new G(zv(new Dd(e,r),{colorSystem:null}).text.replace(/\n$/,``)).cellLength,o=a([i(`#101010`)]),s={chrome:o-1,seam:a([i(`#101010`),i(`#202020`)])-o-1};return Uv.set(t,s),s}function Gv(e){return Wv(e).chrome}function Kv(e){return Wv(e).seam}const qv=/[\u{E000}-\u{F8FF}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]/gu;function Jv(e){return[...new Set(e.match(qv)??[])].join(``)}function Yv(e){let t=Hv(e.endcaps,e.separator),n=e=>new G(`x`,{end:``,style:new H({bgcolor:e})});return Jv(zv(new Dd([n(`#101010`),n(`#202020`),n(`#202020`)],t),{colorSystem:null}).text)}function Xv(e,t,n=Ov){if(e.length===0)return{text:``,moves:!1};let r=Hv(t.endcaps,t.separator),i=t.wrap&&Number.isFinite(t.width),a={colorSystem:t.colorCompatibility,...i?{width:t.width}:{}},o=i?new gm([...e],{joiner:r}):new Dd([...e],r),s=zv(n.kind===`still`?o:n.wrap(o),a);if(!s.text.endsWith(`
54
+ `?[t+1,0]:[t,n+Zo(e)],a+=Zo(e),{glyph:e,cell:r}})}})}function Qf(e){return[e.underline,e.underline2,e.strike,e.overline,e.frame,e.encircle].some(e=>e===!0)}function $f(e,t,n,r){let i=r.backgroundColor.hex,a,o=()=>t().flatMap(({look:e,glyphs:t})=>{if(e===void 0)return[];let n=e.pair.bg.hex!==i||Qf(e.style);return t.flatMap(({glyph:e,cell:t})=>t!==void 0&&(e.trim()!==``||n)?[t]:[])}),s=e.flatMap(({segment:e,look:t})=>t!==void 0&&e.text.trim()!==``&&!hu(t.style.anchor,Sd)?[t.pair]:[]),c=[...new Map(s.map(e=>[`${e.fg.hex}/${e.bg.hex}/${e.terminal.fg}/${e.terminal.bg}/${e.reverse}`,e])).values()],l=e=>c.flatMap(t=>t.terminal[e]?[]:[t[e].hex]);return{cells:()=>a??=o(),pairs:c,colors:new Set([...l(`fg`),...l(`bg`)]),fills:new Set(l(`bg`)),depth:n,theme:r}}function ep(e,...t){let n=new Set(t),r=e=>wd(e.anchor,n),i=({fg:e,bg:t})=>e||t,a=e=>({...e,cells:()=>e.cells().filter(e=>i(r(e)))});return t=>au.map(e(a(t)),e=>(t,n)=>{let a=r(n);if(!i(a))return t;let o=e(t,n);return{fg:a.fg?o.fg:t.fg,bg:a.bg?o.bg:t.bg}})}function tp(e,t){return t?{fg:e.bg,bg:e.fg}:e}function np(e,t,n,r){let i=t.bg.compositeOver(Cs),a=t.fg.compositeOver(i);return{fg:B.matchMove(e.fg,a,n,r,!0),bg:B.matchMove(e.bg,i,n,r,!1)}}function rp(e,t){return ip(e.color,t.color,!0)&&ip(e.bgcolor,t.bgcolor,!1)}function ip(e,t,n){return e===t||ap(e,n)===ap(t,n)}function ap(e,t){return e?.getAnsiCodes(t).join(`;`)??``}function op(e,t){return sp(e.fg,t.fg)&&sp(e.bg,t.bg)}function sp(e,t){return e.red===t.red&&e.green===t.green&&e.blue===t.blue&&e.alpha===t.alpha}const cp=(()=>{let e=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];return[...e,...e]})(),lp=e=>e*e*e*(e*(e*6-15)+10),up=(e,t,n)=>e+n*(t-e);function dp(e,t,n,r){let i=e&15,a=i<8?t:n,o=i<4?n:i===12||i===14?t:r;return(i&1?-a:a)+(i&2?-o:o)}function fp(e,t,n){let r=Math.floor(e),i=Math.floor(t),a=Math.floor(n),o=r&255,s=i&255,c=a&255;e-=r,t-=i,n-=a;let l=lp(e),u=lp(t),d=lp(n),f=cp[o]+s,p=cp[f]+c,m=cp[f+1]+c,h=cp[o+1]+s,g=cp[h]+c,_=cp[h+1]+c;return up(up(up(dp(cp[p],e,t,n),dp(cp[g],e-1,t,n),l),up(dp(cp[m],e,t-1,n),dp(cp[_],e-1,t-1,n),l),u),up(up(dp(cp[p+1],e,t,n-1),dp(cp[g+1],e-1,t,n-1),l),up(dp(cp[m+1],e,t-1,n-1),dp(cp[_+1],e-1,t-1,n-1),l),u),d)}function pp(e,t,n,r){let i=0,a=1,o=0;for(let s=0;s<r;s++){let r=2**s;i+=a*fp(e*r,t*r,n*r),o+=a,a/=2}return i/o}function mp(e,t){let n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)}function hp(e,t,n){let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)}const gp=Array.from({length:48},(e,t)=>(t+1)/48);function _p(e,t){return Math.min(Ts(e.fg,e.bg),4.5)-(t===z.TRUECOLOR?.01:0)}const vp=[`fg`,`bg`];function yp({pairs:e,depth:t,theme:n},r,i){let a=(e,t)=>e.terminal[t]?void 0:e[t].hex,o=new Map(e.flatMap(e=>vp.flatMap(t=>{let n=a(e,t);return n===void 0?[]:[[n,e[t]]]}))),s=new Map([...r].filter(e=>!o.has(e)).map(e=>[e,1])),c=e=>V.fromRgba(o.get(e)).l;for(let l of[...r].filter(e=>o.has(e)).sort((e,t)=>c(t)-c(e))){let r=e.flatMap(e=>{let t=vp.find(t=>a(e,t)===l);if(t===void 0)return[];let n=a(e,t===`fg`?`bg`:`fg`);return[[e,t,n===void 0?0:s.get(n)??0]]}),o=e=>r.every(([r,a,o])=>{let s=_p(r,t),c=(t,n)=>Ep(i,r[t],(t===a?e:o)*n);return gp.every(e=>{let i=Jf.shows(r,{fg:c(`fg`,e),bg:c(`bg`,e)},t,n);return Ts(i.fg,i.bg)>=s})}),[c,u]=o(1)?[1,1]:[0,1];for(let e=0;e<20&&u-c>.001;e++){let e=(c+u)/2;[c,u]=o(e)?[e,u]:[c,e]}s.set(l,c)}return s}function bp(e,t){let n=new WeakMap;return wp(Cp(e,r=>{let i=t??r.colors,a=[xp(r),`|`,...i].join(` `),o=n.get(r.theme)??new Go;return n.set(r.theme,o),o.get(a,()=>yp(r,i,e.touch))}))}function xp({depth:e,pairs:t}){return[e,...t.map(Sp)].join(` `)}function Sp({fg:e,bg:t,terminal:n,reverse:r}){return`${e.hex}/${t.hex}/${n.fg}/${n.bg}/${r}`}function Cp(e,t){return n=>{let r=t(n);return au.continuous(t=>{let i=e.field(t,n);return({fg:t,bg:n},a)=>{let o=Math.round(Ap(i(a))*48)/48,s=(t,n)=>Ep(e.touch,t,(n?0:r.get(t.hex)??0)*o);return{fg:s(t,a.terminal.fg),bg:s(n,a.terminal.bg)}}})}}function wp(e){return t=>Tp(t.depth)?au.constant(e=>e):e(t)}function Tp(e){switch(e){case z.DEFAULT:case z.STANDARD:case z.WINDOWS:return!0;case z.EIGHT_BIT:case z.TRUECOLOR:return!1}}function Ep(e,t,n){return n===0?t:e(t,n)}function Dp(e){if(!(Number.isFinite(e.seconds)&&e.seconds>0))throw RangeError(`curve: seconds must be a positive number of seconds, got ${e.seconds}`);if(!(e.swing>=0&&e.swing<=1))throw RangeError(`curve: swing must be in [0, 1], got ${e.swing}`)}const Op={shimmer:{seconds:109,ease:ql.linear,swing:.9},pulse:{seconds:43,ease:ql.linear,swing:.85},sparkle:{seconds:139,ease:ql.linear,swing:.95},wheel:{seconds:907,ease:ql.linear,swing:1},fade:{seconds:20,ease:ql[`ease-in-out`],swing:1},dissolve:{seconds:30,ease:ql[`ease-in-out`],swing:1}},kp={sun:new R(255,228,176),firefly:new R(222,245,140)},Ap=e=>Math.min(1,Math.max(0,e));function jp(e,t,n){if(!(n>=0&&n<=1))throw RangeError(`blend: w must be in [0, 1]; got ${n}`);let r=Math.PI/180,i=(1-n)*e.c*Math.cos(e.h*r)+n*t.c*Math.cos(t.h*r),a=(1-n)*e.c*Math.sin(e.h*r)+n*t.c*Math.sin(t.h*r);return new V((1-n)*e.l+n*t.l,Math.hypot(i,a),Math.atan2(a,i)/r,e.alpha)}function Mp(e){let t=V.fromRgba(e);return(e,n)=>{let r=V.fromRgba(e);return jp(r,new V(Math.max(r.l,t.l),t.c,t.h,t.alpha),n).toRgba()}}const Np=(e,t)=>t*e[e.length-1][0];function Pp(e,t,n){let r=t/n,i=e.findIndex(([e])=>r<e);if(!(r>0)||i<0)return 0;let[a,o]=i===0?[0,0]:e[i-1],[s,c]=e[i];return n*(o+(c-o)*(1-Math.cos(Math.PI*(r-a)/(s-a)))/2)}function Fp(e,t,n){let r=Np(e,n),i=t=>{let r=0;for(let i=0;i<24;i++)r+=Pp(e,(i+.5)/24*t,n);return r*t};return i(Math.min(Math.max(t,0),r))/i(r)}const Ip=[[.24,1],[.6,0]];function Lp(e,t,n){Dp(e);let r=.9+.2*mp(n,3.1),i=t=>.1*fp(t/(3*e.seconds),.5,.5+n),a=i(0);return{touch:Mp(t),field:t=>{let o=r*t/e.seconds+i(t)-a,s=Math.floor(o),c=.7+.3*hp(-.5,.5,fp(s*.37,2.1,n)),l=.5-.5*Math.cos(2*Math.PI*(o-s)),u=e.swing*e.ease(c*l);return()=>u}}}const Rp=e=>Math.abs(e)>=1?0:(1-e*e)**3;function zp(e,t,n,r){Dp(e);let i=e.seconds,a=i/2,o=e=>hp(-.4,.4,fp(e/7,3.3,5.5+r)),s=.7,c=.51,l=.4,u=(e,n,u)=>{let d=o(e),f=(mp(e,7.5+r)<.35+.6*d)*(.3+.7*d*(.6+.4*mp(e,8.5+r))),p=i*u/80*(c+l*mp(e,5.5+r)),m=Ap((n-(e+s*mp(e,6.5+r))*a)/p);return{strength:f,centre:m*u-t+.06*u*Math.sin(Math.PI*m)*fp(m,2.7,e+r)}},d=(e,t)=>{let n=s+(c+l)*i*t/80/a,r=Math.floor(e/a),o=[];for(let i=Math.max(0,Math.ceil(r-n));i<=r;i++)o.push(u(i,e,t));return o},f=(e,t,n)=>Math.exp(-((fp(e,t,n)/.8)**2));return{touch:Mp(n),field:(n,i)=>{let[a,o]=Gp(i.cells().map(e=>e.col)),s=d(n,o-a+1+2*t);return i=>{let o=0;for(let{strength:e,centre:n}of s)o=Math.max(o,e*Rp((i.col-a-n)/t));let c=i.row+r,l=.8*fp(i.col*.05,c*.3+1.3,n*.02),u=(f(i.col*.21+l,c*.9,n*.022)*f(i.col*.33+9.1-l,c*.7,n*.018+4.2))**2;return e.swing*e.ease(o*(.1+.6*u))}}}}function Bp(e,t,n){Dp(e);let r=e.seconds,i=22.1,a=3.1,o=(e,t,i,a,o)=>{let s=e*4.9+t*31.7+.3+n,c=e+.5+.7*fp(e*1.7+.2,.3+t*2.9,.5+n),l=i+mp(e+t*1013,.7+n)*r,u=Math.floor(l/r),d=mp(u,s+1)<.15?0:1,f=.5+.5*mp(u,s+2),p=mp(u,s+3)*(1-Np(Ip,f)),m=l/r-u-p;return{x:a+c*8+5*(2*mp(u,s+4)-1)+5*f*(2*mp(u,s+5)-1)*Fp(Ip,m,f)+1.5*fp(s,.1,i*.035),y:o+t*3+.6*fp(s,2.2,i*.035),glow:d*Pp(Ip,m,f)}};return{touch:Mp(t),field:(t,n)=>{let r=n.cells(),[s,c]=Gp(r.map(e=>e.col)),[l,u]=Gp(r.map(e=>e.row)),d=e=>(e-s)/8-.5,f=e=>(e-l)/3,[p,m]=[Math.ceil(d(s-i)),Math.floor(d(c+i))],[h,g]=[Math.ceil(f(l-a)),Math.floor(f(u+a))],_=Array.from({length:g-h+1},(e,n)=>Array.from({length:m-p+1},(e,r)=>o(p+r,h+n,t,s,l)));return t=>{let n=0,[r,o]=[Math.max(p,Math.ceil(d(t.col-i))),Math.min(m,Math.floor(d(t.col+i)))],[s,c]=[Math.max(h,Math.ceil(f(t.row-a))),Math.min(g,Math.floor(f(t.row+a)))];for(let e=s;e<=c;e++)for(let i=r;i<=o;i++){let r=_[e-h][i-p];n=Math.max(n,r.glow*Rp(Math.hypot(t.col-r.x,2*(t.row-r.y))/5))}return e.swing*e.ease(n)}}}}function Vp(e,t){return n=>{let r=V.fromRgba(n.theme.backgroundColor);return au.continuous(i=>{let a=e(i,n);return(e,n)=>{let i=t*(1-Ap(a(n)));if(i===0)return e;let o=jp(V.fromRgba(e.bg),r,i);return{fg:jp(V.fromRgba(e.fg),o,i).toRgba(),bg:o.toRgba()}}})}}function Hp(e){let t=new Map;return n=>{let r=`${n.row}:${n.col}`,i=t.get(r)??Ap(.5+1.1*pp(n.col*.09+1.4*fp(n.col*.035,n.row*.2+2.6,e+.5),n.row*.45,e,3));return t.set(r,i),i}}function Up(e,t){let n=t=>t>=e.seconds;return{effect:r=>{let i=t(r);return{at:e=>i.at(e),nextChange:e=>n(e)?1/0:i.nextChange(e),lastChange:t=>n(t)?e.seconds:i.lastChange(t)}},done:n}}function Wp(e,t){let n=new Map,r=e=>`${e.row}:${e.col}`;return i=>{let[a,o]=Gp(i.map(t)),s=(o>a?.55:0)*e.seconds,c=iu.once(0,e.seconds-s),l=e=>{let n=o>a?Ap((t(e)-a)/(o-a)):0;return{along:n,progress:e=>c(e-n*s)}};for(let e of i){let t=r(e);n.set(t,n.get(t)??l(e))}return e=>n.get(r(e))??l(e)}}function Gp(e){let t=e[0]??0,n=t;for(let r of e)t=Math.min(t,r),n=Math.max(n,r);return[t,n]}function Kp(e,t){Dp(e);let n=Wp(e,Hp(1.7+t));return Up(e,Vp((t,r)=>{let i=n(r.cells());return n=>e.ease(i(n).progress(t))},e.swing))}const qp={depth:.4,from:.5,to:.95,maskFrom:.35,maskTo:.75,late:.6};function Jp(e,t){Dp(e);let n=Hp(9.3+t),r=Wp(e,Hp(4.2+t)),{depth:i,from:a,to:o,maskFrom:s,maskTo:c,late:l}=qp;return Up(e,Vp((t,u)=>{let d=r(u.cells());return r=>{let{along:u,progress:f}=d(r),p=e.ease(f(t)),m=Ap((p-a)/(o-a)),h=i*hp(s,c,n(r))*(1-l+l*u)*Math.sin(Math.PI*m)**2;return 1-p+h}},e.swing))}const Yp=[211,337];function Xp(e,t){Dp(e);let n=e.seconds,r=e=>mp(Number.parseInt(e.slice(1),16)*1e-4,17.3+t),i=(e,n)=>fp(n/Yp[0],5.9+97*e,t)+.5*fp(n/Yp[1],2.3+89*e,t+7.1),a=(t,a)=>{let o=r(t);return 360*a/n+e.swing*180*((i(o,a)-i(o,0))/1.5)},o=new WeakMap;return wp(e=>{let{colors:t,fills:n,depth:r,theme:i}=e,s=(e,n)=>!e&&t.has(n.hex),c=(e,t,r)=>n.has(e.hex)||!r?e.hex:t.hex,l=(e,t)=>`${e.hex} ${t}`,u=o.get(i)??new Go;o.set(i,u);let d=u.get(xp(e),()=>nm(e.pairs,r,(e,t)=>{let n=t===`fg`?`bg`:`fg`;return s(e.terminal[t],e[t])?l(e[t],c(e[t],e[n],s(e.terminal[n],e[n]))):void 0})),f=am(r,i);return au.continuous(e=>{let t=new Map,n=(t,n)=>{let i=Zp(t,a(n,e));return om(i.looks,t,r===z.TRUECOLOR?i.either.map(rm):f,d.get(l(t,n))??$p)},i=(e,r)=>{let i=t.get(l(e,r))??n(e,r);return t.set(l(e,r),i),i};return(e,t)=>{let n={fg:s(t.terminal.fg,e.fg),bg:s(t.terminal.bg,e.bg)},r=(e,t,n,r)=>t?i(e,c(e,n,r)):e;return{fg:r(e.fg,n.fg,e.bg,n.bg),bg:r(e.bg,n.bg,e.fg,n.fg)}}})})}function Zp(e,t){if(t===0)return{looks:e,either:[e]};let n=V.fromRgba(e),r=ws(e),i=e=>new V(e,n.c,n.h+t,n.alpha).toRgba(),[a,o]=[0,1];for(let e=0;e<24;e++){let e=(a+o)/2;[a,o]=ws(i(e))<r?[e,o]:[a,e]}return{looks:i(o),either:[i(a),i(o)]}}const Qp=e=>Math.log(Ts(e,new R(0,0,0))),$p={lo:-1/0,hi:1/0},em={lo:1/0,hi:-1/0},tm=Math.log(1.031);function nm(e,t,n){let r=new Map;for(let i of e.filter(e=>_p(e,t)>1)){let e=(Math.log(Ts(i.fg,i.bg))-Math.log(_p(i,t)))/vp.filter(e=>n(i,e)!==void 0).length;for(let t of vp){let a=n(i,t);if(a===void 0)continue;let[o,s]=[Qp(i[t]),Qp(i[t===`fg`?`bg`:`fg`])],{lo:c,hi:l}=r.get(a)??$p;r.set(a,o>=s?{lo:Math.max(c,o-e),hi:l}:{lo:c,hi:Math.min(l,o+e)})}}return new Map([...r].map(([e,{lo:t,hi:n}])=>[e,n-t<tm?em:{lo:t,hi:n}]))}const rm=e=>({color:e,looks:V.fromRgba(e),stop:Qp(e)}),im=new WeakMap;function am(e,t){let n=B.indexed(e,t),r=im.get(n)??n.map(([,e])=>rm(e));return im.set(n,r),r}function om(e,t,n,{lo:r,hi:i}){return sm(e,[rm(t),...n.filter(({stop:e})=>e>=r&&e<=i)]).color}function sm(e,t){let n=V.fromRgba(e),r;for(let e of t){let t=n.deltaE(e.looks);(r===void 0||t<r[1])&&(r=[e,t])}return r?.[0]}const cm={loops:{shimmer:(e,t=Op.shimmer)=>bp(zp(t,24,kp.sun,e.z)),pulse:(e,t=Op.pulse)=>bp(Lp(t,kp.sun,e.z)),sparkle:(e,t=Op.sparkle)=>bp(Bp(t,kp.firefly,e.z)),wheel:(e,t=Op.wheel)=>Xp(t,e.z)},transitions:{fade:(e,t=Op.fade)=>Kp(t,e.z),dissolve:(e,t=Op.dissolve)=>Jp(t,e.z)}};var lm=class{beat;width;_shown;constructor(e){this.beat=ru(e.map(e=>e.seconds));let t=e.map(e=>qf(e.text.copy())),n=t.map(e=>e.cellLength);this.width=Math.max(...n),this._shown=t.map((e,t)=>(e.noWrap=!0,e.overflow=`crop`,e.padRight(this.width-n[t])))}at(e){return this._shown[this.beat.at(e)].copy()}nextChange(e){return this.beat.nextChange(e)}lastChange(e){return this.beat.lastChange(e)}};function um(e,t){return e.at(t).copy().stylize(new H({nextChange:e.nextChange(t)}))}function dm(e,t){let n=[...Hu(e,t)],r=0;for(let e of n)r+=e.cellLength;return{segments:n,width:r}}const fm={segments:[],width:0},pm={left:()=>0,justify:()=>0,center:e=>Math.floor(e/2),right:e=>e};function mm(e,t){return pm[e](t)}function hm(e,t,n,r){let i=Math.max(0,r-1),a=e===`justify`&&!t&&i>0&&n>0?n:0,o=i>0?Math.floor(a/i):0,s=a-o*i;return Array.from({length:i},(e,t)=>o+ +(t<s))}var gm=class{items;joiner;gap;align;constructor(e,t){this.items=e,this.joiner=t?.joiner,this.gap=t?.gap??0,this.align=t?.align??`left`}contents(){return this.items}*render(e){let t=this.items;if(t.length===0)return;let n=Math.max(1,e.maxWidth),r=this.gap,i=this.joiner,a=t.map(t=>dm(Ed(t),e)),o=n=>i?dm(Td(i,null,t[n],{index:n}),e):fm,s=n=>i?dm(Td(i,t[n],null,{index:n+1}),e):fm,c=(n,r)=>i?dm(Td(i,t[n],t[r],{index:r}),e):fm,l=[],u=null,d=r>0?{segments:[new W(` `.repeat(r))],width:r}:fm;for(let e=0;e<t.length;e++){let t=a[e];if(u===null){let n=o(e),r=s(e),i=n.width>0?[n,t]:[t],a=[i.length-1];u={blocks:i,width:n.width+t.width,lastIndex:e,itemBlockIndices:a},u.endCap=r;continue}let i=u.lastIndex,f=c(i,e),p=s(e),m=(r>0?r:0)+f.width+(r>0?r:0)+t.width;if(u.width+m+p.width<=n)r>0&&u.blocks.push(d),f.width>0&&u.blocks.push(f),r>0&&u.blocks.push(d),u.blocks.push(t),u.itemBlockIndices.push(u.blocks.length-1),u.width+=m,u.lastIndex=e,u.endCap=p;else{let n=u.endCap;n.width>0&&u.blocks.push(n),u.width+=n.width,l.push(u);let r=o(e),i=s(e),a=r.width>0?[r,t]:[t],c=[a.length-1];u={blocks:a,width:r.width+t.width,lastIndex:e,itemBlockIndices:c},u.endCap=i}}let f=u;{let e=f.endCap;e.width>0&&f.blocks.push(e),f.width+=e.width,l.push(f)}let p=this.align;for(let e=0;e<l.length;e++){let t=l[e],r=e===l.length-1,i=Math.max(0,n-t.width),a=mm(p,i),o=hm(p,r,i,t.itemBlockIndices.length),s=new Map;t.itemBlockIndices.forEach((e,t)=>s.set(e,t)),a>0&&(yield new W(` `.repeat(a)));for(let e=0;e<t.blocks.length;e++){let n=s.get(e);if(n!==void 0&&n>0){let e=o[n-1];e>0&&(yield new W(` `.repeat(e)))}yield*t.blocks[e].segments}yield W.line()}}measure(e){let t=this.items;if(t.length===0)return{minimum:0,maximum:0};let n=0,r=0;for(let i=0;i<t.length;i++){let a=dm(t[i],e).width,o=this.joiner?dm(Td(this.joiner,null,t[i],{index:i}),e).width:0,s=this.joiner?dm(Td(this.joiner,t[i],null,{index:i+1}),e).width:0;n=Math.max(n,a+o+s),r+=a,i>0&&(r+=this.gap*2,this.joiner&&(r+=dm(Td(this.joiner,t[i-1],t[i],{index:i}),e).width))}return this.joiner&&(r+=dm(Td(this.joiner,null,t[0],{index:0}),e).width,r+=dm(Td(this.joiner,t[t.length-1],null,{index:t.length}),e).width),{minimum:n,maximum:r}}};function _m(){let e=new WeakMap;return(t,n,r)=>{let i=e.get(t);i===void 0&&(i=new Map,e.set(t,i));let a=i.get(n);if(a!==void 0)return a;let o=r();return i.set(n,o),o}}const vm=[`primary`,`secondary`,`accent`],ym=[`darken-3`,`darken-2`,`darken-1`,`base`,`lighten-1`,`lighten-2`,`lighten-3`],bm={"darken-3":`-darken-3`,"darken-2":`-darken-2`,"darken-1":`-darken-1`,base:``,"lighten-1":`-lighten-1`,"lighten-2":`-lighten-2`,"lighten-3":`-lighten-3`,muted:`-muted`},xm=(e,t)=>`${e}${bm[t]}`,Sm=(e,t,n,r)=>th(e,n,r),Cm=(e,t,n,r)=>rh(e,Gm(e,`text-${t}`),n,r),wm=e=>({tones:[ym[e],ym[e+2],ym[e+1]],text:Sm}),Tm={muted:{tones:[`muted`],text:Cm},deepest:wm(0),deeper:wm(1),middle:wm(2),brighter:wm(3),brightest:wm(4)},Em=1/0,Dm={accent:{hues:[`secondary`,`accent`],run:Em},duo:{hues:[`primary`,`secondary`],run:Em},mono:{hues:[`primary`],run:Em},alt:{hues:[`secondary`,`accent`],run:3}},Om=e=>e.variation.hues.flatMap(t=>e.shade.tones.map(e=>({hue:t,shade:e}))),km=e=>{let t=0,n=.5;for(let r=e;r>0;r>>=1,n/=2)t+=n*(r&1);return t},Am=[`van-der-corput`,`golden-angle`,`ends-interleaved`,`monotonic`,`uniform`],jm=e=>typeof e==`string`&&Am.includes(e),Mm={"van-der-corput":km,"golden-angle":e=>e*.6180339887498949%1,"ends-interleaved":(e,t)=>((e%2==0?e/2:t-1-(e-1)/2)+.5)/t,monotonic:(e,t)=>(e+.5)/t,uniform:()=>.5},Nm=e=>Mm[e??`van-der-corput`];function Pm(e){let t=0,n=1;for(let{index:r,count:i,distribution:a}of e)t+=a(r,i)*n,n*=.37;return t%1}const Fm=(e,t)=>Math.floor(e*t),Im=(e,t)=>Math.round(e*t)%t;function Lm(e){return e===void 0?0:e.distribution(e.index,e.count)}function Rm(e,t,n){let r=e[n(Lm(t),e.length)];if(r===void 0)throw Error(`vocabularySelect: empty vocabulary`);return r}function zm(e){let t=e.findIndex(e=>e.axis===`cell`),n=t===-1?e:e.slice(0,t);return{row:n.at(-1),cell:e[n.length]}}const Bm=(e,t)=>Fm(Lm(t),e.hues.length);function Vm(e,t){let{row:n,cell:r}=zm(t);return Hm(e,n,r)}function Hm(e,t,n){let{hues:r,run:i}=e.variation,a=n===void 0?0:Math.floor(n.index/i),o=r[(Bm(e.variation,t)+a)%r.length];if(o===void 0)throw Error(`decorEntryFor: empty variation`);return{hue:o,shade:Rm(e.shade.tones,n,Im)}}function Um(e,t){let{row:n,cell:r}=zm(t),i=r===void 0?[void 0]:Array.from({length:r.count},(e,t)=>({...r,index:t}));return[...new Map(i.map(t=>Hm(e,n,t)).map(e=>[xm(e.hue,e.shade),e])).values()].sort((e,t)=>vm.indexOf(e.hue)-vm.indexOf(t.hue)||Wm.indexOf(e.shade)-Wm.indexOf(t.shade))}const Wm=[...ym,`muted`];function Gm(e,t){let n=e.get(t);if(n===void 0)throw Error(`palette "${e.name}" has no "${t}" role; decoration needs it`);return n}const Km=(e,t)=>Gm(e,xm(t.hue,t.shade)),qm=2.2,Jm=(e,t)=>t.map(t=>Km(e,t)),Ym=e=>t=>Gc(t,e),Xm=Ym(z.TRUECOLOR);function Zm(e,t,n,r){return Qm(e,`${t}|${n.map(e=>e.hex).join(`+`)}|${r}`,()=>$m(e,t,n,r))}const Qm=_m();function $m(e,t,n,r){let i=n.map(Xm),a=Gm(e,t),o=new R(0,0,0),s=new R(255,255,255),c=(e,t)=>V.fromRgba(a).mixAxes(V.fromRgba(e),{l:t,c:0,h:0,alpha:0}).toRgba(),l=e=>Array.from({length:12},(t,n)=>c(e,(n+1)/12)),u=l(o),d=[a,...l(s).flatMap((e,t)=>[e,u[t]])],f=e=>{let t=Ym(e),n=i.map(t);return e=>Math.min(1/0,...n.map(n=>Ts(t(e),n)))},p=f(z.TRUECOLOR),m=f(r),h=e=>Wc(e,r,(e,t)=>i.every(n=>Ts(e,t(n))>=qm)),g=e=>p(e)>=2.2&&h(e)!==void 0,_=(e,t)=>{let n=n=>Ts(Xm(n),e)-Ts(Xm(n),t),r=n(a)<0?o:s,i=r===o?1:-1,[l,u]=[0,1];for(let e=0;e<40;e++){let e=(l+u)/2;i*n(c(r,e))>0?u=e:l=e}return[c(r,l),c(r,u)]},v=()=>{let e=[...i].sort((e,t)=>ws(e)-ws(t));return e.slice(1).flatMap((t,n)=>_(t,e[n]))},y=d.find(g)??[...d,...v()].reduce((e,t)=>m(t)>m(e)?t:e),b=h(y)??y,ee=m(b);return{anchor:y,state:b,short:ee>=2.2?null:ee}}const eh=4.5;function th(e,t,n){return nh(e,`${t.hex}|${n}`,()=>{let r=Hc(t);return rh(e,[`background`,`foreground`].map(t=>Gm(e,t)).reduce((e,t)=>Ts(r,t)<Ts(r,e)?t:e),t,n)})}const nh=_m();function rh(e,t,n,r){return ih(e,`${t.hex}|${n.hex}|${r}`,()=>Uc(t,n,eh,r))}const ih=_m();function ah(e,t,n){return t.depth===0?Jm(e,t.ground):oh(e,t,n)}const oh=(e,t,n)=>t.depth===0?[]:[_h(e,{...t,depth:t.depth-1},n).plane],sh=(e,{short:t},n)=>t===null?[]:[`theme "${e.name}": no open-trigger colour stands ${qm}:1 off every cell beside it — the nearest stands ${t.toFixed(2)}:1 as drawn at depth ${z[n]}; another shade or variation clears it`],ch=(e,t,n)=>t>=fh.triggerPlane?[]:[`theme "${e.name}": an open band's plane stands ΔE ${t.toFixed(3)} off the trigger that opened it as drawn at depth ${z[n]}, under the ${fh.triggerPlane} that tells them apart; another style clears it`],lh={base:.42,perDepth:.14,cap:.75},uh={floor:.12,span:.8};function dh(e,t){return vm[(vm.indexOf(e)+t)%vm.length]}const fh={triggerPlane:.1,nestedPlane:.035};function ph(e,t,n){return mh(e,`${hh(t)}|${n}`,()=>{let r=Zm(e,dh(t.hue,t.depth),ah(e,t,n),n),{state:i}=r,a=xh(e,t,i,n),o=Wc(_h(e,t,n).plane,n,(e,t)=>a.every(n=>n(e,t)));if(o===void 0)throw Error(`palette "${e.name}": the ${t.hue} band at depth ${t.depth} cannot keep its floors on the colours drawn at depth ${z[n]}`);let s=Ym(n);return{state:i,plane:o,shortfalls:n===z.DEFAULT?[]:[...sh(e,r,n),...ch(e,gh(s(i),s(o)),n)]}})}const mh=_m(),hh=({hue:e,depth:t,ground:n})=>`${e}|${t}|${n.map(e=>xm(e.hue,e.shade)).join(`+`)}`,gh=(e,t)=>V.fromRgba(e).deltaE(V.fromRgba(t));function _h(e,t,n){return vh(e,`${hh(t)}|${n}`,()=>yh(e,t,n))}const vh=_m();function yh(e,t,n){let{anchor:r}=Zm(e,dh(t.hue,t.depth),ah(e,t,n),n),i=Math.min(lh.cap,lh.base+lh.perDepth*t.depth),a=(t,n)=>ic(r,Gm(e,t),n),o=oh(e,t,n),s=e=>gh(Xm(r),Xm(e))>=fh.triggerPlane&&o.every(t=>gh(Xm(t),Xm(e))>=fh.nestedPlane),c=a(`background`,i);return{state:r,plane:[c,a(`foreground`,i),a(`background`,lh.cap),a(`foreground`,lh.cap),...bh.toSorted((e,t)=>Math.abs(e-i)-Math.abs(t-i)).flatMap(e=>[a(`background`,e),a(`foreground`,e)])].find(s)??c}}const bh=Array.from({length:12},(e,t)=>(t+1)/12);function xh(e,t,n,r){let{hue:i,depth:a,ground:o}=t,s=t=>_h(e,{hue:i,depth:t,ground:o},r).state,c=t=>_h(e,{hue:i,depth:t,ground:o},r).plane,l=c(a),u=(e,t)=>gh(Xm(l),Xm(t))>=e?e:0,d=Zm(e,dh(i,a+1),ah(e,{hue:i,depth:a+1,ground:o},r),r),f=Ts(Xm(l),Xm(d.anchor))>=2.2?qm:0,p=(e,t)=>(n,r)=>gh(n,r(e))>=t;return[p(n,u(fh.triggerPlane,s(a))),(e,t)=>Ts(e,t(d.state))>=f,...a>0?[p(ph(e,{hue:i,depth:a-1,ground:o},r).plane,u(fh.nestedPlane,c(a-1)))]:[]]}function Sh(e,t,n,r){let i=ph(e,t,r),a=_h(e,t,r),o=e=>ic(a.plane,a.state,e),s=uh.floor+uh.span*Pm(n),c=uh.floor+uh.span/2,l=(e,t)=>e.hex!==t(i.plane).hex&&e.hex!==t(i.state).hex;for(let e=0;e<=12;e++){let t=Wc(o(s+(c-s)*e/12),r,l);if(t!==void 0)return t}return o(s)}const Ch=e=>({kind:`bar`,decor:e,address:[]}),wh=(e,t)=>({...e,address:[...e.address,t]}),Th=e=>({kind:`band`,band:e,address:[]});function Eh(e,t,n){switch(t.kind){case`bar`:{let{decor:r,address:i}=t,a=Vm(r,i),o=Km(e,a),s;return{tint:o,text:r.shade.text(e,a.hue,o,n),disclosure:{hue:`accent`,depth:0,get ground(){return s??=Um(r,i)}}}}case`band`:{let{band:r,address:i}=t,a=Sh(e,r,i,n);return{tint:a,text:th(e,a,n),disclosure:{...r,depth:r.depth+1}}}}}const Dh=new Map([[`dark`,`textual-dark`],[`light`,`textual-light`]]);function Oh(e){let t=typeof e==`string`?Dh.get(e):void 0;return t===void 0?``:` — "${e}" was retired; write "${t}", the same palette`}const kh=`textual-dark`;function Ah(e,t,n,r,i){let a=t===null?null:i(t);return e??a??n??r}function jh(){return fl()}function Mh(){return[`bar`,...jh()]}let Nh;function Ph(e){return Nh??=new Set(Mh()),Nh.has(e)}function Fh(e,t,n,r,i){let a=e=>Object.prototype.hasOwnProperty.call(i,e)?e:null;return Ah(e===void 0?null:a(e),t,a(n??r),r,a)}const Ih=[`style`,`palette`,`effect`];function Lh(e){return e!==void 0&&e.includes(`{{`)}function Rh(e,t,n,r,i){let a=Lh(n)?{kind:`expression`,source:n}:i(n??r.name);return Ah(e===void 0?null:i(e),t,a,r,i)}function zh(e,t){return e.kind===`decided`?e:t(e.source)}const Bh=`none`;function Vh(e,t){let n=t[e];return n===void 0?null:{kind:`decided`,name:e,value:n}}function Hh(e,t){return Vh(e,t)??Vh(`none`,t)??{kind:`decided`,name:`none`,value:Sc}}function Uh(e,t,n,r){return Rh(e,t,n,Hh(Bh,r),e=>Vh(e,r))}const Wh=`none`,Gh={style:Bh,palette:kh,effect:Wh};function Kh(e,t,n){return`${e} rendered "${Gh[t]}": ${n}`}const qh=Object.freeze([Wh,...Object.keys(cm.loops)]),Jh=Object.freeze([`bar`,...qh]);function Yh(e){let t=qh.find(t=>t===e);return t===void 0?null:{kind:`decided`,name:e,value:t}}function Xh(e){return Yh(e)??{kind:`decided`,name:`none`,value:`none`}}function Zh(e,t,n){return Rh(e,t,n,Xh(Wh),Yh)}const Qh=Object.freeze(Object.keys(Mf)),$h=[`powerline`,`capsule`,`plain`];function eg(e){return $h.includes(e)}const tg=[`truecolor`,`256`,`ansi`,`none`];function ng(e){return Rs(e)??z.DEFAULT}const rg=Object.keys(Dm),ig=Object.keys(Tm),ag=`true`,og=`false`,sg=[ag,og],cg={min:0,max:16};function lg(e){return e===`true`?!0:e===`false`?!1:null}function ug(e,t){let n=Number(e);return Number.isInteger(n)&&String(n)===e&&n>=t.min&&n<=t.max?n:null}const dg=[`vertical`,`horizontal`],fg={vertical:`row`,horizontal:`cell`};function pg(e){return e.id??e.name}function mg(e){return[..._g(e)].flatMap(e=>e.kind===`segment`?[pg(e)]:[])}function hg(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function gg(e,t){return e.opens===void 0?e:{...e,opens:{...e.opens,body:t(e.opens.body)}}}function*_g(e){yield e;for(let t of xg(e))yield*_g(t)}const vg=(e,t)=>`${e}.children[${t}]`,yg=e=>`${e}.opens.body`;function*bg(e,t){if(yield[e,t],e.kind===`container`)for(let[n,r]of e.children.entries())yield*bg(r,vg(t,n));else e.opens!==void 0&&(yield*bg(e.opens.body,yg(t)))}function xg(e){return e.kind===`container`?e.children:e.opens===void 0?[]:[e.opens.body]}function Sg(e){return e===void 0||`text`in e?`text`:`regex`in e?`regex`:`json`}const Cg=[`ttl`,`watch_file`,`depends_on`,`key`,`never`];function wg(e){return e.kind===`file`||e.kind===`shell`}const Tg=[`branch`,`sha`,`dirty`,`ahead`,`behind`,`stash`],Eg=[`fail`,`ignore`];function Dg(e){return e.missingData??`fail`}function*Og(e){for(let[t,n]of Object.entries(e.variables))n.kind===`state`&&(yield[t,n]);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))r.kind===`state`&&(yield[`${t}.${e}`,r])}const kg=`theme`,Ag=`effect`,jg=[kg,Ag];function Mg(e){return{...e.settings,[kg]:{label:kg,domain:`theme`,default:e.palette??`bar`},[Ag]:{label:Ag,domain:Jh,default:`bar`}}}function Ng(e){let t=e?.domain;return typeof t==`object`&&`min`in t?t:void 0}function Pg(e,t){return Object.entries(e).flatMap(([n,r])=>{let i=Ng(r)?.atLeast;if(i===void 0)return[];let a=t[n],o=t[i];return a>=o?[]:[{setting:n,message:`"${n}" (${a}) is below "${i}" (${o}) — ${r.label} must be at least ${e[i].label}`}]})}function Fg(e,t){let{domain:n}=e;return n===`bool`?typeof t==`boolean`:n===`theme`?typeof t==`string`&&Ph(t):`min`in n?typeof t==`number`&&Number.isInteger(t)&&t>=n.min&&t<=n.max:typeof t==`string`&&n.includes(t)}function Ig(e){return String(e)}function Lg(e,t){let{domain:n}=e;if(typeof n==`object`&&`min`in n)return ug(t,n)??void 0;let r=n===`bool`?t===`true`?!0:t===`false`?!1:t:t;return Fg(e,r)?r:void 0}function Rg(e,t,n,r){let i=e.settings?.[t]??n.default,a=e.drafts?.[t],o=a===void 0?null:r(a);return(o===null?void 0:Lg(n,o))??i}function zg(e){let{domain:t}=e;return t===`bool`?`true or false`:t===`theme`?`"bar" (the bar's own theme) or an installed theme name`:`min`in t?`an integer from ${t.min} to ${t.max}`:`one of ${t.map(e=>JSON.stringify(e)).join(`, `)}`}const Bg=[`left`,`center`,`right`],Vg=[`right`,`left`,`middle`];var Hg=class extends Error{file;issues;warnings;constructor(e,t,n=[]){super(Kg(e,t)),this.name=`ConfigError`,this.file=e,this.issues=t,this.warnings=n}};function K(e,t){let n=0,r;for(let i of t){if(i===``||/^\d+$/.test(i))continue;let t=Ug(e,n,i);if(t===-1)return r===void 0?void 0:Wg(e,r);n=t,r=t}return r===void 0?void 0:Wg(e,r)}function Ug(e,t,n){let r=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),i=RegExp(`(?:["']${r}["']|\\b${r}\\b)\\s*:`,`g`);i.lastIndex=t;let a=i.exec(e);return a?a.index:-1}function Wg(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function Gg(e,t){try{return _i(t),null}catch(n){if(!(n instanceof di))throw n;return`${e}:${Wg(t,n.offset)}: ${n.reason} — the settings menu cannot edit this file until it is fixed`}}function Kg(e,t){if(t.length===0)return`${e}: invalid config (no details)`;let n=[`Invalid config in ${e} (${t.length} issue${t.length===1?``:`s`}):`];for(let e of t){let t=[];e.line!==void 0&&t.push(`line ${e.line}${e.col===void 0?``:`:${e.col}`}`),e.path&&t.push(e.path);let r=t.length>0?`[${t.join(` • `)}] `:``;n.push(` ${r}${e.message}`)}return n.join(`
55
+ `)}function qg(e,t,n,r){let i=n[r];return typeof i==`string`?i:(e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),r])}),null)}function Jg(e,t,n,r){let i=n.default;if(i!==void 0){if(!(r===`string`&&typeof i==`string`||r===`number`&&typeof i==`number`||r===`boolean`&&typeof i==`boolean`)){e.issues.push({path:`${t}.default`,message:`default must be a ${r}, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),`default`])});return}return i}}function Yg(e,t,n,r){let i=n[r];if(i!==void 0){if(typeof i!=`string`){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),r])});return}return i}}function Xg(e,t,n){let r=Yg(e,t,n,`palette`);if(r!==void 0){if(!e.allowedPalettes.has(r)){e.issues.push({path:`${t}.palette`,message:`Unknown palette "${r}"${Oh(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:K(e.source,[...t.split(`.`),`palette`])});return}return r}}function Zg(e,t,n,r,i){let a=n[r];if(a!==void 0){if(typeof a!=`string`||!i.includes(a)){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be one of: ${i.join(`, `)}; got ${q(a)}`,line:K(e.source,[...t.split(`.`),r])});return}return a}}function Qg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $g(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function q(e){return typeof e==`string`?JSON.stringify(e):e===void 0?`undefined`:String(e)}function e_(e,t,n,r){return Qg(r)?(i_(e,n,r,t.noun,new Set(Object.keys(t.fields)),t_(e,t.removed??{},n,r)),n_(e,t.fields,n,r)):(e.issues.push({path:n,message:`${n} must be an object, got ${$g(r)}`,line:K(e.source,n.split(`.`))}),null)}function t_(e,t,n,r){let i=Object.entries(t).filter(([e])=>r[e]!==void 0);for(let[t,r]of i)a_(e,`${n}.${t}`,`${n}.${t} was removed: ${r}`);return new Set(i.map(([e])=>`${n}.${e}`))}function n_(e,t,n,r){let i=t,a={},o=!0;for(let[t,s]of Object.entries(i)){let i=s.parse(e,n,t,r);i===void 0?s.required&&(o=!1):a[t]=i}return o?a:null}const r_=new Set;function i_(e,t,n,r,i,a=r_){for(let o of Object.keys(n))!i.has(o)&&!a.has(`${t}.${o}`)&&e.issues.push({path:`${t}.${o}`,message:`Unknown ${r} "${o}". Expected one of: ${[...i].join(`, `)}`,line:K(e.source,[...t.split(`.`),o])})}function a_(e,t,n){return e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))}),null}function o_(e,t,n,r){if(!Qg(r))return e.issues.push({path:n,message:`${t.noun} must be an object, got ${$g(r)}`,line:K(e.source,n.split(`.`))}),null;let i=t.arms,a=Object.keys(i),o=Object.keys(r).filter(e=>e in i),s=Object.keys(r).filter(e=>!(e in i));for(let r of s)e.issues.push({path:`${n}.${r}`,message:`Unknown ${t.noun} key "${r}". Expected exactly one of: ${a.join(`, `)}`,line:K(e.source,[...n.split(`.`),r])});if(o.length===0)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)}`,line:K(e.source,n.split(`.`))}),null;if(o.length>1)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)} (found: ${o.join(`, `)})`,line:K(e.source,n.split(`.`))}),null;let c=o[0];return i[c].parse(e,`${n}.${c}`,r[c])}function s_(e,t,n,r){if(!Qg(r))return e.issues.push({path:n,message:`${n} must be an object, got ${$g(r)}`,line:K(e.source,n.split(`.`))}),null;let i=r[t.tag];if(typeof i!=`string`)return e.issues.push({path:`${n}.${t.tag}`,message:`${n}.${t.tag} must be a string, got ${$g(i)}`,line:K(e.source,n.split(`.`))}),null;let a=t.arms;if(!(i in a))return e.issues.push({path:`${n}.${t.tag}`,message:`Unknown ${t.noun} "${i}". Expected one of: ${Object.keys(a).join(`, `)}`,line:K(e.source,[...n.split(`.`),t.tag])}),null;let o=a[i],s=e.issues.length,c=o.parse(e,n,r),l=new Set(e.issues.slice(s).map(e=>e.path));return i_(e,n,r,`${i} ${t.memberNoun} key`,o.keys,l),c}function c_(e,t,n){return{json:S_(b_(n),e,t),keys:new Set([e,...Object.keys(n)])}}function l_(e){return(...t)=>e()(...t)}function u_(e,...t){return(n,r,i)=>{let a=e(n,r,i);if(a===null)return null;for(let e of t){if(e.ok(a))continue;let{field:t,message:i}=e.issue(a),o=t===``?r:`${r}.${t}`;return n.issues.push({path:o,message:i,line:K(n.source,o.split(`.`))}),null}return a}}function d_(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>Yg(e,t,r,n)}}function f_(){return{required:!1,json:{type:`boolean`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`boolean`){e.issues.push({path:`${t}.${n}`,message:`${n} must be a boolean, got ${$g(i)}`,line:K(e.source,[n])});return}return i}}}}function p_(e){let{min:t,max:n}=e;return{required:!1,json:{type:`integer`,minimum:t,maximum:n},parse:(e,r,i,a)=>{let o=a[i];if(o!==void 0){if(typeof o!=`number`||!Number.isInteger(o)||o<t||o>n){e.issues.push({path:`${r}.${i}`,message:`${i} must be an integer between ${t} and ${n}, got ${q(o)}`,line:K(e.source,[i])});return}return o}}}}function m_(e={}){let{min:t}=e;return{required:!1,json:{type:`number`,...t!==void 0&&{minimum:t}},parse:(e,n,r,i)=>{let a=i[r];if(a!==void 0){if(typeof a!=`number`||!Number.isFinite(a)||t!==void 0&&a<t){let i=t===void 0?`a finite number`:`a finite number >= ${t}`;e.issues.push({path:`${n}.${r}`,message:`${r} must be ${i}, got ${q(a)}`,line:K(e.source,[r])});return}return a}}}}function h_(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>Xg(e,t,r)}}function g_(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>qg(e,t,r,n)??void 0}}function __(e,t){return u(t)?null:`${e} must be an absolute path (\`~\` and relative paths are not expanded), got ${JSON.stringify(t)}`}function v_(){return{required:!0,json:{type:`string`,pattern:`^/`},parse:(e,t,n,r)=>{let i=qg(e,t,r,n);if(i===null)return;let a=__(`${t}.${n}`,i);return a===null?i:a_(e,`${t}.${n}`,a)??void 0}}}function y_(e){return{required:!1,json:{enum:[...e]},parse:(t,n,r,i)=>Zg(t,n,i,r,e)}}function b_(e,t={closed:!0}){let n=e,r={},i=[];for(let[e,t]of Object.entries(n))r[e]=t.json,t.required&&i.push(e);return{type:`object`,properties:r,...i.length>0&&{required:i},...t.closed&&{additionalProperties:!1}}}function x_(e){return b_(e.fields)}function S_(e,t,n){let r=e,i={[t]:{const:n},...r.properties},a=[t,...r.required??[]];return{...r,properties:i,required:a}}function C_(e){let t=e.arms;return{anyOf:Object.values(t).map(e=>e.json)}}function w_(e){let t=e.arms;return{anyOf:Object.entries(t).map(([e,t])=>({type:`object`,properties:{[e]:t.json},required:[e],additionalProperties:!1}))}}const T_={band:{setting:`experimentalBand`,label:`🧪 band (A)`,elsewhere:`the band above the prompt`},statusline:{setting:`experimentalStatusline`,label:`🧪 statusline (B)`,elsewhere:null},pane:{setting:`experimentalPane`,label:`🧪 tmux pane (C)`,elsewhere:`a tmux pane below`},tmuxStatus:{setting:`experimentalTmuxStatus`,label:`🧪 tmux status line (C)`,elsewhere:`the tmux status line`}},E_=Object.keys(T_),D_={by:`request`},O_=e=>`drawing.${e}`,k_={subscribers:0,fps:0,shown:!0},A_=(e,t)=>`feeds.${e}.${t}`;function j_(e){return Object.fromEntries(E_.map(t=>[t,e(t)]))}const M_=j_(()=>k_);function N_(e){return typeof e==`string`&&Object.hasOwn(T_,e)?e:null}const P_=(e,t,n=[])=>({label:e,place:t,previews:n}),F_=(e,t)=>({spec:y_(e),domain:{from:e},parse:t=>e.includes(t)?t:null,...t!==void 0&&{optionDomain:{name:t,members:e}}}),I_={spec:f_(),domain:`bool`,parse:lg},L_=e=>({spec:p_(e),domain:e,parse:t=>ug(t,e)});function R_(e,t,n,r={}){return{kind:`session`,...F_(e,r.optionDomain),floor:t,control:n,themeDefault:r.themeDefault??!1}}function z_(e,t){return{kind:`session`,...I_,floor:e,control:t,themeDefault:!1}}function B_(e,t,n){return{kind:`session`,...L_(e),floor:t,control:n,themeDefault:!1}}function V_(e,t,n,r,i={}){return{kind:`selection`,sessionKey:e,spec:t,domain:n,control:r,themeDefault:i.themeDefault??!1}}const H_=e=>({kind:`text`,spec:e}),U_={required:!1,json:{enum:[...tg]},parse:(e,t,n,r)=>{if(r[n]===`auto`){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: "auto" is not supported — the render daemon runs detached, so terminal detection would read the daemon's environment, not your terminal's. Pick an explicit depth: ${tg.join(`, `)}`,line:K(e.source,[...t.split(`.`),n])});return}return Zg(e,t,r,n,tg)}},W_={required:!1,json:{type:`string`},parse:(e,t,n,r)=>{let i=Yg(e,t,r,n);return Lh(i)?i:Xg(e,t,r)}},G_={required:!1,json:{anyOf:[{enum:[...qh]},{type:`string`,pattern:`\\{\\{`}]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&Lh(i)?i:Zg(e,t,r,n,qh)}},K_=/^[^\r\n]*\S[^\r\n]*$/u,q_=RegExp(`^(?:✖|✕)[\\uFE0E\\uFE0F]?$`,`u`),J_={required:!1,json:{type:`string`,pattern:K_.source,not:{pattern:q_.source}},parse:(e,t,n,r)=>{let i=Yg(e,t,r,n);if(i===void 0||K_.test(i)&&!q_.test(i))return i;e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: must be one line of visible text other than a close glyph ("✖", "✕") — the settings menu needs a glyph to click`,line:K(e.source,[...t.split(`.`),n])})}},Y_=Object.fromEntries(E_.map(e=>[T_[e].setting,z_(!1,P_(T_[e].label,`toggles`))])),X_={palette:V_(`theme`,W_,{themes:`themes`},P_(`🎨 theme`,`door`)),preset:V_(`preset`,d_(),{from:`presets`},P_(`▦`,`door`,[`layout`,`presetDelete`])),style:V_(`style`,d_(),{from:`styles`},P_(`◐`,`gear`,[`palette`]),{themeDefault:!0}),effect:V_(`effect`,G_,{from:qh},P_(`✨`,`look`)),endcaps:R_(Qh,`powerline`,P_(`✦`,`look`),{optionDomain:`endcaps`}),variation:R_(rg,`accent`,P_(`🎼`,`gear`,[`layout`]),{optionDomain:`variations`,themeDefault:!0}),shade:R_(ig,`middle`,P_(`🔆`,`gear`,[`layout`]),{optionDomain:`shades`,themeDefault:!0}),transitions:z_(!1,P_(`fade in/out`,`look`)),autoWrap:z_(!0,P_(`wrap`,`config`)),padding:B_({...cg,step:1},1,P_(`padding`,`config`)),updateNotice:z_(!0,P_(`update notice`,`config`)),...Y_,colorCompatibility:{kind:`config`,...F_(tg,`colorCompatibilities`),spec:U_,floor:`truecolor`},default_empty_value:H_(d_()),default_separator:H_(d_()),menuGlyph:H_(J_)},Z_=Object.entries(X_),Q_=Z_.filter(([,e])=>e.kind===`session`||e.kind===`config`).map(([e])=>e),$_=Z_.filter(([,e])=>e.kind===`session`||e.kind===`selection`).map(([e])=>e),ev=Z_.filter(([,e])=>(e.kind===`session`||e.kind===`selection`)&&e.themeDefault).map(([e])=>e),tv=Z_.flatMap(([,e])=>`optionDomain`in e&&e.optionDomain!==void 0?[e.optionDomain]:[]);function nv(e){return X_[e]}const rv=e=>nv(e).floor;function iv(e){let t=X_[e];if(t.kind===`text`)return`string`;let{domain:n}=t;return n===`bool`?`boolean`:typeof n==`object`&&`min`in n?`number`:`string`}const av=e=>`${e}.effective`,ov=e=>{let t=X_[e];return t.kind===`selection`?t.sessionKey:e},sv=Object.fromEntries($_.map(e=>{let t=ov(e);return[t,{configKey:e,sessionKey:t,effectiveVar:av(t),...X_[e].control}]})),cv=Object.keys(sv),lv=Object.values(sv),uv=Q_.filter(e=>X_[e].kind===`config`).map(e=>({configKey:e,effectiveVar:av(e)})),dv=new Set(uv.map(e=>e.configKey)),fv=new Map([...lv,...uv].map(e=>[e.configKey,e.effectiveVar])),pv=new Map(lv.map(e=>[e.sessionKey,e.effectiveVar]));function mv(e){return Object.fromEntries(cv.map(t=>[t,e(t)]))}const hv=new Map(cv.map(e=>[sv[e].sessionKey,e])),gv=[[0,31],[127,159],[8234,8238],[8294,8303]];function _v(e){return gv.some(([t,n])=>e>=t&&e<=n)}function vv(e){let t=``;for(let n of e)t+=_v(n.codePointAt(0)??0)?` `:n;return t.replace(/\s+/g,` `).trim()}function yv(e,t){let n=vv(e),r=``,i=0;for(let e of n){if(i===t)return r.replace(/.$/u,`…`);r+=e,i++}return r}const bv=`\x1B[38;2;255;255;255m`,xv=`\x1B[48;2;200;40;40m`,Sv=`\x1B[0m`;function Cv(e){let t=/;2;(\d+);(\d+);(\d+)m$/.exec(e);if(t===null)throw Error(`diagnostic-style: not a 24-bit SGR: ${e}`);return`#`+t.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}const wv={fg:Cv(bv),bg:Cv(xv)},Tv={fg:Cv(`\x1B[38;2;0;0;0m`),bg:Cv(`\x1B[48;2;220;160;40m`)},Ev=new Cu({"strip.separator":`default`,"strip.rail":`default`});function Dv(e){return Ev.resolve(e)}const Ov={kind:`still`},kv=Symbol(`bar`);function Av(e){return e.name!==Wh}function jv(e,t){return n=>au.map(au.all(t.map(({t,effect:r})=>pu.run(pu.play(e-t),r(n)))),e=>(t,n)=>e.reduce((e,t)=>t(e,n),t))}const Mv=xl;function Nv(e,t){let n=new ac(t,Mv.foregroundColor,Mv.ansiColors,Mv.palette);return t=>e({...t,theme:n})}function Pv(e,t){return n=>ep(()=>e(n),...t)(n)}function Fv(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t/4294967296}const Iv=4096;var Lv=class{inForce=null;placements=new Map;made=new Map;drawn=null;frame={effect:Wh,t:0,made:0,reused:0,own:[],basis:`off`,revision:0,fades:[],leaves:[]};constructor(e){this.key=e}lastFrame(){return this.frame}get heldCount(){let e=[...this.drawn?.placements.values()??[]].filter(({passage:e})=>e!==null).length;return[...this.made.values()].reduce((e,t)=>e+t.size,e)}motion(e,t,n){let r=this.inForce?.name===e?this.inForce:{name:e,since:t},i={scope:kv,name:e,t:t-r.since},a=this.placements,o=new Map,s=this.made,c=new Map,l=[],u=this.drawn,d=n.transitions?u!==null&&u.source.config===n.source.config&&u.source.preset===n.source.preset&&u.source.revision===n.source.revision&&u.source.width===n.source.width?`compared`:`fresh`:`off`,f=d===`compared`?u.placements:null,p=new Map,m=[],h=[],g={effect:e,t:i.t,made:0,reused:0,own:l,basis:d,revision:n.source.revision,fades:m,leaves:h},_=(e,n,{ground:r})=>{let i=cm.transitions[e]({z:Fv(`${this.key}@${n}`)*Iv});return{name:e,since:t,transition:{effect:Nv(i.effect,r),done:e=>i.done(e)}}},v=({since:e,transition:n})=>n.done(t-e),y=(e,t,n)=>({drawing:t,passage:f===null?null:n===void 0||n.passage?.name===`dissolve`?_(`fade`,e,t):n.passage!==null&&!v(n.passage)?n.passage:null}),b=(e,t)=>{if(t===void 0||t.drawing.own.length===0)return;if(t.passage?.name===`dissolve`)return v(t.passage)?void 0:t;let r={...t.drawing,own:t.drawing.own.map(n.hold)};return{drawing:r,passage:_(`dissolve`,e,r)}},ee=(e,r)=>{if(p.has(e))throw Error(`placement "${e}" was reached twice in one frame`);let i=f?.get(e),{drawing:a,deeper:o}=n.returned(e,r),s=a===null?b(e,i):y(e,a,i);return s===void 0?r:(p.set(e,s),s.passage!==null&&(s.passage.name===`fade`?m:h).push({placement:e,t:t-s.passage.since}),a===null?[...s.drawing.own,...o]:r)},x=(e,n)=>{let r=o.get(e)??a.get(e),i=r?.name===n?r:{name:n,since:t},s=t-i.since;return o.has(e)||(o.set(e,i),l.push({placement:e,effect:n,t:s})),{scope:e,name:n,t:s}},S=(e,t)=>{let n=c.get(e)??new Map;c.set(e,n);let r=n.get(t.scope);if(r!==void 0)return r.effect;let i=s.get(e)?.get(t.scope),a=i?.name===t.name,o=Fv(t.scope===kv?e:`${e}@${t.scope}`),l=a?i.effect:cm.loops[t.name]({z:o*Iv});return g[a?`reused`:`made`]++,n.set(t.scope,{name:t.name,effect:l}),l},te=e=>{let t=new Map;for(let{owner:n,placement:r}of e){let e=r.effect===`bar`?i:x(r.id,r.effect),a=t.get(e.scope);a===void 0?t.set(e.scope,{...e,owners:[n]}):a.owners.push(n)}return[...t.values()]},ne=e=>{let n=new Map;for(let{owner:t,placement:r}of e){let e=n.get(r.id);e===void 0?n.set(r.id,[t]):e.push(t)}return[...n].flatMap(([e,n])=>{let r=p.get(e)?.passage??null;return r===null?[]:[{t:t-r.since,effect:ep(r.transition.effect,...n)}]})};return{placed:d===`off`?(e,t)=>t:ee,row:(e,t)=>{let n=(t.some(e=>e.placement.effect!==`bar`)?te(t):[{...i,owners:void 0}]).filter(Av),r=ne(t);if(n.length===0&&r.length===0)return Ov;let a=`${this.key}#${e}`;return{kind:`moving`,wrap:e=>new Jf(e,jv(i.t,[...n.map(e=>{let t=S(a,e);return{t:e.t,effect:e.owners===void 0?t:Pv(t,e.owners)}}),...r]),{t:i.t,key:a,theme:Mv})}},drawn:()=>{this.inForce=r,this.placements=o,this.made=c,this.drawn=d===`off`?null:{source:n.source,placements:p},this.frame=g}}}},Rv=class{sessions=new Map;constructor(e=256){this.maxSessions=e}of(e){let t=this.sessions.get(e)??new Lv(e);this.sessions.delete(e),this.sessions.set(e,t);for(let e of this.sessions.keys()){if(this.sessions.size<=this.maxSessions)break;this.sessions.delete(e)}return t}getStats(){let e=0;for(let t of this.sessions.values())e+=t.heldCount;return{sessions:this.sessions.size,effects:e}}};function zv(e,t){let n=Ls(t.colorSystem),r=[...Hu(e,{maxWidth:t.width??80,isTerminal:!1,asciiOnly:!1,theme:Ev,colorSystem:n.colorSystem,onStyleError:e=>{throw e}})];return{text:Pf(r,n),moves:Number.isFinite(W.nextChange(r))}}const Bv=new Map;function Vv(e){let t=Bv.get(e);if(t!==void 0)return t;let n=t=>{let n=t.seam.map(t=>`cap`in t?t:{...t,glyph:e});return{seam:n,divider:n}},{seam:r,caps:i}=Mf.plain,a=new ef({glyph:n(r.glyph),ascii:r.ascii},i);return Bv.set(e,a),a}function Hv(e,t){return e===`plain`&&t!==void 0?Vv(t):Mf[e]}const Uv=new Map;function Wv(e){let t=JSON.stringify([e.endcaps,e.separator??null]),n=Uv.get(t);if(n!==void 0)return n;let r=Hv(e.endcaps,e.separator),i=e=>new G(`x`,{end:``,overflow:`ignore`,style:new H({bgcolor:e})}),a=e=>new G(zv(new Dd(e,r),{colorSystem:null}).text.replace(/\n$/,``)).cellLength,o=a([i(`#101010`)]),s={chrome:o-1,seam:a([i(`#101010`),i(`#202020`)])-o-1};return Uv.set(t,s),s}function Gv(e){return Wv(e).chrome}function Kv(e){return Wv(e).seam}const qv=/[\u{E000}-\u{F8FF}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]/gu;function Jv(e){return[...new Set(e.match(qv)??[])].join(``)}function Yv(e){let t=Hv(e.endcaps,e.separator),n=e=>new G(`x`,{end:``,style:new H({bgcolor:e})});return Jv(zv(new Dd([n(`#101010`),n(`#202020`),n(`#202020`)],t),{colorSystem:null}).text)}function Xv(e,t,n=Ov){if(e.length===0)return{text:``,moves:!1};let r=Hv(t.endcaps,t.separator),i=t.wrap&&Number.isFinite(t.width),a={colorSystem:t.colorCompatibility,...i?{width:t.width}:{}},o=i?new gm([...e],{joiner:r}):new Dd([...e],r),s=zv(n.kind===`still`?o:n.wrap(o),a);if(!s.text.endsWith(`
56
56
  `))throw Error(`drawStripCells: rich-js strip output did not end its last line`);return{text:s.text.slice(0,-1),moves:s.moves}}function Zv(e,t){return Xv(e,t).text}function Qv(e){return Math.min(20,e??20)}const $v={heading:`ERROR`,glyph:`⚠`,colors:wv},ey={heading:`WARNING`,glyph:`⚠`,colors:Tv},ty={heading:`UPDATE`,glyph:`⬆`,colors:Tv},ny={heading:`LANES`,glyph:`🧪`,colors:Tv};function ry(e,t){return{text:vv(e),link:t}}function iy(e,t,n){let[r,...i]=[ay(e,$v,yr),t,ay(n,ey,br)].flat();return r===void 0?null:{channels:[r,...i]}}function ay(e,t,n){let r=Hr([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>ry(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function oy(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
57
57
  `)}function sy(e,t,n,r){if(t===null)return e;let i=uy(r),a=ly(t,i),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[fy(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
58
58
  `);return e?`${l}\n${e}`:l}function cy(e,t){return ly(e,uy(t)).join(`
59
- `)}function ly(e,t){return e.channels.flatMap(e=>dy(e,t))}function uy(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,colorCompatibility:e.colorCompatibility}}function dy(e,t){let n=new H({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=Zo(Math.max(2,t.width-1)),i=(e,t)=>new G(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>Zv([i(o===0?e.severity.glyph:` `,n.withLink(a[0].link)),...a.flatMap(e=>{let t=n.withLink(e.link);return e.text.split(` `).flatMap(e=>ns(e,r)).map(e=>i(e,t))})],t).split(`
59
+ `)}function ly(e,t){return e.channels.flatMap(e=>dy(e,t))}function uy(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,colorCompatibility:e.colorCompatibility}}function dy(e,t){let n=new H({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=Qo(Math.max(2,t.width-1)),i=(e,t)=>new G(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>Zv([i(o===0?e.severity.glyph:` `,n.withLink(a[0].link)),...a.flatMap(e=>{let t=n.withLink(e.link);return e.text.split(` `).flatMap(e=>rs(e,r)).map(e=>i(e,t))})],t).split(`
60
60
  `))}function fy(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:o,failedConfigFile:s}=t,c=new H({bgcolor:i.bg,color:i.fg}),l=(e,t)=>new G(e,{style:t,end:``,overflow:`ignore`}),u=n>0?[l(`${n} more rows · `,c),o.kind===`file`?l(`open full text`,c.withLink(a(o.path).href)):l(`full text unavailable: ${vv(o.reason)}`,c)]:[],d=s===null?[]:[l(`${u.length>0?` · `:``}open `,c),l(vv(s),c.withLink(a(s).href))],f=[l(`↳ `,c),...u,...d.slice(0,-1)],p=f.reduce((e,t)=>e+t.cellLength,0),m=d.slice(-1).map(e=>e.truncate(Math.max(1,r.width-p),{mode:`middle`})),h=G.fromFragments([...f,...m]).truncate(r.width);return h.overflow=`ignore`,Zv([h],r)}var J=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const py=new Map;function my(e){let t=gy(e);if(t===null)throw Error(`Palette "${e}" did not resolve in the theme registry — allowed names and the registry are inconsistent`);return t}function hy(e,t){return e===`bar`?t:my(e)}function gy(e){let t=py.get(e);if(t!==void 0)return t;let n=pl(e);return n===null?null:(py.set(e,n),n)}function _y(e,t){return vy(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>Tl(e,t))}const vy=_m();function yy(e){let t=gy(e);return t===null?null:{kind:`decided`,name:e,value:t}}function by(e,t,n){let r=yy(e);return r===null?(n(Kh(t,`palette`,`"${e}" names no installed theme${Oh(e)}`)),Sy()):r}function xy(e,t,n){return Rh(e,t,n,Sy(),yy)}function Sy(){return{kind:`decided`,name:kh,value:my(kh)}}const Cy=/^[A-Za-z_][A-Za-z0-9_]*$/;function wy(e){return`#${e+1}`}const Ty={rows:{}};function Ey(e){return`rows`in e}function Dy(e){return Object.fromEntries(e.map((e,t)=>[wy(t),e]))}function Oy(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:Dy(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:Dy([n])}}function ky(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function Ay(e){return Ey(e)?ky(e):e}function*jy(e,t){if(!Ey(e)){yield*bg(e,t);return}yield[ky(e),t];for(let[n,r]of Object.entries(e.rows))yield*bg(r,`${t}.rows.${n}`)}function My(e,t){return Ey(e)?{...t,...e,rows:{...t.rows,...e.rows}}:Oy(e)}function Ny(e){if(!Ey(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const Py=`default`,Fy={};function Iy(e){return[...new Set([Py,...Object.keys(e)])]}function Ly(e,t,n){return Fh(void 0,e,t,Py,n)}function Ry(e,t){let n={[Py]:Fy,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${Py}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function zy(e,t){let n=Ry(e.presets,t).root??Ty;return{node:ky(My(n,e.root)),path:Ny(n)?`presets.${t}.root`:`root`}}function By(e,t){return{...e.globals,...Ry(e.presets,t).globals}}const Vy=new Map;function Hy(e,t,n){Vy.set(e,{permanent:!0,resolve:t,paletteOf:n})}Hy(`themes`,()=>jh(),e=>my(e));const Uy=`placementThemes`;Hy(Uy,Mh,(e,t)=>hy(e,t.palette));for(let{name:e,members:t}of tv)Hy(e,()=>t);function Wy(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>_y(n.basePalette,e.styles[t])}],[`presets`,{members:Iy(e.presets)}]])}function Gy(e){return[...new Set([...Vy.keys(),...e.keys()])]}function Ky(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=Vy.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(Jy(e,t))}const qy=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function Jy(e,t){let n=qy.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${Gy(t).join(`, `)})`}const Yy=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*Xy(e){let t=e.indexOf(`{{`);for(;t!==-1;){let n=``,r=t+2;for(;r<e.length&&!e.startsWith(`}}`,r);){if(e.startsWith(`/*`,r)){let t=e.indexOf(`*/`,r+2);r=t===-1?e.length:t+2;continue}let t=r,i=e[r];if(r+=1,i===`"`||i===`'`||i==="`"){for(;r<e.length&&e[r]!==i;)r+=e[r]===`\\`&&i!=="`"?2:1;r+=1}n+=e.slice(t,r)}if(r>=e.length)return;yield n,t=e.indexOf(`{{`,r+2)}}const Zy=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,Qy=RegExp(`^(?:(\\$)(?:\\.(${Zy}))?|\\.(${Zy})?)(?=[\\s)]|$)`);function $y(e,t,n){let r=Qy.exec(e.trimStart());if(r===null)return null;let[i,a]=r[1]===void 0?[t,r[3]]:[n,r[2]];return i===null?null:a===void 0?i:`${i}${a}.`}const eb=/^(\w+)\b\s*([\s\S]*)$/;function*tb(e,t){let n=[t];for(let r of Xy(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=eb.exec(e)??[],o=n[n.length-1],s=n.length>1?n[n.length-2]:o;if(i===`end`){n.length>1&&n.pop();continue}if(i===`else`){yield{code:e,dot:s};let r=/^with\b([\s\S]*)$/.exec(a);n[n.length-1]=r===null?s:$y(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push($y(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const nb=/(?<![.$])\btemplate\s+$/;function*rb(e,t,n){let r=0;for(let i of[...e.matchAll(Yy)]){let a=i.index+i[0].length;nb.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:$y(e.slice(a),t,n)}),r=a}}function*ib(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...tb(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...rb(s,c,i)]){let i=Object.hasOwn(t,e.name)?t[e.name]:void 0,a=`${e.name}\0${e.at??`\0`}`;i===void 0||o.has(e.name)||n.has(a)||(n.add(a),yield*r(i,e.at,e.name,new Set([...o,e.name])))}}}yield*r(e,``,null,new Set)}const ab=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${Zy})`,`g`);function*ob({code:e,dot:t,root:n}){let r=e.replace(Yy,``);for(let e of[...r.matchAll(ab)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function sb(e,t){let n=new Map;for(let r of ib(e,t))for(let e of ob(r))n.has(e)||n.set(e,r.via);return n}const cb=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,lb={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*ub(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(Yy)]){let o=e.slice(t,a.index),s=cb.exec(o);if(s!==null)n=lb[s[1]],r=0,i=s[1]===`action`?`action`:`options`;else for(let e of o)e===`(`&&r++,e===`)`&&r--,(r<0||e===`|`&&r===0)&&(n=0);n>0&&r===0&&(yield{name:a[0].slice(1,-1),site:i},n--),t=a.index+a[0].length}}function db(e,t){let n=new Map;for(let{code:r,via:i}of ib(e,t))for(let{name:e,site:t}of ub(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function fb(e,t){return new Set([...pb(e,t)].filter(e=>Object.hasOwn(t,e)))}function pb(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of ib(e,t))for(let{name:e}of rb(r,i,a))n.add(e);return n}function mb(e,t){if(t.names.has(e))return!0;let n=`${e}.`;for(let e of t.names)if(e.startsWith(n))return!0;for(let n of t.documents)if(e.startsWith(`${n}.`))return!0;return!1}function hb(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),gb(r)&&n.add(e)};for(let[t,n]of Object.entries(e.variables))r(t,n);for(let[t,n]of Object.entries(e.segments))for(let[e,i]of Object.entries(n.vars??{}))r(`${t}.${e}`,i);return{names:t,documents:n,helpers:e.helpers}}function gb(e){return e.kind===`dropped`||(e.kind===`shell`||e.kind===`file`)&&Sg(e.parse)===`json`}function _b(e){let t=s.basename(e),n=s.dirname(e);for(;;){let r=vb(n);if(r!==null)return{dir:r,name:t,leaf:n===s.dirname(e)};t=s.basename(n),n=s.dirname(n)}}function vb(e){try{return p.statSync(e).isDirectory()?p.realpathSync(e):null}catch{return null}}var yb=Te((e=>{function t(e,...t){throw Error(`[MobX] minified error nr: ${e}${t.length?` `+t.map(String).join(`,`):``}. See mobx.js.org/errors`)}function n(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function r(e){return typeof e==`function`}function i(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function a(e){return typeof e==`object`&&!!e}function o(e){if(!a(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=p(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===Vt}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){Lt(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function l(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return a(e)&&!0===e[n]}}function u(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function d(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function f(e){return e===null?null:typeof e==`object`?``+e:e}function p(e,t){return Rt.hasOwnProperty.call(e,t)}function m(e,t){return!!(e&t)}function h(e,t,n){return n?e|=t:e&=~t,e}function g(e,t=Ht,n=Ht){let r=new Gt(e);return t!==Ht&&(r.onBOL=new Set([t])),n!==Ht&&(r.onBUOL=new Set([n])),r}function _(e,t){return At(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||tt(e)?e:Array.isArray(e)?cn.array(e,{name:n}):o(e)?cn.object(e,void 0,{name:n}):u(e)?cn.map(e,{name:n}):d(e)?cn.set(e,{name:n}):typeof e!=`function`||We(e)||Qe(e)?e:s(e)?Gn(e):Ln(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:ee,u:x}}function ee(e,t,n,r){var i;return(i=this.i)!=null&&i.bound?this.u(e,t,n,!1)===null?0:1:r===e.h?this.u(e,t,n,!1)===null?0:2:We(n.value)?1:(Lt(r,t,te(e,this,t,n,!1)),2)}function x(e,t,n,r){let i=te(e,this,t,n);return e.l(t,i,r)}function S(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return ye(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return We(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(We(n)||(n=c(n)),(l=s.i)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),n):void t(43,s.t,String(a),i);var l}function te(e,t,n,r,i=N.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:ye(t.i?.name??n.toString(),c,(o=t.i?.autoAction)!=null&&o,(s=t.i)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function ne(e,t){return{t:e,i:t,o:C,u:re}}function C(e,t,n,r){var i;return r===e.h?this.u(e,t,n,!1)===null?0:2:(i=this.i)!=null&&i.bound&&(!p(e.h,t)||!Qe(e.h[t]))&&this.u(e,t,n,!1)===null?0:Qe(n.value)?1:(Lt(r,t,ae(e,0,0,n,!1,!1)),2)}function re(e,t,n,r){let i=ae(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function ie(e,t,n){var r;let{name:i,addInitializer:a}=n;return Qe(t)||(t=Gn(t)),(r=e.i)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function ae(e,t,n,r,i,a=N.safeDescriptors){let{value:o}=r;return Qe(o)||(o=Gn(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function w(e,t){return{t:e,i:t,o:T,u:oe}}function T(e,t,n){return this.u(e,t,n,!1)===null?0:1}function oe(e,t,n,r){return e.m(t,Ft({},this.i,{get:n.get,set:n.set}),r)}function E(e,t,n){function r(e){let n=Ft({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new M(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=Ct(this)[A],n=this,i=e.j.get(a);i instanceof M&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[A],n=e.j.get(a);if(n instanceof M&&n.derivation!==t){let e=s?.get(this);return e||(e=r(this),(s??=new WeakMap).set(this,e)),e.get()}return e._(a)}}function se(e,t){return{t:e,i:t,o:ce,u:le}}function ce(e,t,n){return this.u(e,t,n,!1)===null?0:1}function le(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function ue(e,t,n){function r(e,t){let n=Ct(e)[A];return(n.V??=new Map).set(o,()=>new vn(t,i.i?.A??v,`ObservableObject.${o.toString()}`,!1)),n}let i=e,{kind:a,name:o}=n;if(a===`accessor`)return{get(){return(this[A]??r(this,t.get.call(this)))._(o)},set(e){return(this[A]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function de(e){return{t:Yt,i:e,o:fe,u:pe}}function fe(e,t,n,r){var i,a,o;if(n.get)return fn.o(e,t,n,r);if(n.set){let i=We(n.set)?n.set:ye(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!N.safeDescriptors||e.p,set:i})===null?0:2:(Lt(r,t,{configurable:!0,set:i}),2)}if(r!==e.h&&typeof n.value==`function`)return s(n.value)?((o=this.i)!=null&&o.autoBind?Kn:Gn).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?zn:Ln).o(e,t,n,r);let c=!1===this.i?.deep?rn:cn;return typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function pe(e,t,n,r){var i;return n.get?fn.u(e,t,n,r):n.set?e.l(t,{configurable:!N.safeDescriptors||e.p,set:ye(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.i?.deep?rn:cn).u(e,t,n,r))}function me(e,t){return Ft(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function he(e){return e||Zt}function ge(e){return me(e,ue)}function _e(e){return!0===e.deep?v:!1===e.deep?y:(t=e.defaultDecorator)&&(n=(r=t.i)?.A)!=null?n:v;var t,n,r}function ve(e){return me(e,E)}function ye(e,t,n=!1,r){function i(){return be(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),gn&&(_n.value=e,Lt(i,`name`,_n)),i}function be(e,t,n,r,i){let a=xe(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{Se(a)}}function xe(e,t){let n=N.trackingDerivation,r=!t||!n;Pe();let i=N.allowStateChanges;r&&Oe();let a={R:r,k:n,C:i,I:N.allowStateReads,P:!1,T:0,B:hn++,D:mn};return mn=a.B,a}function Se(e){mn!==e.B&&t(30),mn=e.D,e.N!==void 0&&(N.suppressReactionErrors=!0),Fe(),e.R&&ke(e.k),N.suppressReactionErrors=!1}function Ce(e,t){let n=function(e){let t=N.allowStateChanges;return N.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){N.allowStateChanges=e})(n)}}function we(e){return e instanceof xn}function Te(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=Oe(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(bn(r)){if(N.disableErrorBoundaries)r.get();else try{r.get()}catch{return ke(t),!0}if(e.K===2)return ke(t),!0}}return Ae(e),ke(t),!1}}}function Ee(e,t,n){Ae(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++N.runId;let r=N.trackingDerivation,i;if(N.trackingDerivation=e,N.inBatch++,!0===N.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new xn(e)}return N.inBatch--,N.trackingDerivation=r,function(e){let t=e.L,n=e.L=e.$,r=0,i=0,a=e.W;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.K>r&&(r=t.K)}for(n.length=i,e.$=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&Me(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,je(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function De(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Me(t[n],e);e.K=-1}function D(e){let t=Oe();try{return e()}finally{ke(t)}}function Oe(){let e=N.trackingDerivation;return N.trackingDerivation=null,e}function ke(e){N.trackingDerivation=e}function Ae(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function je(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Me(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&Ne(e))}function Ne(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,N.pendingUnobservations.push(e))}function Pe(){N.inBatch++}function Fe(){--N.inBatch===0&&(ze(),!N.isRunningUnobservations&&N.pendingUnobservations.length>0&&function(){N.isRunningUnobservations=!0;try{let e=N.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,n.H&&n.H.size!==0||(n.H=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof M&&n.G())}N.pendingUnobservations=[]}finally{N.isRunningUnobservations=!1}}())}function Ie(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Ie))}function Le(e){let t=N.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&N.inBatch>0&&Ne(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&N.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Re(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(e=>{e.K===0&&e.q(),e.K=2}))}function ze(){N.inBatch>0||N.isRunningReactions||On(Be)}function Be(){N.isRunningReactions=!0;let e=N.pendingReactions,t=0;for(;e.length>0;){++t===Dn&&(console.error(`[mobx] cycle in reaction: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].X()}N.isRunningReactions=!1}function Ve(e){return me(e,S)}function He(e){return function(t,n){return n&&typeof n.kind==`string`?S(e?Pn:Mn,t,n):r(t)?ye(t.name||`<unnamed action>`,t,e):r(n)?ye(t,n,e):i(t)?Ve(b(e?jn:An,{name:t,autoAction:e})):void 0}}function Ue(e){return be(0,!1,e,this,void 0)}function We(e){return r(e)&&!0===e.isMobxAction}function Ge(e,t=Bt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=Ke(t),r=!1;a=new En(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new En(i,function(){this.track(n)},t.onError,t.requiresObservable);return t!=null&&(r=t.signal)!=null&&r.aborted||a.Y(),a.Z(t?.signal)}function Ke(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Bn}function qe(e,t,n,i){let a=typeof i==`function`?Et(t,n):Et(t),o=r(i)?i:n,s=`${e}L`;return a[s]?a[s].add(o):a[s]=new Set([o]),function(){let e=a[s];e&&(e.delete(o),e.size===0&&delete a[s])}}function Je(e,t,n,r){let i=Wt(t);return kt(()=>{let t=Ct(e,r)[A];Ut(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function Ye(e){let t={name:e.tt};var n;return e.L&&e.L.length>0&&(t.dependencies=(n=e.L,Array.from(new Set(n))).map(Ye)),t}function Xe(e){let t={name:e.tt};return function(e){return!!e.H&&e.H.size>0}(e)&&(t.observers=Array.from(function(e){return e.H??new Set}(e),Xe)),t}function Ze(e){r(e.cancel)&&e.cancel()}function Qe(e){return!0===e?.isMobXFlow}function $e(e,t){var n;if(t===void 0)return bn(e);if(!1===Tt(e))return!1;let r=e[A];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?bn(Et(e,t)):!1}function et(e,t){if(!e)return!1;if(t!==void 0){if(Tt(e)){var n,r;let i=e[A];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return Tt(e)||!!e[A]||Kt(e)||kn(e)||bn(e)}function tt(e){return et(e)}function nt(e){return Tt(e)?e[A].nt():ir(e)||sr(e)?Array.from(e.keys()):bt(e)?e.map((e,t)=>t):void t(5)}function rt(e,n){return Tt(e)?e[A].et(n):ir(e)||sr(e)?e.has(n):bt(e)?n>=0&&n<e.length:void t(10)}function it(e){if(Tt(e))return e[A].it();t(38)}function at(e,t,n){if(bn(e)){let r,i=!0;return Ge(()=>{let a=e.get();if(!i||n){let n=Oe();t({observableKind:`computed`,debugObjectName:e.tt,type:Xn,object:e,newValue:a,oldValue:r}),ke(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Xn,newValue:e.rt,oldValue:void 0}),mt(e,t)}function ot(e,t,n){return e.set(t,n),n}function st(e,t){if(typeof e!=`object`||!e||e instanceof Date||!tt(e))return e;if(yn(e)||bn(e))return st(e.get(),t);if(t.has(e))return t.get(e);if(bt(e)){let n=ot(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=st(e,t)}),n}if(sr(e)){let n=ot(t,e,new Set);return e.forEach(e=>{n.add(st(e,t))}),n}if(ir(e)){let n=ot(t,e,new Map);return e.forEach((e,r)=>{n.set(r,st(e,t))}),n}{let n=ot(t,e,{});return it(e).forEach(r=>{Rt.propertyIsEnumerable.call(e,r)&&(n[r]=st(e[r],t))}),n}}function ct(e,t){Pe();try{return e.apply(t)}finally{Fe()}}function lt(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[A].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=ye(`When-effect`,t);var a=Ge(t=>{Ce(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function ut(e){return e[A]}function dt(e){return e.st!==void 0&&e.st.length>0}function ft(e,t){let r=e.st;return r?r.push(t):r=e.st=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function O(e,n){let r=Oe();try{let r=[...e.st||[]];for(let e=0,i=r.length;e<i&&((n=r[e](n))&&!n.type&&t(14),n);e++);return n}finally{ke(r)}}function pt(e){return e.ot!==void 0&&e.ot.length>0}function mt(e,t){let r=e.ot;return r?r.push(t):r=e.ot=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function ht(e,t){let n=Oe(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);ke(n)}}function gt(e,n,r){if(!0===r&&(r=e.ut),!1===r)return;n in e.h||t(1,r.t,`${e.tt}.${n.toString()}`);let i=e.h;for(;i&&i!==Rt;){let t=It(i,n);if(t){let a=r.o(e,n,t,i);if(a===0)return;if(a===1)break}i=Object.getPrototypeOf(i)}}function k(e,t){typeof Array.prototype[e]==`function`&&($n[e]=t(e))}function _t(e){return function(){let t=this[A];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function vt(e){return function(t,n){let r=this[A];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function yt(e){return function(){let t=this[A];t.ct.reportObserved();let n=t.ht(t.j),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}function bt(e){return a(e)&&er(e[A])}function xt(e){return e[Symbol.toStringTag]=`MapIterator`,Nt(e)}function St(e){return e[Symbol.toStringTag]=`SetIterator`,Nt(e)}function Ct(e,t){if(p(e,A))return e;let n=t?.name??`ObservableObject`;return c(e,A,new ur(e,new Map,String(n),function(e){return e?e.defaultDecorator??function(e){let t=!1!==e.deep,n=!!e.autoBind,r=!t|(n?2:0);return j[r]??(j[r]=de({deep:t,autoBind:n}))}(e):void 0}(t))),e}function wt(e){return cr[e]||(cr[e]={get(){return this[A]._(e)},set(t){return this[A].M(e,t)}})}function Tt(e){return!!a(e)&&dr(e[A])}function Et(e,n){if(typeof e==`object`&&e){if(bt(e))return n!==void 0&&t(23),e[A].ct;if(sr(e))return e.ct;if(ir(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,Ot(e)),r}if(Tt(e)){if(!n)return t(26);let r=e[A],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,Ot(e)),i}if(Kt(e)||bn(e)||kn(e))return e}else if(r(e)&&kn(e[A]))return e[A];t(28)}function Dt(e,n){return e||t(29),n===void 0?Kt(e)||bn(e)||kn(e)||ir(e)||sr(e)?e:e[A]?e[A]:void t(24,e):Dt(Et(e,n))}function Ot(e,t){let n;if(t!==void 0)n=Et(e,t);else{if(We(e))return e.name;n=Tt(e)||ir(e)||sr(e)?Dt(e):Et(e)}return n.tt}function kt(e){let t=Oe();Pe();try{return e()}finally{Fe(),ke(t)}}function At(e,t,n=-1){return jt(e,t,n)}function jt(e,t,n,i,a){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!=e)return t!=t;let o=typeof e;if(o!==`function`&&o!==`object`&&typeof t!=`object`)return!1;let s=fr.call(e);if(s!==fr.call(t))return!1;switch(s){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++}e=Mt(e),t=Mt(t);let c=s===`[object Array]`;if(!c){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,i=t.constructor;if(n!==i&&!(r(n)&&n instanceof n&&r(i)&&i instanceof i)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),a||=[];let l=(i||=[]).length;for(;l--;)if(i[l]===e)return a[l]===t;if(i.push(e),a.push(t),c){if(l=e.length,l!==t.length)return!1;for(;l--;)if(!jt(e[l],t[l],n-1,i,a))return!1}else{let r=Object.keys(e),o=r.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=r[s];if(!p(t,o)||!jt(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function Mt(e){return bt(e)?e.slice():u(e)||ir(e)||d(e)||sr(e)?Array.from(e.entries()):e}function Nt(e){return e[Symbol.iterator]=Pt,Ft(Object.create(pr),e)}function Pt(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let Ft=Object.assign,It=Object.getOwnPropertyDescriptor,Lt=Object.defineProperty,Rt=Object.prototype,zt=[];Object.freeze(zt);let Bt={};Object.freeze(Bt);let Vt=Object.toString(),Ht=()=>{},Ut=Reflect.ownKeys,Wt=Object.getOwnPropertyDescriptors,A=Symbol(`mobx administration`);var Gt=class{constructor(e=`Atom`){this.tt=void 0,this.yt=0,this.H=null,this.J=0,this.F=-1,this.onBOL=void 0,this.onBUOL=void 0,this.tt=e}get isBeingObserved(){return m(this.yt,1)}set isBeingObserved(e){this.yt=h(this.yt,1,e)}get isPendingUnobservation(){return m(this.yt,2)}set isPendingUnobservation(e){this.yt=h(this.yt,2,e)}get diffValue(){return+!!m(this.yt,4)}set diffValue(e){this.yt=h(this.yt,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return Le(this)}reportChanged(){Pe(),Re(this),Fe()}toString(){return this.tt}};let Kt=l(`Atom`,Gt),qt=Object.is,Jt={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},Yt=`true`,Xt=de(),j=[Xt],Zt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Zt);let Qt=se(`observable`),$t=se(`observable.ref`,{A:y}),en=se(`observable.shallow`,{A:function(e,t,n){return e==null||Tt(e)||bt(e)||ir(e)||sr(e)?e:Array.isArray(e)?cn.array(e,{name:n,deep:!1}):o(e)?cn.object(e,void 0,{name:n,deep:!1}):u(e)?cn.map(e,{name:n,deep:!1}):d(e)?cn.set(e,{name:n,deep:!1}):void 0}}),tn=se(`observable.struct`,{A:function(e,t){return At(e,t)?t:e}}),nn={box(e,t){let n=he(t);return new vn(e,_e(n),n.name,!0,n.equals)},array(e,t){let n=he(t);return function(e,t,n=`ObservableArray`,r=!1){return kt(()=>{let i=new Qn(n,t,r);Lt(i.j,A,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Zn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,_e(n),n.name)},map(e,t){let n=he(t);return new rr(e,_e(n),n.name)},set(e,t){let n=he(t);return new or(e,_e(n),n.name)},object:(e,t,n)=>kt(()=>Je(function(e,t){var n;return(n=(e=Ct(e,t))[A]).v??(n.v=new Proxy(e,qn))}({},n),e,t))},rn=ge($t),an=ge(en),on=ge(Qt),sn=ge(tn);var cn=Ft(function(e,t,n){return t&&typeof t.kind==`string`?ue(Qt,e,t):tt(e)?e:o(e)?cn.object(e,t,n):Array.isArray(e)?cn.array(e,t):u(e)?cn.map(e,t):d(e)?cn.set(e,t):typeof e==`object`&&e?e:cn.box(e,t)},Qt,nn);let ln=`computed`,un=w(ln),dn=ve(w(`computed.struct`,{equals:_})),fn=function(e,t){if(t&&typeof t.kind==`string`)return E(un,e,t);if(o(e))return ve(w(ln,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new M(n)};var pn;Ft(fn,un);let mn=0,hn=1,gn=(pn=It(()=>{},`name`)?.configurable)!=null&&pn,_n={value:`action`,configurable:!0,writable:!1,enumerable:!1};var vn=class extends Gt{constructor(e,t,n=`ObservableValue`,r=!0,i=qt){super(n),this.A=void 0,this.tt=void 0,this.xt=void 0,this.gt=!1,this.st=void 0,this.ot=void 0,this.rt=void 0,this.dehancer=void 0,this.A=t,this.tt=n,this.xt=i,this.rt=t(e,void 0,n)}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){(e=this.jt(e))!==N.UNCHANGED&&this.Ot(e)}jt(e){if(dt(this)){let t=O(this,{object:this,type:Xn,newValue:e});if(!t)return N.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?N.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),pt(this)&&ht(this,{type:Xn,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.rt)}raw(){return this.rt}toJSON(){return this.get()}toString(){return`${this.tt}[${this.rt}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let yn=l(`ObservableValue`,vn);var M=class{constructor(e){this.K=-1,this.L=[],this.$=null,this.H=null,this.U=0,this.J=0,this.F=0,this.W=0,this.rt=new xn(null),this.tt=void 0,this._t=void 0,this.yt=0,this.derivation=void 0,this.St=void 0,this.At=void 0,this.xt=void 0,this.Vt=void 0,this.Mt=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||t(31),this.derivation=e.get,this.tt=e.name||`ComputedValue`,e.set&&(this.St=ye(`ComputedValue-setter`,e.set)),this.xt=e.equals||qt,this.At=e.context,this.Vt=e.requiresReaction,this.Mt=!!e.keepAlive}q(){(function(e){var t;e.F===0&&(e.F=1,(t=e.H)==null||t.forEach(e=>{e.K===0&&(e.K=1,e.q())}))})(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return m(this.yt,1)}set isComputing(e){this.yt=h(this.yt,1,e)}get isRunningSetter(){return m(this.yt,2)}set isRunningSetter(e){this.yt=h(this.yt,2,e)}get isBeingObserved(){return m(this.yt,4)}set isBeingObserved(e){this.yt=h(this.yt,4,e)}get isPendingUnobservation(){return m(this.yt,8)}set isPendingUnobservation(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}get(){if(this.isComputing&&t(32,this.tt,this.derivation),N.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Le(this),Te(this)){let e=N.trackingContext;e||!this.Mt&&!this.isBeingObserved||(N.trackingContext=this),this.trackAndCompute()&&function(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(t=>{t.K===1?t.K=2:t.K===0&&(e.F=0)}))}(this),N.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Ie)}else Te(this)&&(this.Nt(),Pe(),this.rt=this.Rt(!1),Fe());let e=this.rt;if(we(e))throw e.cause;return e}set(e){if(this.St){this.isRunningSetter&&t(33,this.tt),this.isRunningSetter=!0;try{this.St.call(this.At,e)}finally{this.isRunningSetter=!1}}else t(34,this.tt)}trackAndCompute(){let e=this.rt,t=this.K===-1,n=this.Rt(!0),r=t||we(e)||we(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=Ee(this,this.derivation,this.At);else if(!0===N.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new xn(e)}return this.isComputing=!1,t}G(){this.Mt||(De(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let bn=l(`ComputedValue`,M);var xn=class{constructor(e){this.cause=void 0,this.cause=e}};let Sn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Cn=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let wn=!0,Tn=!1,N=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(wn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(wn=!1),wn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Cn):(setTimeout(()=>{Tn||t(35)},1),new Cn)}();var En=class{constructor(e=`Reaction`,t,n,r){this.tt=void 0,this.Et=void 0,this.kt=void 0,this.Ct=void 0,this.L=[],this.$=[],this.K=-1,this.U=0,this.W=0,this.yt=0,this.It=void 0,this.tt=e,this.Et=t,this.kt=n,this.Ct=r}get isDisposed(){return m(this.yt,1)}set isDisposed(e){this.yt=h(this.yt,1,e)}get isScheduled(){return m(this.yt,2)}set isScheduled(e){this.yt=h(this.yt,2,e)}get isTrackPending(){return m(this.yt,4)}set isTrackPending(e){this.yt=h(this.yt,4,e)}get isRunning(){return m(this.yt,8)}set isRunning(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}q(){this.Y()}Y(){this.isScheduled||(this.isScheduled=!0,N.pendingReactions.push(this),ze())}X(){if(!this.isDisposed){Pe(),this.isScheduled=!1;let e=N.trackingContext;if(N.trackingContext=this,Te(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}N.trackingContext=e,Fe()}}track(e){if(this.isDisposed)return;Pe(),this.isRunning=!0;let t=N.trackingContext;N.trackingContext=this;let n=Ee(this,e,void 0);N.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&De(this),we(n)&&this.Pt(n.cause),Fe()}Pt(e){if(this.kt)this.kt(e,this);else{if(N.disableErrorBoundaries)throw e;N.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),N.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(Pe(),De(this),Fe()))}Z(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.It=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[A]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let Dn=100,On=e=>e(),kn=l(`Reaction`,En),An=`action`,jn=`autoAction`,Mn=b(An),Nn=b(`action.bound`,{bound:!0}),Pn=b(jn,{autoAction:!0}),Fn=b(`autoAction.bound`,{autoAction:!0,bound:!0}),In=He(!1);Ft(In,Mn);let Ln=He(!0);Ft(Ln,Pn);let Rn=Ve(Nn),zn=Ve(Fn),Bn=e=>e(),Vn=`always`;var Hn=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Un=ne(`flow`),Wn=ne(`flow.bound`,{bound:!0}),Gn=Ft(function(e,t){if(t&&typeof t.kind==`string`)return ie(Un,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=In(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=In(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=In(i,t.throw).call(t,e)}catch(e){return n(e)}l(r)}function l(t){if(!r(t?.then))return t.done?e(t.value):(o=Promise.resolve(t.value),o.then(s,c));t.then(l,n)}a=n,s(void 0)});return s.cancel=In(i,function(){try{o&&Ze(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Ht,Ht),Ze(n),a(new Hn)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Un),Kn=me(Wn,ie),qn={has:(e,t)=>ut(e).et(t),get:(e,t)=>ut(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=ut(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=ut(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=ut(e).l(t,n))==null||r},ownKeys:e=>ut(e).it(),preventExtensions(e){t(13)}},Jn=Symbol(`mobx-keys`),Yn=`splice`,Xn=`update`,Zn={get(e,t){let n=e[A];return t===A?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p($n,t)?$n[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[A];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var Qn=class{constructor(e=`ObservableArray`,t,n){this.$t=void 0,this.ct=void 0,this.j=[],this.st=void 0,this.ot=void 0,this.A=void 0,this.dehancer=void 0,this.v=void 0,this.Ut=0,this.$t=n,this.ct=new Gt(e),this.A=(e,n)=>t(e,n,`ObservableArray[..]`)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}ht(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}Kt(){return this.ct.reportObserved(),this.j.length}Lt(e){(!Number.isInteger(e)||e<0)&&t(40,e);let n=this.j.length;if(e!==n)if(e>n){let t=Array.from({length:e-n});this.wt(n,0,t)}else this.wt(e,n-e)}zt(e,n){e!==this.Ut&&t(16),this.Ut+=n}wt(e,t,n){let r=this.j.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=zt),dt(this)){let r=O(this,{object:this.v,type:Yn,index:e,removedCount:t,added:n});if(!r)return zt;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.A(e,void 0));let i=this.qt(e,t,n);return t===0&&n.length===0||this.Ft(e,n,i),this.ht(i)}qt(e,t,n){if(n.length<1e4)return this.j.splice(e,t,...n);{let r=this.j.slice(e,e+t),i=this.j.slice(e+t);this.j.length+=n.length-t;for(let t=0;t<n.length;t++)this.j[e+t]=n[t];for(let t=0;t<i.length;t++)this.j[e+n.length+t]=i[t];return r}}Ht(e,t,n){let r=pt(this),i=r?{observableKind:`array`,object:this.v,type:Xn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&ht(this,i)}Ft(e,t,n){let r=pt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:Yn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&ht(this,i)}Tt(e){return this.ct.reportObserved(),this.Wt(this.j[e])}Bt(e,t){let n=this.j;if(e<n.length){let r=n[e];if(dt(this)){let n=O(this,{type:Xn,object:this.v,index:e,newValue:t});if(!n)return;t=n.newValue}(t=this.A(t,r))!==r&&(n[e]=t,this.Ht(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.wt(n.length,0,r)}}},$n={clear(){return this.splice(0)},replace(e){let t=this[A];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[A];switch(arguments.length){case 0:return[];case 1:return r.wt(e);case 2:return r.wt(e,t)}return r.wt(e,t,n)},spliceWithArray(e,t,n){return this[A].wt(e,t,n)},push(...e){let t=this[A];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[A].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[A];return t.wt(0,0,e),t.j.length},reverse(){return N.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){N.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[A],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};k(`at`,_t),k(`concat`,_t),k(`flat`,_t),k(`includes`,_t),k(`indexOf`,_t),k(`join`,_t),k(`lastIndexOf`,_t),k(`slice`,_t),k(`toString`,_t),k(`toLocaleString`,_t),k(`toSorted`,_t),k(`toSpliced`,_t),k(`with`,_t),k(`every`,vt),k(`filter`,vt),k(`find`,vt),k(`findIndex`,vt),k(`findLast`,vt),k(`findLastIndex`,vt),k(`flatMap`,vt),k(`forEach`,vt),k(`map`,vt),k(`some`,vt),k(`toReversed`,vt),k(`reduce`,yt),k(`reduceRight`,yt);let er=l(`ObservableArrayAdministration`,Qn),tr={},nr=`delete`;var rr=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[A]=tr,this.ft=void 0,this.dt=void 0,this.lt=void 0,this.st=void 0,this.ot=void 0,this.dehancer=void 0,this.A=t,this.tt=n,kt(()=>{this.lt=g(`ObservableMap.keys()`),this.ft=new Map,this.dt=new Map,e&&this.merge(e)})}et(e){return this.ft.has(e)}has(e){if(!N.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new vn(this.et(e),y,`ObservableMap.key?`,!1);this.dt.set(e,n),n.onBUOL=new Set([()=>this.dt.delete(e)])}return t.get()}set(e,t){let n=this.et(e);if(dt(this)){let r=O(this,{type:n?Xn:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.Gt(e,t):this.Jt(e,t),this}delete(e){if(dt(this)&&!O(this,{type:nr,object:this,name:e}))return!1;if(this.et(e)){let t=pt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:nr,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return ct(()=>{var t;this.lt.reportChanged(),(t=this.dt.get(e))==null||t.Ot(!1),this.ft.get(e).Ot(void 0),this.ft.delete(e)}),t&&ht(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==N.UNCHANGED){let r=pt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Xn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&ht(this,i)}}Jt(e,t){ct(()=>{var n;let r=new vn(t,this.A,`ObservableMap.key`,!1);this.ft.set(e,r),t=r.rt,(n=this.dt.get(e))==null||n.Ot(!0),this.lt.reportChanged()});let n=pt(this);n&&ht(this,n?{observableKind:`map`,debugObjectName:this.tt,type:`add`,object:this,name:e,newValue:t}:null)}get(e){return this.has(e)?this.Wt(this.ft.get(e).get()):this.Wt(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.lt.reportObserved(),this.ft.keys()}values(){let e=this,t=this.keys();return xt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return xt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return ir(e)&&(e=new Map(e)),ct(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>Rt.propertyIsEnumerable.call(e,t))]:t}(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):u(e)?(function(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}(e)||t(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&t(20,e)}),this}clear(){ct(()=>{D(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return ct(()=>{let n=function(e){if(u(e)||ir(e))return e;if(Array.isArray(e))return new Map(e);if(o(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}return t(21,e)}(e),r=new Map,i=!1;for(let e of this.ft.keys())if(!n.has(e))if(this.delete(e))i=!0;else{let t=this.ft.get(e);r.set(e,t)}for(let[e,t]of n.entries()){let n=this.ft.has(e);if(this.set(e,t),this.ft.has(e)){let t=this.ft.get(e);r.set(e,t),n||(i=!0)}}if(!i)if(this.ft.size!==r.size)this.lt.reportChanged();else{let e=this.ft.keys(),t=r.keys(),n=e.next(),i=t.next();for(;!n.done;){if(n.value!==i.value){this.lt.reportChanged();break}n=e.next(),i=t.next()}}this.ft=r}),this}get size(){return this.lt.reportObserved(),this.ft.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},ir=l(`ObservableMap`,rr);let ar={};var or=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[A]=ar,this.ft=new Set,this.ct=void 0,this.ot=void 0,this.st=void 0,this.dehancer=void 0,this.A=void 0,this.tt=n,this.A=(e,r)=>t(e,r,n),kt(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){ct(()=>{D(()=>{for(let e of this.ft.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.ct.reportObserved(),this.ft.size}add(e){if(dt(this)){let t=O(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){ct(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=pt(this);t&&ht(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(dt(this)&&!O(this,{type:nr,object:this,oldValue:e}))return!1;if(this.has(e)){let t=pt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:nr,object:this,oldValue:e}:null;return ct(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&ht(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return St({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.ct.reportObserved();let e=this,t=this.ft.values();return St({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.Wt(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return sr(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?ct(()=>{let t=d(e)?e:new Set(e);if(t.size!==0)if(this.ft.size!==0){for(let e of this.ft.values())t.has(this.Wt(e))||this.delete(e);t.forEach(e=>this.add(e))}else t.forEach(e=>this.add(e));else this.clear()}):e!=null&&t(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},sr=l(`ObservableSet`,or);let cr=Object.create(null),lr=`remove`;var ur=class{constructor(e,t=new Map,n,r=Xt){this.h=void 0,this.j=void 0,this.tt=void 0,this.ut=void 0,this.lt=void 0,this.ot=void 0,this.st=void 0,this.v=void 0,this.p=void 0,this.Xt=void 0,this.Qt=void 0,this.O=void 0,this.V=void 0,this.h=e,this.j=t,this.tt=n,this.ut=r,this.lt=new Gt(`ObservableObject.keys`),this.p=o(this.h)}_(e){return(this.j.get(e)??this.vt(e)??this.bt(e)).get()}vt(e){let t=this.O?.get(e);if(!t)return;this.O.delete(e),this.O.size===0&&(this.O=void 0);let n=t();return this.j.set(e,n),n}bt(e){let t=this.V?.get(e);if(!t)return;this.V.delete(e),this.V.size===0&&(this.V=void 0);let n=t();return this.j.set(e,n),n}M(e,t){let n=this.j.get(e)??this.vt(e)??this.bt(e);if(n instanceof M)return n.set(t),!0;if(dt(this)){let n=O(this,{type:Xn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==N.UNCHANGED){let r=pt(this),i=r?{type:Xn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&ht(this,i)}return!0}Tt(e){return N.trackingDerivation&&!p(this.h,e)&&this.et(e),this.h[e]}Bt(e,t,n=!1){return p(this.h,e)?this.j.has(e)?this.M(e,t):n?Reflect.set(this.h,e,t):(this.h[e]=t,!0):this.u(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.ut,n)}et(e){if(!N.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new vn(e in this.h,y,`ObservableObject.key?`,!1),this.Qt.set(e,t)),t.get()}u(e,t,n,r=!1){return!0===n&&(n=this.ut),!1===n?this.l(e,t,r):n.u(this,e,t,r)}l(e,t,n=!1){try{Pe();let r=this.Dt(e);if(!r)return r;if(dt(this)){let n=O(this,{object:this.v||this.h,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:r}=n;t.value!==r&&(t=Ft({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else Lt(this.h,e,t);this.Yt(e,t.value)}finally{Fe()}return!0}S(e,t,n,r=!1){try{Pe();let i=this.Dt(e);if(!i)return i;if(dt(this)){let n=O(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=wt(e),o={configurable:!N.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else Lt(this.h,e,o);let s=new vn(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Fe()}return!0}m(e,t,n=!1){try{Pe();let r=this.Dt(e);if(!r)return r;if(dt(this)&&!O(this,{object:this.v||this.h,name:e,type:`add`,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;let i=wt(e),a={configurable:!N.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else Lt(this.h,e,a);this.j.set(e,new M(t)),this.Yt(e,void 0)}finally{Fe()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(dt(this)&&!O(this,{object:this.v||this.h,name:e,type:lr}))return null;try{var n;Pe();let r=pt(this),i=this.j.get(e),a;if(i||!r||(a=It(this.h,e)?.value),t){if(!Reflect.deleteProperty(this.h,e))return!1}else delete this.h[e];i&&(this.j.delete(e),i instanceof vn&&(a=i.rt),Re(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&ht(this,{type:lr,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Fe()}return!0}Yt(e,t){var n;let r=pt(this);r&&r&&ht(this,r?{type:`add`,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,name:e,newValue:t}:null),(n=this.Qt)==null||(n=n.get(e))==null||n.set(!0),this.lt.reportChanged()}it(){return this.lt.reportObserved(),Ut(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let dr=l(`ObservableObjectAdministration`,ur),fr=Rt.toString,pr=globalThis.Iterator?.prototype||{};e.$mobx=A,e.FlowCancellationError=Hn,e.ObservableMap=rr,e.ObservableSet=or,e.Reaction=En,e._allowStateChanges=Ce,e._allowStateChangesInsideComputed=Ue,e._allowStateReadsEnd=function(e){N.allowStateReads=e},e._allowStateReadsStart=function(e){let t=N.allowStateReads;return N.allowStateReads=e,t},e._autoAction=Ln,e._autoActionBound=zn,e._endAction=Se,e._getAdministration=Dt,e._getGlobalState=function(){return N},e._interceptReads=function(e,t,n){let r;return ir(e)||bt(e)||yn(e)?r=Dt(e):Tt(e)&&(r=Dt(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return N.trackingDerivation!==null},e._resetGlobalState=function(){let e=new Cn;for(let t in e)Sn.indexOf(t)===-1&&(N[t]=e[t]);N.allowStateChanges=!N.enforceActions},e._startAction=xe,e.action=In,e.actionBound=Rn,e.autorun=Ge,e.compareDefault=qt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return At(e,t,1)},e.compareStructural=_,e.computed=fn,e.computedStruct=dn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((N.pendingReactions.length||N.inBatch||N.isRunningReactions)&&t(36),Tn=!0,wn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),N=new Cn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===Vn?Vn:n===`observed`;N.enforceActions=e,N.allowStateChanges=!0!==e&&e!==Vn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(N[t]=!!e[t])}),N.allowStateReads=!N.observableRequiresReaction,e.reactionScheduler&&function(e){let t=On;On=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(Tt(e))return e[A].l(n,r);t(39)},e.entries=function(e){return Tt(e)?nt(e).map(t=>[t,e[t]]):ir(e)?nt(e).map(t=>[t,e.get(t)]):sr(e)?Array.from(e.entries()):bt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Je,e.flow=Gn,e.flowBound=Kn,e.flowResult=function(e){return e},e.get=function(e,n){if(rt(e,n))return Tt(e)?e[A].Tt(n):ir(e)?e.get(n):bt(e)?e[n]:void t(11)},e.getAtom=Et,e.getDebugName=Ot,e.getDependencyTree=function(e,t){return Ye(Et(e,t))},e.getObserverTree=function(e,t){return Xe(Et(e,t))},e.has=rt,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return ft(Dt(e,t),n)}(e,t,n):function(e,t){return ft(Dt(e),t)}(e,t)},e.isAction=We,e.isBoxedObservable=yn,e.isComputed=function(e){return $e(e)},e.isComputedProp=function(e,t){return $e(e,t)},e.isFlow=Qe,e.isFlowCancellationError=function(e){return e instanceof Hn},e.isObservable=tt,e.isObservableArray=bt,e.isObservableMap=ir,e.isObservableObject=Tt,e.isObservableProp=function(e,t){return et(e,t)},e.isObservableSet=sr,e.keys=nt,e.makeAutoObservable=function(e,t,n){return o(e)?Je(e,e,t,n):(kt(()=>{let r=Ct(e,n)[A];if(!e[Jn]){let t=Object.getPrototypeOf(e),n=new Set([...Ut(e),...Ut(t)]);n.delete(`constructor`),n.delete(A),c(t,Jn,n)}e[Jn].forEach(e=>gt(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return kt(()=>{let r=Ct(e,n)[A];Ut(t).forEach(e=>gt(r,e,t[e]))}),e},e.observable=cn,e.observableDeep=on,e.observableRef=rn,e.observableShallow=an,e.observableStruct=sn,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return at(Dt(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Dt(e);if(bt(e))n&&t({observableKind:`array`,object:r.v,debugObjectName:r.ct.tt,type:`splice`,index:0,added:r.j.slice(),addedCount:r.j.length,removed:[],removedCount:0});else if(!ir(e)&&!sr(e)&&!Tt(e))return at(r,t,n);return mt(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return qe(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return qe(`onBUO`,e,t,n)},e.onReactionError=function(e){return N.globalReactionErrorHandlers.push(e),()=>{let t=N.globalReactionErrorHandlers.indexOf(e);t>=0&&N.globalReactionErrorHandlers.splice(t,1)}},e.override=Jt,e.ownKeys=it,e.reaction=function(e,t,n=Bt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=Ce(!1,()=>e(h));t=f||!m(d,n),d=n}),(f&&n.fireImmediately||!f&&t)&&o(d,r,h),f=!1}var i;let a=n.name??`Reaction`,o=In(a,n.onError?(s=n.onError,c=t,function(){try{return c.apply(this,arguments)}catch(e){s.call(this,e)}}):t);var s,c;let l=!n.scheduler&&!n.delay,u=Ke(n),d,f=!0,p=!1,m=n.equals||qt,h=new En(a,()=>{f||l?r():p||(p=!0,u(r))},n.onError,n.requiresObservable);return n!=null&&(i=n.signal)!=null&&i.aborted||h.Y(),h.Z(n?.signal)},e.remove=function(e,n){Tt(e)?e[A].Dt(n):ir(e)||sr(e)?e.delete(n):bt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=Ue,e.set=function e(n,r,i){if(arguments.length===2&&!sr(n)){Pe();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Fe()}return}Tt(n)?n[A].Bt(r,i):ir(n)?n.set(r,i):sr(n)?n.add(r):bt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),Pe(),r>=n.length&&(n.length=r+1),n[r]=i,Fe()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return st(e,new Map)},e.transaction=ct,e.untracked=D,e.values=function(e){return Tt(e)?nt(e).map(t=>e[t]):ir(e)?nt(e).map(t=>e.get(t)):sr(e)?Array.from(e.values()):bt(e)?e.slice():void t(6)},e.when=function(e,t,n){return arguments.length===1||t&&typeof t==`object`?function(e,t){var n;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Ft(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=lt(e,n,Ft({},t,{onError:a}));r=()=>{s(),a(Error(`WHEN_CANCELLED`))},i=()=>{s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)});return a.cancel=r,a}(e,t):lt(e,t,n||{})}})),bb=Te((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t={0:`Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,1(e,t){return`Cannot apply '${e}' to '${t.toString()}': Field not found.`},5:`'keys()' can only be used on observable objects, arrays, sets and maps`,6:`'values()' can only be used on observable objects, arrays, sets and maps`,7:`'entries()' can only be used on observable objects, arrays and maps`,8:`'set()' can only be used on observable objects, arrays and maps`,9:`'remove()' can only be used on observable objects, arrays and maps`,10:`'has()' can only be used on observable objects, arrays and maps`,11:`'get()' can only be used on observable objects, arrays and maps`,12:`Invalid annotation`,13:`Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,14:`Intercept handlers should return nothing or a change object`,15:`Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,16:`Modification exception: the internal structure of an observable array was changed.`,19(e){return`Cannot initialize from classes that inherit from Map: `+e.constructor.name},20(e){return`Cannot initialize map from `+e},21(e){return`Cannot convert to map from '${e}'`},23:`It is not possible to get index atoms from arrays`,24(e){return`Cannot obtain administration from `+e},25(e,t){return`the entry '${e}' does not exist in the observable map '${t}'`},26:`please specify a property`,27(e,t){return`no observable property '${e.toString()}' found on the observable object '${t}'`},28(e){return`Cannot obtain atom from `+e},29:`Expecting some object`,30:`invalid action stack. did you forget to finish an action?`,31:`missing option for computed: get`,32(e,t){return`Cycle detected in computation ${e}: ${t}`},33(e){return`The setter of computed value '${e}' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?`},34(e){return`[ComputedValue '${e}'] It is not possible to assign a new value to a computed value.`},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:`isolateGlobalState should be called before MobX is running any reactions`,37(e){return`[mobx] \`observableArray.${e}()\` mutates the array in-place, which is not allowed inside a derivation. Use \`array.slice().${e}()\` instead`},38:`'ownKeys()' can only be used on observable objects`,39:`'defineProperty()' can only be used on observable objects`,40(e){return`Out of range: `+e},41(e){return`Cannot initialize set from `+e},42(e){return`Invalid index: '${e}'`},43(e,t,n){return`Cannot apply '${e}' to '${t}' (kind: ${n}):\n'${e}' can only be used on properties with a function value.`},44(e){return`'${e}' can only be used with 'makeObservable'`}};function n(e,...n){{let r=typeof e==`string`?e:t[e];throw typeof r==`function`&&(r=r.apply(null,n)),Error(`[MobX] ${r}`)}}let r=Object.assign,i=Object.getOwnPropertyDescriptor,a=Object.defineProperty,o=Object.prototype,s=[];Object.freeze(s);let c={};Object.freeze(c);let l=Object.toString();function u(){return++j.mobxGuid}function d(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}let f=()=>{};function p(e){return typeof e==`function`}function m(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function h(e){return typeof e==`object`&&!!e}function g(e){if(!h(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=ie(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===l}function _(e){let t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function v(e,t,n){a(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function y(e,t,n){a(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function b(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return h(e)&&e[n]===!0}}function ee(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function x(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function S(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function te(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let ne=Reflect.ownKeys;function C(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function re(e){return e===null?null:typeof e==`object`?``+e:e}function ie(e,t){return o.hasOwnProperty.call(e,t)}let ae=Object.getOwnPropertyDescriptors;function w(e,t){return!!(e&t)}function T(e,t,n){return n?e|=t:e&=~t,e}function oe(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let E=Symbol(`mobx administration`);var se=class{constructor(e=`Atom@`+u()){this.name_=void 0,this.flags_=0,this.observers_=null,this.lastAccessedBy_=0,this.lowestObserverState_=-1,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}get isBeingObserved(){return w(this.flags_,1)}set isBeingObserved(e){this.flags_=T(this.flags_,1,e)}get isPendingUnobservation(){return w(this.flags_,2)}set isPendingUnobservation(e){this.flags_=T(this.flags_,2,e)}get diffValue(){return+!!w(this.flags_,4)}set diffValue(e){this.flags_=T(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return un(this)}reportChanged(){on(),dn(this),sn()}toString(){return this.name_}};let ce=b(`Atom`,se);function le(e,t=f,n=f){let r=new se(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function ue(e,t){return e===t}function de(e,t){return Li(e,t)}function fe(e,t){return Li(e,t,1)}let pe=Object.is;function me(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||xr(e)?e:Array.isArray(e)?O.array(e,{name:n}):g(e)?O.object(e,void 0,{name:n}):ee(e)?O.map(e,{name:n}):S(e)?O.set(e,{name:n}):typeof e==`function`&&!zn(e)&&!fr(e)?_(e)?cr(e):Fn(n,e):e}function he(e,t,r){if(e==null||ki(e)||fi(e)||gi(e)||xi(e))return e;if(Array.isArray(e))return O.array(e,{name:r,deep:!1});if(g(e))return O.object(e,void 0,{name:r,deep:!1});if(ee(e))return O.map(e,{name:r,deep:!1});if(S(e))return O.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function ge(e){return e}function _e(e,t){return xr(e)&&n(`observable.struct should not be used with observable values`),Li(e,t)?t:e}let ve=`override`,ye={annotationType_:ve,make_:xe,extend_:Se};function be(e){return e.annotationType_===ve}function xe(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),ie(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function Se(e,t,r,i){n(44,this.annotationType_)}function Ce(e,t){return{annotationType_:e,options_:t,make_:we,extend_:Te}}function we(e,t,n,r){var i;return(i=this.options_)!=null&&i.bound?this.extend_(e,t,n,!1)===null?0:1:r===e.target_?this.extend_(e,t,n,!1)===null?0:2:zn(n.value)?1:(a(r,t,D(e,this,t,n,!1)),2)}function Te(e,t,n,r){let i=D(e,this,t,n);return e.defineProperty_(t,i,r)}function Ee(e,t,r){oe(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>xt(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return zn(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return zn(t)||(t=c(t)),(l=s.options_)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),t}n(43,s.annotationType_,String(a),i)}function De(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a function value.`)}function D(e,t,n,r,i=j.safeDescriptors){var a,o;De(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:xt(t.options_?.name??n.toString(),s,t.options_?.autoAction??!1,(o=t.options_)!=null&&o.bound?e.proxy_??e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function Oe(e,t){return{annotationType_:e,options_:t,make_:ke,extend_:Ae}}function ke(e,t,n,r){var i;return r===e.target_?this.extend_(e,t,n,!1)===null?0:2:(i=this.options_)!=null&&i.bound&&(!ie(e.target_,t)||!fr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:fr(n.value)?1:(a(r,t,Ne(e,this,t,n,!1,!1)),2)}function Ae(e,t,n,r){let i=Ne(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function je(e,t,n){var r;oe(n,[`method`]);let{name:i,addInitializer:a}=n;return fr(t)||(t=cr(t)),(r=e.options_)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function Me(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a generator function value.`)}function Ne(e,t,n,r,i,a=j.safeDescriptors){Me(e,t,n,r);let{value:o}=r;return fr(o)||(o=cr(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function Pe(e,t){return{annotationType_:e,options_:t,make_:Fe,extend_:Ie}}function Fe(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Ie(e,t,n,i){return Re(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Le(e,t,n){oe(n,[`getter`]);let i=e,{name:a,addInitializer:o}=n,s;function c(e,n){let o=r({},i.options_,{get:t,context:e});return o.name||=`${n.name_}.${a.toString()}`,new At(o)}return o(function(){let e=Ei(this)[E],n=this,r=e.values_.get(a);r instanceof At&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[E],n=e.values_.get(a);if(n instanceof At&&n.derivation!==t){let t=s?.get(this);return t||(t=c(this,e),(s??=new WeakMap).set(this,t)),t.get()}return e.getObservablePropValue_(a)}}function Re(e,{annotationType_:t},r,{get:i}){i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on getter(+setter) properties.`)}function ze(e,t){return{annotationType_:e,options_:t,make_:Be,extend_:Ve}}function Be(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Ve(e,t,n,r){return Ue(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??me,r)}function He(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);oe(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=Ei(e)[E];return(n.lazyObservableKeys_??=new Map).set(o,()=>new Ot(t,i.options_?.enhancer_??me,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[E]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[E]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function Ue(e,{annotationType_:t},r,i){`value`in i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' cannot be used on getter/setter properties`)}let We=Ge();function Ge(e){return{annotationType_:`true`,options_:e,make_:Je,extend_:Ye}}let Ke=[We];function qe(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return Ke[r]??(Ke[r]=Ge({deep:t,autoBind:n}))}function Je(e,t,n,r){var i;if(n.get)return k.make_(e,t,n,r);if(n.set){let i=zn(n.set)?n.set:xt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:j.safeDescriptors?e.isPlainObject_:!0,set:i})===null?0:2:(a(r,t,{configurable:!0,set:i}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(_(n.value)){var s;return((s=this.options_)!=null&&s.autoBind?lr:cr).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Ln:Fn).make_(e,t,n,r)}let c=this.options_?.deep===!1?lt:O;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),c.make_(e,t,n,r)}function Ye(e,t,n,r){var i;return n.get?k.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:j.safeDescriptors?e.isPlainObject_:!0,set:xt(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),(this.options_?.deep===!1?lt:O).extend_(e,t,n,r))}function Xe(e,t){return r(function(r,i){if(i&&typeof i.kind==`string`)return t(e,r,i);n(`Invalid arguments for \`${e.annotationType_}\``)},e)}let Ze={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Ze);function Qe(e){return e||Ze}let $e=ze(`observable`),et=ze(`observable.ref`,{enhancer_:ge}),tt=ze(`observable.shallow`,{enhancer_:he}),nt=ze(`observable.struct`,{enhancer_:_e});function rt(e){return Xe(e,He)}function it(e){return e.deep===!0?me:e.deep===!1?ge:ot(e.defaultDecorator)}function at(e){return e?e.defaultDecorator??qe(e):void 0}function ot(e){return e?e.options_?.enhancer_??me:me}function st(e,t,n){return t&&typeof t.kind==`string`?He($e,e,t):xr(e)?e:g(e)?O.object(e,t,n):Array.isArray(e)?O.array(e,t):ee(e)?O.map(e,t):S(e)?O.set(e,t):typeof e==`object`&&e?e:O.box(e,t)}let ct={box(e,t){let n=Qe(t);return new Ot(e,it(n),n.name,!0,n.equals)},array(e,t){let n=Qe(t);return ai(e,it(n),n.name)},map(e,t){let n=Qe(t);return new hi(e,it(n),n.name)},set(e,t){let n=Qe(t);return new bi(e,it(n),n.name)},object(e,t,n){return Fi(()=>Xn(Gr({},n),e,t))}},lt=rt(et),ut=rt(tt),dt=rt($e),ft=rt(nt);var O=r(st,$e,ct);let pt=`computed`;function mt(e){return Xe(e,Le)}let ht=Pe(pt),gt=mt(Pe(`computed.struct`,{equals:de})),k=function(e,t){if(t&&typeof t.kind==`string`)return Le(ht,e,t);if(g(e))return mt(Pe(pt,e));p(e)||n("First argument to `computed` should be an expression."),p(t)&&n("A setter as second argument is no longer supported, use `{ set: fn }` option instead");let r=g(t)?t:{};return r.get=e,r.name||=e.name||``,new At(r)};r(k,ht);let _t=0,vt=1,yt=i(()=>{},`name`)?.configurable??!1,bt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function xt(e,t,r=!1,i){p(t)||n("`action` can only be invoked on functions"),(typeof e!=`string`||!e)&&n(`actions should have valid names, got: '${e}'`);function o(){return St(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),yt&&(bt.value=e,a(o,`name`,bt)),o}function St(e,t,n,r,i){let a=Ct(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{wt(a)}}function Ct(e,t,n,r){let i=bn()&&!!e,a=0;i&&(a=Date.now(),Sn({type:N,name:e,object:n,arguments:r?Array.from(r):s}));let o=j.trackingDerivation,c=!t||!o;on();let l=j.allowStateChanges;c&&(Ut(),l=Et(!0));let u=j.allowStateReads;A(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:vt++,parentActionId_:_t};return _t=d.actionId_,d}function wt(e){_t!==e.actionId_&&n(30),_t=e.parentActionId_,e.error_!==void 0&&(j.suppressReactionErrors=!0),Dt(e.prevAllowStateChanges_),Gt(e.prevAllowStateReads_),sn(),e.runAsAction_&&Wt(e.prevDerivation_),e.notifySpy_&&wn({time:Date.now()-e.startTime_}),j.suppressReactionErrors=!1}function Tt(e,t){let n=Et(e);try{return t()}finally{Dt(n)}}function Et(e){let t=j.allowStateChanges;return j.allowStateChanges=e,t}function Dt(e){j.allowStateChanges=e}var Ot=class extends se{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=pe){super(n),this.enhancer_=void 0,this.name_=void 0,this.equals_=void 0,this.hasUnreportedChange_=!1,this.interceptors_=void 0,this.changeListeners_=void 0,this.value_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,this.equals_=i,this.value_=t(e,void 0,n),r&&bn()&&xn({type:`create`,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:this.value_})}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){let t=this.value_;if(e=this.prepareNewValue_(e),e!==j.UNCHANGED){let n=bn();n&&Sn({type:ni,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&wn()}}prepareNewValue_(e){if(It(this),Kr(this)){let t=P(this,{object:this,type:ni,newValue:e});if(!t)return j.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?j.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),Jr(this)&&Xr(this,{type:ni,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.value_)}raw(){return this.value_}toJSON(){return this.get()}toString(){return`${this.name_}[${this.value_}]`}valueOf(){return re(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let kt=b(`ObservableValue`,Ot);var At=class{constructor(e){this.dependenciesState_=-1,this.observing_=[],this.newObserving_=null,this.observers_=null,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=0,this.unboundDepsCount_=0,this.value_=new Mt(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||n(31),this.derivation=e.get,this.name_=e.name||`ComputedValue@`+u(),e.set&&(this.setter_=xt(this.name_+`-setter`,e.set)),this.equals_=e.equals||pe,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){pn(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return w(this.flags_,1)}set isComputing(e){this.flags_=T(this.flags_,1,e)}get isRunningSetter(){return w(this.flags_,2)}set isRunningSetter(e){this.flags_=T(this.flags_,2,e)}get isBeingObserved(){return w(this.flags_,4)}set isBeingObserved(e){this.flags_=T(this.flags_,4,e)}get isPendingUnobservation(){return w(this.flags_,8)}set isPendingUnobservation(e){this.flags_=T(this.flags_,8,e)}get diffValue(){return+!!w(this.flags_,16)}set diffValue(e){this.flags_=T(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),j.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Pt(this)&&(this.warnAboutUntrackedRead_(),on(),this.value_=this.computeValue_(!1),sn());else{let e=this.isBeingObserved;if(un(this),Pt(this)){let e=j.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(j.trackingContext=this),this.trackAndCompute()&&fn(this),j.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(ln)}let e=this.value_;if(Nt(e))throw e.cause;return e}set(e){if(this.setter_){this.isRunningSetter&&n(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter=!1}}else n(34,this.name_)}trackAndCompute(){let e=this.value_,t=this.dependenciesState_===-1,n=this.computeValue_(!0),r=t||Nt(e)||Nt(n)||!this.equals_(e,n);return r&&(this.value_=n,bn()&&xn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=Et(!1),n;if(e)n=Rt(this,this.derivation,this.scope_);else if(j.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new Mt(e)}return Dt(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(Vt(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:j.computedRequiresReaction)&&console.warn(`[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`)}toString(){return`${this.name_}[${this.derivation.toString()}]`}valueOf(){return re(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let jt=b(`ComputedValue`,At);var Mt=class{constructor(e){this.cause=void 0,this.cause=e}};function Nt(e){return e instanceof Mt}function Pt(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=A(!0),n=Ut(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(jt(i)){if(j.disableErrorBoundaries)i.get();else try{i.get()}catch{return Wt(n),Gt(t),!0}if(e.dependenciesState_===2)return Wt(n),Gt(t),!0}}return Kt(e),Wt(n),Gt(t),!1}}}function Ft(){return j.trackingDerivation!==null}function It(e){let t=!!e.observers_&&e.observers_.size>0;!j.allowStateChanges&&(t||j.enforceActions===`always`)&&console.warn(`[MobX] `+(j.enforceActions?`Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: `:`Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: `)+e.name_)}function Lt(e){!j.allowStateReads&&j.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function Rt(e,t,n){let r=A(!0);Kt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++j.runId;let i=j.trackingDerivation;j.trackingDerivation=e,j.inBatch++;let a;if(j.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new Mt(e)}return j.inBatch--,j.trackingDerivation=i,Bt(e),zt(e),Gt(r),a}function zt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:j.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function Bt(e){let t=e.observing_,n=e.observing_=e.newObserving_,r=0,i=0,a=e.unboundDepsCount_;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.dependenciesState_>r&&(r=t.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&rn(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,nn(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function Vt(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)rn(t[n],e);e.dependenciesState_=-1}function Ht(e){let t=Ut();try{return e()}finally{Wt(t)}}function Ut(){let e=j.trackingDerivation;return j.trackingDerivation=null,e}function Wt(e){j.trackingDerivation=e}function A(e){let t=j.allowStateReads;return j.allowStateReads=e,t}function Gt(e){j.allowStateReads=e}function Kt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let qt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Jt=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let Yt=!0,Xt=!1,j=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Yt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Yt=!1),Yt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Jt):(setTimeout(()=>{Xt||n(35)},1),new Jt)}();function Zt(){if((j.pendingReactions.length||j.inBatch||j.isRunningReactions)&&n(36),Xt=!0,Yt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),j=new Jt}}function Qt(){return j}function $t(){let e=new Jt;for(let t in e)qt.indexOf(t)===-1&&(j[t]=e[t]);j.allowStateChanges=!j.enforceActions}function en(e){return!!e.observers_&&e.observers_.size>0}function tn(e){return e.observers_??new Set}function nn(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function rn(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&an(e))}function an(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,j.pendingUnobservations.push(e))}function on(){j.inBatch++}function sn(){--j.inBatch===0&&(_n(),!j.isRunningUnobservations&&j.pendingUnobservations.length>0&&cn())}function cn(){j.isRunningUnobservations=!0;try{let e=j.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,(!n.observers_||n.observers_.size===0)&&(n.observers_=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof At&&n.suspend_())}j.pendingUnobservations=[]}finally{j.isRunningUnobservations=!1}}function ln(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(ln))}function un(e){Lt(e);let t=j.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&j.inBatch>0&&an(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&j.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function dn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&e.onBecomeStale_(),e.dependenciesState_=2}))}function fn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(t=>{t.dependenciesState_===1?t.dependenciesState_=2:t.dependenciesState_===0&&(e.lowestObserverState_=0)}))}function pn(e){var t;e.lowestObserverState_===0&&(e.lowestObserverState_=1,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&(e.dependenciesState_=1,e.onBecomeStale_())}))}var mn=class{constructor(e=`Reaction@`+u(),t,n,r){this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=-1,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.removeAbortListener_=void 0,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}get isDisposed(){return w(this.flags_,1)}set isDisposed(e){this.flags_=T(this.flags_,1,e)}get isScheduled(){return w(this.flags_,2)}set isScheduled(e){this.flags_=T(this.flags_,2,e)}get isTrackPending(){return w(this.flags_,4)}set isTrackPending(e){this.flags_=T(this.flags_,4,e)}get isRunning(){return w(this.flags_,8)}set isRunning(e){this.flags_=T(this.flags_,8,e)}get diffValue(){return+!!w(this.flags_,16)}set diffValue(e){this.flags_=T(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,j.pendingReactions.push(this),_n())}runReaction_(){if(!this.isDisposed){on(),this.isScheduled=!1;let e=j.trackingContext;if(j.trackingContext=this,Pt(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&bn()&&xn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}j.trackingContext=e,sn()}}track(e){if(this.isDisposed)return;on();let t=bn(),n;t&&(n=Date.now(),Sn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=j.trackingContext;j.trackingContext=this;let i=Rt(this,e,void 0);j.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Vt(this),Nt(i)&&this.reportExceptionInDerivation_(i.cause),t&&wn({time:Date.now()-n}),sn()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(j.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;j.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),bn()&&xn({type:`error`,name:this.name_,message:t,error:``+e}),j.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(on(),Vt(this),sn())}}getDisposer_(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.removeAbortListener_=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[E]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function hn(e){return j.globalReactionErrorHandlers.push(e),()=>{let t=j.globalReactionErrorHandlers.indexOf(e);t>=0&&j.globalReactionErrorHandlers.splice(t,1)}}let gn=e=>e();function _n(){j.inBatch>0||j.isRunningReactions||gn(vn)}function vn(){j.isRunningReactions=!0;let e=j.pendingReactions,t=0;for(;e.length>0;){++t===100&&(console.error(`Reaction doesn't converge to a stable state after 100 iterations. Probably there is a cycle in the reactive function: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].runReaction_()}j.isRunningReactions=!1}let yn=b(`Reaction`,mn);function M(e){let t=gn;gn=n=>e(()=>t(n))}function bn(){return!!j.spyListeners.length}function xn(e){if(!j.spyListeners.length)return;let t=j.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function Sn(e){xn(r({},e,{spyReportStart:!0}))}let Cn={type:`report-end`,spyReportEnd:!0};function wn(e){xn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):Cn)}function Tn(e){return j.spyListeners.push(e),d(()=>{j.spyListeners=j.spyListeners.filter(t=>t!==e)})}let N=`action`,En=`autoAction`,Dn=`<unnamed action>`,On=Ce(N),kn=Ce(`action.bound`,{bound:!0}),An=Ce(En,{autoAction:!0}),jn=Ce(`autoAction.bound`,{autoAction:!0,bound:!0});function Mn(e){return Xe(e,Ee)}function Nn(e){return function(t,r){if(r&&typeof r.kind==`string`)return Ee(e?An:On,t,r);if(p(t))return xt(t.name||Dn,t,e);if(p(r))return xt(t,r,e);if(m(t))return Mn(Ce(e?En:N,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Pn=Nn(!1);r(Pn,On);let Fn=Nn(!0);r(Fn,An);let In=Mn(kn),Ln=Mn(jn);function Rn(e){return St(e.name||Dn,!1,e,this,void 0)}function zn(e){return p(e)&&e.isMobxAction===!0}function Bn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),zn(e)&&n(`Autorun does not accept actions since actions are untrackable`);let i=t?.name??(e.name||`Autorun@`+u()),a=!t.scheduler&&!t.delay,o;if(a)o=new mn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Hn(t),n=!1;o=new mn(i,()=>{n||(n=!0,e(()=>{n=!1,o.isDisposed||o.track(s)}))},t.onError,t.requiresObservable)}function s(){e(o)}return t!=null&&(r=t.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}let Vn=e=>e();function Hn(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Vn}function Un(e,t,r=c){var i;(!p(e)||!p(t))&&n(`First and second argument to reaction should be functions`),g(r)||n(`Third argument of reactions should be an object`);let a=r.name??`Reaction@`+u(),o=Pn(a,r.onError?Wn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Hn(r),d=!0,f=!1,m,h=r.equals||pe,_=new mn(a,()=>{d||s?v():f||(f=!0,l(v))},r.onError,r.requiresObservable);function v(){if(f=!1,_.isDisposed)return;let t=!1,n=m;_.track(()=>{let n=Tt(!1,()=>e(_));t=d||!h(m,n),m=n}),(d&&r.fireImmediately||!d&&t)&&o(m,n,_),d=!1}return r!=null&&(i=r.signal)!=null&&i.aborted||_.schedule_(),_.getDisposer_(r?.signal)}function Wn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Gn(e,t,n){return qn(`onBO`,e,t,n)}function Kn(e,t,n){return qn(`onBUO`,e,t,n)}function qn(e,t,n,r){let i=typeof r==`function`?Mi(t,n):Mi(t),a=p(r)?r:n,o=`${e}L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){let e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}let Jn=`always`;function Yn(e){e.isolateGlobalState===!0&&Zt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Jn?Jn:t===`observed`;j.enforceActions=e,j.allowStateChanges=!(e===!0||e===Jn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(j[t]=!!e[t])}),j.allowStateReads=!j.observableRequiresReaction,j.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&M(e.reactionScheduler)}function Xn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),gi(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(xr(t)||xr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=ae(t);return Fi(()=>{let t=Ei(e,i)[E];ne(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Zn(e,t){return Qn(Mi(e,t))}function Qn(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=tr(e.observing_).map(Qn)),t}function $n(e,t){return er(Mi(e,t))}function er(e){let t={name:e.name_};return en(e)&&(t.observers=Array.from(tn(e),er)),t}function tr(e){return Array.from(new Set(e))}let nr=0;var rr=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function ir(e){return e instanceof rr}function ar(e){return Xe(e,je)}let or=Oe(`flow`),sr=Oe(`flow.bound`,{bound:!0}),cr=r(function(e,t){if(t&&typeof t.kind==`string`)return je(or,e,t);arguments.length!==1&&n(`Flow expects single argument with generator function`);let r=e,i=r.name||`<unnamed flow>`,a=function(){let e=this,t=arguments,n=++nr,a=Pn(`${i} - runid: ${n} - init`,r).apply(e,t),o,s,c=new Promise(function(e,t){let r=0;o=t;function c(e){s=void 0;let o;try{o=Pn(`${i} - runid: ${n} - yield ${r++}`,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;let o;try{o=Pn(`${i} - runid: ${n} - yield ${r++}`,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(p(n?.then)){n.then(u,t);return}return n.done?e(n.value):(s=Promise.resolve(n.value),s.then(c,l))}c(void 0)});return c.cancel=Pn(`${i} - runid: ${n} - cancel`,function(){try{s&&ur(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),ur(t),o(new rr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},or),lr=ar(sr);function ur(e){p(e.cancel)&&e.cancel()}function dr(e){return e}function fr(e){return e?.isMobXFlow===!0}function pr(e,t,r){let i;if(gi(e)||fi(e)||kt(e))i=Ni(e);else if(ki(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=Ni(e,t)}else return n(`Expected observable map, object or array as first array`);return i.dehancer===void 0?(i.dehancer=typeof t==`function`?t:r,()=>{i.dehancer=void 0}):n(`An intercept reader was already established`)}function mr(e,t,n){return p(n)?gr(e,t,n):hr(e,t)}function hr(e,t){return qr(Ni(e),t)}function gr(e,t,n){return qr(Ni(e,t),n)}function _r(e,t){var n;if(t===void 0)return jt(e);if(ki(e)===!1)return!1;let r=e[E];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?jt(Mi(e,t)):!1}function vr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):_r(e)}function yr(e,t){return m(t)?_r(e,t):n(`isComputed expected a property name as second argument`)}function br(e,t){if(!e)return!1;if(t!==void 0){if(gi(e)||fi(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(ki(e)){var r,i;let n=e[E];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return ki(e)||!!e[E]||ce(e)||yn(e)||jt(e)}function xr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),br(e)}function Sr(e,t){return m(t)?br(e,t):n(`expected a property name as second argument`)}function Cr(e){if(ki(e))return e[E].keys_();if(gi(e)||xi(e))return Array.from(e.keys());if(fi(e))return e.map((e,t)=>t);n(5)}function wr(e){if(ki(e))return Cr(e).map(t=>e[t]);if(gi(e))return Cr(e).map(t=>e.get(t));if(xi(e))return Array.from(e.values());if(fi(e))return e.slice();n(6)}function Tr(e){if(ki(e))return Cr(e).map(t=>[t,e[t]]);if(gi(e))return Cr(e).map(t=>[t,e.get(t)]);if(xi(e))return Array.from(e.entries());if(fi(e))return e.map((e,t)=>[t,e]);n(7)}function Er(e,t,r){if(arguments.length===2&&!xi(e)){on();let n=t;try{for(let t in n)Er(e,t,n[t])}finally{sn()}return}ki(e)?e[E].set_(t,r):gi(e)?e.set(t,r):xi(e)?e.add(t):fi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),on(),t>=e.length&&(e.length=t+1),e[t]=r,sn()):n(8)}function Dr(e,t){ki(e)?e[E].delete_(t):gi(e)||xi(e)?e.delete(t):fi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function Or(e,t){if(ki(e))return e[E].has_(t);if(gi(e)||xi(e))return e.has(t);if(fi(e))return t>=0&&t<e.length;n(10)}function kr(e,t){if(Or(e,t)){if(ki(e))return e[E].get_(t);if(gi(e))return e.get(t);if(fi(e))return e[t];n(11)}}function Ar(e,t,r){if(ki(e))return e[E].defineProperty_(t,r);n(39)}function jr(e){if(ki(e))return e[E].ownKeys_();n(38)}function Mr(e,t,n,r){return p(n)?Pr(e,t,n,r):Nr(e,t,n)}function Nr(e,t,r){let i=Ni(e);if(fi(e))r&&t({observableKind:`array`,object:i.proxy_,debugObjectName:i.atom_.name_,type:`splice`,index:0,added:i.values_.slice(),addedCount:i.values_.length,removed:[],removedCount:0});else if(gi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(xi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(ki(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Fr(i,t,r);return Yr(i,t)}function Pr(e,t,n,r){return Fr(Ni(e,t),n,r)}function Fr(e,t,n){if(jt(e)){let r=!0,i;return Bn(()=>{let a=e.get();if(!r||n){let n=Ut();t({observableKind:`computed`,debugObjectName:e.name_,type:ni,object:e,newValue:a,oldValue:i}),Wt(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ni,newValue:e.value_,oldValue:void 0}),Yr(e,t)}function Ir(e,t,n){return e.set(t,n),n}function Lr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!xr(e))return e;if(kt(e)||jt(e))return Lr(e.get(),t);if(t.has(e))return t.get(e);if(fi(e)){let n=Ir(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Lr(e,t)}),n}if(xi(e)){let n=Ir(t,e,new Set);return e.forEach(e=>{n.add(Lr(e,t))}),n}if(gi(e)){let n=Ir(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Lr(e,t))}),n}else{let n=Ir(t,e,{});return jr(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Lr(e[r],t))}),n}}function Rr(e,t){return t&&n(`toJS no longer supports options`),Lr(e,new Map)}function zr(e,t=void 0){on();try{return e.apply(t)}finally{sn()}}function Br(e,t,n){return arguments.length===1||t&&typeof t==`object`?Hr(e,t):Vr(e,t,n||{})}function Vr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[E].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=xt(n.name+`-effect`,t);var a=Bn(t=>{Tt(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function Hr(e,t){var i;if(t&&t.onError)return n(`the options 'onError' and 'promise' cannot be combined`);if(t!=null&&(i=t.signal)!=null&&i.aborted)return r(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let a,o,s=new Promise((n,i)=>{var s;let c=Vr(e,n,r({},t,{onError:i}));a=()=>{c(),i(Error(`WHEN_CANCELLED`))},o=()=>{c(),i(Error(`WHEN_ABORTED`))},t==null||(s=t.signal)==null||s.addEventListener==null||s.addEventListener(`abort`,o)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,o)});return s.cancel=a,s}function Ur(e){return e[E]}let Wr={has(e,t){return Ur(e).has_(t)},get(e,t){return Ur(e).get_(t)},set(e,t,n){return m(t)?Ur(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Ur(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Ur(e).defineProperty_(t,n)??!0},ownKeys(e){return Ur(e).ownKeys_()},preventExtensions(e){n(13)}};function Gr(e,t){var n;return e=Ei(e,t),(n=e[E]).proxy_??(n.proxy_=new Proxy(e,Wr))}function Kr(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function qr(e,t){let n=e.interceptors_;return n?n.push(t):n=e.interceptors_=[t],d(()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function P(e,t){let r=Ut();try{let r=[...e.interceptors_||[]];for(let e=0,i=r.length;e<i&&(t=r[e](t),t&&!t.type&&n(14),t);e++);return t}finally{Wt(r)}}function Jr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Yr(e,t){let n=e.changeListeners_;return n?n.push(t):n=e.changeListeners_=[t],d(()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function Xr(e,t){let n=Ut(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Wt(n)}}function Zr(e,t,n){return Fi(()=>{let r=Ei(e,n)[E];ne(t).forEach(e=>ei(r,e,t[e]))}),e}let Qr=Symbol(`mobx-keys`);function $r(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),ki(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Xn(e,e,t,r):(Fi(()=>{let n=Ei(e,r)[E];if(!e[Qr]){let t=Object.getPrototypeOf(e),n=new Set([...ne(e),...ne(t)]);n.delete(`constructor`),n.delete(E),v(t,Qr,n)}e[Qr].forEach(e=>ei(n,e,t&&e in t?t[e]:!0))}),e)}function ei(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;ji(e,r,t),t in e.target_||n(1,r.annotationType_,`${e.name_}.${t.toString()}`);let a=e.target_;for(;a&&a!==o;){let n=i(a,t);if(n){let i=r.make_(e,t,n,a);if(i===0)return;if(i===1)break}a=Object.getPrototypeOf(a)}Ai(e,r,t)}let ti=`splice`,ni=`update`,ri={get(e,t){let n=e[E];return t===E?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):ie(oi,t)?oi[t]:e[t]},set(e,t,n){let r=e[E];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var ii=class{constructor(e=`ObservableArray@`+u(),t,n){this.owned_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=n,this.atom_=new se(e),this.enhancer_=(n,r)=>t(n,r,e+`[..]`)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}dehanceValues_(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}getArrayLength_(){return this.atom_.reportObserved(),this.values_.length}setArrayLength_(e){(!Number.isInteger(e)||e<0)&&n(40,e);let t=this.values_.length;if(e!==t)if(e>t){let n=Array.from({length:e-t});this.spliceWithArray_(t,0,n)}else this.spliceWithArray_(e,t-e)}updateArrayLength_(e,t){e!==this.lastKnownLength_&&n(16),this.lastKnownLength_+=t}spliceWithArray_(e,t,n){It(this.atom_);let r=this.values_.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=s),Kr(this)){let r=P(this,{object:this.proxy_,type:ti,index:e,removedCount:t,added:n});if(!r)return s;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.enhancer_(e,void 0));{let e=n.length-t;this.updateArrayLength_(r,e)}let i=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,i),this.dehanceValues_(i)}spliceItemsIntoValues_(e,t,n){if(n.length<1e4)return this.values_.splice(e,t,...n);{let r=this.values_.slice(e,e+t),i=this.values_.slice(e+t);this.values_.length+=n.length-t;for(let t=0;t<n.length;t++)this.values_[e+t]=n[t];for(let t=0;t<i.length;t++)this.values_[e+n.length+t]=i[t];return r}}notifyArrayChildUpdate_(e,t,n){let r=!this.owned_&&bn(),i=Jr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ni,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&Sn(a),this.atom_.reportChanged(),i&&Xr(this,a),r&&wn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&bn(),i=Jr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:ti,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Sn(a),this.atom_.reportChanged(),i&&Xr(this,a),r&&wn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){It(this.atom_);let r=n[e];if(Kr(this)){let n=P(this,{type:ni,object:this.proxy_,index:e,newValue:t});if(!n)return;t=n.newValue}t=this.enhancer_(t,r),t!==r&&(n[e]=t,this.notifyArrayChildUpdate_(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.spliceWithArray_(n.length,0,r)}}};function ai(e,t,n=`ObservableArray@`+u(),r=!1){return Fi(()=>{let i=new ii(n,t,r);y(i.values_,E,i);let a=new Proxy(i.values_,ri);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var oi={clear(){return this.splice(0)},replace(e){let t=this[E];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[E];switch(arguments.length){case 0:return[];case 1:return r.spliceWithArray_(e);case 2:return r.spliceWithArray_(e,t)}return r.spliceWithArray_(e,t,n)},spliceWithArray(e,t,n){return this[E].spliceWithArray_(e,t,n)},push(...e){let t=this[E];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[E].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[E];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return j.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){j.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[E],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};si(`at`,ci),si(`concat`,ci),si(`flat`,ci),si(`includes`,ci),si(`indexOf`,ci),si(`join`,ci),si(`lastIndexOf`,ci),si(`slice`,ci),si(`toString`,ci),si(`toLocaleString`,ci),si(`toSorted`,ci),si(`toSpliced`,ci),si(`with`,ci),si(`every`,li),si(`filter`,li),si(`find`,li),si(`findIndex`,li),si(`findLast`,li),si(`findLastIndex`,li),si(`flatMap`,li),si(`forEach`,li),si(`map`,li),si(`some`,li),si(`toReversed`,li),si(`reduce`,ui),si(`reduceRight`,ui);function si(e,t){typeof Array.prototype[e]==`function`&&(oi[e]=t(e))}function ci(e){return function(){let t=this[E];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function li(e){return function(t,n){let r=this[E];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function ui(e){return function(){let t=this[E];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}let di=b(`ObservableArrayAdministration`,ii);function fi(e){return h(e)&&di(e[E])}let pi={},mi=`delete`;var hi=class{constructor(e,t=me,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[E]=pi,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,Fi(()=>{this.keysAtom_=le(`${this.name_}.keys()`),this.data_=new Map,this.hasMap_=new Map,e&&this.merge(e)})}has_(e){return this.data_.has(e)}has(e){if(!j.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new Ot(this.has_(e),ge,`${this.name_}.${C(e)}?`,!1);this.hasMap_.set(e,n),n.onBUOL=new Set([()=>this.hasMap_.delete(e)])}return t.get()}set(e,t){let n=this.has_(e);if(Kr(this)){let r=P(this,{type:n?ni:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this}delete(e){if(It(this.keysAtom_),Kr(this)&&!P(this,{type:mi,object:this,name:e}))return!1;if(this.has_(e)){let t=bn(),n=Jr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:mi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&Sn(r),zr(()=>{var t;this.keysAtom_.reportChanged(),(t=this.hasMap_.get(e))==null||t.setNewValue_(!1),this.data_.get(e).setNewValue_(void 0),this.data_.delete(e)}),n&&Xr(this,r),t&&wn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==j.UNCHANGED){let r=bn(),i=Jr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ni,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&Sn(a),n.setNewValue_(t),i&&Xr(this,a),r&&wn()}}addValue_(e,t){It(this.keysAtom_),zr(()=>{var n;let r=new Ot(t,this.enhancer_,`${this.name_}.${C(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=bn(),r=Jr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&Sn(i),r&&Xr(this,i),n&&wn()}get(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.keysAtom_.reportObserved(),this.data_.keys()}values(){let e=this,t=this.keys();return _i({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return _i({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return gi(e)&&(e=new Map(e)),zr(()=>{g(e)?te(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):ee(e)?(x(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){zr(()=>{Ht(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return zr(()=>{let t=vi(e),n=new Map,r=!1;for(let e of this.data_.keys())if(!t.has(e))if(this.delete(e))r=!0;else{let t=this.data_.get(e);n.set(e,t)}for(let[e,i]of t.entries()){let t=this.data_.has(e);if(this.set(e,i),this.data_.has(e)){let i=this.data_.get(e);n.set(e,i),t||(r=!0)}}if(!r)if(this.data_.size!==n.size)this.keysAtom_.reportChanged();else{let e=this.data_.keys(),t=n.keys(),r=e.next(),i=t.next();for(;!r.done;){if(r.value!==i.value){this.keysAtom_.reportChanged();break}r=e.next(),i=t.next()}}this.data_=n}),this}get size(){return this.keysAtom_.reportObserved(),this.data_.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},gi=b(`ObservableMap`,hi);function _i(e){return e[Symbol.toStringTag]=`MapIterator`,Vi(e)}function vi(e){if(ee(e)||gi(e))return e;if(Array.isArray(e))return new Map(e);if(g(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}else return n(21,e)}let yi={};var bi=class{constructor(e,t=me,n=`ObservableSet@`+u()){this.name_=void 0,this[E]=yi,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,this.enhancer_=(e,r)=>t(e,r,n),Fi(()=>{this.atom_=le(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){zr(()=>{Ht(()=>{for(let e of this.data_.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.atom_.reportObserved(),this.data_.size}add(e){if(It(this.atom_),Kr(this)){let t=P(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){zr(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=bn(),n=Jr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&Sn(r),n&&Xr(this,r),t&&wn()}return this}delete(e){if(Kr(this)&&!P(this,{type:mi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=bn(),n=Jr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:mi,object:this,oldValue:e}:null;return t&&Sn(r),zr(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Xr(this,r),t&&wn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return Si({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.atom_.reportObserved();let e=this,t=this.data_.values();return Si({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.dehanceValue_(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return xi(e)&&(e=new Set(e)),Array.isArray(e)||S(e)?zr(()=>{let t=S(e)?e:new Set(e);if(t.size===0){this.clear();return}if(this.data_.size===0){t.forEach(e=>this.add(e));return}for(let e of this.data_.values())t.has(this.dehanceValue_(e))||this.delete(e);t.forEach(e=>this.add(e))}):e!=null&&n(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},xi=b(`ObservableSet`,bi);function Si(e){return e[Symbol.toStringTag]=`SetIterator`,Vi(e)}let Ci=Object.create(null),wi=`remove`;var Ti=class{constructor(e,t=new Map,r,i=We){this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.lazyComputedKeys_=void 0,this.lazyObservableKeys_=void 0,this.target_=e,this.values_=t,this.name_=r,this.defaultAnnotation_=i,this.keysAtom_=new se(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Ui(this.defaultAnnotation_)||n(`defaultAnnotation must be valid annotation`),this.appliedAnnotations_={}}getObservablePropValue_(e){return(this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e)).get()}materializeLazyComputed_(e){let t=this.lazyComputedKeys_?.get(e);if(!t)return;this.lazyComputedKeys_.delete(e),this.lazyComputedKeys_.size===0&&(this.lazyComputedKeys_=void 0);let n=t();return this.values_.set(e,n),n}materializeLazyObservable_(e){let t=this.lazyObservableKeys_?.get(e);if(!t)return;this.lazyObservableKeys_.delete(e),this.lazyObservableKeys_.size===0&&(this.lazyObservableKeys_=void 0);let n=t();return this.values_.set(e,n),n}setObservablePropValue_(e,t){let n=this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e);if(n instanceof At)return n.set(t),!0;if(Kr(this)){let n=P(this,{type:ni,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==j.UNCHANGED){let r=Jr(this),i=bn(),a=r||i?{type:ni,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&Sn(a),n.setNewValue_(t),r&&Xr(this,a),i&&wn()}return!0}get_(e){return j.trackingDerivation&&!ie(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return ie(this.target_,e)?this.values_.has(e)?this.setObservablePropValue_(e,t):n?Reflect.set(this.target_,e,t):(this.target_[e]=t,!0):this.extend_(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,n)}has_(e){if(!j.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new Ot(e in this.target_,ge,`${this.name_}.${C(e)}?`,!1),this.pendingKeys_.set(e,t)),t.get()}extend_(e,t,n,r=!1){if(n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);ji(this,n,e);let i=n.extend_(this,e,t,r);return i&&Ai(this,n,e),i}defineProperty_(e,t,n=!1){It(this.keysAtom_);try{on();let i=this.delete_(e);if(!i)return i;if(Kr(this)){let n=P(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:i}=n;t.value!==i&&(t=r({},t,{value:i}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else a(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{sn()}return!0}defineObservableProperty_(e,t,n,r=!1){It(this.keysAtom_);try{on();let i=this.delete_(e);if(!i)return i;if(Kr(this)){let n=P(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=Oi(e),s={configurable:j.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,s))return!1}else a(this.target_,e,s);let c=new Ot(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{sn()}return!0}defineComputedProperty_(e,t,n=!1){It(this.keysAtom_);try{on();let r=this.delete_(e);if(!r)return r;if(Kr(this)&&!P(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:void 0}))return null;t.name||=`${this.name_}.${e.toString()}`,t.context=this.proxy_||this.target_;let i=Oi(e),o={configurable:j.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,o))return!1}else a(this.target_,e,o);this.values_.set(e,new At(t)),this.notifyPropertyAddition_(e,void 0)}finally{sn()}return!0}delete_(e,t=!1){if(It(this.keysAtom_),!ie(this.target_,e))return!0;if(Kr(this)&&!P(this,{object:this.proxy_||this.target_,name:e,type:wi}))return null;try{var n;on();let r=Jr(this),a=bn(),o=this.values_.get(e),s;if(!o&&(r||a)&&(s=i(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(delete this.appliedAnnotations_[e],o&&(this.values_.delete(e),o instanceof Ot&&(s=o.value_),dn(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:wi,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&Sn(t),r&&Xr(this,t),a&&wn()}}finally{sn()}return!0}notifyPropertyAddition_(e,t){var n;let r=Jr(this),i=bn();if(r||i){let n=r||i?{type:`add`,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;i&&Sn(n),r&&Xr(this,n),i&&wn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),ne(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function Ei(e,t){if(t&&ki(e)&&n(`Options can't be provided for already observable objects.`),ie(e,E))return Ni(e)instanceof Ti||n(`Cannot convert '${Pi(e)}' into observable object:\nThe target is already observable of different type.\nExtending builtins is not supported.`),e;Object.isExtensible(e)||n(`Cannot make the designated object observable; it is not extensible`);let r=t?.name??`${g(e)?`ObservableObject`:e.constructor.name}@${u()}`;return v(e,E,new Ti(e,new Map,String(r),at(t))),e}let Di=b(`ObservableObjectAdministration`,Ti);function Oi(e){return Ci[e]||(Ci[e]={get(){return this[E].getObservablePropValue_(e)},set(t){return this[E].setObservablePropValue_(e,t)}})}function ki(e){return h(e)?Di(e[E]):!1}function Ai(e,t,n){e.appliedAnnotations_[n]=t}function ji(e,t,r){if(Ui(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!be(t)&&ie(e.appliedAnnotations_,r)){let i=`${e.name_}.${r.toString()}`,a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '${o}' to '${i}':\nThe field is already annotated with '${a}'.\nRe-annotating fields is not allowed.\nUse 'override' annotation for methods overridden by subclass.`)}}function Mi(e,t){if(typeof e==`object`&&e){if(fi(e))return t!==void 0&&n(23),e[E].atom_;if(xi(e))return e.atom_;if(gi(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,Pi(e)),r}if(ki(e)){if(!t)return n(26);let r=e[E],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,Pi(e)),i}if(ce(e)||jt(e)||yn(e))return e}else if(p(e)&&yn(e[E]))return e[E];n(28)}function Ni(e,t){if(e||n(29),t!==void 0)return Ni(Mi(e,t));if(ce(e)||jt(e)||yn(e)||gi(e)||xi(e))return e;if(e[E])return e[E];n(24,e)}function Pi(e,t){let n;if(t!==void 0)n=Mi(e,t);else if(zn(e))return e.name;else n=ki(e)||gi(e)||xi(e)?Ni(e):Mi(e);return n.name_}function Fi(e){let t=Ut(),n=Et(!0);on();try{return e()}finally{sn(),Dt(n),Wt(t)}}let Ii=o.toString;function Li(e,t,n=-1){return Ri(e,t,n)}function Ri(e,t,n,r,i){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;let a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;let o=Ii.call(e);if(o!==Ii.call(t))return!1;switch(o){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++;break}e=zi(e),t=zi(t);let s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,r=t.constructor;if(n!==r&&!(p(n)&&n instanceof n&&p(r)&&r instanceof r)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];let c=r.length;for(;c--;)if(r[c]===e)return i[c]===t;if(r.push(e),i.push(t),s){if(c=e.length,c!==t.length)return!1;for(;c--;)if(!Ri(e[c],t[c],n-1,r,i))return!1}else{let a=Object.keys(e),o=a.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=a[s];if(!(ie(t,o)&&Ri(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function zi(e){return fi(e)?e.slice():ee(e)||gi(e)||S(e)||xi(e)?Array.from(e.entries()):e}let Bi=globalThis.Iterator?.prototype||{};function Vi(e){return e[Symbol.iterator]=Hi,r(Object.create(Bi),e)}function Hi(){return this}function Ui(e){return e instanceof Object&&typeof e.annotationType_==`string`&&p(e.make_)&&p(e.extend_)}{let e=globalThis;[`Symbol`,`Map`,`Set`,`Proxy`].forEach(t=>{e[t]===void 0&&n(`MobX requires global '${t}' to be available or polyfilled`)})}typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Tn,extras:{getDebugName:Pi},$mobx:E}),e.$mobx=E,e.FlowCancellationError=rr,e.ObservableMap=hi,e.ObservableSet=bi,e.Reaction=mn,e._allowStateChanges=Tt,e._allowStateChangesInsideComputed=Rn,e._allowStateReadsEnd=Gt,e._allowStateReadsStart=A,e._autoAction=Fn,e._autoActionBound=Ln,e._endAction=wt,e._getAdministration=Ni,e._getGlobalState=Qt,e._interceptReads=pr,e._isComputingDerivation=Ft,e._resetGlobalState=$t,e._startAction=Ct,e.action=Pn,e.actionBound=In,e.autorun=Bn,e.compareDefault=pe,e.compareIdentity=ue,e.compareShallow=fe,e.compareStructural=de,e.computed=k,e.computedStruct=gt,e.configure=Yn,e.createAtom=le,e.defineProperty=Ar,e.entries=Tr,e.extendObservable=Xn,e.flow=cr,e.flowBound=lr,e.flowResult=dr,e.get=kr,e.getAtom=Mi,e.getDebugName=Pi,e.getDependencyTree=Zn,e.getObserverTree=$n,e.has=Or,e.intercept=mr,e.isAction=zn,e.isBoxedObservable=kt,e.isComputed=vr,e.isComputedProp=yr,e.isFlow=fr,e.isFlowCancellationError=ir,e.isObservable=xr,e.isObservableArray=fi,e.isObservableMap=gi,e.isObservableObject=ki,e.isObservableProp=Sr,e.isObservableSet=xi,e.keys=Cr,e.makeAutoObservable=$r,e.makeObservable=Zr,e.observable=O,e.observableDeep=dt,e.observableRef=lt,e.observableShallow=ut,e.observableStruct=ft,e.observe=Mr,e.onBecomeObserved=Gn,e.onBecomeUnobserved=Kn,e.onReactionError=hn,e.override=ye,e.ownKeys=jr,e.reaction=Un,e.remove=Dr,e.runInAction=Rn,e.set=Er,e.spy=Tn,e.toJS=Rr,e.transaction=zr,e.untracked=Ht,e.values=wr,e.when=Br})),xb=Te(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=yb():t.exports=bb()}))();function Sb(e){if(Array.isArray(e))return Object.freeze(e.map(Sb));if(typeof e==`object`&&e){let t=Object.create(null),n=Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t));for(let[e,r]of n)t[e]=Sb(r);return Object.freeze(t)}return e}function Cb(e){let t=typeof e;if(t===`string`||t===`number`||t===`boolean`)return t;throw TypeError(`Variable values must be string|number|boolean (got ${t})`)}function wb(e){return typeof e==`string`?e:String(e)}function Tb(e){if(typeof e==`number`)return e;if(typeof e==`boolean`)return+!!e;let t=e.trim();if(t===``)throw TypeError(`Cannot cast empty string to number`);let n=Number(t);if(!Number.isFinite(n))throw TypeError(`Cannot cast ${JSON.stringify(e)} to number`);return n}function Eb(e){if(typeof e==`boolean`)return e;if(typeof e==`number`){if(e===0||e===1)return e===1;throw TypeError(`Cannot cast number ${e} to bool (only 0 and 1 are accepted)`)}if(e===`true`)return!0;if(e===`false`)return!1;throw TypeError(`Cannot cast ${JSON.stringify(e)} to bool (expected "true" or "false")`)}var Db=class extends Error{constructor(e,t){super(t),this.variable=e}};function Ob(e){return e instanceof Db||e instanceof Error&&e.cause!==void 0&&Ob(e.cause)}var kb=class extends Error{name=`TemplateError`;kind=`EvalError`;pos;source;constructor(e,t,n={}){super(e,{cause:n.cause}),this.pos=t,this.source=n.source}get sourceSnippet(){return this.source?Rb(this.source,this.pos):``}toString(){let e=`${this.name}: ${this.message}\n at line ${this.pos.line}, column ${this.pos.column}`,t=this.sourceSnippet;return t?`${e}\n\n${t}`:e}},Ab=class extends kb{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},jb=class extends kb{name=`EvalError`;kind=`EvalError`},Mb=class extends jb{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=zb(e,n.available??[]),i=r.length===0?``:` (did you mean: ${r.join(`, `)}?)`;super(`function ${JSON.stringify(e)} is not registered${i}`,t,n),this.funcName=e,this.suggestions=r}},Nb=class extends jb{name=`ArgCountError`;kind=`ArgCountError`;funcName;accepted;got;constructor(e,t,n,r,i={}){let a=t.minimum===t.maximum?`${t.minimum}`:`at least ${t.minimum}`;super(`wrong number of args for ${e}: want ${a} got ${n}`,r,i),this.funcName=e,this.accepted=t,this.got=n}},Pb=class extends jb{name=`TypeMismatchError`;kind=`TypeMismatchError`;funcName;argIndex;expected;receivedSummary;constructor(e,t,n,r,i,a={}){super(`function ${JSON.stringify(e)} arg ${t}: expected ${n}, but a ${r} flowed in. Pass it through \`unstyled\` (or your engine's flatten function) to convert.`,i,a),this.funcName=e,this.argIndex=t,this.expected=n,this.receivedSummary=r}},Fb=class extends Pb{constructor(e,t,n,r,i={}){super(e,t,`integer`,String(n),r,i),this.message=Number.isInteger(Number(n))?`integer out of range: ${String(n)}`:`expected integer; found ${String(n)}`}},Ib=class extends jb{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},Lb=class extends jb{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function Rb(e,t){let n=e.split(`
61
61
  `),r=t.line-1,i=[];if(r-1>=0&&r-1<n.length&&i.push({num:r,text:n[r-1]??``}),r>=0&&r<n.length&&i.push({num:r+1,text:n[r]??``}),r+1<n.length&&i.push({num:r+2,text:n[r+1]??``}),i.length===0)return``;let a=String(i[i.length-1]?.num??1).length,o=[];for(let e of i)if(o.push(` ${String(e.num).padStart(a,` `)} | ${e.text}`),e.num===t.line){let e=` ${` `.repeat(a)} | `,n=` `.repeat(Math.max(0,t.column-1));o.push(`${e}${n}^`)}return o.join(`
62
62
  `)}function zb(e,t){if(t.length===0)return[];let n=t.map(t=>({name:t,dist:Bb(e,t)})).sort((e,t)=>e.dist-t.dist),r=Math.max(2,Math.floor(e.length/2));return n.filter(e=>e.dist<=r).slice(0,3).map(e=>e.name)}function Bb(e,t){if(e===t)return 0;let n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;let i=Array(r+1),a=Array(r+1);for(let e=0;e<=r;e++)i[e]=e;for(let o=1;o<=n;o++){a[0]=o;for(let n=1;n<=r;n++){let r=e[o-1]===t[n-1]?0:1;a[n]=Math.min((a[n-1]??0)+1,(i[n]??0)+1,(i[n-1]??0)+r)}for(let e=0;e<=r;e++)i[e]=a[e]??0}return i[r]??0}function Vb(e){throw Error(`unhandled node kind: ${JSON.stringify(e)}`)}const Hb=new Map([[`if`,`If`],[`else`,`Else`],[`end`,`End`],[`range`,`Range`],[`with`,`With`],[`break`,`Break`],[`continue`,`Continue`],[`define`,`Define`],[`template`,`Template`],[`block`,`Block`],[`true`,`Bool`],[`false`,`Bool`],[`nil`,`Nil`]]),Ub={left:`{{`,right:`}}`};var Wb=class{src;leftDelim;rightDelim;offset=0;line=1;column=1;mode=`text`;pending;constructor(e,t=Ub){this.src=e,this.leftDelim=t.left,this.rightDelim=t.right}pos(){return{line:this.line,column:this.column,offset:this.offset}}err(e,t,n={}){return new Ab(e,t,{...n,source:this.src})}next(){if(this.pending){let e=this.pending;return this.pending=void 0,e}return this.read()}peek(){return this.pending||=this.read(),this.pending}read(){switch(this.mode){case`text`:return this.readText();case`action`:return this.readAction();case`done`:return this.makeToken(`EOF`,``,this.pos())}}readText(){if(this.offset>=this.src.length)return this.mode=`done`,this.makeToken(`EOF`,``,this.pos());let e=this.pos(),t=this.offset;for(;t<this.src.length&&!this.src.startsWith(this.leftDelim,t);)t+=1;let n=t<this.src.length&&this.src[t+this.leftDelim.length]===`-`,r=t;if(n)for(;r>this.offset&&Gb(this.src[r-1]??``);)--r;if(r>this.offset){let t=this.src.slice(this.offset,r);return this.advanceTo(r),this.makeToken(`Text`,t,e)}return this.advanceTo(t),this.emitLeftDelim(n)}emitLeftDelim(e){let t=this.pos();if(this.advanceBy(this.leftDelim.length),e)for(this.advanceBy(1);Gb(this.src[this.offset]??``);)this.advanceBy(1);return this.mode=`action`,this.src.startsWith(`/*`,this.offset)?this.readComment(t,e):this.makeToken(`LeftDelim`,e?`${this.leftDelim}-`:this.leftDelim,t,e?{trimLeft:!0}:{})}readComment(e,t){this.advanceBy(2);let n=this.offset,r=this.src.indexOf(`*/`,this.offset);if(r===-1)throw this.err(`unclosed comment`,e,{expected:`*/${this.rightDelim}`,found:`end of input`});this.advanceTo(r);let i=this.src.slice(n,r).trim();for(this.advanceBy(2);Gb(this.src[this.offset]??``);)this.advanceBy(1);let a=!1;if(this.src[this.offset]===`-`&&(a=!0,this.advanceBy(1)),!this.src.startsWith(this.rightDelim,this.offset))throw this.err(`expected \`${this.rightDelim}\` to close comment`,this.pos(),{expected:this.rightDelim,found:this.src[this.offset]??`end of input`});if(this.advanceBy(this.rightDelim.length),a)for(;Gb(this.src[this.offset]??``);)this.advanceBy(1);return this.mode=`text`,this.makeToken(`Comment`,i,e,{...t?{trimLeft:!0}:{},...a?{trimRight:!0}:{}})}readAction(){if(this.skipActionSpaces(),this.src.startsWith(`-${this.rightDelim}`,this.offset)){let e=this.pos();for(this.advanceBy(1+this.rightDelim.length),this.mode=`text`;Gb(this.src[this.offset]??``);)this.advanceBy(1);return this.makeToken(`RightDelim`,`-${this.rightDelim}`,e,{trimRight:!0})}if(this.src.startsWith(this.rightDelim,this.offset)){let e=this.pos();return this.advanceBy(this.rightDelim.length),this.mode=`text`,this.makeToken(`RightDelim`,this.rightDelim,e)}if(this.offset>=this.src.length)throw this.err(`unclosed action`,this.pos(),{expected:this.rightDelim,found:`end of input`});let e=this.src[this.offset],t=this.pos();switch(e){case`(`:return this.advanceBy(1),this.makeToken(`LeftParen`,`(`,t);case`)`:return this.advanceBy(1),this.makeToken(`RightParen`,`)`,t);case`|`:return this.advanceBy(1),this.makeToken(`Pipe`,`|`,t);case`,`:return this.advanceBy(1),this.makeToken(`Comma`,`,`,t);case`:`:if(this.src[this.offset+1]===`=`)return this.advanceBy(2),this.makeToken(`Declare`,`:=`,t);throw this.err("expected `:=`",t,{expected:`:=`,found:`:`});case`=`:return this.advanceBy(1),this.makeToken(`Assign`,`=`,t);case`"`:return this.readQuotedString(t);case"`":return this.readRawString(t);case`'`:return this.readChar(t)}if(e===`$`)return this.readVariable(t);if(e!==void 0&&(qb(e)||Kb(e)&&qb(this.src[this.offset+1]??``)||e===`.`&&qb(this.src[this.offset+1]??``)))return this.readNumber(t);if(e===`.`)return this.readDotOrField(t);if(e!==void 0&&Qb(e))return this.readIdentifier(t);throw this.err(`unexpected character ${JSON.stringify(e)}`,t,{found:e??`end of input`})}readQuotedString(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){let n=this.src[this.offset];if(n===`\\`){this.advanceBy(1),this.offset<this.src.length&&this.advanceBy(1);continue}if(n===`
@@ -69,11 +69,11 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
69
69
  `).map(e=>n+e).join(`
70
70
  `)}function GT(e){let t=new TextEncoder;return e.split(/\s+/).filter(e=>e.length>0).map(e=>String.fromCharCode(...t.encode(e).slice(0,1))).join(``)}function KT(e,t){let n=[];for(let e of t){if(typeof e==`object`&&e)throw Pw(`join`,2,`list of strings/primitives`,`list element of type ${qT(e)}`);n.push(String(e))}return n.join(e)}function qT(e){return Array.isArray(e)?`array`:e instanceof Map?`Map`:e instanceof Set?`Set`:`object`}function JT(e){return LT(e,`-`)}function YT(e){return e.toLowerCase()}function XT(e,t){return`\n${WT(e,t)}`}function ZT(e){return e.replace(/\s+/g,``)}function QT(e,t,n){return n===1?e:t}function $T(...e){return e.map(e=>`"${e}"`).join(` `)}function eE(e){return e.replace(/[\\.+*?()|[\]{}^$]/g,`\\$&`)}function tE(e,t){return t.repeat(Math.max(0,e))}function nE(e,t,n){return ST(e,n).join(t)}function rE(e){return LT(e,`_`)}function iE(e,t){let n=ST(e,t),r={};for(let e=0;e<n.length;e++)r[`_${e}`]=n[e];return r}function aE(e,t){return ST(e,t)}function oE(e,t,n){let r=sE(n,e,t),i={};for(let e=0;e<r.length;e++)i[`_${e}`]=r[e]??``;return i}function sE(e,t,n){if(n===0)return[];let r=ST(t,e);if(n<0||r.length<=n)return r;let i=r.slice(0,n-1),a=r.slice(n-1).join(t);return[...i,a]}function cE(...e){return e.map(e=>`'${e}'`).join(` `)}function lE(e,t,n){let r=xT(n),i=t<0||t>r.length?r.length:t,a=Math.min(Math.max(0,e),i);return r.slice(a,i).join(``)}function uE(e){let t=``;for(let n of e)dE(n)?t+=n.toLowerCase():fE(n)?t+=n.toUpperCase():t+=n;return t}function dE(e){return e!==e.toLowerCase()&&e===e.toUpperCase()}function fE(e){return e!==e.toUpperCase()&&e===e.toLowerCase()}function pE(e){return e.replace(/\b([a-zA-Z])/g,e=>e.toUpperCase())}function mE(e){return e.trim()}function hE(e,t){if(e.length===0)return t;let n=new Set(xT(e)),r=xT(t),i=0;for(;i<r.length&&n.has(r[i]);)i+=1;let a=r.length;for(;a>i&&n.has(r[a-1]);)--a;return r.slice(i,a).join(``)}function gE(e,t){return t.startsWith(e)?t.slice(e.length):t}function _E(e,t){return t.endsWith(e)?t.slice(0,t.length-e.length):t}function vE(e,t){let n=xT(t);if(e<0){let r=-e;return r>=n.length?t:n.slice(n.length-r).join(``)}return e>=n.length?t:n.slice(0,e).join(``)}function yE(e){return e.replace(/\b([A-Z])/g,e=>e.toLowerCase())}function bE(e){return e.toUpperCase()}function xE(e,t){return SE(e,`
71
71
  `,t)}function SE(e,t,n){if(e<=0)return n;let r=[];for(let t of n.split(`
72
- `)){let n=``;for(let i of t.split(/\s+/))i.length!==0&&(n.length===0?n=i:n.length+1+i.length<=e?n+=` ${i}`:(r.push(n),n=i));n.length>0&&r.push(n)}return r.join(t)}function CE(e,t,n){return SE(e,t,n)}function wE(){return{abbrev:{fn:(e,t)=>CT(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},abbrevboth:{fn:(e,t,n)=>wT(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},camelcase:{fn:e=>zT(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},cat:{fn:(...e)=>BT(...e),argTypes:[`string`],arity:{kind:`variadic`}},contains:{fn:(e,t)=>VT(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasPrefix:{fn:(e,t)=>HT(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasSuffix:{fn:(e,t)=>UT(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},indent:{fn:(e,t)=>WT(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},initials:{fn:e=>GT(e),argTypes:[`string`],arity:{kind:`exact`}},join:{fn:(e,t)=>KT(e,t),argTypes:[`string`,`list`],arity:{kind:`exact`}},kebabcase:{fn:e=>JT(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},lower:{fn:e=>YT(e),argTypes:[`string`],arity:{kind:`exact`}},nindent:{fn:(e,t)=>XT(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},nospace:{fn:e=>ZT(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},plural:{fn:(e,t,n)=>QT(e,t,n),argTypes:[`string`,`string`,`int`],arity:{kind:`exact`},returnType:`string`},quote:{fn:(...e)=>$T(...e),argTypes:[`string`],arity:{kind:`variadic`}},regexQuoteMeta:{fn:e=>eE(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},repeat:{fn:(e,t)=>tE(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},replace:{fn:(e,t,n)=>nE(e,t,n),argTypes:[`string`,`string`,`string`],arity:{kind:`exact`}},snakecase:{fn:e=>rE(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},split:{fn:(e,t)=>iE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitList:{fn:(e,t)=>aE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitn:{fn:(e,t,n)=>oE(e,t,n),argTypes:[`string`,`int`,`string`],arity:{kind:`exact`},returnType:`dict`},squote:{fn:(...e)=>cE(...e),argTypes:[`string`],arity:{kind:`variadic`}},substr:{fn:(e,t,n)=>lE(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},swapcase:{fn:e=>uE(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},title:{fn:e=>pE(e),argTypes:[`string`],arity:{kind:`exact`}},trim:{fn:e=>mE(e),argTypes:[`string`],arity:{kind:`exact`}},trimAll:{fn:(e,t)=>hE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimPrefix:{fn:(e,t)=>gE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimSuffix:{fn:(e,t)=>_E(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trunc:{fn:(e,t)=>vE(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},untitle:{fn:e=>yE(e),argTypes:[`string`],arity:{kind:`exact`}},upper:{fn:e=>bE(e),argTypes:[`string`],arity:{kind:`exact`}},wrap:{fn:(e,t)=>xE(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},wrapWith:{fn:(e,t,n)=>CE(e,t,n),argTypes:[`int`,`string`,`string`],arity:{kind:`exact`}}}}function TE(e,t){let n=EE(e),r=n.copy();return r.style=Su(n.style,t),r}function EE(e){if(!(e instanceof G))throw TypeError(`template function expected a RichText fragment, got ${typeof e==`object`?Object.prototype.toString.call(e):typeof e}`);return e}function DE(e){return{fn:(t=>TE(t,e)),argTypes:[`liftable`],arity:{kind:`exact`},returnType:`T`}}function OE(e){return{fn:((t,n)=>TE(n,new H({[e]:V.parse(t)}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`}}function kE(e,t){return new H({[e]:t})}function AE(){let e={};for(let t of gu)e[t]=DE(kE(t,!0)),e[`not_${t}`]=DE(kE(t,!1));for(let[t,n]of Object.entries(vu))e[t]=DE(kE(n,!0));return e}const jE={fn:((e,t)=>TE(t,H.parse(e))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`},ME={fn:((e,t)=>TE(t,new H({link:e}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`};function NE(){return{fg:OE(`color`),bg:OE(`bgcolor`),...AE(),link:ME,style:jE}}function PE(e,t){let n;try{n=nc(e.trim())}catch(n){throw n instanceof Rs?TypeError(`${t} expected a color (#RRGGBB or #RRGGBBAA), got ${JSON.stringify(e)} — to use a palette name here, wrap it: ${t} (color ${JSON.stringify(e)}) …`,{cause:n}):n}return FE(n,t,JSON.stringify(e))}function FE(e,t,n){if(e.alpha===0)throw RangeError(`${t} got ${n}, which is fully transparent: it draws no colour of its own, so there is nothing to compute with — use the colour of the surface it sits on, e.g. (color "background")`);return e}function IE(e,t){return{fn:t,argTypes:e,arity:{kind:`exact`},returnType:`string`}}function LE(e,t,n,r){let i=r===void 0||e>=r.min&&e<=r.max;if(!Number.isFinite(e)||!i){let i=r===void 0?`a finite number`:`within ${r.min}..${r.max} (${r.note})`;throw RangeError(`${t}'s ${n} must be ${i}, got ${e}`)}return e}const RE=IE([`string`,`int`],((e,t)=>Bc(PE(e,`darken`),t).hex)),zE=IE([`string`,`int`],((e,t)=>Bc(PE(e,`lighten`),-t).hex)),BE={min:0,max:100,note:`0 = from, 100 = toward`},VE=IE([`string`,`string`,`float`],((e,t,n)=>rc(PE(e,`mix`),PE(t,`mix`),LE(n,`mix`,`percentage`,BE)/100).hex)),HE={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},UE=IE([`string`],(e=>Hc(PE(e,`contrastOn`)).hex)),WE={depth:B.TRUECOLOR},GE=e=>IE([`string`,`string`,`float`],((t,n,r)=>{let{depth:i,terminal:a}=e();return Uc(PE(t,`readableOn`),PE(n,`readableOn`),LE(r,`readableOn`,`ratio`,HE),i,void 0,a).hex})),KE={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function qE(){let e={};for(let[t,n]of Object.entries(KE)){let r=t;e[n]=IE([`string`,`float`],((e,t)=>{let i={...xc,[r]:LE(t,n,`amount`)};return Mc.fromRgba(PE(e,n)).applyKey(i).toRgba().hex}))}return e}function JE(e=()=>WE){return{darken:RE,lighten:zE,mix:VE,contrastOn:UE,readableOn:GE(e),...qE()}}function YE(e,t){if(e.length%2!=0)throw RangeError(`ramp's last stop (position ${String(e[e.length-1])}) has no color — stops are <position> <color> pairs`);let n=[];for(let r=0;r<e.length;r+=2)n.push({at:e[r],color:FE(Pc(t,e[r+1]),`ramp`,JSON.stringify(e[r+1]))});return n}function XE(e){return{color:{fn:(t=>Pc(e(),t).hex),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},ramp:{fn:((t,n,...r)=>new su(Jl(n),YE(r,e())).at(t).hex),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:4},returnType:`string`}}}function ZE(e,t,n){if(t.length%2!=0)throw RangeError(`last hold (${String(t[t.length-1])} s) has no ${e} — the arguments are <seconds> <${e}> pairs`);let r=[];for(let e=0;e<t.length;e+=2){let i=t[e];if(!Number.isFinite(i)||i<=0)throw RangeError(`hold ${e/2} must be a positive number of seconds, got ${i}`);r.push({seconds:i,value:n(t[e+1])})}return r}function QE(e){return{frames:{fn:((...t)=>um(new lm(ZE(`frame`,t,EE).map(({seconds:e,value:t})=>({seconds:e,text:t}))),e())),argTypes:[`float`,`liftable`],arity:{kind:`alternating`,minimum:2},returnType:`T`},stepped:{fn:((...t)=>{let n=ZE(`color`,t,e=>PE(e,`stepped`));return n[ru(n.map(e=>e.seconds)).at(e())].value.hex}),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:2},returnType:`string`}}}function $E(e){return{...NE(),...JE(e)}}new H({color:`red`,dim:!0});const eD=/^(?:(?:global|apac|au|eu|us|us-east-\d|us-west-\d|eu-west-\d|eu-central-\d)\.)?(?:anthropic\.|azure_ai\/|bedrock\/|vertex_ai\/)?claude-(?:(?<family>opus|sonnet|haiku)-(?<newMajor>\d+)(?:-(?<newMinor>\d))?|(?<oldMajor>\d+)(?:-(?<oldMinor>\d))?-(?<oldFamily>opus|sonnet|haiku))(?:[-@]\d{8})?(?:-v\d+:\d+)?(?:-latest)?$/i,tD=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function nD(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(eD);if(n?.groups){let{family:e,newMajor:t,newMinor:r,oldMajor:i,oldMinor:a,oldFamily:o}=n.groups,s=e||o,c=t||i,l=r||a;if(s&&c)return`${s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()} ${l?`${c}.${l}`:c}`}let r=t.match(tD);if(r?.groups){let e=r.groups.family,t=r.groups.major,n=r.groups.minor;return`${e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()} ${n?`${t}.${n}`:t}`}return t||e}function rD(e){let t=e.match(tD);if(!t?.groups)return e;let n=t.groups.family,r=t.groups.major,i=t.groups.minor;return`${n.charAt(0).toUpperCase()}${i?`${r}.${i}`:r}`}function iD(e){let t=e.split(`/`),n=t.length-1;return t.map((e,t)=>{if(t===n)return e;let r=e.match(/^\.*./);return r?r[0]:e}).join(`/`)}function aD(e){return e.toLocaleString()}function oD(e){if(e.length===0)throw Error(`a cascade needs at least one stop, e.g. "0:calm"`);let t=[];for(let[n,r]of e.entries()){let e=r.indexOf(`:`),i=e<0?NaN:Number(r.slice(0,e));if(!Number.isFinite(i))throw Error(`cascade stop ${n} ("${r}") must be "<position>:<result>", e.g. "80:hot" — the position must be a number`);let a=t[n-1];if(a!==void 0&&i<a.at)throw Error(`cascade stops must be in ascending position order; stop ${n} at ${i} follows stop ${n-1} at ${a.at}`);t.push({at:i,text:r.slice(e+1)})}return t}function sD(e,t){if(!Number.isFinite(e))throw Error(`a cascade needs a finite value, got ${e}`);let n=-1;for(;n+1<t.length&&t[n+1].at<=e;)n++;return(n<0?t[0]:t[n]).text}const cD=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],lD=cD.length;function uD(e,t){let n=t===void 0?e:t<=0?[]:e.slice(-t);if(n.length===0)return``;let r=n[0],i=n[0];for(let e of n)e<r&&(r=e),e>i&&(i=e);let a=i-r,o=``;for(let e of n){let t=a===0?0:Math.round((e-r)/a*(lD-1));o+=cD[t]}return o}function dD(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(e===``)continue;let r=Number(e);if(!Number.isFinite(r))throw TypeError(`sparkline: non-numeric series element ${JSON.stringify(n)}`);t.push(r)}return t}function fD(e,t,n){if(n.length!==0)throw Error(`${e}: takes at most ${t.length} optional argument${t.length===1?``:`s`} (${t.join(`, `)}), got ${t.length+n.length}`)}const pD=jh(),mD=[...Qh];function hD(){return{basename:{fn:e=>c(e),argTypes:[`string`],arity:{kind:`exact`}},dirname:{fn:e=>l(e),argTypes:[`string`],arity:{kind:`exact`}},abbreviatePath:{fn:e=>iD(e),argTypes:[`string`],arity:{kind:`exact`}},int:{fn:e=>Math.trunc(Tb(e)),argTypes:[`value`],arity:{kind:`exact`}},string:{fn:e=>wb(e),argTypes:[`value`],arity:{kind:`exact`}},bool:{fn:e=>Eb(e),argTypes:[`value`],arity:{kind:`exact`}},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`],arity:{kind:`exact`}},themes:{fn:()=>pD,argTypes:[],arity:{kind:`exact`}},endcaps:{fn:()=>mD,argTypes:[],arity:{kind:`exact`}},sparkline:{fn:(e,t,...n)=>(fD(`sparkline`,[`width`],n),uD(dD(e),t)),argTypes:[`string`,`int`],arity:{kind:`variadic`}},cascade:{fn:(e,...t)=>sD(e,oD(t)),argTypes:[`float`,`string`],arity:{kind:`variadic`}}}}function gD(e){return{minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e().getTime())/6e4),argTypes:[`int`],arity:{kind:`exact`}},formatInteger:{fn:e=>aD(e),argTypes:[`int`],arity:{kind:`exact`}},round:{fn:e=>Math.round(e),argTypes:[`float`],arity:{kind:`exact`}},formatModelName:{fn:e=>nD(e),argTypes:[`string`],arity:{kind:`exact`}},shortenModelName:{fn:e=>rD(e),argTypes:[`string`],arity:{kind:`exact`}}}}function _D(e){let{clock:t,drawnAt:n,extraFuncs:r}=e;return xS({fromString:e=>new G(e),toString:e=>e.plain,isT:e=>e instanceof G,clock:t,missingKey:`error`,funcs:{...uw(),...wE(),...Qw(),...bT(),...nw(t),...KS(),...Ew(),...ww(),...$E(n&&(()=>({depth:n()}))),...QE(()=>t().getTime()/1e3),...hD(),...gD(t),...r??{}}})}function vD(e){return yD(e,new Set(e.names()),``)}function yD(e,t,n){return new Proxy(Object.create(null),{has(e,r){if(typeof r!=`string`)return!1;let i=n?`${n}.${r}`:r;if(t.has(i))return!0;let a=`${i}.`;for(let e of t)if(e.startsWith(a))return!0;return!1},get(r,i){if(typeof i!=`string`)return;let a=n?`${n}.${i}`:i;if(t.has(a))return e.getKind(a)===`document`?xD(a,e.readDocument(a)):e.read(a);let o=`${a}.`;for(let n of t)if(n.startsWith(o))return yD(e,t,a)}})}function bD(e,t){return new Proxy(e,{has:(e,t)=>t===`settings`||Reflect.has(e,t),get:(e,n)=>n===`settings`?t:Reflect.get(e,n)})}function xD(e,t){switch(t.kind){case`ok`:return t.value;case`absent`:throw new Db(e,`variable "${e}" has no value yet: its source has not completed a scan`);case`failed`:throw Error(`variable "${e}": ${t.reason}`)}}function SD(e){return p.existsSync(s.join(e,`.git`))}function CD(e){let t=s.resolve(e);for(;;){if(SD(t))return t;let e=s.dirname(t);if(e===t)return;t=e}}function wD(e){let t=CD(e);return t===void 0?{root:s.resolve(e),git:!1}:{root:t,git:!0}}function TD(e,t){return e.kind===`absent`?F(`none`):e.kind===`failed`?e:t.kind===`failed`?t:F(t.kind===`ok`?`tracked`:`gone`)}function ED(e,t){return e.kind!==`ok`||e.value.state===`open`?e:t.kind===`failed`?L(`HEAD: ${t.reason}`):t.kind===`ok`&&t.value===e.value.head?e:{kind:`earlier`,value:e.value}}const DD={OPEN:`open`,MERGED:`merged`,CLOSED:`closed`},OD={opened:`open`,locked:`open`,merged:`merged`,closed:`closed`};function kD(e,t,n){return Object.hasOwn(t,n)?F(t[n]):L(`${e}: unknown state ${JSON.stringify(n)}`)}function AD(e,t,n){return t.ok?F(t.stdout):t.reason===`non-zero`&&n===`absent`||t.reason===`non-zero`&&n===t.exitCode?I:L(jD(e,t))}function jD(e,t){return`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??MD(t.stderr)].filter(Boolean).join(`, `)}`}function MD(e){return e.trim().split(`
72
+ `)){let n=``;for(let i of t.split(/\s+/))i.length!==0&&(n.length===0?n=i:n.length+1+i.length<=e?n+=` ${i}`:(r.push(n),n=i));n.length>0&&r.push(n)}return r.join(t)}function CE(e,t,n){return SE(e,t,n)}function wE(){return{abbrev:{fn:(e,t)=>CT(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},abbrevboth:{fn:(e,t,n)=>wT(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},camelcase:{fn:e=>zT(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},cat:{fn:(...e)=>BT(...e),argTypes:[`string`],arity:{kind:`variadic`}},contains:{fn:(e,t)=>VT(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasPrefix:{fn:(e,t)=>HT(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasSuffix:{fn:(e,t)=>UT(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},indent:{fn:(e,t)=>WT(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},initials:{fn:e=>GT(e),argTypes:[`string`],arity:{kind:`exact`}},join:{fn:(e,t)=>KT(e,t),argTypes:[`string`,`list`],arity:{kind:`exact`}},kebabcase:{fn:e=>JT(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},lower:{fn:e=>YT(e),argTypes:[`string`],arity:{kind:`exact`}},nindent:{fn:(e,t)=>XT(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},nospace:{fn:e=>ZT(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},plural:{fn:(e,t,n)=>QT(e,t,n),argTypes:[`string`,`string`,`int`],arity:{kind:`exact`},returnType:`string`},quote:{fn:(...e)=>$T(...e),argTypes:[`string`],arity:{kind:`variadic`}},regexQuoteMeta:{fn:e=>eE(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},repeat:{fn:(e,t)=>tE(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},replace:{fn:(e,t,n)=>nE(e,t,n),argTypes:[`string`,`string`,`string`],arity:{kind:`exact`}},snakecase:{fn:e=>rE(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},split:{fn:(e,t)=>iE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitList:{fn:(e,t)=>aE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitn:{fn:(e,t,n)=>oE(e,t,n),argTypes:[`string`,`int`,`string`],arity:{kind:`exact`},returnType:`dict`},squote:{fn:(...e)=>cE(...e),argTypes:[`string`],arity:{kind:`variadic`}},substr:{fn:(e,t,n)=>lE(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},swapcase:{fn:e=>uE(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},title:{fn:e=>pE(e),argTypes:[`string`],arity:{kind:`exact`}},trim:{fn:e=>mE(e),argTypes:[`string`],arity:{kind:`exact`}},trimAll:{fn:(e,t)=>hE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimPrefix:{fn:(e,t)=>gE(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimSuffix:{fn:(e,t)=>_E(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trunc:{fn:(e,t)=>vE(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},untitle:{fn:e=>yE(e),argTypes:[`string`],arity:{kind:`exact`}},upper:{fn:e=>bE(e),argTypes:[`string`],arity:{kind:`exact`}},wrap:{fn:(e,t)=>xE(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},wrapWith:{fn:(e,t,n)=>CE(e,t,n),argTypes:[`int`,`string`,`string`],arity:{kind:`exact`}}}}function TE(e,t){let n=EE(e),r=n.copy();return r.style=Su(n.style,t),r}function EE(e){if(!(e instanceof G))throw TypeError(`template function expected a RichText fragment, got ${typeof e==`object`?Object.prototype.toString.call(e):typeof e}`);return e}function DE(e){return{fn:(t=>TE(t,e)),argTypes:[`liftable`],arity:{kind:`exact`},returnType:`T`}}function OE(e){return{fn:((t,n)=>TE(n,new H({[e]:B.parse(t)}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`}}function kE(e,t){return new H({[e]:t})}function AE(){let e={};for(let t of gu)e[t]=DE(kE(t,!0)),e[`not_${t}`]=DE(kE(t,!1));for(let[t,n]of Object.entries(vu))e[t]=DE(kE(n,!0));return e}const jE={fn:((e,t)=>TE(t,H.parse(e))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`},ME={fn:((e,t)=>TE(t,new H({link:e}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`};function NE(){return{fg:OE(`color`),bg:OE(`bgcolor`),...AE(),link:ME,style:jE}}function PE(e,t){let n;try{n=rc(e.trim())}catch(n){throw n instanceof zs?TypeError(`${t} expected a color (#RRGGBB or #RRGGBBAA), got ${JSON.stringify(e)} — to use a palette name here, wrap it: ${t} (color ${JSON.stringify(e)}) …`,{cause:n}):n}return FE(n,t,JSON.stringify(e))}function FE(e,t,n){if(e.alpha===0)throw RangeError(`${t} got ${n}, which is fully transparent: it draws no colour of its own, so there is nothing to compute with — use the colour of the surface it sits on, e.g. (color "background")`);return e}function IE(e,t){return{fn:t,argTypes:e,arity:{kind:`exact`},returnType:`string`}}function LE(e,t,n,r){let i=r===void 0||e>=r.min&&e<=r.max;if(!Number.isFinite(e)||!i){let i=r===void 0?`a finite number`:`within ${r.min}..${r.max} (${r.note})`;throw RangeError(`${t}'s ${n} must be ${i}, got ${e}`)}return e}const RE=IE([`string`,`int`],((e,t)=>Bc(PE(e,`darken`),t).hex)),zE=IE([`string`,`int`],((e,t)=>Bc(PE(e,`lighten`),-t).hex)),BE={min:0,max:100,note:`0 = from, 100 = toward`},VE=IE([`string`,`string`,`float`],((e,t,n)=>ic(PE(e,`mix`),PE(t,`mix`),LE(n,`mix`,`percentage`,BE)/100).hex)),HE={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},UE=IE([`string`],(e=>Hc(PE(e,`contrastOn`)).hex)),WE={depth:z.TRUECOLOR},GE=e=>IE([`string`,`string`,`float`],((t,n,r)=>{let{depth:i,terminal:a}=e();return Uc(PE(t,`readableOn`),PE(n,`readableOn`),LE(r,`readableOn`,`ratio`,HE),i,void 0,a).hex})),KE={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function qE(){let e={};for(let[t,n]of Object.entries(KE)){let r=t;e[n]=IE([`string`,`float`],((e,t)=>{let i={...Sc,[r]:LE(t,n,`amount`)};return V.fromRgba(PE(e,n)).applyKey(i).toRgba().hex}))}return e}function JE(e=()=>WE){return{darken:RE,lighten:zE,mix:VE,contrastOn:UE,readableOn:GE(e),...qE()}}function YE(e,t){if(e.length%2!=0)throw RangeError(`ramp's last stop (position ${String(e[e.length-1])}) has no color — stops are <position> <color> pairs`);let n=[];for(let r=0;r<e.length;r+=2)n.push({at:e[r],color:FE(Pc(t,e[r+1]),`ramp`,JSON.stringify(e[r+1]))});return n}function XE(e){return{color:{fn:(t=>Pc(e(),t).hex),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},ramp:{fn:((t,n,...r)=>new su(Jl(n),YE(r,e())).at(t).hex),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:4},returnType:`string`}}}function ZE(e,t,n){if(t.length%2!=0)throw RangeError(`last hold (${String(t[t.length-1])} s) has no ${e} — the arguments are <seconds> <${e}> pairs`);let r=[];for(let e=0;e<t.length;e+=2){let i=t[e];if(!Number.isFinite(i)||i<=0)throw RangeError(`hold ${e/2} must be a positive number of seconds, got ${i}`);r.push({seconds:i,value:n(t[e+1])})}return r}function QE(e){return{frames:{fn:((...t)=>um(new lm(ZE(`frame`,t,EE).map(({seconds:e,value:t})=>({seconds:e,text:t}))),e())),argTypes:[`float`,`liftable`],arity:{kind:`alternating`,minimum:2},returnType:`T`},stepped:{fn:((...t)=>{let n=ZE(`color`,t,e=>PE(e,`stepped`));return n[ru(n.map(e=>e.seconds)).at(e())].value.hex}),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:2},returnType:`string`}}}function $E(e){return{...NE(),...JE(e)}}new H({color:`red`,dim:!0});const eD=/^(?:(?:global|apac|au|eu|us|us-east-\d|us-west-\d|eu-west-\d|eu-central-\d)\.)?(?:anthropic\.|azure_ai\/|bedrock\/|vertex_ai\/)?claude-(?:(?<family>opus|sonnet|haiku)-(?<newMajor>\d+)(?:-(?<newMinor>\d))?|(?<oldMajor>\d+)(?:-(?<oldMinor>\d))?-(?<oldFamily>opus|sonnet|haiku))(?:[-@]\d{8})?(?:-v\d+:\d+)?(?:-latest)?$/i,tD=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function nD(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(eD);if(n?.groups){let{family:e,newMajor:t,newMinor:r,oldMajor:i,oldMinor:a,oldFamily:o}=n.groups,s=e||o,c=t||i,l=r||a;if(s&&c)return`${s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()} ${l?`${c}.${l}`:c}`}let r=t.match(tD);if(r?.groups){let e=r.groups.family,t=r.groups.major,n=r.groups.minor;return`${e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()} ${n?`${t}.${n}`:t}`}return t||e}function rD(e){let t=e.match(tD);if(!t?.groups)return e;let n=t.groups.family,r=t.groups.major,i=t.groups.minor;return`${n.charAt(0).toUpperCase()}${i?`${r}.${i}`:r}`}function iD(e){let t=e.split(`/`),n=t.length-1;return t.map((e,t)=>{if(t===n)return e;let r=e.match(/^\.*./);return r?r[0]:e}).join(`/`)}function aD(e){return e.toLocaleString()}function oD(e){if(e.length===0)throw Error(`a cascade needs at least one stop, e.g. "0:calm"`);let t=[];for(let[n,r]of e.entries()){let e=r.indexOf(`:`),i=e<0?NaN:Number(r.slice(0,e));if(!Number.isFinite(i))throw Error(`cascade stop ${n} ("${r}") must be "<position>:<result>", e.g. "80:hot" — the position must be a number`);let a=t[n-1];if(a!==void 0&&i<a.at)throw Error(`cascade stops must be in ascending position order; stop ${n} at ${i} follows stop ${n-1} at ${a.at}`);t.push({at:i,text:r.slice(e+1)})}return t}function sD(e,t){if(!Number.isFinite(e))throw Error(`a cascade needs a finite value, got ${e}`);let n=-1;for(;n+1<t.length&&t[n+1].at<=e;)n++;return(n<0?t[0]:t[n]).text}const cD=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],lD=cD.length;function uD(e,t){let n=t===void 0?e:t<=0?[]:e.slice(-t);if(n.length===0)return``;let r=n[0],i=n[0];for(let e of n)e<r&&(r=e),e>i&&(i=e);let a=i-r,o=``;for(let e of n){let t=a===0?0:Math.round((e-r)/a*(lD-1));o+=cD[t]}return o}function dD(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(e===``)continue;let r=Number(e);if(!Number.isFinite(r))throw TypeError(`sparkline: non-numeric series element ${JSON.stringify(n)}`);t.push(r)}return t}function fD(e,t,n){if(n.length!==0)throw Error(`${e}: takes at most ${t.length} optional argument${t.length===1?``:`s`} (${t.join(`, `)}), got ${t.length+n.length}`)}const pD=jh(),mD=[...Qh];function hD(){return{basename:{fn:e=>c(e),argTypes:[`string`],arity:{kind:`exact`}},dirname:{fn:e=>l(e),argTypes:[`string`],arity:{kind:`exact`}},abbreviatePath:{fn:e=>iD(e),argTypes:[`string`],arity:{kind:`exact`}},int:{fn:e=>Math.trunc(Tb(e)),argTypes:[`value`],arity:{kind:`exact`}},string:{fn:e=>wb(e),argTypes:[`value`],arity:{kind:`exact`}},bool:{fn:e=>Eb(e),argTypes:[`value`],arity:{kind:`exact`}},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`],arity:{kind:`exact`}},themes:{fn:()=>pD,argTypes:[],arity:{kind:`exact`}},endcaps:{fn:()=>mD,argTypes:[],arity:{kind:`exact`}},sparkline:{fn:(e,t,...n)=>(fD(`sparkline`,[`width`],n),uD(dD(e),t)),argTypes:[`string`,`int`],arity:{kind:`variadic`}},cascade:{fn:(e,...t)=>sD(e,oD(t)),argTypes:[`float`,`string`],arity:{kind:`variadic`}}}}function gD(e){return{minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e().getTime())/6e4),argTypes:[`int`],arity:{kind:`exact`}},formatInteger:{fn:e=>aD(e),argTypes:[`int`],arity:{kind:`exact`}},round:{fn:e=>Math.round(e),argTypes:[`float`],arity:{kind:`exact`}},formatModelName:{fn:e=>nD(e),argTypes:[`string`],arity:{kind:`exact`}},shortenModelName:{fn:e=>rD(e),argTypes:[`string`],arity:{kind:`exact`}}}}function _D(e){let{clock:t,drawnAt:n,extraFuncs:r}=e;return xS({fromString:e=>new G(e),toString:e=>e.plain,isT:e=>e instanceof G,clock:t,missingKey:`error`,funcs:{...uw(),...wE(),...Qw(),...bT(),...nw(t),...KS(),...Ew(),...ww(),...$E(n&&(()=>({depth:n()}))),...QE(()=>t().getTime()/1e3),...hD(),...gD(t),...r??{}}})}function vD(e){return yD(e,new Set(e.names()),``)}function yD(e,t,n){return new Proxy(Object.create(null),{has(e,r){if(typeof r!=`string`)return!1;let i=n?`${n}.${r}`:r;if(t.has(i))return!0;let a=`${i}.`;for(let e of t)if(e.startsWith(a))return!0;return!1},get(r,i){if(typeof i!=`string`)return;let a=n?`${n}.${i}`:i;if(t.has(a))return e.getKind(a)===`document`?xD(a,e.readDocument(a)):e.read(a);let o=`${a}.`;for(let n of t)if(n.startsWith(o))return yD(e,t,a)}})}function bD(e,t){return new Proxy(e,{has:(e,t)=>t===`settings`||Reflect.has(e,t),get:(e,n)=>n===`settings`?t:Reflect.get(e,n)})}function xD(e,t){switch(t.kind){case`ok`:return t.value;case`absent`:throw new Db(e,`variable "${e}" has no value yet: its source has not completed a scan`);case`failed`:throw Error(`variable "${e}": ${t.reason}`)}}function SD(e){return p.existsSync(s.join(e,`.git`))}function CD(e){let t=s.resolve(e);for(;;){if(SD(t))return t;let e=s.dirname(t);if(e===t)return;t=e}}function wD(e){let t=CD(e);return t===void 0?{root:s.resolve(e),git:!1}:{root:t,git:!0}}function TD(e,t){return e.kind===`absent`?F(`none`):e.kind===`failed`?e:t.kind===`failed`?t:F(t.kind===`ok`?`tracked`:`gone`)}function ED(e,t){return e.kind!==`ok`||e.value.state===`open`?e:t.kind===`failed`?L(`HEAD: ${t.reason}`):t.kind===`ok`&&t.value===e.value.head?e:{kind:`earlier`,value:e.value}}const DD={OPEN:`open`,MERGED:`merged`,CLOSED:`closed`},OD={opened:`open`,locked:`open`,merged:`merged`,closed:`closed`};function kD(e,t,n){return Object.hasOwn(t,n)?F(t[n]):L(`${e}: unknown state ${JSON.stringify(n)}`)}function AD(e,t,n){return t.ok?F(t.stdout):t.reason===`non-zero`&&n===`absent`||t.reason===`non-zero`&&n===t.exitCode?I:L(jD(e,t))}function jD(e,t){return`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??MD(t.stderr)].filter(Boolean).join(`, `)}`}function MD(e){return e.trim().split(`
73
73
  `,1)[0]??``}function ND(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?I:F(n)}function PD(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?F(t):I}const FD={github:`gh`,gitlab:`glab`};function ID(e){return!e.ok&&e.reason===`spawn-error`&&/ENOENT/i.test(e.error??``)}const LD=/^[A-Za-z]:[\\/]/;function RD(e){let t=e.trim();if(LD.test(t))return null;let n=t.match(/^(?:[^@/]+@)?(\[[^\]]+\]):(.*)$/)??t.match(/^(?:[^@/:]+@)?([^/:]+):(?!\/\/)(.*)$/),r=n?`ssh://${n[1]}/${n[2].replace(/^\/+/,``)}`:t,i;try{i=new URL(r)}catch{return null}return{scheme:i.protocol.replace(/:$/,``),host:i.hostname.toLowerCase(),port:i.port,path:i.pathname.replace(/^\/+/,``).replace(/\/+$/,``)}}function zD(e){return RD(e)?.host||null}function BD(e){let t=zD(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}const VD=[`config`,`--local`,`--get-regexp`,`^remote\\..*\\.url$`];function HD(e){let t=AD(`git config --get-regexp remote url`,e,1);return t.kind===`failed`?t:{kind:`ok`,value:t.kind===`ok`?UD(t.value):[]}}function UD(e){let t=new Map;for(let n of e.split(`
74
74
  `)){let e=n.match(/^remote\.(.+)\.url\s+(\S.*)$/);if(!e)continue;let r=t.get(e[1])??[];r.push(e[2].trim()),t.set(e[1],r)}return[...t].map(([e,t])=>({name:e,urls:t}))}function WD(e){return e.urls.find(e=>YD(e)!==null)??e.urls[0]??null}function GD(e){return e.find(e=>e.name===`origin`)??e[0]??null}function KD(e){let t=GD(e);return t?WD(t):null}function qD(e){let t=GD(e);return t?t.urls.find(e=>BD(e)!==null)??WD(t):null}function JD(e){let t=(RD(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function YD(e){let t=RD(e);if(!t)return null;let n=t.scheme===`https`?{scheme:`https`,port:t.port}:t.scheme===`http`?{scheme:`http`,port:t.port}:t.scheme===`ssh`||t.scheme===`git`?{scheme:`https`,port:``}:null;if(!n||!t.host)return null;let r=t.path.replace(/\.git$/,``);if(!r)return null;let i=n.port?`${t.host}:${n.port}`:t.host;return`${n.scheme}://${i}/${r}`}function XD(e){let t=KD(e);return t===null?null:YD(t)}function ZD(e,t,n,r){return t.ok?r(t.stdout):ID(t)||t.reason===`non-zero`&&n.test(t.stderr)?I:L(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??MD(t.stderr)].filter(Boolean).join(`, `)}`)}function QD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $D(e){let t=`detached`,n=I,r=I,i=I,a=0,o=0,s=0,c=0;for(let l of e.split(`
75
75
  `)){if(!l)continue;if(l.startsWith(`# `)){let e=l.slice(2);if(e.startsWith(`branch.oid `)){let t=e.slice(11).trim();n=t===`(initial)`?I:F(t)}else if(e.startsWith(`branch.head `)){let n=e.slice(12).trim();t=n===`(detached)`?`detached`:n}else if(e.startsWith(`branch.upstream `))r=F(e.slice(16).trim());else if(e.startsWith(`branch.ab `)){let t=e.slice(10).trim().match(/^\+(\d+)\s+-(\d+)$/);t&&(i=F({ahead:parseInt(t[1],10),behind:parseInt(t[2],10)}))}continue}let e=l[0];if(e===`1`||e===`2`){let e=l.slice(2,4);e[0]!==`.`&&a++,e[1]!==`.`&&o++}else e===`u`?c++:e===`?`&&s++}let l=`clean`;return c>0?l=`conflicts`:(a||o||s)&&(l=`dirty`),{branch:t,status:l,aheadBehind:i,oid:n,upstream:r,workingTree:{staged:a,unstaged:o,untracked:s,conflicts:c}}}function eO(e){let t;try{t=JSON.parse(e)}catch(e){return L(`gh pr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!QD(t))return L(`gh pr view: JSON is not an object`);let{number:n,state:r,url:i,headRefOid:a}=t;if(typeof n!=`number`||typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return L(`gh pr view: missing number/state/url/headRefOid`);let o=kD(`gh pr view`,DD,r);return o.kind===`ok`?F({number:n,state:o.value,url:i,head:a}):o}function tO(e){let t;try{t=JSON.parse(e)}catch(e){return L(`glab mr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!QD(t))return L(`glab mr view: JSON is not an object`);let n=t.iid,r=t.state,i=t.web_url,a=t.sha;if(typeof n!=`number`||typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return L(`glab mr view: missing iid/state/web_url/sha`);let o=kD(`glab mr view`,OD,r);return o.kind===`ok`?F({number:n,state:o.value,url:i,head:a}):o}function nO(e){try{let t=p.statSync(e);return{key:`${t.dev}:${t.ino}`,stamp:`${t.mtimeMs}:${t.size}`}}catch{return null}}var rO=class{isGitRepo(e){return SD(e)}async execGitAsync(e,t){return lt({bin:`git`,args:[...e],cwd:t.cwd,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:t.timeout,category:`git`})}async resolveEffectiveGitDir(e,t){return this.isWorktree(e)?F(e):t&&this.isGitRepo(t)?F(t):this.isGitRepo(e)?F(e):this.findGitRoot(e)}async findGitRoot(e){let t=CD(e);return t===void 0?I:F(t)}async getGitInfo(e,t={},n){try{return await this.computeGitInfo(e,t,n)}catch(e){return L(`git: ${e instanceof Error?e.message:String(e)}`)}}async computeGitInfo(e,t={},n){let r,i=this.isWorktree(e);if(i)r=e;else if(n&&this.isGitRepo(n))r=n;else if(this.isGitRepo(e))r=e;else{let t=await this.findGitRoot(e);if(t.kind!==`ok`)return t;r=t.value}let a=await this.getCoreAsync(r);if(a.kind!==`ok`)return a;let o={branch:a.value.branch,status:a.value.status,aheadBehind:a.value.aheadBehind,head:a.value.oid};t.showWorkingTree&&(o.workingTree=a.value.workingTree),t.showSha&&(o.sha=ND(a.value.oid,e=>e.slice(0,7))),t.showUpstream&&(o.upstream=a.value.upstream),t.showTag&&(o.tag=await this.getNearestTagAsync(r)),t.showTimeSinceCommit&&(o.committedAt=await this.committedAt(r,a.value.oid)),t.showStashCount&&(o.stashCount=this.getStashCount(r));let s=t.showRepoName||t.showRepoUrl?await this.getRemotesAsync(r):void 0;return s!==void 0&&t.showRepoName&&(o.repoName=ND(s,e=>this.repoNameFrom(e,r)),o.isWorktree=i),s!==void 0&&t.showRepoUrl&&(o.repoUrl=ND(s,XD)),t.showOperation&&(o.operation=this.getOngoingOperation(r)),F(o)}resolveGitDir(e){let t=s.join(e,`.git`);try{if(p.existsSync(t)&&p.statSync(t).isFile()){let n=p.readFileSync(t,`utf-8`).match(/^gitdir:\s*(.+)$/m);if(n?.[1])return s.resolve(e,n[1].trim())}}catch{}return t}getOngoingOperation(e){try{let t=this.resolveGitDir(e);return p.existsSync(s.join(t,`MERGE_HEAD`))?F(`MERGE`):p.existsSync(s.join(t,`CHERRY_PICK_HEAD`))?F(`CHERRY-PICK`):p.existsSync(s.join(t,`REVERT_HEAD`))?F(`REVERT`):p.existsSync(s.join(t,`BISECT_LOG`))?F(`BISECT`):p.existsSync(s.join(t,`rebase-merge`))||p.existsSync(s.join(t,`rebase-apply`))?F(`REBASE`):I}catch(e){return L(`git operation probe: ${e instanceof Error?e.message:String(e)}`)}}async getNearestTagAsync(e){return PD(AD(`git describe --tags`,await this.execGitAsync([`describe`,`--tags`,`--abbrev=0`],{cwd:e,timeout:2e3}),`absent`))}async committedAt(e,t){return t.kind===`ok`?this.commitTimestampMs(e,t.value):t}commitTimes=new Map;async commitTimestampMs(e,t){let n=this.commitTimes.get(t);if(n!==void 0)return this.commitTimes.delete(t),this.commitTimes.set(t,n),n;let r=this.readCommitTimestampMs(e,t);for(this.commitTimes.set(t,r),r.then(e=>{e.kind!==`ok`&&this.commitTimes.get(t)===r&&this.commitTimes.delete(t)},()=>{this.commitTimes.get(t)===r&&this.commitTimes.delete(t)});this.commitTimes.size>256;){let e=this.commitTimes.keys().next().value;if(e===void 0)break;this.commitTimes.delete(e)}return r}async readCommitTimestampMs(e,t){let n=PD(AD(`git log -1`,await this.execGitAsync([`log`,`-1`,`--format=%ct`,t,`--`],{cwd:e,timeout:2e3}),`absent`));if(n.kind!==`ok`)return n;let r=parseInt(n.value,10)*1e3;return Number.isNaN(r)?L(`git log -1: unparseable timestamp "${n.value}"`):F(r)}resolveCommonGitDir(e){let t=this.resolveGitDir(e);try{let e=p.readFileSync(s.join(t,`commondir`),`utf-8`).trim();if(e)return s.resolve(t,e)}catch{}return t}getStashCount(e){let t=s.join(this.resolveCommonGitDir(e),`logs`,`refs`,`stash`),n;try{n=p.readFileSync(t,`utf-8`)}catch(e){return e.code===`ENOENT`?F(0):L(`git stash reflog ${t}: ${e instanceof Error?e.message:String(e)}`)}let r=n.trim();return F(r?r.split(`
76
- `).length:0)}async getRemotesAsync(e){let t=nO(s.join(this.resolveCommonGitDir(e),`config`));if(t===null)return this.readRemotes(e);let{key:n,stamp:r}=t,i=this.remotesByConfig.get(n);if(i!==void 0&&i.stamp===r)return this.remotesByConfig.delete(n),this.remotesByConfig.set(n,i),i.remotes;let a=this.readRemotes(e);for(this.remotesByConfig.set(n,{stamp:r,remotes:a}),a.then(e=>{let t=this.remotesByConfig.get(n);e.kind!==`ok`&&t?.remotes===a&&this.remotesByConfig.delete(n)},()=>{this.remotesByConfig.get(n)?.remotes===a&&this.remotesByConfig.delete(n)});this.remotesByConfig.size>256;){let e=this.remotesByConfig.keys().next().value;if(e===void 0)break;this.remotesByConfig.delete(e)}return a}remotesByConfig=new Map;async readRemotes(e){return HD(await this.execGitAsync(VD,{cwd:e,timeout:2e3}))}repoNameFrom(e,t){let n=KD(e);return(n===null?null:JD(n))??s.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=qD(t.value);return n===null?I:F(n)}async execForgeAsync(e,t,n){return lt({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=BD(t);return n===`github`?ZD(`gh pr view`,await this.execForgeAsync(FD.github,[`pr`,`view`,`--json`,`number,state,url,headRefOid`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,eO):n===`gitlab`?ZD(`glab mr view`,await this.execForgeAsync(FD.gitlab,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,tO):I}isWorktree(e){try{let t=s.join(e,`.git`);return!!(p.existsSync(t)&&p.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){D(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=AD(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?F($D(t.value)):t}};const iO=(e,t)=>D(t);var aO=class{slots=new Map;counters;logger;closed=!1;constructor(e={}){this.counters=e.counters,this.logger=e.logger??iO}acquire(e,t,n){if(this.closed)return{release:()=>{}};let r=this.slots.get(e);if(r)return r.refcount++,r.onInvalidate=n,this.makeHandle(e);let i={key:e,watchers:[],refcount:1,debounceTimer:null,onInvalidate:n,targets:t};return this.openWatchers(i),this.slots.set(e,i),this.counters&&this.counters.watchersOpened++,this.makeHandle(e)}makeHandle(e){let t=!1;return{release:()=>{if(t)return;t=!0;let n=this.slots.get(e);n&&(n.refcount=Math.max(0,n.refcount-1),n.refcount===0&&(this.closeSlot(n),this.slots.delete(e)))}}}openWatchers(e){let t=()=>{e.debounceTimer||(e.debounceTimer=setTimeout(()=>{e.debounceTimer=null;try{e.onInvalidate()}catch(e){this.logger(`warn`,`watcher invalidate threw: ${e.message}`)}},50),e.debounceTimer.unref())};for(let n of e.targets.files)try{let r=p.watch(n,{persistent:!1},t);r.on(`error`,e=>{this.logger(`warn`,`watcher error ${n}: ${e.message}`)}),e.watchers.push(r)}catch(e){this.logger(`warn`,`watch failed ${n}: ${e.message}`)}for(let n of e.targets.dirs)try{let r=n.filenames?new Set(n.filenames):null,i=p.watch(n.path,{persistent:!1},(e,n)=>{r&&(!n||!r.has(n))||t()});i.on(`error`,e=>{this.logger(`warn`,`watcher error ${n.path}: ${e.message}`)}),e.watchers.push(i)}catch(e){this.logger(`warn`,`watch failed ${n.path}: ${e.message}`)}}closeSlot(e){e.debounceTimer&&=(clearTimeout(e.debounceTimer),null);for(let t of e.watchers)try{t.close()}catch{}e.watchers=[],this.counters&&this.counters.watchersClosed++}size(){return this.slots.size}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e);this.slots.clear()}},oO=class{running=new Set;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:(this.running.add(e),{kind:`started`,done:this.loop(e,t)})}async loop(e,t){try{do this.again.delete(e),await t();while(this.again.has(e))}finally{this.running.delete(e),this.again.delete(e)}}clear(){this.running.clear(),this.again.clear()}get size(){return this.running.size}};const sO={showSha:!0,showStashCount:!0};function cO(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function lO(e){let t=t=>{try{return p.statSync(s.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function uO(e,t){return e.head!==t.head||e.index!==t.index}function dO(e){let t=[{path:e,filenames:[`HEAD`,`index`]}],n=s.join(e,`refs/heads`);try{p.statSync(n).isDirectory()&&t.push({path:n})}catch{}return{files:[],dirs:t}}var fO=class extends rO{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;resolutions=new Map;prCache=new Map;prFetchInFlight=new Map;refreshes=new oO;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new rO,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??Oe,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new aO({logger:this.logger}),this.ownsWatchers=!0);let t=e.sanityIntervalMs??3e5;t>0&&(this.sanityTimer=setInterval(()=>this.runSanityCheck(),t),this.sanityTimer.unref())}getWatcherRegistry(){return this.watchers}getStats(){let e=0;for(let t of this.entries.values())t.value.kind===`expired`&&e++;return{size:this.entries.size,expired:e,hits:this.hits,misses:this.misses,invalidations:this.invalidations,watchers:this.watchers.size()}}resolveEffectiveGitDir(e,t){let n=`${e}|${t??``}`,r=Date.now(),i=this.resolutions.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.resolutions.delete(n),this.resolutions.set(n,i),i.dir;let a=this.inner.resolveEffectiveGitDir(e,t);return this.resolutions.set(n,{dir:a,computedAt:r}),a.catch(()=>{this.resolutions.get(n)?.dir===a&&this.resolutions.delete(n)}),this.evictResolutionsIfNeeded(),a}evictResolutionsIfNeeded(){for(;this.resolutions.size>this.maxEntries;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}}async getGitInfo(e,t={},n){let r=await this.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${cO(t)}`,r=Date.now(),i=this.entries.get(n);if(i?.value.kind===`fresh`&&r-i.value.computedAt<this.ttlMs)return this.entries.delete(n),this.entries.set(n,i),this.hits++,Promise.resolve(F(i.value.info));let a=this.fetchInFlight.get(n);if(a)return a;let o=this.doFetch(e,n,t,r).finally(()=>{this.fetchInFlight.delete(n)});return this.fetchInFlight.set(n,o),o}async doFetch(e,t,n,r){this.misses++;let i=this.inner.resolveGitDir(e),a=lO(i),o=await this.inner.getGitInfo(e,n);if(o.kind===`absent`&&this.dropRepo(e),o.kind!==`ok`)return o;let s=o.value;n.showPullRequest&&(s.pullRequest=await this.getPullRequestCached(e,s.branch));let c={kind:`fresh`,info:s,computedAt:r,mtime:a},l=this.entries.get(t)??{value:c,watcher:this.watchers.acquire(`git:${e}`,dO(i),()=>this.invalidateRepo(e)),repoRoot:e};return l.value=c,this.entries.delete(t),this.entries.set(t,l),this.evictIfNeeded(),o}async getPullRequestCached(e,t){let n=await this.inner.getRepoRemoteUrl(e);if(n.kind===`failed`)return n;if(n.kind===`absent`)return I;let r=n.value,i=`${e}|${t}|${r}`,a=Date.now(),o=this.prCache.get(i);if(o){let e=o.pr.kind===`failed`?45e3:3e5;if(a-o.computedAt<e)return this.prCache.delete(i),this.prCache.set(i,o),o.pr}let s=this.prFetchInFlight.get(i);if(s)return s;let c=this.inner.resolvePullRequest(e,r).then(e=>(this.prCache.set(i,{pr:e,computedAt:Date.now()}),this.evictPrIfNeeded(),e)).finally(()=>{this.prFetchInFlight.delete(i)});return this.prFetchInFlight.set(i,c),c}evictPrIfNeeded(){for(;this.prCache.size>this.maxEntries;){let e=this.prCache.keys().next().value;if(e===void 0)break;this.prCache.delete(e)}}deliverable(e,t){return e.kind===`failed`?(this.logger(`warn`,`git fetch failed (${t}): ${e.reason}`),null):e.kind===`ok`?e.value:null}subscribe(e,t){let n=!1,r=null;return{firstDelivery:(async()=>{let i=await this.resolveEffectiveGitDir(e);if(n)return;if(i.kind!==`ok`){i.kind===`failed`&&this.logger(`warn`,`git resolve failed (subscribe ${e}): ${i.reason}`),this.safeInvoke(t,null);return}let a=i.value,o=this.subscribersByRepo.get(a);if(!o){let t=this.inner.resolveGitDir(a),n=this.watchers.acquire(`git:${a}`,dO(t),()=>this.invalidateRepo(a));o={workingDir:e,repoRoot:a,callbacks:new Set,watcher:n},this.subscribersByRepo.set(a,o)}o.callbacks.add(t),r={repoRoot:a,entry:o};let s=await this.getGitInfoForRoot(a,{...sO});n||this.safeInvoke(t,this.deliverable(s,a))})(),unsubscribe:()=>{if(n=!0,!r)return;let{repoRoot:e,entry:i}=r;i.callbacks.delete(t),i.callbacks.size===0&&(i.watcher.release(),this.subscribersByRepo.delete(e))}}}invalidateRepo(e){let t=0;for(let n of this.entries.values())n.repoRoot===e&&n.value.kind===`fresh`&&(n.value={kind:`expired`},t++);t>0&&(this.invalidations+=t,this.logger(`info`,`gitCache invalidate ${e} expired=${t}`)),this.refreshSubscribers(e)}refreshSubscribers(e){let t=this.subscribersByRepo.get(e);!t||t.callbacks.size===0||this.refreshes.run(e,()=>this.refreshOnce(e))}async refreshOnce(e){let t=this.subscribersByRepo.get(e);if(!t||t.callbacks.size===0)return;let n=await this.getGitInfoForRoot(e,{...sO}),r=this.deliverable(n,e),i=this.subscribersByRepo.get(e);if(!(!i||i.callbacks.size===0))for(let e of[...i.callbacks])i.callbacks.has(e)&&this.safeInvoke(e,r)}safeInvoke(e,t){try{e(t)}catch(e){this.logger(`warn`,`git subscriber threw: ${e.message??String(e)}`)}}dropEntry(e){let t=this.entries.get(e);t&&(t.watcher.release(),this.entries.delete(e))}dropRepo(e){let t=0;for(let[n,r]of this.entries)r.repoRoot===e&&(this.dropEntry(n),t++);t>0&&this.logger(`info`,`gitCache drop ${e} entries=${t}`)}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.dropEntry(e),this.logger(`info`,`gitCache evict ${e}`)}}runSanityCheck(){let e=new Map;for(let t of this.entries.values()){if(t.value.kind===`expired`)continue;let n=e.get(t.repoRoot);n||(n=lO(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),uO(t.value.mtime,n)&&this.invalidateRepo(t.repoRoot)}}runSanityCheckNow(){this.runSanityCheck()}close(){this.sanityTimer&&=(clearInterval(this.sanityTimer),null);for(let e of this.entries.values())e.watcher.release();this.entries.clear();for(let e of this.subscribersByRepo.values())e.callbacks.clear(),e.watcher.release();this.subscribersByRepo.clear(),this.refreshes.clear(),this.fetchInFlight.clear(),this.prCache.clear(),this.prFetchInFlight.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}};const pO=/\r\n|\r|\n/g,mO=e=>F(e.replace(pO,` `).trim());function hO(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?L(`regex no-match`):F(n.replace(pO,` `))}}const gO=e=>{try{return F(JSON.parse(e))}catch(e){return L(`JSON parse failed: ${e.message}`)}},_O=e=>e.getTime()/1e3,vO=e=>new Date(e*1e3);function yO(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(D(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function bO(e){let t=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/.exec(e);if(!t)throw RangeError(`Invalid duration: "${e}"`);let n=parseFloat(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;default:throw RangeError(`Unexpected duration unit: "${t[2]}"`)}}const xO=`session.id`;function SO(e,t,n){return{where:`output of "${e}" in ${t}`,read:async()=>{let r=await lt({bin:`/bin/sh`,args:[`-c`,e],cwd:t,category:`user-shell`,signal:n});if(!r.ok&&r.reason===`aborted`)throw n.reason;return r.ok?F(r.stdout):L(`shell "${e}" ${r.exitCode===null?[r.reason,r.error].filter(e=>e!==void 0).join(`: `):`exited with code ${r.exitCode}`} in ${t}`)}}}function CO(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await le(e,{encoding:`utf8`,signal:n});return F(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return L(`file unreadable: ${e}`)}}}}function wO(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?L(`${r.reason} in ${n}`):r}const TO=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],EO=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],DO=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],OO=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function kO(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>TO[e.getMonth()]],[`Monday`,e=>DO[e.getDay()]],[`Jan`,e=>EO[e.getMonth()]],[`Mon`,e=>OO[e.getDay()]],[`15`,e=>String(e.getHours()).padStart(2,`0`)],[`06`,e=>String(e.getFullYear()%100).padStart(2,`0`)],[`01`,e=>String(e.getMonth()+1).padStart(2,`0`)],[`02`,e=>String(e.getDate()).padStart(2,`0`)],[`04`,e=>String(e.getMinutes()).padStart(2,`0`)],[`05`,e=>String(e.getSeconds()).padStart(2,`0`)],[`PM`,e=>e.getHours()<12?`AM`:`PM`],[`pm`,e=>e.getHours()<12?`am`:`pm`],[`1`,e=>String(e.getMonth()+1)],[`2`,e=>String(e.getDate())],[`3`,e=>String(e.getHours()%12||12)],[`4`,e=>String(e.getMinutes())],[`5`,e=>String(e.getSeconds())]],r=``,i=0;for(;i<e.length;){let a=!1;for(let[o,s]of n)if(e.startsWith(o,i)){r+=s(t),i+=o.length,a=!0;break}a||(r+=e[i],i++)}return r}const AO={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function jO(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=AO[t];try{return zO(r,e)}catch{return BO(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return ta(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return ta(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return ta(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return ta(e.stashCount,0)}}function MO(e){try{return b(e)}catch{return e}}function NO(e){try{return ee(e).isDirectory()}catch{return!1}}function PO(e){let t=MO(e);return NO(t)?{dir:t,name:null,leaf:!0}:_b(t)}const FO=e=>`${e.dir}\0${e.name??``}`;var IO=class{watchers=new Map;subscribe(e,t,n){let r=this.watchers.get(e)??this.arm(e);return r.subscribers.set(t,n),r.watcher===null&&n(r.failure),()=>this.unsubscribe(e,t)}arm(e){let t={watcher:null,failure:``,target:PO(e),subscribers:new Map};return t.watcher=this.open(e,t,t.target),this.watchers.set(e,t),t}rearm(e,t){let n=PO(e);if(t.watcher!==null&&FO(n)===FO(t.target))return;let r=this.open(e,t,n);r!==null&&(t.watcher?.close(),t.watcher=r,t.target=n)}open(e,t,n){let{dir:r,name:i}=n,a=s.basename(r);try{return x(r,(n,r)=>{if(!(r===null||i===null||r===i)&&r!==a)return;let o=t.target.leaf;if(this.rearm(e,t),!(!o&&!t.target.leaf))for(let e of t.subscribers.keys())e()})}catch(n){let i=`watch_file ${e}: cannot watch ${r} — ${n instanceof Error?n.message:String(n)}`;t.failure=i;for(let e of t.subscribers.values())e(i);return null}}unsubscribe(e,t){let n=this.watchers.get(e);n&&(n.subscribers.delete(t),n.subscribers.size===0&&(n.watcher?.close(),this.watchers.delete(e)))}dispose(){for(let{watcher:e}of this.watchers.values())e?.close();this.watchers.clear()}size(){return this.watchers.size}},LO=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:me(()=>{for(let e of t)e()},e),callbacks:t},this.buckets.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.buckets.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(fe(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())fe(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function RO(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function zO(e,t){if(typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Expected string|number|boolean from payload, got ${typeof e}`);return t===`string`?wb(e):t===`number`?Tb(e):Eb(e)}function BO(e){return e===`number`?0:e===`boolean`?!1:``}var VO=class{inputMetas=new Map;lastErrors=new Map;policyFaults=new Map;watchMgr=new IO;ttlMgr=new LO;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;reads=new oO;abort=new AbortController;drawn=xb.observable.box(B.TRUECOLOR);drawnAt=()=>this.drawn.get();instant=xb.observable.box(null);now=()=>{let e=this.instant.get();if(e===null)throw Error(`the time was read before any render published its instant`);return vO(e)};engine=_D({clock:this.now,drawnAt:this.drawnAt});gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new fO({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,Cb(t),t)}declareFailedDocument(e,t){this.store.defineDocument(e,L(t))}declareInput(e,t,n,r){let i=r===void 0?this.defaultFor(n):r;this.store.defineBox(e,n,i),this.inputMetas.set(e,{path:t,varDefault:r})}declareEnv(e,t,n){let r=process.env[t];if(r!==void 0){this.store.defineBox(e,`string`,r);return}let i=n===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:n;this.store.defineBox(e,`string`,i),this.recordError(e,`env var "${t}" is not set`)}declareShell(e,t,n){this.declareSource(e,SO(t,n.cwd,this.abort.signal),yO(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,CO(t,n.readMode??`whole`,this.abort.signal),n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r,t.where),a=()=>this.runSource(e,t,i);a(),this.registerCachePolicy(e,n,a)}publisherFor(e,t,n){switch(t.kind){case`text`:return this.scalarPublisher(e,mO,t.default,n);case`regex`:return this.scalarPublisher(e,hO(t.regex),t.default,n);case`json`:return this.documentPublisher(e,t.default,n)}}scalarPublisher(e,t,n,r){let i=this.stringInitial(n);return this.store.defineBox(e,`string`,i),n=>{let a=wO(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,ta(a,i))}}documentPublisher(e,t,n){let r=t===void 0?I:F(t);this.store.defineDocument(e,r);let i,a=!1;return this.cleanups.push(()=>clearTimeout(i)),o=>{clearTimeout(i);let s=o.kind===`ok`&&o.value.trim()===``?I:o,c=wO(s,gO,n);this.noteOutcome(e,c);let l=c.kind===`ok`||s.kind===`ok`||t===void 0?c:r,u=a&&s.kind===`ok`&&c.kind!==`ok`,d=()=>{a=c.kind===`ok`,this.store.setDocument(e,l)};u?i=setTimeout(d,250):d()}}runSource(e,t,n){let r=this.reads.run(e,()=>t.read().then(n,e=>{if(e!==this.abort.signal.reason)throw e}));r.kind===`started`&&this.track(e,r.done)}track(e,t){let n=t.finally(()=>{this.inFlight.get(e)===n&&this.inFlight.delete(e)});this.inFlight.set(e,n)}async settled(e){let t=Date.now()+e;for(;this.inFlight.size>0;){let e=t-Date.now();if(e<=0)break;let n,r=await Promise.race([Promise.all(this.inFlight.values()).then(()=>`settled`),new Promise(t=>{n=setTimeout(()=>t(`deadline`),e)})]);if(clearTimeout(n),r===`deadline`)break}return[...this.inFlight.keys()]}declareTemplate(e,t,n={}){let r=this.engine.parse(t);this.declareDerived(e,()=>r.evaluate(vD(this.store)).map(e=>e.plain).join(``),n.varDefault)}declareTime(e,t){this.declareDerived(e,()=>kO(t.format,this.now()),t.varDefault)}declareDerived(e,t,n){this.store.defineComputed(e,`string`,()=>{try{let n=t();return this.lastErrors.delete(e),n}catch(t){let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),n===void 0)throw Ob(t)?new Db(e,`variable "${e}": ${r}`):Error(`variable "${e}": ${r}`);return n}})}declareGit(e,t){let n=AO[t.field],r=t.varDefault===void 0?BO(n):zO(t.varDefault,n);this.store.defineBox(e,n,r);let i=this.gitSubscriptions.get(t.cwd);if(!i){let e=new Map,n=this.gitProvider.subscribe(t.cwd,t=>{this.store.runInAction(()=>{for(let[n,r]of e)for(let{name:e,varDefault:i}of r)this.store.setBox(e,jO(t,n,i,this.defaultEmptyValue))})});i={fieldSubs:e,firstDelivery:n.firstDelivery,unsubscribe:n.unsubscribe},this.gitSubscriptions.set(t.cwd,i)}let a=i.fieldSubs.get(t.field);a||(a=[],i.fieldSubs.set(t.field,a)),a.push({name:e,varDefault:t.varDefault}),this.track(e,i.firstDelivery)}declareState(e,t){if(!this.sessionState)throw Error(`declareState("${e}"): SourceRegistry was constructed without a SessionState — state-kind variables require a SessionState (the daemon provides one; tests must supply one)`);let n=this.sessionState,r=t.varDefault??this.stringInitial(void 0);this.store.defineComputed(e,`string`,e=>{let i=e(xO);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}stateRevision(){let e=this.store.has(`session.id`)?this.store.read(xO):``;return this.sessionState!==void 0&&typeof e==`string`&&e!==``?this.sessionState.revision(e):0}applyInput(e){this.store.runInAction(()=>{for(let[t,n]of this.inputMetas){let r=RO(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,zO(r,i)),this.lastErrors.delete(t)}catch(e){this.applyFallback(t,i,n.varDefault,e instanceof Error?e.message:String(e))}else this.applyFallback(t,i,n.varDefault,`input path "${n.path}" not found in payload`)}})}drawAt(e){this.store.runInAction(()=>this.drawn.set(e))}renderAt(e){this.store.runInAction(()=>this.instant.set(e))}getLastError(e){let t=this.lastErrors.get(e),n=this.policyFaults.get(e);return n===void 0?t:t===void 0?n:{timestamp:t.timestamp,message:`${n.message}; ${t.message}`}}cachePolicyFaults(){return this.policyFaults}dispose(){this.abort.abort();for(let e of this.cleanups)e();this.cleanups.length=0;for(let e of this.gitSubscriptions.values())e.unsubscribe();return this.gitSubscriptions.clear(),this.reads.clear(),this.watchMgr.dispose(),this.ttlMgr.dispose(),this.ownsGitProvider&&this.gitProvider.close(),this.store.dispose()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:break;case`ttl`:{let e=this.ttlMgr.subscribe(t.durationMs,n);this.cleanups.push(e);break}case`watch_file`:{let r=this.watchMgr.subscribe(t.path,n,t=>this.notePolicy(e,L(t)));this.cleanups.push(r);break}case`key`:{let r=this.engine.parse(t.template),i=()=>{try{return F(r.evaluate(vD(this.store)).map(e=>e.plain).join(``))}catch(e){return Ob(e)?I:L(`cache key: ${e instanceof Error?e.message:String(e)}`)}},a=i();this.notePolicy(e,a);let o=a.kind===`ok`?a.value:void 0,s=(0,xb.reaction)(i,t=>{this.notePolicy(e,t),!(t.kind!==`ok`||t.value===o)&&(o=t.value,n())});this.cleanups.push(s);break}case`depends_on`:{let e=(0,xb.reaction)(()=>t.varNames.map(e=>this.store.changeKey(e)).join(`,`),n);this.cleanups.push(e);break}}}applyFallback(e,t,n,r){if(this.recordError(e,r),n!==void 0){this.store.setBox(e,n);return}try{this.store.setBox(e,zO(this.defaultEmptyValue,t))}catch{this.store.setBox(e,BO(t))}}defaultFor(e){try{return zO(this.defaultEmptyValue,e)}catch{return BO(e)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:Date.now(),message:t})}notePolicy(e,t){t.kind===`failed`?this.policyFaults.set(e,{timestamp:Date.now(),message:t.reason}):this.policyFaults.delete(e)}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};function HO(e,t){let n=X_[e],r=iv(e),i=n.kind===`session`||n.kind===`config`?n.floor:``;return r===`string`?{kind:`input`,path:t,default:``}:{kind:`input`,path:t,type:r,default:i}}const UO=Object.fromEntries([...fv].map(([e,t])=>[t,HO(e,t)])),WO={subscribers:`number`,fps:`number`,shown:`boolean`},GO=Object.keys(WO),KO={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[xO]:{kind:`input`,path:`session_id`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},resume_command:{kind:`input`,path:`resumeCommand`,default:``},config_path:{kind:`input`,path:`configPath`,default:``},...UO,"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},...Object.fromEntries(E_.flatMap(e=>GO.map(t=>[A_(e,t),{kind:`input`,path:A_(e,t),type:WO[t],default:k_[t]}]))),[O_(`by`)]:{kind:`input`,path:O_(`by`),default:D_.by},[O_(`fps`)]:{kind:`input`,path:O_(`fps`),type:`number`,default:0},"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},"tmux.pane":{kind:`input`,path:`tmux.pane`,default:``},"autocompact.window":{kind:`input`,path:`autocompact.window`,type:`number`,default:-1},...Object.fromEntries([`applied`,`lower`,`higher`].map(e=>[`autocompact.${e}`,{kind:`input`,path:`autocompact.${e}`,type:`number`,default:0}])),"autocompact.error":{kind:`input`,path:`autocompact.error`,default:``},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},qO=`ne .tmux.pane ""`;function JO(e,t,n){let r=new Set,i=e=>{for(let t of sb(e??``,n).keys())r.add(t)};for(let t of Object.values(e.segments))i(t.template),i(t.bg),i(t.fg),i(t.when);for(let e of t)for(let t of _g(e))i(t.when),t.kind===`segment`&&(i(t.lead),i(t.trail));for(let t of Object.values(e.variables))t.kind===`template`&&i(t.template),t.kind===`state`&&r.add(xO);for(let t of Object.values(e.actions)){r.add(xO),`copy`in t&&i(t.copy),`open`in t&&i(t.open);let e=`set`in t?pv.get(t.set):void 0,n=`persist`in t?fv.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function YO(e,t,n){let r=hb({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of JO(e,t,n.helpers)){if(mb(a,r))continue;let e=KO[a];if(e===void 0)throw Error(`synthesized chrome reads ".${a}", which it does not declare and PAYLOAD_INPUTS does not supply`);i[a]=e}return i}function XO(e){return e.replace(/[^A-Za-z0-9]+/g,`_`)}const ZO=`groups.`,QO=`menus.`,$O=`edit.`,X=`candybar.`,ek=[ZO,QO,$O,X];function tk(e){return ek.some(t=>e.startsWith(t))}function nk(e){let t=XO(e);return ek.find(e=>t.startsWith(XO(e)))}function rk(e,t,n,r){for(let i of[`variables`,`actions`,`segments`])for(let a of Object.keys(t[i]??{}))a.startsWith(n)&&e.issues.push({path:`${i}.${a}`,message:`"${a}" is in the reserved "${n}" namespace (synthesized by ${r}) — rename it`,line:K(e.source,[`root`])})}function ik(e){return e}function ak(e,t,n){return n===void 0?QO+XO(e)+`.`+XO(t):ok(n)}function ok(e){return QO+XO(e)}function sk(e,t){return e+`.`+t}function ck(e){return e+`.page`}const lk=[`closeOnPick`,`paged`,`key`,`distribution`],uk=e=>lk.includes(e),dk=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${Am.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function fk(e){for(let t of Object.keys(e))if(!uk(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${dk}`);let t=(t,n)=>{let r=e[t];if(r===void 0)return n;if(typeof r!=`boolean`)throw Error(`{{ menu }} option "${t}" must be a boolean, got ${JSON.stringify(r)} (e.g. (dict "${t}" ${String(!n)}))`);return r},n=e.key;if(n!==void 0&&typeof n!=`string`)throw Error(`{{ menu }} option "key" must be a string naming the accordion group, got ${JSON.stringify(n)}`);if(n===``)throw Error(`{{ menu }} has an empty accordion key — a shared key must be a non-empty name (or omit "key" for an independent menu)`);let r=e.distribution;if(r!==void 0&&!jm(r))throw Error(`{{ menu }} option "distribution" must be one of: ${Am.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:Nm(r)}}const pk=e=>`from`in e?e.from:e.themes;function mk(e,t,n){return e===`bool`?lg(t)!==null:`min`in e?ug(t,e)!==null:Ky(pk(e),n).members.includes(t)}function hk(e,t){if(e===`bool`)return sg.join(` or `);if(!(`min`in e)){let n=pk(e),{members:r}=Ky(n,t),i=r.map(e=>JSON.stringify(e));if(r.length<=8)return`one of ${i.join(`, `)}`;let a=typeof n==`string`?` "${n}"`:``;return`one of the ${r.length}${a} names, such as ${i.slice(0,3).join(`, `)}`}return`an integer from ${e.min} to ${e.max}`}function gk(e){return{label:e.label,domain:_k(e.domain)}}function _k(e){return e===`theme`?{themes:Uy}:e===`bool`||`min`in e?e:{from:e}}function vk(e,t,n,r,i){let a=Zr(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...sg]}},variables:{}};if(`from`in o)return yk(t,r,i,o.from,e=>({template:`{{ "${a}" }} {{ carousel "${e.apply}" 0 "${e.open}" }}`,rows:[`{{ picker "${e.apply}" "${e.page}" false true true }}`]}));if(`themes`in o)return yk(t,r,i,o.themes,e=>({template:`{{ action "${e.open}" "${a}" .${n} }} {{ action "${e.open}" (swatch "${e.apply}") }}`,rows:[`{{ swatches "${e.apply}" "${e.page}" }}`,`{{ themePreview "${e.apply}" }}`]}));let s=e=>({set:t,min:o.min,max:o.max,by:e});return{kind:`inline`,template:`{{ action "${r}.down" "◀" }} {{ "${a}" }} {{ .${n} }} {{ action "${r}.up" "▶" }}`,actions:{[`${r}.down`]:s(-o.step),[`${r}.up`]:s(o.step)},variables:{}}}function yk(e,t,n,r,i){let a={variable:n,key:n,member:t},o=sk(n,t),s=`${t}.open`,c=ck(n),l=`${c}.current`,{template:u,rows:d}=i({apply:t,open:s,page:c});return{kind:`picker`,template:u,actions:{[t]:{set:e,from:r},[o]:ai(n,t),[c]:{set:c,int:!0},[l]:{set:c,to:`-1`},[s]:{do:[o,l]}},variables:{[n]:ii(n,P),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,rows:d}}}const bk=Object.fromEntries(Object.entries(X_).map(([e,t])=>[e,t.spec]));function xk(e){return X_[e].domain}function Sk(e,t){return{required:!1,json:{not:{},description:`not allowed here — ${e}`},parse:(e,n,r,i)=>{i[r]!==void 0&&e.issues.push({path:`${n}.${r}`,message:t(`${n}.${r}`),line:K(e.source,[...n.split(`.`),r])})}}}function Ck(e){return Sk(`${e} cannot select a preset`,t=>`${t}: ${e} cannot select a preset. Which preset is active is resolved once, as session pick over globals.preset over "default"; a fragment naming another would be a second authority over that. Set the default arrangement in the top-level globals.preset instead.`)}function wk(e){return Sk(`${e} cannot change the settings menu glyph`,t=>`${t}: ${e} cannot change the settings menu glyph — one menu is shared by every preset. Set it in the top-level globals.menuGlyph instead.`)}function Tk(e,t,n){return{...e,json:{...e.json,not:{pattern:`\\{\\{`}},parse:(r,i,a,o)=>{let s=o[a];if(typeof s==`string`&&Lh(s)){r.issues.push({path:`${i}.${a}`,message:`${i}.${a}: a rule is not allowed here — ${t} ${n}, so it names a value. Write the rule in globals.${a} (or a preset's globals.${a}) instead.`,line:K(r.source,[...i.split(`.`),a])});return}return e.parse(r,i,a,o)}}}const Ek={default_bg:"nothing reads it — a segment with no `bg:` wears the decoration tint of its place in the bar. Delete the key, and author `bg:` on the segments that need a fixed colour.",default_fg:"nothing reads it — a segment with no `fg:` wears text chosen for contrast against its background. Delete the key, and author `fg:` on the segments that need a fixed colour.",default_truncate_marker:'nothing reads it — a segment clipped to its `width:` always ends in "…". Delete the key.',look:`it was renamed "style" — write the same name as style: "<name>"`,progression:`it was renamed "variation", and its values with it: accent (was secondary-accent), duo (was primary-secondary), mono (was primary)`,charset:"the bar always draws Nerd Font glyphs. Delete the key; `cc-candybar doctor` names what your terminal's font is missing."},Dk={noun:`globals key`,fields:bk,removed:Ek},Ok={preset:Ck(`a preset`),menuGlyph:wk(`a preset`)},kk={noun:`preset globals key`,fields:{...bk,...Ok},removed:Ek};function Ak(e){return Bk(e)&&!(e in Ok)}const jk=`is decided later than any rule could be settled`,Mk={noun:`editGlobals key`,removed:Ek,fields:{...bk,preset:Ck(`the editGlobals fragment`),menuGlyph:wk(`the editGlobals fragment`),palette:Tk(bk.palette,`the editGlobals fragment`,jk),style:Tk(bk.style,`the editGlobals fragment`,jk),effect:Tk(bk.effect,`the editGlobals fragment`,jk)}},Nk={noun:`theme default key`,fields:{...Object.fromEntries(ev.map(e=>[e,bk[e]])),style:Tk(bk.style,`a theme's default`,`is the look that theme wears by name`)}};function Pk(e,t){if(!Qg(t))return e.issues.push({path:`themeDefaults`,message:`themeDefaults must be an object mapping theme names to { shade, variation, style }, got ${$g(t)}`,line:K(e.source,[`themeDefaults`])}),{};let n={};for(let[r,i]of Object.entries(t)){let t=`themeDefaults.${r}`;if(!e.allowedPalettes.has(r)){e.issues.push({path:t,message:`${t}: "${r}" is not an installed theme${Oh(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:K(e.source,[`themeDefaults`,r])});continue}let a=e_(e,Nk,t,i);a!==null&&(n[r]=a)}return n}function Fk(e,t,n){return n===void 0?{}:e_(e,Dk,t,n)??{}}function Ik(e,t,n){return e_(e,kk,t,n)??{}}function Lk(){return x_(kk)}function Rk(e,t,n){return e_(e,Mk,t,n)??{}}const zk=new Set(Object.keys(bk));function Bk(e){return zk.has(e)}function Vk(e){return Object.hasOwn(Ek,e)?Ek[e]:void 0}function Hk(){return[...zk]}const Uk=new Map(Object.entries(X_).flatMap(([e,t])=>`floor`in t&&typeof t.floor==`number`?[[e,t.floor]]:[]));function Wk(e){let t=new Map;for(let[n,r]of Uk){let i=e[n];t.set(n,typeof i==`number`?i:r)}return t}const Gk=/^segments\.([^.]+)\.palette$/,Kk=/^presets\.(.+)\.root$/,qk=/^presets\.(.+)\.globals\.([^.]+)$/,Jk=/^themeDefaults\.(.+)\.([^.]+)$/;function Yk(e){return`presets.${e}.root`}function Xk(e,t){return`themeDefaults.${e}.${t}`}const Zk=e=>ev.includes(e);function Qk(e,t){return`presets.${e}.globals.${t}`}function $k(e){if(Bk(e))return{scope:`globals`,field:e};let t=Gk.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=qk.exec(e);if(n&&Ak(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=Jk.exec(e);if(r&&Zk(r[2]))return{scope:`theme-default`,theme:r[1],field:r[2]};let i=Kk.exec(e);return i?{scope:`preset-root`,preset:i[1]}:null}function eA(e){switch(e.scope){case`globals`:return[`globals`,e.field];case`preset-globals`:return[`presets`,e.preset,`globals`,e.field];case`segment-palette`:return[`segments`,e.segment,`palette`];case`theme-default`:return[`themeDefaults`,e.theme,e.field]}}const tA=[`location`,`git`,`model-context`,`cost-limits`,`activity`,`session-tools`],nA=[...tA,`other`],rA={location:`location`,git:`git`,"model-context":`model & context`,"cost-limits":`cost & limits`,activity:`activity`,"session-tools":`session tools`,other:`other`},iA=xS({fromString:e=>e}),aA=`edit.mode`,oA=`edit.configure`,sA=`edit.toggle`,cA=`edit.unconfigure`,lA=[sA,cA],uA=`arrange`,dA=`${$O}draft.`;function fA(e,t){return`${e}:${t}`}const pA={variable:aA,key:aA,member:uA},mA=$r(pA);function hA(e){try{return iA.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function gA(e){if(Object.values(e.actions??{}).some(e=>`do`in e&&e.do.includes(`edit.toggle`)))return!0;for(let t of Object.values(e.segments??{}))for(let e of[t.template,t.bg,t.fg])if(typeof e==`string`&&hA(e))return!0;return!1}function _A(e,t){if(rk(e,t,$O,`edit mode`),!gA(t))return;let{variables:n,actions:r}=vA();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function vA(){return{variables:{[aA]:ii(aA,P),[oA]:ii(oA,P)},actions:{[sA]:ai(aA,uA),[cA]:{set:oA,to:P}}}}const yA=`open`;function bA(e,t,n,r){let i={variable:e,key:e,member:yA};return r.variables[e]=ii(e,P),r.actions[e]=ai(e,yA),r.segments[e]={template:ti(e,`(?)`,`✕`),...xA(n)},Qr(e,i,{kind:`container`,direction:`horizontal`,children:t.map((t,n)=>{let i=`${e}.${n}`;return r.segments[i]={template:t},{kind:`segment`,name:i}})},`drop`)}function xA(e){let[t,...n]=e;return t===void 0?{}:{when:$r(t,...n)}}const SA=`none`;function CA(e){return Pc(e,`background`)}var wA=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function TA(e,t,n,r,i){let{palette:a,tint:o,text:s}=e,c=EA(n,i),l=c!==SA,u=l?c===void 0?o:DA(a,c,`bg`):CA(a);e.bg=u;let d=EA(r,i),f=d===void 0?l?(e=>e.hex===o.hex?s:th(a,e,t))(u):void 0:DA(a,d,`fg`);return new H({...l&&{bgcolor:V.fromRgba(u)},...f!==void 0&&{color:V.fromRgba(f)}})}function EA(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function DA(e,t,n){try{return Pc(e,t)}catch(e){throw e instanceof Nc?new wA(t,n,e.message):e}}const OA=`🔧`,kA={help:[`-h`,`--help`],version:[`-V`,`--version`]},AA=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],jA=Object.fromEntries(AA.map(e=>[e.member,e.label])),MA={gear:{beside:`theme`,trigger:`⚙`},toggles:{beside:`updateNotice`,trigger:`🧪 toggles`}},NA=Object.keys(MA),PA=mv(e=>sv[e].place),FA=e=>Object.hasOwn(MA,e),IA=e=>FA(e)?IA(PA[MA[e].beside]):e,LA=e=>FA(e)?`${LA(PA[MA[e].beside])} › ${MA[e].trigger}`:e===`door`?`first line`:jA[e],RA=e=>LA(PA[e]),zA=e=>`${T_[e].label} is off — turn it on in the settings menu's ${RA(T_[e].setting)}, or set globals.${T_[e].setting}: true`,BA=[...new Set(Object.values(T_).map(e=>RA(e.setting)))].join(` or `),VA=[`✚ inserts`,`✖ removes`,`${OA} configures`,`↺ resets layout`],HA={band:[`animates the bar in the band above the prompt, through a Claude Code mod`,`on: installs the candybar-band mod from this checkout and types /reload-plugins`],statusline:[`animates the statusline itself, through the attach launcher shipped with cc-candybar`,`on: exits this Claude Code and starts it again under that launcher, on this session`,`or start one yourself: cc-candybar --help prints the line to type`],pane:[`animates the bar in a tmux pane under this session's`,`on: opens that pane · off: closes it`],tmuxStatus:[`animates the bar in the tmux status line, while this session's pane is the one it shows`,`on: the daemon draws it there · off: puts the status line back as it was`]},UA=`
76
+ `).length:0)}async getRemotesAsync(e){let t=nO(s.join(this.resolveCommonGitDir(e),`config`));if(t===null)return this.readRemotes(e);let{key:n,stamp:r}=t,i=this.remotesByConfig.get(n);if(i!==void 0&&i.stamp===r)return this.remotesByConfig.delete(n),this.remotesByConfig.set(n,i),i.remotes;let a=this.readRemotes(e);for(this.remotesByConfig.set(n,{stamp:r,remotes:a}),a.then(e=>{let t=this.remotesByConfig.get(n);e.kind!==`ok`&&t?.remotes===a&&this.remotesByConfig.delete(n)},()=>{this.remotesByConfig.get(n)?.remotes===a&&this.remotesByConfig.delete(n)});this.remotesByConfig.size>256;){let e=this.remotesByConfig.keys().next().value;if(e===void 0)break;this.remotesByConfig.delete(e)}return a}remotesByConfig=new Map;async readRemotes(e){return HD(await this.execGitAsync(VD,{cwd:e,timeout:2e3}))}repoNameFrom(e,t){let n=KD(e);return(n===null?null:JD(n))??s.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=qD(t.value);return n===null?I:F(n)}async execForgeAsync(e,t,n){return lt({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=BD(t);return n===`github`?ZD(`gh pr view`,await this.execForgeAsync(FD.github,[`pr`,`view`,`--json`,`number,state,url,headRefOid`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,eO):n===`gitlab`?ZD(`glab mr view`,await this.execForgeAsync(FD.gitlab,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,tO):I}isWorktree(e){try{let t=s.join(e,`.git`);return!!(p.existsSync(t)&&p.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){D(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=AD(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?F($D(t.value)):t}};const iO=(e,t)=>D(t);var aO=class{slots=new Map;counters;logger;closed=!1;constructor(e={}){this.counters=e.counters,this.logger=e.logger??iO}acquire(e,t,n){if(this.closed)return{release:()=>{}};let r=this.slots.get(e);if(r)return r.refcount++,r.onInvalidate=n,this.makeHandle(e);let i={key:e,watchers:[],refcount:1,debounceTimer:null,onInvalidate:n,targets:t};return this.openWatchers(i),this.slots.set(e,i),this.counters&&this.counters.watchersOpened++,this.makeHandle(e)}makeHandle(e){let t=!1;return{release:()=>{if(t)return;t=!0;let n=this.slots.get(e);n&&(n.refcount=Math.max(0,n.refcount-1),n.refcount===0&&(this.closeSlot(n),this.slots.delete(e)))}}}openWatchers(e){let t=()=>{e.debounceTimer||(e.debounceTimer=setTimeout(()=>{e.debounceTimer=null;try{e.onInvalidate()}catch(e){this.logger(`warn`,`watcher invalidate threw: ${e.message}`)}},50),e.debounceTimer.unref())};for(let n of e.targets.files)try{let r=p.watch(n,{persistent:!1},t);r.on(`error`,e=>{this.logger(`warn`,`watcher error ${n}: ${e.message}`)}),e.watchers.push(r)}catch(e){this.logger(`warn`,`watch failed ${n}: ${e.message}`)}for(let n of e.targets.dirs)try{let r=n.filenames?new Set(n.filenames):null,i=p.watch(n.path,{persistent:!1},(e,n)=>{r&&(!n||!r.has(n))||t()});i.on(`error`,e=>{this.logger(`warn`,`watcher error ${n.path}: ${e.message}`)}),e.watchers.push(i)}catch(e){this.logger(`warn`,`watch failed ${n.path}: ${e.message}`)}}closeSlot(e){e.debounceTimer&&=(clearTimeout(e.debounceTimer),null);for(let t of e.watchers)try{t.close()}catch{}e.watchers=[],this.counters&&this.counters.watchersClosed++}size(){return this.slots.size}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e);this.slots.clear()}},oO=class{running=new Set;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:(this.running.add(e),{kind:`started`,done:this.loop(e,t)})}async loop(e,t){try{do this.again.delete(e),await t();while(this.again.has(e))}finally{this.running.delete(e),this.again.delete(e)}}clear(){this.running.clear(),this.again.clear()}get size(){return this.running.size}};const sO={showSha:!0,showStashCount:!0};function cO(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function lO(e){let t=t=>{try{return p.statSync(s.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function uO(e,t){return e.head!==t.head||e.index!==t.index}function dO(e){let t=[{path:e,filenames:[`HEAD`,`index`]}],n=s.join(e,`refs/heads`);try{p.statSync(n).isDirectory()&&t.push({path:n})}catch{}return{files:[],dirs:t}}var fO=class extends rO{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;resolutions=new Map;prCache=new Map;prFetchInFlight=new Map;refreshes=new oO;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new rO,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??Oe,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new aO({logger:this.logger}),this.ownsWatchers=!0);let t=e.sanityIntervalMs??3e5;t>0&&(this.sanityTimer=setInterval(()=>this.runSanityCheck(),t),this.sanityTimer.unref())}getWatcherRegistry(){return this.watchers}getStats(){let e=0;for(let t of this.entries.values())t.value.kind===`expired`&&e++;return{size:this.entries.size,expired:e,hits:this.hits,misses:this.misses,invalidations:this.invalidations,watchers:this.watchers.size()}}resolveEffectiveGitDir(e,t){let n=`${e}|${t??``}`,r=Date.now(),i=this.resolutions.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.resolutions.delete(n),this.resolutions.set(n,i),i.dir;let a=this.inner.resolveEffectiveGitDir(e,t);return this.resolutions.set(n,{dir:a,computedAt:r}),a.catch(()=>{this.resolutions.get(n)?.dir===a&&this.resolutions.delete(n)}),this.evictResolutionsIfNeeded(),a}evictResolutionsIfNeeded(){for(;this.resolutions.size>this.maxEntries;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}}async getGitInfo(e,t={},n){let r=await this.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${cO(t)}`,r=Date.now(),i=this.entries.get(n);if(i?.value.kind===`fresh`&&r-i.value.computedAt<this.ttlMs)return this.entries.delete(n),this.entries.set(n,i),this.hits++,Promise.resolve(F(i.value.info));let a=this.fetchInFlight.get(n);if(a)return a;let o=this.doFetch(e,n,t,r).finally(()=>{this.fetchInFlight.delete(n)});return this.fetchInFlight.set(n,o),o}async doFetch(e,t,n,r){this.misses++;let i=this.inner.resolveGitDir(e),a=lO(i),o=await this.inner.getGitInfo(e,n);if(o.kind===`absent`&&this.dropRepo(e),o.kind!==`ok`)return o;let s=o.value;n.showPullRequest&&(s.pullRequest=await this.getPullRequestCached(e,s.branch));let c={kind:`fresh`,info:s,computedAt:r,mtime:a},l=this.entries.get(t)??{value:c,watcher:this.watchers.acquire(`git:${e}`,dO(i),()=>this.invalidateRepo(e)),repoRoot:e};return l.value=c,this.entries.delete(t),this.entries.set(t,l),this.evictIfNeeded(),o}async getPullRequestCached(e,t){let n=await this.inner.getRepoRemoteUrl(e);if(n.kind===`failed`)return n;if(n.kind===`absent`)return I;let r=n.value,i=`${e}|${t}|${r}`,a=Date.now(),o=this.prCache.get(i);if(o){let e=o.pr.kind===`failed`?45e3:3e5;if(a-o.computedAt<e)return this.prCache.delete(i),this.prCache.set(i,o),o.pr}let s=this.prFetchInFlight.get(i);if(s)return s;let c=this.inner.resolvePullRequest(e,r).then(e=>(this.prCache.set(i,{pr:e,computedAt:Date.now()}),this.evictPrIfNeeded(),e)).finally(()=>{this.prFetchInFlight.delete(i)});return this.prFetchInFlight.set(i,c),c}evictPrIfNeeded(){for(;this.prCache.size>this.maxEntries;){let e=this.prCache.keys().next().value;if(e===void 0)break;this.prCache.delete(e)}}deliverable(e,t){return e.kind===`failed`?(this.logger(`warn`,`git fetch failed (${t}): ${e.reason}`),null):e.kind===`ok`?e.value:null}subscribe(e,t){let n=!1,r=null;return{firstDelivery:(async()=>{let i=await this.resolveEffectiveGitDir(e);if(n)return;if(i.kind!==`ok`){i.kind===`failed`&&this.logger(`warn`,`git resolve failed (subscribe ${e}): ${i.reason}`),this.safeInvoke(t,null);return}let a=i.value,o=this.subscribersByRepo.get(a);if(!o){let t=this.inner.resolveGitDir(a),n=this.watchers.acquire(`git:${a}`,dO(t),()=>this.invalidateRepo(a));o={workingDir:e,repoRoot:a,callbacks:new Set,watcher:n},this.subscribersByRepo.set(a,o)}o.callbacks.add(t),r={repoRoot:a,entry:o};let s=await this.getGitInfoForRoot(a,{...sO});n||this.safeInvoke(t,this.deliverable(s,a))})(),unsubscribe:()=>{if(n=!0,!r)return;let{repoRoot:e,entry:i}=r;i.callbacks.delete(t),i.callbacks.size===0&&(i.watcher.release(),this.subscribersByRepo.delete(e))}}}invalidateRepo(e){let t=0;for(let n of this.entries.values())n.repoRoot===e&&n.value.kind===`fresh`&&(n.value={kind:`expired`},t++);t>0&&(this.invalidations+=t,this.logger(`info`,`gitCache invalidate ${e} expired=${t}`)),this.refreshSubscribers(e)}refreshSubscribers(e){let t=this.subscribersByRepo.get(e);!t||t.callbacks.size===0||this.refreshes.run(e,()=>this.refreshOnce(e))}async refreshOnce(e){let t=this.subscribersByRepo.get(e);if(!t||t.callbacks.size===0)return;let n=await this.getGitInfoForRoot(e,{...sO}),r=this.deliverable(n,e),i=this.subscribersByRepo.get(e);if(!(!i||i.callbacks.size===0))for(let e of[...i.callbacks])i.callbacks.has(e)&&this.safeInvoke(e,r)}safeInvoke(e,t){try{e(t)}catch(e){this.logger(`warn`,`git subscriber threw: ${e.message??String(e)}`)}}dropEntry(e){let t=this.entries.get(e);t&&(t.watcher.release(),this.entries.delete(e))}dropRepo(e){let t=0;for(let[n,r]of this.entries)r.repoRoot===e&&(this.dropEntry(n),t++);t>0&&this.logger(`info`,`gitCache drop ${e} entries=${t}`)}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.dropEntry(e),this.logger(`info`,`gitCache evict ${e}`)}}runSanityCheck(){let e=new Map;for(let t of this.entries.values()){if(t.value.kind===`expired`)continue;let n=e.get(t.repoRoot);n||(n=lO(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),uO(t.value.mtime,n)&&this.invalidateRepo(t.repoRoot)}}runSanityCheckNow(){this.runSanityCheck()}close(){this.sanityTimer&&=(clearInterval(this.sanityTimer),null);for(let e of this.entries.values())e.watcher.release();this.entries.clear();for(let e of this.subscribersByRepo.values())e.callbacks.clear(),e.watcher.release();this.subscribersByRepo.clear(),this.refreshes.clear(),this.fetchInFlight.clear(),this.prCache.clear(),this.prFetchInFlight.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}};const pO=/\r\n|\r|\n/g,mO=e=>F(e.replace(pO,` `).trim());function hO(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?L(`regex no-match`):F(n.replace(pO,` `))}}const gO=e=>{try{return F(JSON.parse(e))}catch(e){return L(`JSON parse failed: ${e.message}`)}},_O=e=>e.getTime()/1e3,vO=e=>new Date(e*1e3);function yO(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(D(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function bO(e){let t=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/.exec(e);if(!t)throw RangeError(`Invalid duration: "${e}"`);let n=parseFloat(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;default:throw RangeError(`Unexpected duration unit: "${t[2]}"`)}}const xO=`session.id`;function SO(e,t,n){return{where:`output of "${e}" in ${t}`,read:async()=>{let r=await lt({bin:`/bin/sh`,args:[`-c`,e],cwd:t,category:`user-shell`,signal:n});if(!r.ok&&r.reason===`aborted`)throw n.reason;return r.ok?F(r.stdout):L(`shell "${e}" ${r.exitCode===null?[r.reason,r.error].filter(e=>e!==void 0).join(`: `):`exited with code ${r.exitCode}`} in ${t}`)}}}function CO(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await le(e,{encoding:`utf8`,signal:n});return F(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return L(`file unreadable: ${e}`)}}}}function wO(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?L(`${r.reason} in ${n}`):r}const TO=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],EO=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],DO=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],OO=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function kO(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>TO[e.getMonth()]],[`Monday`,e=>DO[e.getDay()]],[`Jan`,e=>EO[e.getMonth()]],[`Mon`,e=>OO[e.getDay()]],[`15`,e=>String(e.getHours()).padStart(2,`0`)],[`06`,e=>String(e.getFullYear()%100).padStart(2,`0`)],[`01`,e=>String(e.getMonth()+1).padStart(2,`0`)],[`02`,e=>String(e.getDate()).padStart(2,`0`)],[`04`,e=>String(e.getMinutes()).padStart(2,`0`)],[`05`,e=>String(e.getSeconds()).padStart(2,`0`)],[`PM`,e=>e.getHours()<12?`AM`:`PM`],[`pm`,e=>e.getHours()<12?`am`:`pm`],[`1`,e=>String(e.getMonth()+1)],[`2`,e=>String(e.getDate())],[`3`,e=>String(e.getHours()%12||12)],[`4`,e=>String(e.getMinutes())],[`5`,e=>String(e.getSeconds())]],r=``,i=0;for(;i<e.length;){let a=!1;for(let[o,s]of n)if(e.startsWith(o,i)){r+=s(t),i+=o.length,a=!0;break}a||(r+=e[i],i++)}return r}const AO={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function jO(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=AO[t];try{return zO(r,e)}catch{return BO(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return ta(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return ta(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return ta(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return ta(e.stashCount,0)}}function MO(e){try{return b(e)}catch{return e}}function NO(e){try{return ee(e).isDirectory()}catch{return!1}}function PO(e){let t=MO(e);return NO(t)?{dir:t,name:null,leaf:!0}:_b(t)}const FO=e=>`${e.dir}\0${e.name??``}`;var IO=class{watchers=new Map;subscribe(e,t,n){let r=this.watchers.get(e)??this.arm(e);return r.subscribers.set(t,n),r.watcher===null&&n(r.failure),()=>this.unsubscribe(e,t)}arm(e){let t={watcher:null,failure:``,target:PO(e),subscribers:new Map};return t.watcher=this.open(e,t,t.target),this.watchers.set(e,t),t}rearm(e,t){let n=PO(e);if(t.watcher!==null&&FO(n)===FO(t.target))return;let r=this.open(e,t,n);r!==null&&(t.watcher?.close(),t.watcher=r,t.target=n)}open(e,t,n){let{dir:r,name:i}=n,a=s.basename(r);try{return x(r,(n,r)=>{if(!(r===null||i===null||r===i)&&r!==a)return;let o=t.target.leaf;if(this.rearm(e,t),!(!o&&!t.target.leaf))for(let e of t.subscribers.keys())e()})}catch(n){let i=`watch_file ${e}: cannot watch ${r} — ${n instanceof Error?n.message:String(n)}`;t.failure=i;for(let e of t.subscribers.values())e(i);return null}}unsubscribe(e,t){let n=this.watchers.get(e);n&&(n.subscribers.delete(t),n.subscribers.size===0&&(n.watcher?.close(),this.watchers.delete(e)))}dispose(){for(let{watcher:e}of this.watchers.values())e?.close();this.watchers.clear()}size(){return this.watchers.size}},LO=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:me(()=>{for(let e of t)e()},e),callbacks:t},this.buckets.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.buckets.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(fe(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())fe(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function RO(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function zO(e,t){if(typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Expected string|number|boolean from payload, got ${typeof e}`);return t===`string`?wb(e):t===`number`?Tb(e):Eb(e)}function BO(e){return e===`number`?0:e===`boolean`?!1:``}var VO=class{inputMetas=new Map;lastErrors=new Map;policyFaults=new Map;watchMgr=new IO;ttlMgr=new LO;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;reads=new oO;abort=new AbortController;drawn=xb.observable.box(z.TRUECOLOR);drawnAt=()=>this.drawn.get();instant=xb.observable.box(null);now=()=>{let e=this.instant.get();if(e===null)throw Error(`the time was read before any render published its instant`);return vO(e)};engine=_D({clock:this.now,drawnAt:this.drawnAt});gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new fO({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,Cb(t),t)}declareFailedDocument(e,t){this.store.defineDocument(e,L(t))}declareInput(e,t,n,r){let i=r===void 0?this.defaultFor(n):r;this.store.defineBox(e,n,i),this.inputMetas.set(e,{path:t,varDefault:r})}declareEnv(e,t,n){let r=process.env[t];if(r!==void 0){this.store.defineBox(e,`string`,r);return}let i=n===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:n;this.store.defineBox(e,`string`,i),this.recordError(e,`env var "${t}" is not set`)}declareShell(e,t,n){this.declareSource(e,SO(t,n.cwd,this.abort.signal),yO(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,CO(t,n.readMode??`whole`,this.abort.signal),n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r,t.where),a=()=>this.runSource(e,t,i);a(),this.registerCachePolicy(e,n,a)}publisherFor(e,t,n){switch(t.kind){case`text`:return this.scalarPublisher(e,mO,t.default,n);case`regex`:return this.scalarPublisher(e,hO(t.regex),t.default,n);case`json`:return this.documentPublisher(e,t.default,n)}}scalarPublisher(e,t,n,r){let i=this.stringInitial(n);return this.store.defineBox(e,`string`,i),n=>{let a=wO(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,ta(a,i))}}documentPublisher(e,t,n){let r=t===void 0?I:F(t);this.store.defineDocument(e,r);let i,a=!1;return this.cleanups.push(()=>clearTimeout(i)),o=>{clearTimeout(i);let s=o.kind===`ok`&&o.value.trim()===``?I:o,c=wO(s,gO,n);this.noteOutcome(e,c);let l=c.kind===`ok`||s.kind===`ok`||t===void 0?c:r,u=a&&s.kind===`ok`&&c.kind!==`ok`,d=()=>{a=c.kind===`ok`,this.store.setDocument(e,l)};u?i=setTimeout(d,250):d()}}runSource(e,t,n){let r=this.reads.run(e,()=>t.read().then(n,e=>{if(e!==this.abort.signal.reason)throw e}));r.kind===`started`&&this.track(e,r.done)}track(e,t){let n=t.finally(()=>{this.inFlight.get(e)===n&&this.inFlight.delete(e)});this.inFlight.set(e,n)}async settled(e){let t=Date.now()+e;for(;this.inFlight.size>0;){let e=t-Date.now();if(e<=0)break;let n,r=await Promise.race([Promise.all(this.inFlight.values()).then(()=>`settled`),new Promise(t=>{n=setTimeout(()=>t(`deadline`),e)})]);if(clearTimeout(n),r===`deadline`)break}return[...this.inFlight.keys()]}declareTemplate(e,t,n={}){let r=this.engine.parse(t);this.declareDerived(e,()=>r.evaluate(vD(this.store)).map(e=>e.plain).join(``),n.varDefault)}declareTime(e,t){this.declareDerived(e,()=>kO(t.format,this.now()),t.varDefault)}declareDerived(e,t,n){this.store.defineComputed(e,`string`,()=>{try{let n=t();return this.lastErrors.delete(e),n}catch(t){let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),n===void 0)throw Ob(t)?new Db(e,`variable "${e}": ${r}`):Error(`variable "${e}": ${r}`);return n}})}declareGit(e,t){let n=AO[t.field],r=t.varDefault===void 0?BO(n):zO(t.varDefault,n);this.store.defineBox(e,n,r);let i=this.gitSubscriptions.get(t.cwd);if(!i){let e=new Map,n=this.gitProvider.subscribe(t.cwd,t=>{this.store.runInAction(()=>{for(let[n,r]of e)for(let{name:e,varDefault:i}of r)this.store.setBox(e,jO(t,n,i,this.defaultEmptyValue))})});i={fieldSubs:e,firstDelivery:n.firstDelivery,unsubscribe:n.unsubscribe},this.gitSubscriptions.set(t.cwd,i)}let a=i.fieldSubs.get(t.field);a||(a=[],i.fieldSubs.set(t.field,a)),a.push({name:e,varDefault:t.varDefault}),this.track(e,i.firstDelivery)}declareState(e,t){if(!this.sessionState)throw Error(`declareState("${e}"): SourceRegistry was constructed without a SessionState — state-kind variables require a SessionState (the daemon provides one; tests must supply one)`);let n=this.sessionState,r=t.varDefault??this.stringInitial(void 0);this.store.defineComputed(e,`string`,e=>{let i=e(xO);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}stateRevision(){let e=this.store.has(`session.id`)?this.store.read(xO):``;return this.sessionState!==void 0&&typeof e==`string`&&e!==``?this.sessionState.revision(e):0}applyInput(e){this.store.runInAction(()=>{for(let[t,n]of this.inputMetas){let r=RO(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,zO(r,i)),this.lastErrors.delete(t)}catch(e){this.applyFallback(t,i,n.varDefault,e instanceof Error?e.message:String(e))}else this.applyFallback(t,i,n.varDefault,`input path "${n.path}" not found in payload`)}})}drawAt(e){this.store.runInAction(()=>this.drawn.set(e))}renderAt(e){this.store.runInAction(()=>this.instant.set(e))}getLastError(e){let t=this.lastErrors.get(e),n=this.policyFaults.get(e);return n===void 0?t:t===void 0?n:{timestamp:t.timestamp,message:`${n.message}; ${t.message}`}}cachePolicyFaults(){return this.policyFaults}dispose(){this.abort.abort();for(let e of this.cleanups)e();this.cleanups.length=0;for(let e of this.gitSubscriptions.values())e.unsubscribe();return this.gitSubscriptions.clear(),this.reads.clear(),this.watchMgr.dispose(),this.ttlMgr.dispose(),this.ownsGitProvider&&this.gitProvider.close(),this.store.dispose()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:break;case`ttl`:{let e=this.ttlMgr.subscribe(t.durationMs,n);this.cleanups.push(e);break}case`watch_file`:{let r=this.watchMgr.subscribe(t.path,n,t=>this.notePolicy(e,L(t)));this.cleanups.push(r);break}case`key`:{let r=this.engine.parse(t.template),i=()=>{try{return F(r.evaluate(vD(this.store)).map(e=>e.plain).join(``))}catch(e){return Ob(e)?I:L(`cache key: ${e instanceof Error?e.message:String(e)}`)}},a=i();this.notePolicy(e,a);let o=a.kind===`ok`?a.value:void 0,s=(0,xb.reaction)(i,t=>{this.notePolicy(e,t),!(t.kind!==`ok`||t.value===o)&&(o=t.value,n())});this.cleanups.push(s);break}case`depends_on`:{let e=(0,xb.reaction)(()=>t.varNames.map(e=>this.store.changeKey(e)).join(`,`),n);this.cleanups.push(e);break}}}applyFallback(e,t,n,r){if(this.recordError(e,r),n!==void 0){this.store.setBox(e,n);return}try{this.store.setBox(e,zO(this.defaultEmptyValue,t))}catch{this.store.setBox(e,BO(t))}}defaultFor(e){try{return zO(this.defaultEmptyValue,e)}catch{return BO(e)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:Date.now(),message:t})}notePolicy(e,t){t.kind===`failed`?this.policyFaults.set(e,{timestamp:Date.now(),message:t.reason}):this.policyFaults.delete(e)}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};function HO(e,t){let n=X_[e],r=iv(e),i=n.kind===`session`||n.kind===`config`?n.floor:``;return r===`string`?{kind:`input`,path:t,default:``}:{kind:`input`,path:t,type:r,default:i}}const UO=Object.fromEntries([...fv].map(([e,t])=>[t,HO(e,t)])),WO={subscribers:`number`,fps:`number`,shown:`boolean`},GO=Object.keys(WO),KO={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[xO]:{kind:`input`,path:`session_id`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},resume_command:{kind:`input`,path:`resumeCommand`,default:``},config_path:{kind:`input`,path:`configPath`,default:``},...UO,"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},...Object.fromEntries(E_.flatMap(e=>GO.map(t=>[A_(e,t),{kind:`input`,path:A_(e,t),type:WO[t],default:k_[t]}]))),[O_(`by`)]:{kind:`input`,path:O_(`by`),default:D_.by},[O_(`fps`)]:{kind:`input`,path:O_(`fps`),type:`number`,default:0},"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},"tmux.pane":{kind:`input`,path:`tmux.pane`,default:``},"autocompact.window":{kind:`input`,path:`autocompact.window`,type:`number`,default:-1},...Object.fromEntries([`applied`,`lower`,`higher`].map(e=>[`autocompact.${e}`,{kind:`input`,path:`autocompact.${e}`,type:`number`,default:0}])),"autocompact.error":{kind:`input`,path:`autocompact.error`,default:``},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},qO=`ne .tmux.pane ""`;function JO(e,t,n){let r=new Set,i=e=>{for(let t of sb(e??``,n).keys())r.add(t)};for(let t of Object.values(e.segments))i(t.template),i(t.bg),i(t.fg),i(t.when);for(let e of t)for(let t of _g(e))i(t.when),t.kind===`segment`&&(i(t.lead),i(t.trail));for(let t of Object.values(e.variables))t.kind===`template`&&i(t.template),t.kind===`state`&&r.add(xO);for(let t of Object.values(e.actions)){r.add(xO),`copy`in t&&i(t.copy),`open`in t&&i(t.open);let e=`set`in t?pv.get(t.set):void 0,n=`persist`in t?fv.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function YO(e,t,n){let r=hb({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of JO(e,t,n.helpers)){if(mb(a,r))continue;let e=KO[a];if(e===void 0)throw Error(`synthesized chrome reads ".${a}", which it does not declare and PAYLOAD_INPUTS does not supply`);i[a]=e}return i}function XO(e){return e.replace(/[^A-Za-z0-9]+/g,`_`)}const ZO=`groups.`,QO=`menus.`,$O=`edit.`,X=`candybar.`,ek=[ZO,QO,$O,X];function tk(e){return ek.some(t=>e.startsWith(t))}function nk(e){let t=XO(e);return ek.find(e=>t.startsWith(XO(e)))}function rk(e,t,n,r){for(let i of[`variables`,`actions`,`segments`])for(let a of Object.keys(t[i]??{}))a.startsWith(n)&&e.issues.push({path:`${i}.${a}`,message:`"${a}" is in the reserved "${n}" namespace (synthesized by ${r}) — rename it`,line:K(e.source,[`root`])})}function ik(e){return e}function ak(e,t,n){return n===void 0?QO+XO(e)+`.`+XO(t):ok(n)}function ok(e){return QO+XO(e)}function sk(e,t){return e+`.`+t}function ck(e){return e+`.page`}const lk=[`closeOnPick`,`paged`,`key`,`distribution`],uk=e=>lk.includes(e),dk=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${Am.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function fk(e){for(let t of Object.keys(e))if(!uk(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${dk}`);let t=(t,n)=>{let r=e[t];if(r===void 0)return n;if(typeof r!=`boolean`)throw Error(`{{ menu }} option "${t}" must be a boolean, got ${JSON.stringify(r)} (e.g. (dict "${t}" ${String(!n)}))`);return r},n=e.key;if(n!==void 0&&typeof n!=`string`)throw Error(`{{ menu }} option "key" must be a string naming the accordion group, got ${JSON.stringify(n)}`);if(n===``)throw Error(`{{ menu }} has an empty accordion key — a shared key must be a non-empty name (or omit "key" for an independent menu)`);let r=e.distribution;if(r!==void 0&&!jm(r))throw Error(`{{ menu }} option "distribution" must be one of: ${Am.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:Nm(r)}}const pk=e=>`from`in e?e.from:e.themes;function mk(e,t,n){return e===`bool`?lg(t)!==null:`min`in e?ug(t,e)!==null:Ky(pk(e),n).members.includes(t)}function hk(e,t){if(e===`bool`)return sg.join(` or `);if(!(`min`in e)){let n=pk(e),{members:r}=Ky(n,t),i=r.map(e=>JSON.stringify(e));if(r.length<=8)return`one of ${i.join(`, `)}`;let a=typeof n==`string`?` "${n}"`:``;return`one of the ${r.length}${a} names, such as ${i.slice(0,3).join(`, `)}`}return`an integer from ${e.min} to ${e.max}`}function gk(e){return{label:e.label,domain:_k(e.domain)}}function _k(e){return e===`theme`?{themes:Uy}:e===`bool`||`min`in e?e:{from:e}}function vk(e,t,n,r,i){let a=Zr(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...sg]}},variables:{}};if(`from`in o)return yk(t,r,i,o.from,e=>({template:`{{ "${a}" }} {{ carousel "${e.apply}" 0 "${e.open}" }}`,rows:[`{{ picker "${e.apply}" "${e.page}" false true true }}`]}));if(`themes`in o)return yk(t,r,i,o.themes,e=>({template:`{{ action "${e.open}" "${a}" .${n} }} {{ action "${e.open}" (swatch "${e.apply}") }}`,rows:[`{{ swatches "${e.apply}" "${e.page}" }}`,`{{ themePreview "${e.apply}" }}`]}));let s=e=>({set:t,min:o.min,max:o.max,by:e});return{kind:`inline`,template:`{{ action "${r}.down" "◀" }} {{ "${a}" }} {{ .${n} }} {{ action "${r}.up" "▶" }}`,actions:{[`${r}.down`]:s(-o.step),[`${r}.up`]:s(o.step)},variables:{}}}function yk(e,t,n,r,i){let a={variable:n,key:n,member:t},o=sk(n,t),s=`${t}.open`,c=ck(n),l=`${c}.current`,{template:u,rows:d}=i({apply:t,open:s,page:c});return{kind:`picker`,template:u,actions:{[t]:{set:e,from:r},[o]:ai(n,t),[c]:{set:c,int:!0},[l]:{set:c,to:`-1`},[s]:{do:[o,l]}},variables:{[n]:ii(n,P),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,rows:d}}}const bk=Object.fromEntries(Object.entries(X_).map(([e,t])=>[e,t.spec]));function xk(e){return X_[e].domain}function Sk(e,t){return{required:!1,json:{not:{},description:`not allowed here — ${e}`},parse:(e,n,r,i)=>{i[r]!==void 0&&e.issues.push({path:`${n}.${r}`,message:t(`${n}.${r}`),line:K(e.source,[...n.split(`.`),r])})}}}function Ck(e){return Sk(`${e} cannot select a preset`,t=>`${t}: ${e} cannot select a preset. Which preset is active is resolved once, as session pick over globals.preset over "default"; a fragment naming another would be a second authority over that. Set the default arrangement in the top-level globals.preset instead.`)}function wk(e){return Sk(`${e} cannot change the settings menu glyph`,t=>`${t}: ${e} cannot change the settings menu glyph — one menu is shared by every preset. Set it in the top-level globals.menuGlyph instead.`)}function Tk(e,t,n){return{...e,json:{...e.json,not:{pattern:`\\{\\{`}},parse:(r,i,a,o)=>{let s=o[a];if(typeof s==`string`&&Lh(s)){r.issues.push({path:`${i}.${a}`,message:`${i}.${a}: a rule is not allowed here — ${t} ${n}, so it names a value. Write the rule in globals.${a} (or a preset's globals.${a}) instead.`,line:K(r.source,[...i.split(`.`),a])});return}return e.parse(r,i,a,o)}}}const Ek={default_bg:"nothing reads it — a segment with no `bg:` wears the decoration tint of its place in the bar. Delete the key, and author `bg:` on the segments that need a fixed colour.",default_fg:"nothing reads it — a segment with no `fg:` wears text chosen for contrast against its background. Delete the key, and author `fg:` on the segments that need a fixed colour.",default_truncate_marker:'nothing reads it — a segment clipped to its `width:` always ends in "…". Delete the key.',look:`it was renamed "style" — write the same name as style: "<name>"`,progression:`it was renamed "variation", and its values with it: accent (was secondary-accent), duo (was primary-secondary), mono (was primary)`,charset:"the bar always draws Nerd Font glyphs. Delete the key; `cc-candybar doctor` names what your terminal's font is missing."},Dk={noun:`globals key`,fields:bk,removed:Ek},Ok={preset:Ck(`a preset`),menuGlyph:wk(`a preset`)},kk={noun:`preset globals key`,fields:{...bk,...Ok},removed:Ek};function Ak(e){return Bk(e)&&!(e in Ok)}const jk=`is decided later than any rule could be settled`,Mk={noun:`editGlobals key`,removed:Ek,fields:{...bk,preset:Ck(`the editGlobals fragment`),menuGlyph:wk(`the editGlobals fragment`),palette:Tk(bk.palette,`the editGlobals fragment`,jk),style:Tk(bk.style,`the editGlobals fragment`,jk),effect:Tk(bk.effect,`the editGlobals fragment`,jk)}},Nk={noun:`theme default key`,fields:{...Object.fromEntries(ev.map(e=>[e,bk[e]])),style:Tk(bk.style,`a theme's default`,`is the look that theme wears by name`)}};function Pk(e,t){if(!Qg(t))return e.issues.push({path:`themeDefaults`,message:`themeDefaults must be an object mapping theme names to { shade, variation, style }, got ${$g(t)}`,line:K(e.source,[`themeDefaults`])}),{};let n={};for(let[r,i]of Object.entries(t)){let t=`themeDefaults.${r}`;if(!e.allowedPalettes.has(r)){e.issues.push({path:t,message:`${t}: "${r}" is not an installed theme${Oh(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:K(e.source,[`themeDefaults`,r])});continue}let a=e_(e,Nk,t,i);a!==null&&(n[r]=a)}return n}function Fk(e,t,n){return n===void 0?{}:e_(e,Dk,t,n)??{}}function Ik(e,t,n){return e_(e,kk,t,n)??{}}function Lk(){return x_(kk)}function Rk(e,t,n){return e_(e,Mk,t,n)??{}}const zk=new Set(Object.keys(bk));function Bk(e){return zk.has(e)}function Vk(e){return Object.hasOwn(Ek,e)?Ek[e]:void 0}function Hk(){return[...zk]}const Uk=new Map(Object.entries(X_).flatMap(([e,t])=>`floor`in t&&typeof t.floor==`number`?[[e,t.floor]]:[]));function Wk(e){let t=new Map;for(let[n,r]of Uk){let i=e[n];t.set(n,typeof i==`number`?i:r)}return t}const Gk=/^segments\.([^.]+)\.palette$/,Kk=/^presets\.(.+)\.root$/,qk=/^presets\.(.+)\.globals\.([^.]+)$/,Jk=/^themeDefaults\.(.+)\.([^.]+)$/;function Yk(e){return`presets.${e}.root`}function Xk(e,t){return`themeDefaults.${e}.${t}`}const Zk=e=>ev.includes(e);function Qk(e,t){return`presets.${e}.globals.${t}`}function $k(e){if(Bk(e))return{scope:`globals`,field:e};let t=Gk.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=qk.exec(e);if(n&&Ak(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=Jk.exec(e);if(r&&Zk(r[2]))return{scope:`theme-default`,theme:r[1],field:r[2]};let i=Kk.exec(e);return i?{scope:`preset-root`,preset:i[1]}:null}function eA(e){switch(e.scope){case`globals`:return[`globals`,e.field];case`preset-globals`:return[`presets`,e.preset,`globals`,e.field];case`segment-palette`:return[`segments`,e.segment,`palette`];case`theme-default`:return[`themeDefaults`,e.theme,e.field]}}const tA=[`location`,`git`,`model-context`,`cost-limits`,`activity`,`session-tools`],nA=[...tA,`other`],rA={location:`location`,git:`git`,"model-context":`model & context`,"cost-limits":`cost & limits`,activity:`activity`,"session-tools":`session tools`,other:`other`},iA=xS({fromString:e=>e}),aA=`edit.mode`,oA=`edit.configure`,sA=`edit.toggle`,cA=`edit.unconfigure`,lA=[sA,cA],uA=`arrange`,dA=`${$O}draft.`;function fA(e,t){return`${e}:${t}`}const pA={variable:aA,key:aA,member:uA},mA=$r(pA);function hA(e){try{return iA.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function gA(e){if(Object.values(e.actions??{}).some(e=>`do`in e&&e.do.includes(`edit.toggle`)))return!0;for(let t of Object.values(e.segments??{}))for(let e of[t.template,t.bg,t.fg])if(typeof e==`string`&&hA(e))return!0;return!1}function _A(e,t){if(rk(e,t,$O,`edit mode`),!gA(t))return;let{variables:n,actions:r}=vA();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function vA(){return{variables:{[aA]:ii(aA,P),[oA]:ii(oA,P)},actions:{[sA]:ai(aA,uA),[cA]:{set:oA,to:P}}}}const yA=`open`;function bA(e,t,n,r){let i={variable:e,key:e,member:yA};return r.variables[e]=ii(e,P),r.actions[e]=ai(e,yA),r.segments[e]={template:ti(e,`(?)`,`✕`),...xA(n)},Qr(e,i,{kind:`container`,direction:`horizontal`,children:t.map((t,n)=>{let i=`${e}.${n}`;return r.segments[i]={template:t},{kind:`segment`,name:i}})},`drop`)}function xA(e){let[t,...n]=e;return t===void 0?{}:{when:$r(t,...n)}}const SA=`none`;function CA(e){return Pc(e,`background`)}var wA=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function TA(e,t,n,r,i){let{palette:a,tint:o,text:s}=e,c=EA(n,i),l=c!==SA,u=l?c===void 0?o:DA(a,c,`bg`):CA(a);e.bg=u;let d=EA(r,i),f=d===void 0?l?(e=>e.hex===o.hex?s:th(a,e,t))(u):void 0:DA(a,d,`fg`);return new H({...l&&{bgcolor:B.fromRgba(u)},...f!==void 0&&{color:B.fromRgba(f)}})}function EA(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function DA(e,t,n){try{return Pc(e,t)}catch(e){throw e instanceof Nc?new wA(t,n,e.message):e}}const OA=`🔧`,kA={help:[`-h`,`--help`],version:[`-V`,`--version`]},AA=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],jA=Object.fromEntries(AA.map(e=>[e.member,e.label])),MA={gear:{beside:`theme`,trigger:`⚙`},toggles:{beside:`updateNotice`,trigger:`🧪 toggles`}},NA=Object.keys(MA),PA=mv(e=>sv[e].place),FA=e=>Object.hasOwn(MA,e),IA=(e,t)=>e===t||FA(e)&&IA(PA[MA[e].beside],t),LA=e=>FA(e)?`${LA(PA[MA[e].beside])} › ${MA[e].trigger}`:e===`door`?`first line`:jA[e],RA=e=>LA(PA[e]),zA=()=>[`door`,...AA.map(e=>e.member)].flatMap(e=>[e,...NA.filter(t=>IA(t,e))]).map(e=>({path:LA(e),names:cv.filter(t=>PA[t]===e)})).filter(({names:e})=>e.length>0),BA=e=>`${T_[e].label} is off — turn it on in the settings menu's ${RA(T_[e].setting)}, or set globals.${T_[e].setting}: true`,VA=[...new Set(Object.values(T_).map(e=>RA(e.setting)))].join(` or `),HA=Math.max(...Object.values(sv).map(e=>e.configKey.length))+2,UA=[`✚ inserts`,`✖ removes`,`${OA} configures`,`↺ resets layout`],WA={band:[`animates the bar in the band above the prompt, through a Claude Code mod`,`on: installs the candybar-band mod from this checkout and types /reload-plugins`],statusline:[`animates the statusline itself, through the attach launcher shipped with cc-candybar`,`on: exits this Claude Code and starts it again under that launcher, on this session`,`or start one yourself: cc-candybar --help prints the line to type`],pane:[`animates the bar in a tmux pane under this session's`,`on: opens that pane · off: closes it`],tmuxStatus:[`animates the bar in the tmux status line, while this session's pane is the one it shows`,`on: the daemon draws it there · off: puts the status line back as it was`]},GA=`
77
77
  cc-candybar - Beautiful powerline statusline for Claude Code
78
78
 
79
79
  Usage: cc-candybar [options]
@@ -93,20 +93,25 @@ Configuration:
93
93
 
94
94
  Every bar carries a settings menu, whatever your config says — no config
95
95
  needed, and writing your own \`root\` cannot delete it. Click
96
- it on the bar (${Jr} by default; globals.menuGlyph changes it) for
97
- preset switching and its tabs: ${jA.session} (quick actions and commands),
98
- ${jA.look} (theme/style/variation/shade/endcaps), ${jA.layout} (new preset, edit mode,
99
- wrap, padding), ${jA.config} (update notice, ${MA.toggles.trigger}) and
100
- ${jA.tools}. A change applies to this session at once; 💾 save appears while
101
- you have unsaved changes and writes them to your config file.
96
+ it on the bar (${Jr} by default; globals.menuGlyph changes it). Beside
97
+ the settings listed below, its first line holds ◁ back, ✎ arrange (edit mode)
98
+ and 💾 save, which appears while you have unsaved changes and writes them to
99
+ your config file. Under it are its
100
+ tabs, ${AA.map(e=>e.label).join(`, `)};
101
+ ${jA.session} holds quick actions and commands, ${jA.layout} a new preset.
102
+ A change applies to this session at once.
103
+ Where each setting is in the menu: the globals field that sets it in a
104
+ config file, then the control's label.
105
+ ${zA().flatMap(({path:e,names:t})=>[` ${e}`,...t.map(e=>` ${sv[e].configKey.padEnd(HA)}${sv[e].label}`)]).join(`
106
+ `)}
102
107
  The 🧰 tools tab holds 🩺 doctor: click it to check your setup, and click a
103
108
  failed row's [fix] to repair it (the same checks \`cc-candybar doctor\` runs).
104
109
 
105
110
  Anywhere the bar shows (?), clicking it reveals these same instructions
106
- in place. In edit mode: ${VA.join(`, `)}.
111
+ in place. In edit mode: ${UA.join(`, `)}.
107
112
 
108
- Animation lanes (experimental; toggles in the settings menu's ${BA}):
109
- ${E_.map(e=>` ${T_[e].label}\n${HA[e].map(e=>` ${e}`).join(`
113
+ Animation lanes (experimental; toggles in the settings menu's ${VA}):
114
+ ${E_.map(e=>` ${T_[e].label}\n${WA[e].map(e=>` ${e}`).join(`
110
115
  `)}`).join(`
111
116
  `)}
112
117
 
@@ -140,7 +145,7 @@ Subcommands:
140
145
  ${E_.join(`, `)}:
141
146
  the experimental lane this stream serves,
142
147
  which streams only while its toggle in the settings
143
- menu's ${BA} is on.
148
+ menu's ${VA} is on.
144
149
  bar-pane PANE Draw the bar of the Claude Code session in tmux
145
150
  pane PANE (e.g. %3) in this pane, as the daemon
146
151
  pushes it, while this pane is shown. The bar is
@@ -173,16 +178,16 @@ Config tooling:
173
178
  config [--json] The effective merged config. (All three query the
174
179
  running daemon; none spawn one.)
175
180
 
176
- `,WA=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`,GA={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function KA(e){let t=e[GA.socket]??``,n=e[GA.pane]??``;if(t===``||n===``)return null;let r=e[GA.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const qA=[`moves`,`can-move`,`still`];function JA(e,t,n){return t<n+60?{kind:`unseen`,over:Math.max(0,Math.floor(t-n))}:{kind:`seen`,seconds:e.filter(e=>e>=n&&e<n+60).length}}const YA=e=>e.kind===`seen`&&e.seconds>=45,XA=e=>e.kind===`unseen`?[1,e.over]:[YA(e)?2:0,e.seconds],ZA=(e,t)=>{let[n,r]=[XA(e),XA(t)];return n[0]-r[0]||n[1]-r[1]},QA=e=>e.reduce((e,t)=>ZA(t.redraws,e.redraws)<0?t:e);function $A(e){let t=e.context_window?.current_usage;return t===null?`no`:t===void 0?`unknown`:`yes`}const ej=[`carried`,`missing`,`unanswered`];function tj(e){let t=e.rate_limits;return t?.five_hour!=null||t?.seven_day!=null?`carried`:$A(e)===`no`?`unanswered`:`missing`}function nj(e){return{path:e.transcript_path,answered:$A(e)===`yes`}}const rj=[...qA,`failed`,`drawing`],ij=[`statusline`,`frames`],aj=e=>e?.kind===`frames`?`frames`:`statusline`;var oj=class{seen=new Map;see(e,t,n,r){let i=aj(t.client),a=JSON.stringify([e,i]),o=this.seen.get(a);if(o!==void 0&&o.order>r)return;let s=Math.floor(n),c=new Set([...o?.redrawn??[],s].filter(e=>e>s-60));this.seen.delete(a),this.seen.set(a,{sessionId:e,said:{...t,role:i},at:n,order:r,since:o?.since??n,redrawn:c}),this.seen.size>64&&this.seen.delete(this.seen.keys().next().value)}list(e){return[...this.seen.values()].map(({sessionId:t,said:n,at:r,since:i,redrawn:a})=>({...n,sessionId:t,ago:e-r,since:e-i,redrawn:[...a].map(t=>Math.floor(e)-t)}))}ofSession(e,t){return this.list(t).filter(t=>t.sessionId===e)}};const sj={kitty:{label:`kitty`,xtversion:`kitty`,program:null,programVersion:!0,term:`xterm-kitty`,links:{since:`0.19.0`},glyphs:{kind:`bundled`,since:`0.36.0`}},wezterm:{label:`WezTerm`,xtversion:`WezTerm`,program:`WezTerm`,programVersion:!0,term:`wezterm`,links:{since:null},glyphs:{kind:`bundled`,since:`20230712`}},ghostty:{label:`Ghostty`,xtversion:`ghostty`,program:`ghostty`,programVersion:!0,term:`xterm-ghostty`,links:{since:null},glyphs:{kind:`bundled`,since:null}},iterm2:{label:`iTerm2`,xtversion:`iTerm2`,program:`iTerm.app`,programVersion:!0,term:null,links:{since:`3.1`},glyphs:{kind:`configured`}},alacritty:{label:`Alacritty`,xtversion:`alacritty`,program:null,programVersion:!0,term:`alacritty`,links:{since:`0.11.0`},glyphs:{kind:`configured`}},"apple-terminal":{label:`Terminal`,xtversion:null,program:`Apple_Terminal`,programVersion:!0,term:null,links:null,glyphs:{kind:`unread`}},vscode:{label:`VS Code`,xtversion:null,program:`vscode`,programVersion:!1,term:null,links:{since:`1.72`},glyphs:{kind:`unread`}}},cj=e=>sj[e];function lj(e){return cj(e).glyphs.kind===`bundled`}function uj(e){return cj(e).glyphs.kind===`configured`}const dj=e=>cj(e).label,fj=[{since:`3.5.0`,from:57504,to:57507},{since:`3.5.0`,from:57520,to:57554},{since:`3.5.0`,from:57556,to:57556},{since:`3.5.6`,from:57558,to:57559}];function pj(e,t){let n=t.codePointAt(0);return fj.some(({since:t,from:r,to:i})=>r<=n&&n<=i&&e!==null&&gj(e,t)===!0)}const mj=Object.keys(sj);function hj(e){let t=/^\d+(?:\.\d+)*/.exec(e);return t===null?null:t[0].split(`.`).map(Number)}function gj(e,t){let n=hj(e),r=hj(t);if(n===null)return null;for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]??0,i=r[e]??0;if(t!==i)return t>i}return!0}function _j(e){for(let t of mj){let n=cj(t).xtversion;if(n!==null&&e.toLowerCase().startsWith(n.toLowerCase())){let r=e.slice(n.length).replace(/^[\s(]+/,``);return{name:t,version:/^[^\s)]+/.exec(r)?.[0]??null}}}return null}function vj(e){let t=mj.find(t=>cj(t).term===e);return t===void 0?null:{name:t,version:null}}function yj(e){let t=_j(e.termtype)??vj(e.termname);if(t!==null)return{kind:`known`,terminal:t};let n=/^[^\s(]*/.exec(e.termtype)[0];return n===``?{kind:`unnamed`,term:e.termname}:{kind:`unknown`,called:n}}function bj(e){let t=e.TERM_PROGRAM,n=mj.find(e=>cj(e).program===t),r=n===void 0?vj(e.TERM):{name:n,version:cj(n).programVersion?e.TERM_PROGRAM_VERSION??null:null};return r===null?t===void 0||t===`tmux`?{kind:`unnamed`,term:e.TERM??``}:{kind:`unknown`,called:t}:{kind:`known`,terminal:r}}function xj(e){switch(e.kind){case`known`:return dj(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||null}}function Sj(e){switch(e.kind){case`known`:return dj(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||`this terminal`}}function Cj({name:e,version:t}){let n=cj(e).links;if(n===null)return{kind:`none`};if(n.since===null)return{kind:`draws`};if(t===null)return{kind:`unsaid`,since:n.since};let r=gj(t,n.since);return r===null?{kind:`unsaid`,since:n.since}:r?{kind:`draws`}:{kind:`older`,since:n.since,version:t}}const wj=mj.filter(e=>cj(e).links!==null).map(dj).join(`, `);function Tj(e){if(e.kind===`failed`)return{kind:`unread`,reason:e.reason};let t=e.value.flatMap(({scope:e,path:t,settings:n})=>`statusLine`in n?[{from:{scope:e,path:t},line:n.statusLine}]:[]),n=t[0];if(n===void 0)return{kind:`absent`,read:e.value.map(e=>e.path)};if(!Na(n.line))return{kind:`not-an-object`,value:n.line,from:n.from};for(let{from:e,line:r}of t){if(e.scope!==n.from.scope||!Na(r))break;if(`refreshInterval`in r)return{kind:`present`,refreshInterval:r.refreshInterval,from:e}}return{kind:`present`,refreshInterval:void 0,from:n.from}}function Ej(e,t){if(e.kind===`failed`)return e;let n=e.value.find(e=>Object.hasOwn(e.env,t));return{kind:`ok`,value:n===void 0?{kind:`unset`}:{kind:`set`,value:n.env[t],from:{scope:n.scope,path:n.path}}}}const Dj=[`managed`,`project`],Oj=e=>!Dj.includes(e.scope),kj={managed:()=>null,"project-local":e=>({scope:`project-local`,path:e}),project:(e,t)=>({scope:`project-local`,path:Aa(t.projectDir)}),user:e=>({scope:`user`,path:e})},Aj=[`drawn`,`boxes`],jj=1024*1024,Mj=e=>e.kind===`session`?`session ${e.sessionId}'s statusline client`:`this command's terminal`;function Nj(e){switch(e.kind){case`claude-settings`:return`${e.kind} ${e.path.join(`.`)}=${JSON.stringify(e.value)} file=${JSON.stringify(e.file.path)} scope=${e.file.scope}`;case`post-mortems-read`:return`${e.kind} through=${e.through}`}}function Pj(e){let[t,...n]=e;return t===void 0?{ok:!0}:{ok:!1,reason:t,more:n}}const Fj=GA.truecolor;function Ij(e,t){switch(e.kind){case`unreported`:return{ok:!1,reason:"the client reported no tmux facts — re-run `cc-candybar install` to stage a current client"};case`outside`:return{ok:!0};case`inside`:return e.client.kind===`failed`?{ok:!1,reason:`tmux could not be asked: ${e.client.reason}`}:e.client.value===null?{ok:!0}:t(e.client.value,e.hint)}}const Lj={name:`tmuxTruecolor`,label:`tmux truecolor`,takesMark:!1,probe:({tmux:e,claudeSettings:{origin:t}})=>Ij(e,(e,n)=>{if(!e.features.includes(`RGB`)||n.truecolor!==null)return{ok:!0};let r=Ej(t.sources,Fj);if(r.kind===`failed`)return{ok:!1,reason:r.reason};let i=r.value;if(i.kind===`set`&&typeof i.value==`string`&&i.value!==``)return{ok:!1,reason:`${Fj} is set in ${i.from.path} — restart Claude Code to apply`};let a=`Claude Code renders the bar in 256 colours inside tmux`,o=e=>({ok:!1,reason:a,fix:{kind:`claude-settings`,file:e,path:[`env`,Fj],value:`1`}});if(i.kind===`unset`)return o({scope:`user`,path:t.at.userFile});let s=kj[i.from.scope](i.from.path,t.at);return s===null?{ok:!1,reason:`${a} — the value that counts is in managed settings, ${i.from.path}: set ${Fj} to "1" there`}:o(s)})},Rj={name:`utf8`,label:`UTF-8`,takesMark:!1,probe:({tmux:e})=>Ij(e,e=>e.utf8?{ok:!0}:{ok:!1,reason:"tmux draws this terminal without UTF-8, so every glyph on the bar arrives as `_` — attach with `tmux -u`, or set a UTF-8 LC_ALL/LC_CTYPE/LANG in the shell that runs tmux"})},zj={name:`termWidth`,label:`terminal width`,takesMark:!1,probe:({width:e})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.columns===null?{ok:!1,reason:`${Mj(e.value.of)} measured no width (no COLUMNS, and no terminal to ask — or the daemon refused the width sent, which the bar's red strip names), so the bar is laid out as if the terminal were 120 columns wide`}:{ok:!0,note:`${e.value.columns} columns, as ${Mj(e.value.of)} measured`}},Bj={variable:`is never read`,action:`is never clicked`,helper:`is never called`,segment:`is in no preset`},Vj={name:`config`,label:`config`,takesMark:!1,probe:({config:e})=>{switch(e.kind){case`failed`:{let[t=`the config failed to load`,...n]=[...e.error.split(`
177
- `).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return Pj([...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${Bj[e]}`)])}}},Hj="re-run `cc-candybar install`";function Uj(e){if(e.kind===`failed`)return[`Launch Services could not be asked which app opens cc-candybar:// — ${e.reason}`];if(e.value===null)return[`no app is registered for cc-candybar:// — ${Hj}`];let{app:t,missing:n}=e.value;return n.kind===`failed`?[`${t} opens cc-candybar://, but ${n.reason} — ${Hj}`]:n.value.map(e=>`${e} is missing, and ${t} runs it — ${Hj}`)}const Wj={name:`urlHandler`,label:`URL handler`,takesMark:!1,probe:({urlHandler:e})=>{switch(e.kind){case`unsupported`:return{ok:!0};case`unprobed`:return{ok:!1,reason:e.reason};case`arrived`:return e.handler===e.bar?{ok:!0}:{ok:!1,reason:e.handler===null?`the URL handler does not report its version, so it is older than the bar (${e.bar}) — ${Hj}`:`the URL handler runs cc-candybar ${e.handler}; the bar runs ${e.bar} — ${Hj}`};case`lost`:return Pj([...Uj(e.opener),e.unopened===null?`a cc-candybar:// link was opened and did not arrive at the daemon`:`a cc-candybar:// link could not be opened — ${e.unopened}`])}}};function Gj({bundle:e,checkout:t},n){return{bundle:n.bundle.kind===`failed`?{kind:`unresolved`,reason:n.bundle.reason}:n.bundle.value===e?{kind:`same`}:{kind:`other`,path:n.bundle.value},source:n.client!==`native`||t===null?{kind:`uncompared`}:t.rustSource.kind===`failed`?{kind:`unreadable`,root:t.root,reason:t.rustSource.reason}:n.source===null?{kind:`unstamped`}:n.source===t.rustSource.value?{kind:`same`}:{kind:`other`,root:t.root}}}function Kj(e,t){return t===`frames`?`run \`node ${e.bundle} frames --lane <${E_.join(`|`)}>\``:e.checkout===null?Hj:`run \`just install-rust\` and point the statusLine command at ${e.checkout.root}/bin/cc-candybar-native`}function qj(e,t,n){let{checkout:r}=e;if(n.kind===`unreported`)return[`the bar is drawn by a statusline client too old to say what it is — ${Kj(e,`native`)}`];let{bundle:i,source:a}=Gj(e,n);switch(i.kind){case`unresolved`:return[`the statusline client's bundle cannot be resolved: ${i.reason}`];case`other`:return[`the statusline client runs ${i.path}, not the daemon's ${e.bundle} — ${Kj(e,n.client)}`];case`same`:break}if(n.client===`node`&&(t||r!==null))return[`the bar is drawn by the Node fallback, which starts node on every render — ${Kj(e,`native`)}`];switch(a.kind){case`uncompared`:case`same`:return[];case`unreadable`:return[`${a.root}/rust-client could not be read: ${a.reason}`];case`unstamped`:return["the native client carries no source stamp, so which source it was built from is unknown — run `just install-rust`"];case`other`:return[`the native client was built from other source than ${a.root}/rust-client holds — run \`just install-rust\``]}}const Jj=e=>{let t=`restarted since the bar was drawn, or has served 64 newer sessions`;return e.kind===`clicked`?`this daemon holds no render of this bar (it ${t})`:`this daemon holds no render of session ${e.sessionId}'s bar (its statusLine does not run cc-candybar — a \`claude -p\` session draws none — or the daemon ${t}; unset CLAUDE_CODE_SESSION_ID to judge every bar drawn recently)`},Yj={name:`install`,label:`install`,takesMark:!1,probe:({install:e,sighted:t})=>{if(e.kind===`failed`)return{ok:!1,reason:`the daemon could not be asked which clients draw the bar: ${e.reason}`};let{daemon:n,nativeShipped:r,clients:i}=e.value;return i.length===0?{ok:!1,reason:t.kind===`recent`?`no statusline client has drawn a bar for this daemon in the last ${300/60} minutes — run the doctor again once the bar has redrawn; if it never does, the statusLine command does not run cc-candybar`:`${Jj(t)}, so which client draws it is unknown — run the doctor again once the bar has redrawn`}:Pj([...new Set(i.flatMap(e=>qj(n,r,e)))])}};function Xj({postMortems:e},t){return e.kind===`ok`&&t.kind===`ok`?e.value.filter(e=>t.value.through===null||In(e.identity,t.value.through)):[]}function Zj(e,t){return e.kind===`failed`?t:t.filter(t=>t.pid!==e.value.pid)}const Qj={name:`daemon`,label:`daemon`,takesMark:!1,probe:({daemon:{serving:e,processes:t,read:n}})=>{let r=t.kind===`failed`?[`the process table could not be read: ${t.reason}`]:[],i=t.kind===`ok`?Zj(e,t.value):[];if(e.kind===`failed`){let t=i.length>0?` — daemon ${i.map(e=>e.pid).join(`, `)} running`:``;return Pj([`${e.reason}${t}`,...r])}let{pid:a,memory:o,limit:s,postMortems:c}=e.value,l=Xj(e.value,n),u=Pj([...l.map(e=>`the daemon ran out of memory and restarted (${e.identity}) — post-mortem: ${Object.values(e.artifacts).join(`, `)}`),...c.kind===`failed`?[`the daemon's post-mortems could not be listed: ${c.reason}`]:[],...n.kind===`failed`&&!(c.kind===`ok`&&c.value.length===0)?[`which post-mortems were read could not be read: ${n.reason}`]:[],...r,...i.map(e=>`daemon ${e.pid} (started ${e.started}, rss ${Nn(e.rss)} MB${e.ppid===1?``:`, child of ${e.ppid}`}) runs beside the one serving the bar (${a}) — \`kill ${e.pid}\``),...o.kind===`measured`&&o.charge.kind===`stand-in`?[`the daemon could not read what macOS charges it (${o.charge.unread}), so its memory limit judges ${o.charge.gap===0?`RSS, which counts pages macOS has reclaimed`:`RSS less the ${Nn(o.charge.gap)} MB it last ran over that charge, an estimate`}`]:[],...o.kind===`measured`&&Rn(o.charge.bytes,s)?[`the daemon holds ${Hn(o.charge)} of its ${Nn(s)} MB limit — at the limit it records a post-mortem and restarts`]:[]]);if(u.ok&&o.kind===`unmeasured`)return{ok:!0,note:`the daemon has not measured its memory yet`};let d=l[0];return u.ok||d===void 0?u:{...u,fix:{kind:`post-mortems-read`,through:d.identity}}}},$j=`click 🩺 doctor in the bar's settings menu: if it runs, links work`;function eM(e,t){let n=xj(e);return t.kind===`ok`&&n!==null&&t.value.includes(n)?{kind:`draws`}:e.kind===`known`?Cj(e.terminal):{kind:`unknown`}}function tM({identified:e,tmuxClient:t},n){let r=Sj(e),i=eM(e,n),a=xj(e)===null?$j:`${$j}, and the doctor remembers it for this terminal`,o=(()=>{switch(i.kind){case`draws`:return[];case`none`:return[`${r} draws no links (OSC 8), so nothing on the bar can be clicked — run Claude Code in a terminal that draws them: ${wj}`];case`older`:return[`${r} ${i.version} draws no links (OSC 8 came in ${i.since}) — update ${r}`];case`unsaid`:return[`${r} draws links (OSC 8) since ${i.since}, and did not say which release this is — ${a}`];case`unknown`:return[`the doctor does not know whether ${r} draws links (OSC 8) — ${a}`]}})(),s=n.kind===`failed`&&i.kind!==`draws`?[`the terminals a doctor click came back from could not be read: ${n.reason}`]:[],c=i.kind===`none`||t===null||t.features.includes(`hyperlinks`)?[]:[`tmux does not pass links through to ${r} — add \`set -as terminal-features ",${t.termname}:hyperlinks"\` to tmux.conf, then detach and reattach (tmux 3.4 or later)`];return[...o,...s,...c]}const nM={name:`links`,label:`links`,takesMark:!1,probe:({sighted:e,terminal:t,clicked:n})=>{if(e.kind===`clicked`&&e.via===`link`)return{ok:!0};switch(t.kind){case`unreported`:return{ok:!1,reason:"the client reported no terminal — re-run `cc-candybar install` to stage a current client"};case`unasked`:return{ok:!1,reason:`tmux could not be asked which terminal is attached: ${t.reason}`};case`seen`:return Pj(tM(t,n))}}},rM=e=>e.filter(e=>e.role===`statusline`),iM={name:`effectRefresh`,label:`effect refresh`,takesMark:!1,probe:({frames:e,claudeSettings:{origin:t,elsewhere:n},sighted:r})=>{if(e.kind===`failed`)return{ok:!1,reason:e.reason};let i=[t,...n],[a,...o]=i.flatMap(({sources:e,bars:t})=>{let[n,...r]=rM(t).filter(e=>e.frame===`moves`||e.frame===`can-move`);if(n===void 0)return[];let i=QA([n,...r]);return[{redraws:i.redraws,verdict:aM(e,i)}]}).sort((e,t)=>ZA(e.redraws,t.redraws));if(a===void 0){let e=i.flatMap(e=>e.bars),t=rM(e);return t.some(e=>e.frame===`still`)?{ok:!0}:{ok:!1,reason:`${t.length>0?t.some(e=>e.frame===`drawing`)?`the bar's latest render has not finished`:`the bar's recent renders failed`:e.length>0?"only a `cc-candybar frames` display has drawn this bar, not Claude Code's statusline":r.kind===`recent`?`no session has drawn a statusline for this daemon in the last ${300/60} minutes`:Jj(r)}, so whether it moves is unknown — run the doctor again once the bar has redrawn`}}let[s,...c]=[a,...o].flatMap(({verdict:e})=>e.ok?[]:[e]);if(s===void 0)return a.verdict;let l=[...new Set(c.map(e=>e.reason))].filter(e=>e!==s.reason);return l.length===0?s:{...s,more:l}}};function aM(e,t){let n=t.frame===`moves`?`the bar moves (an effect, a fade, or an animated segment)`:`the bar can start moving (a globals.effect rule, placements that fade in and out, or a placement with an effect of its own that is not drawn now)`,r=Tj(e);if(r.kind===`present`&&r.refreshInterval!==1){let{from:e,refreshInterval:t}=r,i=t===void 0?`its statusLine sets no refreshInterval, so Claude Code redraws it only on events`:typeof t==`number`&&t>1?`its statusLine redraws it only every ${t} s`:`its statusLine.refreshInterval is ${JSON.stringify(t)}, not a number of seconds Claude Code accepts (its minimum is 1)`;return Oj(e)?{ok:!1,reason:`${n}, but ${i} (statusLine from ${e.path})`,fix:{kind:`claude-settings`,file:e,path:[`statusLine`,`refreshInterval`],value:1}}:{ok:!1,reason:`${n}, but ${i} — its statusLine is in ${e.scope===`managed`?`managed settings`:`the project's shared settings`}, ${e.path}: set "refreshInterval": 1 there`}}let{redraws:i}=t;if(i.kind===`unseen`)return{ok:!1,reason:`${n}, and this daemon has watched Claude Code redraw it for only ${i.over} of the 60 seconds its redraw rate is judged over, so whether it is redrawn every second is unknown — run the doctor again once the bar has been on screen for a minute`};if(YA(i))return{ok:!0,note:`Claude Code redrew the bar in ${i.seconds} of the last 60 seconds`};let a=`${n}, but Claude Code redrew it in only ${i.seconds} of the last 60 seconds`,o=`a statusLine from --settings, MDM or server-managed settings, which the doctor cannot read, runs the bar; set "refreshInterval": 1 beside its command there`;switch(r.kind){case`unread`:return{ok:!1,reason:`${a}, and Claude Code's settings could not be read: ${r.reason}`};case`absent`:return{ok:!1,reason:`${a}, and no settings file Claude Code reads here sets a statusLine (read: ${r.read.join(`, `)||`none`}) — ${o}`};case`not-an-object`:return{ok:!1,reason:`${a}, and ${r.from.path} sets statusLine to ${JSON.stringify(r.value)}, not a statusLine object — ${r.from.scope===`user`?"re-run `cc-candybar install` to write one":`replace it there with the statusLine object that runs cc-candybar`}`};case`present`:return{ok:!1,reason:`${a}, though ${r.from.path} sets statusLine.refreshInterval to 1 — set within the last minute, it shows once Claude Code has redrawn the bar for one (restart Claude Code if it does not); otherwise ${o}`}}}const oM=e=>[...e].map(e=>`U+${e.codePointAt(0).toString(16).toUpperCase()}`).join(` `);function sM(e){switch(e.kind){case`unreported`:case`unasked`:return`this terminal`;case`unknown`:case`unnamed`:return Sj(e);case`bundling`:case`unread`:case`configured`:return[dj(e.name),e.version].filter(e=>e!==null).join(` `)}}function cM(e){switch(e.kind){case`unreported`:case`unasked`:return null;case`unknown`:case`unnamed`:return xj(e);case`bundling`:case`unread`:return dj(e.name);case`configured`:{let t=dj(e.name);return e.font.kind===`ok`?`${t} with ${e.font.value.font} (${e.font.value.from})`:`${t}, its font unread: ${e.font.reason}`}}}function lM(e){let t=cM(e.terminal);return t===null?void 0:{glyphs:e.glyphs,id:`${t}|${oM(e.glyphs)}`}}const uM={name:`nerdFont`,label:`Nerd Font`,takesMark:!0,probe:({nerdFont:e,marks:t})=>{if(e.kind===`none`)return{ok:!0};let n=lM(e),r=e=>t.kind===`failed`&&n!==void 0?{ok:!1,reason:e,more:[`the mark book could not be read: ${t.reason}`]}:{ok:!1,reason:e,...n!==void 0&&{sighting:n}},i=e.terminal,a=sM(i);switch(n===void 0||t.kind===`failed`?null:t.value.nerdFont?.[n.id]??null){case`drawn`:return{ok:!0};case`boxes`:return r(`${a} draws ${oM(e.glyphs)} as boxes — set a Nerd Font as its font`);case null:break}switch(i.kind){case`unreported`:return r("the client reported no terminal — re-run `cc-candybar install` to stage a current client");case`unasked`:return r(`tmux could not be asked which terminal is attached: ${i.reason}`);case`unknown`:case`unnamed`:case`unread`:return r(`the doctor cannot read ${a}'s font`);case`bundling`:{let e=sj[i.name].glyphs.since;if(e===null)return{ok:!0};let t=i.version===null?null:gj(i.version,e);if(t===!0)return{ok:!0};let n=dj(i.name);return r(t===null?`${n} ships Nerd Font symbols since ${e}, and did not say which release this is`:`${a} ships no Nerd Font symbols (they came in ${e}) — update ${n}, or set a Nerd Font as its font`)}case`configured`:{if(i.font.kind===`failed`)return r(`the doctor cannot read ${a}'s font: ${i.font.reason}`);let{font:e,from:t,lacks:n}=i.font.value;return n===null?r(`${a} is set to ${e} (${t}), which is not installed — install it or set a Nerd Font`):n.length===0?{ok:!0}:r(`${a} draws with ${e} (${t}), which has no ${oM(n)} — set a Nerd Font as its font`)}}}};function dM(e){return e.join(`, `)}function fM(e){return`or set missingData: "ignore" on ${dM(e)}`}function pM(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;if(n.kind===`failed`)return[`${dM(t)}: whether the forge CLI is ready could not be asked: ${n.reason}`];if(n.value===null)return[];let{cli:r,host:i,status:a}=n.value;return a===`ready`?[]:a===`missing`?[`${dM(t)}: ${r} is not installed, so no pull request is ever shown — install it, ${fM(t)}`]:[`${dM(t)}: ${r} is not logged in to ${i} (${a.loggedOut}) — run \`${r} auth login --hostname ${i}\`, ${fM(t)}`]}function mM(e,t){if(e.kind===`unneeded`)return[];let{segments:n,fact:r}=e;return r.kind===`failed`?[`${dM(n)}: ${r.reason}`]:r.value.length===0?[t.kind===`recent`?`${dM(n)}: no session of this Claude Code has drawn a bar for this daemon in the last ${300/60} minutes, so whether it sends rate_limits is unseen — run the doctor again once the bar has redrawn`:`${dM(n)}: ${Jj(t)}, so whether Claude Code sends rate_limits is unseen — run the doctor again once the bar has redrawn`]:r.value.includes(`missing`)&&!r.value.includes(`carried`)?[`${dM(n)}: Claude Code sent no rate_limits — it sends them only to Claude.ai subscription sessions; on any other account, set missingData: "ignore" on ${dM(n)}`]:[]}function hM(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;switch(n.located.kind){case`ok`:return[];case`absent`:return[`${dM(t)}: memento is not installed (or is disabled) for ${n.claudeConfigDir} — install the memento plugin, ${fM(t)}`];case`failed`:return[`${dM(t)}: whether memento is installed could not be read: ${n.located.reason}`]}}const gM={name:`segmentData`,label:`segment data`,takesMark:!1,probe:({data:e,sighted:t})=>Pj([...pM(e.pullRequests),...mM(e.rateLimits,t),...hM(e.memento)])};function _M({path:e,answered:t,read:n}){switch(n.kind){case`absent`:return t?[`the transcript ${e} does not exist, though Claude Code has answered in its session — the bar's session cost, metrics and activity read nothing`]:[];case`failed`:return[`the transcript ${e} cannot be read: ${n.reason}`];case`ok`:{let{lines:t,unparsed:r,whole:i}=n.value;return r===0?[]:[`${r} of the ${t} lines ${i?`in`:`in the last ${jj/1024/1024} MiB of`} the transcript ${e} are not JSON objects — the bar skips them, so what it counts from them is missing`]}}}const vM=[Vj,Yj,Qj,Wj,nM,Lj,Rj,zj,iM,uM,gM,{name:`sessionData`,label:`session data`,takesMark:!1,probe:({transcripts:e,sighted:t})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.length===0?{ok:!1,reason:t.kind===`recent`?`no session has drawn a bar for this daemon in the last ${300/60} minutes, so no transcript was named — run the doctor again once the bar has redrawn`:`${Jj(t)}, so which transcript it reads is unknown — run the doctor again once the bar has redrawn`}:Pj(e.value.flatMap(_M))}],yM=vM.filter(e=>e.takesMark);function bM(e){return vM.map(t=>({check:t,verdict:t.probe(e)}))}function xM(e){return vM.find(t=>t.name===e)}const SM=/^[^\s"=\\]+$/,CM=e=>SM.test(e)?e:JSON.stringify(e),wM=`${X}doctor.`;function TM(e){let t=`${wM}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`,sighting:`${t}sighting`}}function EM(e,t){let n=e.kind===`seen`?e.tmuxClient:null,r=e.kind===`seen`?xj(e.identified):null,i=t.kind===`failed`?`unread`:r===null?`-`:t.value.includes(r)?`yes`:`no`;return`tmuxLinks=${n===null?`-`:n.features.includes(`hyperlinks`)?`yes`:`no`} clicked=${i}`}function DM(e,t){let n=e.kind===`seen`?e.tmuxClient:null;return`cols=${t.kind===`failed`?`failed widthOf=-`:`${t.value.columns??`-`} widthOf=${t.value.of.kind}`} clientUtf8=${n===null?`-`:n.utf8?`yes`:`no`}`}function OM(e){if(e.kind===`failed`)return`clients=unasked`;let{daemon:t,clients:n}=e.value;return`clients=${n.map(e=>{if(e.kind===`unreported`)return`unreported/-/-`;let{bundle:n,source:r}=Gj(t,e);return`${e.client}/${n.kind}/${r.kind===`uncompared`?`-`:r.kind}`}).join(`,`)||`-`}`}const kM=e=>`${e>=0?`+`:``}${Nn(e)}`;function AM({serving:e,processes:t,read:n}){let r=t.kind===`failed`?`daemons=unread others=-`:`daemons=${t.value.length} others=${Zj(e,t.value).map(e=>e.pid).join(`,`)||`-`}`;if(e.kind===`failed`)return`${r} memory=unasked postMortems=unasked`;let{memory:i,limit:a,postMortems:o}=e.value,s=o.kind===`failed`||n.kind===`failed`?`unread`:`${Xj(e.value,n).length}/${o.value.length}`;return`${r} memory=${i.kind===`unmeasured`?`unmeasured`:`${Un(i.charge)}${i.charge.kind===`stand-in`?`(${kM(-i.charge.gap)})`:``}:${Nn(i.charge.bytes)}`}/${Nn(a)} postMortems=${s}`}function jM(e){let t=()=>{if(e.pullRequests.kind===`unneeded`)return`-`;let t=e.pullRequests.fact;if(t.kind===`failed`)return`failed`;if(t.value===null)return`no-forge`;let{status:n}=t.value;return typeof n==`string`?n:`logged-out`},n=()=>{if(e.rateLimits.kind===`unneeded`)return`-`;let t=e.rateLimits.fact;if(t.kind===`failed`)return`failed`;let n=e=>t.value.filter(t=>t===e).length;return`${n(`carried`)}/${n(`missing`)}/${n(`unanswered`)}`},r=e.memento.kind===`unneeded`?`-`:e.memento.fact.located.kind===`ok`?`located`:e.memento.fact.located.kind;return`data=pr:${t()},rateLimits:${n()},memento:${r}`}function MM(e,{origin:t,elsewhere:n}){let r=[t,...n],i=r.map(({sources:e})=>NM(e)).join(`,`);if(e.kind===`failed`)return`frames=failed redrawn=failed chains=${CM(i)}`;let a=rM(r.flatMap(e=>e.bars)),o=e=>a.filter(t=>t.frame===e).length,s=a.map(({redraws:e})=>e.kind===`seen`?`${e.seconds}`:`unseen(${e.over})`);return`frames=${rj.map(o).join(`/`)} redrawn=${s.join(`,`)||`-`} chains=${CM(i)}`}function NM(e){let t=Tj(e);switch(t.kind){case`unread`:return`failed`;case`absent`:case`not-an-object`:return t.kind;case`present`:return`${t.from.scope}:${t.refreshInterval===void 0?`-`:JSON.stringify(t.refreshInterval)}`}}function PM(e){let t=Ej(e,Fj);return t.kind===`failed`?`truecolorEnv=failed`:t.value.kind===`unset`?`truecolorEnv=unset`:`truecolorEnv=${CM(`${t.value.from.scope}:${JSON.stringify(t.value.value)}`)}`}function FM(e){if(e.kind===`failed`)return`transcripts=failed`;let t=t=>e.value.filter(e=>e.read.kind===t).length,n=e.value.reduce((e,t)=>e+(t.read.kind===`ok`?t.read.value.unparsed:0),0);return`transcripts=${t(`ok`)}/${t(`absent`)}/${t(`failed`)} unparsed=${n}`}function IM(e,t){if(e.kind===`none`)return`glyphs=- terminal=- font=- mark=-`;let{glyphs:n,terminal:r}=e,i=[...n].map(e=>e.codePointAt(0).toString(16)),a=(()=>{switch(r.kind){case`unreported`:case`unasked`:return r.kind;case`unknown`:return`unknown:${JSON.stringify(r.called)}`;case`unnamed`:return`unnamed:${JSON.stringify(r.term)}`;case`bundling`:case`unread`:case`configured`:return`${r.name}@${r.version??`-`}`}})(),o=(()=>{if(r.kind!==`configured`)return`-`;if(r.font.kind===`failed`)return`failed`;let{font:e,lacks:t}=r.font.value;return`${JSON.stringify(e)}:${t===null?`not-installed`:`lacks${t.length}`}`})(),s=lM(e),c=t.kind===`failed`?`unread`:s===void 0?`-`:t.value.nerdFont?.[s.id]??`-`;return`glyphs=${i.join(`,`)} terminal=${a} font=${o} mark=${c}`}function LM(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function RM(e){return e.flatMap(({check:e,verdict:t})=>{let n=TM(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:t.note??``},{key:n.fixable,value:og},{key:n.sighting,value:``}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:LM(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?og:ag},{key:n.sighting,value:t.sighting?.glyphs??``}]})}const zM={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function BM(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }}{{ if ne .resume_command "" }} {{ action "${t(`copyResume`)}" "⎘ resume" }}{{ end }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}{{ if ne .config_path "" }} {{ action "${t(`openConfig`)}" "↗ config" }}{{ end }}`,actions:Object.fromEntries(Object.entries(zM).map(([t,n])=>[`${e}${t}`,n]))}}const VM=`armed`,HM=`disarmed`,UM=`.armed`,WM=e=>e.endsWith(UM);function GM(e,t,n){let r=`${e}${UM}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${VM}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:VM},[a]:{set:r,to:HM},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:HM}},disarm:a}}const KM=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function qM(e){return typeof e==`string`&&KM.test(e)?{kind:`line`,line:e}:{kind:`refused`,reason:`a slash command is "/" then its name, e.g. "/compact" or "/model opus", on one line with no control characters, got ${JSON.stringify(e)}`}}function JM(e){let t=qM(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const YM=[`/compact`,`/model`],XM=`/clear`;function ZM(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=GM(`${e}clear`,{arm:XM,confirm:`${XM} ✓ confirm`},[n]);return{template:YM.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${qO} }}`,actions:{...Object.fromEntries(YM.map(e=>[t(e),{slash:JM(e)}])),...r.actions,[n]:{slash:JM(XM)}},variables:r.variables,disarm:r.disarm}}const QM=Array.from({length:10},(e,t)=>(t+1)*1e5),$M=QM[0],eN=QM[QM.length-1];function tN(e){let t;try{t=Da(e)}catch(e){return L(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?F(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=$M&&n<=eN?F(n):L(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${$M}–${eN} tokens)`)}function nN(e,t){let n=Math.min(t??eN,eN),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:QM.filter(e=>e<r).at(-1)??0,higher:QM.find(e=>e>r&&e<=n)??0}}function rN(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${qO} }}{{ if gt .autocompact.lower 0 }} {{ action (printf "${e}%d" .autocompact.lower) "−" }}{{ end }}{{ if gt .autocompact.higher 0 }} {{ action (printf "${e}%d" .autocompact.higher) "+" }}{{ end }}{{ if gt .autocompact.window 0 }} {{ action "${e}auto" "↺" }}{{ end }}{{ end }}{{ end }}`,bg:`{{ if ne .autocompact.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .autocompact.window 0) (ne .autocompact.error "") }}`,actions:{[`${e}auto`]:{slash:JM(`/autocompact auto`)},...Object.fromEntries(QM.map(t=>[`${e}${t}`,{slash:JM(`/autocompact ${t}`)}]))}}}const iN=e=>`{{ if ge ${e} 1000000 }}{{ printf "%.1f" (divf ${e} 1000000) }}M{{ else if ge ${e} 1000 }}{{ printf "%.1f" (divf ${e} 1000) }}K{{ else }}{{ ${e} }}{{ end }}`,aN=`${X}menu`,oN=`open`,sN=`${X}edit`,cN=`${X}toolbar`,lN=BM(X),uN=`${X}commands`,dN=ZM(`${uN}.`),fN=`${X}autocompact`,pN=rN(`${fN}.`,iN),mN=e=>({kind:`segment`,name:e}),hN=`${X}tab`,gN=e=>`${hN}.${e}`,_N=e=>`${gN(e)}.toggle`,vN=e=>({variable:hN,key:hN,member:e}),yN=`${X}save`,bN=`${X}preset.save`,xN=`${X}preset.delete`,SN=e=>`${X}${e}`,CN=e=>`${X}apply.${e}`,wN=e=>`${X}reset.${e}`,TN=`${X}themeDefault.save`,EN=`${X}themeDefault.differs`,DN=`${X}themeDefault.theme`,ON={when:`{{ .${EN} }}`,template:`{{ action "${TN}" (printf "⤓ default for %s" .${DN}) }} {{ swatch "${CN(`theme`)}" .${DN} }}`},kN=`${X}resetAll`,AN=`${aN}.toggle`,jN={variable:aN,key:aN,member:oN},MN=`${X}undo`,NN=`${X}back`,PN=`${NN}.step`,FN=`${X}navigation.back`,IN=NN,LN={template:`{{ if gt .${FN} 0 }}{{ action "${NN}" "◁" }}{{ else }}{{ fg (${WA}) "◁" }}{{ end }}`},RN=`${X}redo`,zN=`${X}doctor`,BN=`${zN}.run`,VN=e=>`${zN}.fix.${e}`,HN=(e,t)=>`${zN}.mark.${e}.${t}`,UN=e=>`${zN}.${e}`,WN={drawn:`[✓ shapes]`,boxes:`[✗ boxes]`},GN=ok(`${X}pickers`),KN=e=>`${X}${e}`,qN=e=>`${KN(e)}.toggle`,JN=e=>FA(e)?ok(`${X}${e}Pickers`):GN,YN=e=>{let t=JN(PA[MA[e].beside]);return{variable:t,key:t,member:e}},XN={layout:{template:`{{ layoutPreview }}`},palette:{template:`{{ themePreview }}`},presetDelete:{when:`{{ not .preset.bundled }}`,template:`{{ action "${xN}" (printf "🚮 delete %s" .${sv.preset.effectiveVar}) }}`}},ZN=(e,t)=>`${X}list.${e}.${t}`,QN=e=>`${X}resettable.${e}`,$N=e=>e.length===0?`false`:`(or ${e.map(e=>`.${QN(e)}`).join(` `)})`,eP=E_.map(e=>[T_[e].setting,e]),tP={variables:{},actions:{},segments:{}},nP=Object.fromEntries(eP.map(([e,t])=>[e,bA(`${X}help.${e}`,HA[t],[],tP)])),rP=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],iP=e=>{let t=t=>`.${A_(e,t)}`,n=rP.map(e=>`${1/30} "${e}"`).join(` `);return`{{ if .${sv[T_[e].setting].effectiveVar} }} {{ if ${t(`subscribers`)} }}{{ frames ${n} }} {{ ${t(`fps`)} }} fps{{ if not ${t(`shown`)} }} · off screen{{ end }}{{ else }}no subscriber{{ end }}{{ end }}`},aP=`{{ if eq .${O_(`by`)} "feed" }} {{ printf "%2d" (int .${O_(`fps`)}) }} fps{{ end }}`,oP=Object.fromEntries(eP.map(([e,t])=>[e,iP(t)])),sP=Object.keys(sv).map(e=>{let t=sv[e],n=xk(t.configKey),r=vk({label:t.label,domain:n},t.sessionKey,t.effectiveVar,CN(e),JN(PA[e]));return{...t,name:e,control:r,beneath:t.previews.map(e=>XN[e])}}),cP=e=>sP.filter(t=>PA[t.name]===e),lP=e=>sP.filter(t=>IA(PA[t.name])===e),uP=e=>NA.filter(t=>MA[t].beside===e),dP=e=>cP(e).flatMap(e=>[CP(e),...[nP[e.name]].filter(e=>e!==void 0),...uP(e.name).map(e=>Qr(KN(e),YN(e),{kind:`container`,direction:`horizontal`,children:dP(e)},`drop`))]);new Set(sP.flatMap(e=>[e.sessionKey,e.configKey]));const fP=GM(kN,{arm:`⟲`,confirm:`⟲ reset all?`},sP.map(e=>wN(e.name))),pP=[`unsaved`,`history.undo`,`history.redo`],mP=e=>`${X}${e}`,hP=mP(`unsaved`),gP=(e,t)=>({body:t,shown:`(gt .${mP(e)} 0)`}),_P=[gP(`unsaved`,`{{ action "${yN}" (printf "💾 save %d" .${hP}) }}`),gP(`history.undo`,`{{ action "${MN}" "↶" }}`),gP(`history.redo`,`{{ action "${RN}" "↷" }}`),{body:fP.template,shown:`(or ${$N(sP.map(e=>e.name))} ${fP.armed})`}],vP={when:`{{ or ${_P.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+_P.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},yP=[{step:fP,place:`door`},{step:dN,place:`session`}],bP=e=>e.map(e=>e.step.disarm),xP=bP(yP),SP=bP(yP.filter(e=>e.place!==`door`));function CP(e){let t=SN(e.name);return e.control.kind===`inline`?mN(t):Qr(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[...e.control.list.rows,...e.beneath].map((t,n)=>mN(ZN(e.name,n)))},`drop`)}function wP(e){return e===aN}function TP(e){let t=mN(aN);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[TP(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function EP(e){return DP(e)>0?e:TP(e)}function DP(e){let t=0;for(let n of _g(e))n.kind===`segment`&&wP(n.name)&&(t+=1);return t}function OP(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&wP(e.name)||e.opens!==void 0&&OP(e.opens.body,!0):e.children.some(e=>OP(e,n))}const kP={session:{direction:`vertical`,content:[mN(cN),{kind:`container`,direction:`horizontal`,children:[mN(uN),mN(fN)]}],after:[]},look:{direction:`horizontal`,content:[],after:[mN(TN)]},layout:{direction:`horizontal`,content:[mN(bN),mN(sN)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[mN(zN),...vM.map(e=>mN(UN(e.name)))],after:[]}},AP=e=>({kind:`container`,direction:kP[e].direction,children:[...kP[e].content,...dP(e),...kP[e].after]});function jP(e){return e.kind===`segment`?wP(e.name)?Qr(e.name,jN,NP,`above`):e:FP(e)}function MP(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[mN(IN),...dP(`door`),mN(yN)]},{kind:`container`,direction:`horizontal`,children:AA.map(({member:e})=>Qr(gN(e),vN(e),AP(e),`drop`))}]}}const NP=MP();function PP(e){let t=new Map;for(let e of _g(NP))e.kind===`segment`&&e.opens!==void 0&&t.set(e.opens.ref.key,e.opens.ref.variable);return[...t].map(([t,n])=>{let r=e.variables[n];if(r?.kind!==`state`||r.default===void 0)throw Error(`settings menu: the door folds "${t}", but "${n}" is not a state variable the menu declares with a default`);let i=`${aN}.fold.${XO(t)}`;return e.actions[i]={set:t,to:r.default},i})}function FP(e){return{...e,children:e.children.map(e=>jP(e))}}function IP(e){let t={variables:{[aN]:ii(aN,P)},actions:{[AN]:ai(aN,oN),[BN]:{doctor:`run`},[sN]:{do:[...lA]},...lN.actions,...dN.actions,...pN.actions,[yN]:{save:!0},[MN]:{undo:!0},[PN]:{back:!0},[NN]:{do:[PN,...xP]},[RN]:{redo:!0},[bN]:{preset:`save`},[TN]:{themeDefault:`save`},[xN]:{preset:`delete`,name:`{{ .${sv.preset.effectiveVar} }}`}},segments:{[aN]:{template:`{{ $door := ${ni(aN,ri(e),ri(`✖`))} }}{{ if ${ei(jN)} }}{{ fg (keptOn (color "error") (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`+aP},[cN]:{template:lN.template},[uN]:{template:dN.template,when:dN.when},[fN]:{template:pN.template,bg:pN.bg,when:pN.when},[IN]:LN,[yN]:vP,[TN]:ON,[bN]:{template:`{{ action "${bN}" "+ preset" }}`},[zN]:{template:`{{ action "${BN}" "🩺 doctor" }}`},[sN]:{template:`{{ action "${sN}" "✎ arrange" "✎ done" }}`}}};t.variables[EN]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[DN]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[FN]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of pP)t.variables[mP(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[hN]=ii(hN,`session`);for(let{member:e,label:n}of AA){t.actions[_N(e)]=ai(hN,e),t.actions[gN(e)]={do:[_N(e),...SP]};let r=$N(lP(e).map(e=>e.name)),i=`(ternary ${ri(` •`)} "" ${r})`,a=e=>`(print ${ri(e)} ${i})`;t.segments[gN(e)]={template:`{{ ${ni(gN(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,dN.variables,fP.variables),RP(t),LP(t),t.actions[aN]={do:[AN,...xP,...PP(t)]},t}function LP(e){for(let t of vM){let n=TM(t.name),r=VN(t.name);for(let t of Object.values(n))e.variables[t]={kind:`state`,key:t,default:``};e.actions[r]={doctor:`fix`,check:t.name};let i=t.takesMark?Aj:[];for(let n of i)e.actions[HN(t.name,n)]={doctor:`mark`,check:t.name,mark:n};let a=i.map(e=>` {{ action "${HN(t.name,e)}" "${WN[e]}" }}`).join(``);e.segments[UN(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ if ne .${n.reason} "" }} — {{ .${n.reason} }}{{ end }}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${ag}" }} {{ action "${r}" "[fix]" }}{{ end }}`+(a===``?``:`{{ if ne .${n.sighting} "" }} {{ .${n.sighting} }}${a}{{ end }}`)+`{{ end }}`}}}function RP(e){for(let t of sP){Object.assign(e.actions,t.control.actions);let n=wN(t.name);e.actions[n]={reset:t.configKey},e.variables[QN(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${QN(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[SN(t.name)]={template:`${t.control.template}${oP[t.name]??``}${r}`},t.control.kind===`picker`&&[...t.control.list.rows.map(e=>({template:e})),...t.beneath].forEach((n,r)=>{e.segments[ZN(t.name,r)]=n})}Object.assign(e.actions,fP.actions),Object.assign(e.variables,tP.variables),Object.assign(e.actions,tP.actions),Object.assign(e.segments,tP.segments);for(let t of NA){let n=YN(t);e.actions[qN(t)]=ai(n.key,n.member),e.segments[KN(t)]={template:`{{ action "${qN(t)}" ${ri(MA[t].trigger)} }}`}}}function zP(e){let{variables:t,actions:n}=vA();Object.assign(e.variables,t),Object.assign(e.actions,n)}function BP(e){let t=IP(e.globals.menuGlyph??`🍫`);zP(t);let n={...e.presets},r=[];for(let t of Iy(e.presets)){let{node:i}=zy(e,t),a=jP(EP(i));r.push(a),n[t]={...Ry(e.presets,t),root:a}}let i=YO(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const VP=`${$O}live`,HP=[`☐ live`,`☑ live`],UP=`${$O}done`,WP=`${$O}cancel`,GP=`${$O}rewind`,KP=`${$O}changes`,qP=`(gt .${KP} 0)`,JP=`(or ${qP} (gt .${hP} 0))`,YP={variable:VP,key:VP,member:`open`};function XP(e){return`${$O}configuring.p${e}`}function ZP(e){return`and ${ei(pA)} (not ${ei(YP)}) (ne .${XP(e)} "true")`}function QP(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${oA} "${Zr(e)}")`).join(` `)} false }}`}}function $P(e,t,n){return`{{ if ${ZP(e)} }}${t}{{ else }}${n}{{ end }}`}const eF=`{{ and ${ei(pA)} .preset.customized }}`,tF=tk;function nF(e){return new Map([...Wy(e),...iF(e)])}const rF=`${$O}addable`;function iF(e){return new Map([[rF,{members:Object.keys(e.segments).filter(e=>!tF(e)),library:{groups:nA.map(e=>({id:e,label:rA[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function aF(e,t,n){return n.segments[e]={template:t,when:mA,bg:SA},{kind:`segment`,name:e}}function oF(e,t,n){let r=`${$O}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${eh}`}) (action "${r}" "✖") }}`}function sF(e){return`{{ if ${ei(pA)} }}${e}{{ end }}`}function cF(e,t){return e.reduce((e,t)=>`{{ if and ${ei(pA)} ${ei(t)} }}true{{ else }}${e}{{ end }}`,t)}function lF(e){return e.flatMap(e=>[..._g(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function uF(e,t,n){return`${dA}${e}.${t}.${n}`}function dF(e,t,n,r){let i=pg(n),a=`${$O}${e.presetIdent}`,o=fA(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=ok(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:P},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:oA,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=uF(e.presetIdent,i,r),l=`${dA}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:Ig(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=vk(gk(o),s,l,d,c);if(Object.assign(e.artifacts.actions,f.actions),Object.assign(e.artifacts.variables,f.variables),f.kind===`inline`)return e.artifacts.segments[d]={template:f.template},{kind:`segment`,name:d};e.artifacts.segments[d]={template:f.template};let p=f.list.rows.map((t,n)=>{let r=`${d}.list.${n}`;return e.artifacts.segments[r]={template:t},{kind:`segment`,name:r}});return Qr(d,f.list.ref,{kind:`container`,direction:`vertical`,children:p},`drop`)});return{term:`{{ action "${s}" "${OA}" }}`,ref:{variable:oA,key:oA,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const fF=`${$O}label:`;function pF(e){if(e.startsWith(fF)){let t=e.slice(fF.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function mF(e,t,n,r){let{artifacts:i}=n,a=pg(e),o=`${fF}${a}:${e.name}`;i.segments[o]={template:`{{ "${Zr(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=Object.fromEntries(jg.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...Qr(o,r.ref,r.body,`drop`,cF([r.ref],`{{ ${ZP(n.presetIdent)} }}`)),...Object.keys(s).length>0&&{settings:s},drafts:Object.fromEntries(jg.map(e=>[e,r.drafts[e]]))}}function hF(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${$O}${i}.insert.${t}`,s=`${$O}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:rF,anchor:n,relation:r};let c=ik(o),l=ak(s,o,void 0),u=ck(l),d=sk(l,c);return a.variables[l]=ii(l,P),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=ai(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${ei({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${eh}`}) $m }}{{ end }}`}}function gF(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!tF(e.name)),i=e=>gF(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=gg(o,i);if(tF(o.name)){n.push(s);continue}let c=pg(o),l=a===r?[hF(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=hF(t,u,c,`after`),f=oF(t,u,c),p=t.segments[o.name],m=dF(t,u,o,Mg(p)),h=sF(f),g=sF(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>aF(e.host,e.template,t.artifacts)),{...mF(o,p,t,m),lead:h,trail:g},{...s,when:$P(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},aF(d.host,d.template,t.artifacts)]};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[_]}:_)}return{...e,children:n,...e.when!==void 0&&{when:cF(lF(n),$P(t.presetIdent,`true`,e.when))}}}function _F(e,t,n,r,i,a,o){let s=`${$O}${t}.resetLayout`,c=`${$O}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:eF},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},vF(e,o)]}}function vF(e,t){if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[e,t]};let n=e.children.at(-1);return e.direction===`vertical`&&n!==void 0&&(n.kind===`segment`||n.when===void 0)?{...e,children:[...e.children.slice(0,-1),vF(n,t)]}:{...e,children:[...e.children,t]}}function yF(e,t,n,r,i,a){let{node:o}=zy(e,t),s={presetIdent:XO(t),rootKey:Yk(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=gF(o,s);return n.variables[XP(s.presetIdent)]=QP(s.configured),_F(c,s.presetIdent,s.rootKey,n,r,i,a)}function bF(e){let t={variables:{},actions:{},segments:{}},n=bA(`${$O}help`,VA,[pA],t);t.variables[VP]=ii(VP,P),t.actions[VP]=ai(VP,YP.member),t.segments[VP]={template:ti(VP,...HP),when:mA};let r={kind:`segment`,name:VP},i=n;t.variables[KP]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[UP]={do:[yN,...lA]},t.segments[UP]={template:`{{ if ${JP} }}{{ action "${UP}" "✓ save" }}{{ else }}{{ action "${UP}" "✓ done" }}{{ end }}`,when:mA},t.actions[GP]={rewind:!0},t.actions[WP]={do:[GP,...lA]},t.segments[WP]={template:`{{ action "${WP}" "↩ cancel" }}`,when:`{{ and ${ei(pA)} ${qP} }}`};let a=[{kind:`segment`,name:UP},{kind:`segment`,name:WP}],o={...e.presets},s=[];for(let n of Iy(e.presets)){let c=yF(e,n,t,a,r,i);s.push(c),o[n]={...Ry(e.presets,n),root:c}}let c=YO(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}function xF(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function SF(e){let t=e.split(`:`);return t[0]===`remove`&&t.length===2&&t[1]?{op:`remove`,target:t[1]}:t[0]===`insert`&&t.length===4&&t[1]&&t[2]&&(t[3]===`before`||t[3]===`after`)?{op:`insert`,segment:t[1],anchor:t[2],relation:t[3]}:null}function CF(e,t,n){let r=hg(e,new Set(n.map(mg).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const wF=/^-?\d+$/;function TF(e,t,n=`set-state`){let r=e.filter(e=>e.includes(`/`));if(r.length>0)throw Error(`makeAllowListValidator(${t}): values contain "/" — the ${n} wire shape splits values on "/" so slash-bearing options cannot be addressed. Offending values: ${r.join(`, `)}`);if(e.includes(``))throw Error(`makeAllowListValidator(${t}): empty string is not a writable option — the validator rejects empty input before the allow-list check, so an "" in the allowed list could be rendered but never delivered. Remove "" from the allowed list.`);let i=new Set(e),a=[...e];return e=>e?i.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown ${t} "${e}" (have: ${a.join(`, `)})`}:{ok:!1,reason:`${t} value is required`}}function EF(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!wF.test(t))return{ok:!1,reason:`${e} must be an integer, got "${t}"`};let n=t[0]===`-`,r=(n?t.slice(1):t).replace(/^0+/,``);return r===``?{ok:!0,value:`0`}:{ok:!0,value:n?`-${r}`:r}}}function DF(e,t,n){return r=>r?wF.test(r)?{ok:!0,value:String(Math.max(e,Math.min(t,parseInt(r,10))))}:{ok:!1,reason:`${n} must be an integer, got "${r}"`}:{ok:!1,reason:`${n} value is required`}}function OF(e,t,n=`state`){let r=t.filter(e=>e.kind===`range`),i=t.some(e=>e.kind===`int`),a=t.flatMap(e=>e.kind===`allow-list`?e.allowed:[]);if(r.length===0&&!i)return{kind:`allow-list`,allowed:[...new Set(a)]};let o=a.filter(e=>!wF.test(e));if(o.length>0)throw Error(`${n} action table: key "${e}" is an integer spec (a paged cursor or a bounded value) but a click writes non-integer value(s) to it (${o.join(`, `)}). A ${n} key has one key shape — point that click at a distinct key, or write an integer.`);if(i&&r.length>0)throw Error(`${n} action table: key "${e}" is declared as both a paged cursor (int) and a bounded value (range) — a ${n} key has one key shape. Use distinct keys.`);if(r.length>0){let t=Math.min(...r.map(e=>e.min)),i=Math.max(...r.map(e=>e.max)),o=a.filter(e=>{let n=parseInt(e,10);return n<t||n>i});if(o.length>0)throw Error(`${n} action table: key "${e}" is a bounded range [${t},${i}] but a click writes out-of-range value(s) to it (${o.join(`, `)}). The range gate would clamp them, storing a different value than the click renders — write an in-range integer, or point that click at a distinct key.`);return{kind:`range`,min:t,max:i}}return{kind:`int`}}function kF(e){return e===`config`?`set-config`:`set-state`}function AF(e,t,n){return t.kind===`int`?EF(`menu page "${e}"`):t.kind===`range`?DF(t.min,t.max,`${n} stepper "${e}"`):TF(t.allowed,`${n} "${e}"`,kF(n))}function jF(e,t=`state`){let n=new Map;for(let{key:t,spec:r}of e){let e=n.get(t);e?e.push(r):n.set(t,[r])}return[...n].map(([e,n])=>({key:e,spec:OF(e,n,t)}))}function MF(e,t,n,r){let i=new Map(Object.entries(e)),a=new Map,o=new Set(t.map(e=>e.key));for(let{key:e,spec:t}of n)if(o.has(e)&&t.kind!==`allow-list`)throw Error(`${r} gate: key "${e}" is written by the daemon's own links as one of a list of values, and cannot be declared as ${t.kind===`int`?`a paged cursor (int)`:`a bounded value (range)`}. Use a distinct key.`);let s=[...t.map(({key:e,allowed:t})=>({key:e,spec:{kind:`allow-list`,allowed:t}})),...n];for(let{key:t,spec:n}of jF(s,r)){if(!t)throw Error(`${r} gate: key is required`);if(t.includes(`/`))throw Error(`${r} gate: key "${t}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);if(Object.hasOwn(e,t))throw Error(`${r} gate: key "${t}" is a built-in ${r} key and cannot be re-claimed (built-in keys: ${Object.keys(e).join(`, `)})`);i.set(t,AF(t,n,r)),n.kind===`range`&&a.set(t,{min:n.min,max:n.max})}return{validate(e,t){let n=i.get(e);return n?n(t):{ok:!1,reason:`unknown ${r} key "${e}" (have: ${[...i.keys()].join(`, `)})`}},listKeys:()=>[...i.keys()],rangeParamsFor:e=>a.get(e)??null}}function NF(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};MF(e,[o],[],t),r.push(o),i++;let s=!0;return()=>{s&&(s=!1,r.splice(r.indexOf(o),1),i++)}},gateFor(o){let s=a.get(o);if(s?.epoch===i)return s.gate;let c=MF(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const PF=NF({},`config`,VF);function FF(e,t){return PF.register(e,t)}function IF(e){return PF.gateFor(e)}function LF(e,t){return`persist`in e?`to`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Ky(e.from,t).members}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[xF({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[xF({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Ky(e.insertSegmentFrom,t).members.map(t=>xF({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function RF(e,t){let n=Wk(e).get(t);return n===void 0?null:String(n)}function zF(e){let t=new Set;for(let n of Object.values(e.actions)){`reset`in n&&t.add(n.reset);let e=`persist`in n?$k(n.persist):null;e?.scope===`preset-root`&&t.add(Yk(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function BF(e){let t=nF(e);return[...zF(e),...Object.values(e.actions).flatMap(e=>LF(e,t))]}function VF(e){return jF(BF(e),`config`)}function HF(e,t){return{globals:{...t.globals,...e.globals??{}},variables:{...t.variables,...e.variables??{}},segments:GF(t.segments,UF(t.segments,e.segments??{})),root:My(e.root??Ty,t.root),actions:{...t.actions,...e.actions??{}},styles:{...t.styles,...e.styles??{}},presets:GF(t.presets,WF(t.presets,e.presets??{})),themeDefaults:GF(t.themeDefaults,e.themeDefaults??{}),editGlobals:{...t.editGlobals,...e.editGlobals??{}},helpers:{...t.helpers,...e.helpers??{}}}}function UF(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.settings===void 0?n:{...n,settings:{...e[t]?.settings,...n.settings}}]))}function WF(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.globals===void 0?n:{...n,globals:{...e[t]?.globals,...n.globals}}]))}function GF(e,t){return{...e,...Object.fromEntries(Object.entries(t).map(([t,n])=>[t,{...e[t],...n}]))}}function KF(e,t,n,r){return n.cache===void 0?(e.issues.push({path:`${t}.cache`,message:`${r} variables must declare a cache policy (one of: ${Cg.join(`, `)})`,line:K(e.source,t.split(`.`))}),null):YF(e,`${t}.cache`,n.cache)}function qF(e){return{required:!0,json:XF(),parse:(t,n,r,i)=>KF(t,n,i,e)??void 0}}const JF={noun:`cache`,arms:{ttl:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&QF(n)?{ttl:n}:a_(e,t,`cache.ttl must be a duration string like "5s", "100ms", "2m", "1h"; got ${q(n)}`)},watch_file:{json:{type:`string`,pattern:`^/`},parse:(e,t,n)=>{if(typeof n!=`string`)return a_(e,t,`cache.watch_file must be a path string, got ${q(n)}`);let r=__(`cache.watch_file`,n);return r===null?{watch_file:n}:a_(e,t,r)}},depends_on:{json:{type:`array`,items:{type:`string`}},parse:(e,t,n)=>Array.isArray(n)&&n.every(e=>typeof e==`string`)?{depends_on:n}:a_(e,t,`cache.depends_on must be an array of variable-name strings, got ${q(n)}`)},key:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&n!==``?{key:n}:a_(e,t,`cache.key must be a non-empty template string, got ${q(n)}`)},never:{json:{const:!0},parse:(e,t,n)=>n===!0?{never:!0}:a_(e,t,`cache.never must be the literal boolean true, got ${q(n)}`)}}};function YF(e,t,n){return o_(e,JF,t,n)}function XF(){return w_(JF)}const ZF=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/;function QF(e){return ZF.test(e)}function $F(e,t,n){if(n===void 0)return{};if(!Qg(n))return e.issues.push({path:t,message:`${t} must be an object, got ${$g(n)}`,line:K(e.source,t.split(`.`))}),{};let r={};for(let[i,a]of Object.entries(n)){let n=s_(e,TI,`${t}.${i}`,a);n!==null&&(r[i]=n)}return r}function eI(){return{required:!0,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.value;if(typeof i!=`string`&&typeof i!=`number`&&typeof i!=`boolean`){e.issues.push({path:`${t}.value`,message:`literal value must be string|number|boolean, got ${$g(i)}`,line:K(e.source,t.split(`.`))});return}return i}}}function tI(){return{required:!0,json:{enum:[...Tg]},parse:(e,t,n,r)=>{let i=r.field;if(typeof i!=`string`||!Tg.includes(i)){e.issues.push({path:`${t}.field`,message:`git field must be one of: ${Tg.join(`, `)}, got ${JSON.stringify(i)}`,line:K(e.source,[...t.split(`.`),`field`])});return}return i}}}function nI(){return{required:!1,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.type;return Jg(e,t,r,i===`number`||i===`boolean`||i===`string`?i:`string`)}}}const rI={noun:`parse`,arms:{text:{json:{const:!0},parse:(e,t,n)=>n===!0?{text:!0}:a_(e,t,`parse.text must be the literal boolean true, got ${q(n)}`)},regex:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`?iI(e,t,n):a_(e,t,`parse.regex must be a pattern string, got ${q(n)}`)},json:{json:{const:!0},parse:(e,t,n)=>n===!0?{json:!0}:a_(e,t,`parse.json must be the literal boolean true, got ${q(n)}`)}}};function iI(e,t,n){let r;try{new RegExp(n),r=RegExp(`${n}|`).exec(``).length-1}catch(n){return a_(e,t,`parse.regex is not a valid regular expression: ${n.message}`)}return r>=1?{regex:n}:a_(e,t,`parse.regex must contain a capture group — its group 1 is the value; got ${JSON.stringify(n)}`)}function aI(){return{required:!1,json:w_(rI),parse:(e,t,n,r)=>(r.regex!==void 0&&e.issues.push({path:`${t}.regex`,message:`${t}.regex was retired; the regex is the parse step's regex arm now: parse: { regex: ${JSON.stringify(r.regex)} }`,line:K(e.source,[...t.split(`.`),`regex`])}),r.parse===void 0?void 0:o_(e,rI,`${t}.parse`,r.parse)??void 0)}}function oI(){return{required:!1,json:{type:[`string`,`number`,`boolean`,`array`,`object`],description:`The value published when the source fails: a string under the text/regex parse arms, any non-null JSON value under the json arm`},parse:(e,t,n,r)=>Qg(r.parse)&&`json`in r.parse?sI(e,t,r.default):Yg(e,t,r,`default`)}}function sI(e,t,n){if(n!==void 0)return cI(n)?n:a_(e,`${t}.default`,`${t}.default must be a JSON value (a json-parsed source's document), got ${q(n)}`)??void 0}function cI(e){return e!==null&&lI(e)}function lI(e){if(e===null)return!0;switch(typeof e){case`string`:case`boolean`:return!0;case`number`:return Number.isFinite(e);case`object`:{if(Array.isArray(e))return e.every(lI);let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&Object.values(e).every(lI)}default:return!1}}const uI={value:eI(),default:d_()},dI={path:g_(),type:y_([`string`,`number`,`boolean`]),default:nI()},fI={name:g_(),default:d_()},pI={path:v_(),readMode:y_([`whole`,`first-line`]),parse:aI(),cache:qF(`file`),default:oI()},mI={command:g_(),parse:aI(),cache:qF(`shell`),default:oI()};function hI(e){return{cache:`${e}, so it takes no cache policy — delete the key`}}const gI={template:g_(),default:d_()},_I=hI(`a template variable recomputes whenever a variable it reads changes`),vI={layout:g_(),default:d_()},yI=hI(`a time variable reads the instant its render is drawn at`),bI={field:tI(),default:d_()},xI=hI(`a git variable is refreshed by the daemon's own watch on the repository`),SI={key:g_(),default:d_()},CI=`kind`;function wI(e,t,n={}){return{...c_(CI,e,t),parse:(r,i,a)=>{t_(r,n,i,a);let o=n_(r,t,i,a);return o===null?null:{kind:e,...o}}}}const TI={tag:CI,noun:`source kind`,memberNoun:`variable`,arms:{literal:wI(`literal`,uI),input:wI(`input`,dI),env:wI(`env`,fI),file:wI(`file`,pI),shell:wI(`shell`,mI),template:wI(`template`,gI,_I),time:wI(`time`,vI,yI),git:wI(`git`,bI,xI),state:wI(`state`,SI)}};function EI(){return C_(TI)}function DI(){return{type:`object`,additionalProperties:EI()}}const OI=new Map([[`gitTaculous`,{kind:`built-in`,to:`gitaculous`}],[`git`,{kind:`built-in`,to:`gitaculous`}],[`settings.menu`,{kind:`built-in`,to:`candybar.menu`}],[`ticket`,{kind:`plugin`,to:`plugins.lit.ticket`,source:`promptctl/links-issue-tracker`}]]);function kI(e){let t=OI.get(e);if(t===void 0)return``;switch(t.kind){case`built-in`:return` (the built-in segment "${e}" was renamed to "${t.to}" — update this reference)`;case`plugin`:return` (the built-in segment "${e}" became "${t.to}", a segment of the plugin \`cc-candybar plugin install ${t.source}\` installs — update this reference)`}}const AI=/^[A-Za-z_][A-Za-z0-9_]*$/,jI={pattern:AI.source},MI={anyOf:[{type:`boolean`},{type:`string`},{type:`integer`}]},NI={type:`object`,additionalProperties:!1,required:[`label`,`domain`,`default`],properties:{label:{type:`string`,pattern:`^[^\\n\\r]+$`},domain:{anyOf:[{const:`bool`},{type:`array`,items:{type:`string`,pattern:`^[^/\\n\\r]+$`},minItems:1,uniqueItems:!0},{type:`object`,additionalProperties:!1,required:[`min`,`max`],properties:{min:{type:`integer`},max:{type:`integer`},step:{type:`integer`,minimum:1},atLeast:{type:`string`,...jI}}}]},default:MI}},PI=[`label`,`domain`,`default`],FI=[`min`,`max`,`step`,`atLeast`];function II(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))})}function LI(e,t,n){if(n===`bool`)return`bool`;if(Array.isArray(n)){let r=n.filter(e=>typeof e==`string`);if(n.length===0||r.length!==n.length)return II(e,t,`a list domain must be a non-empty list of words, got ${JSON.stringify(n)}`);if(new Set(r).size!==r.length)return II(e,t,`a list domain names each word once, got ${JSON.stringify(n)}`);let i=r.filter(e=>e===``||e.includes(`/`)||/[\n\r]/.test(e));return i.length>0?II(e,t,`a list domain's words must be non-empty, slash-free, and newline-free — configure mode writes each on the set-state wire — got ${JSON.stringify(i)}`):r}if(Qg(n)){let{min:r,max:i,step:a=1,atLeast:o}=n;return Object.keys(n).filter(e=>!FI.includes(e)).length===0&&Number.isInteger(r)&&Number.isInteger(i)&&r<=i&&Number.isInteger(a)&&a>=1&&(o===void 0||typeof o==`string`)?{min:r,max:i,step:a,...o!==void 0&&{atLeast:o}}:II(e,t,`a range domain is { min, max, step?, atLeast? } with integers min ≤ max, a whole step ≥ 1, and atLeast naming another range setting, got ${JSON.stringify(n)}`)}return II(e,t,`domain must be "bool", a list of words, or { min, max }, got ${q(n)}`)}function RI(e,t,n){if(!Qg(n))return II(e,t,`${t} must be { label, domain, default }, got ${$g(n)}`);for(let r of Object.keys(n))PI.includes(r)||II(e,`${t}.${r}`,`Unknown setting key "${r}". Expected one of: ${PI.join(`, `)}`);let{label:r}=n,i=typeof r==`string`&&r.length>0&&!/[\n\r]/.test(r);i||II(e,`${t}.label`,`a setting needs a one-line, non-empty "label" — the name its control shows, spliced into a synthesized template string — got ${q(r)}`);let a=LI(e,`${t}.domain`,n.domain);if(!i||a===void 0)return;let o={label:r,domain:a,default:n.default};return!zI(n.default)||!Fg(o,n.default)?II(e,`${t}.default`,`default must be ${zg(o)}, got ${q(n.default)}`):o}function zI(e){return typeof e==`boolean`||typeof e==`string`||typeof e==`number`}const BI={theme:`its default for this segment is segments.<name>.palette, and a placement sets its own with settings: { ${kg}: "<theme>" }`,effect:`a placement follows the bar's effect, or sets its own with settings: { effect: "<effect>" }`};function VI(e){return jg.includes(e)}function HI(){return{required:!1,json:{type:`object`,propertyNames:{...jI,not:{enum:[...jg]}},additionalProperties:NI},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!Qg(i))return II(e,a,`${a} must be an object of name → { label, domain, default }, got ${$g(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i)){if(!AI.test(t)){II(e,`${a}.${t}`,`setting name "${t}" is read as .settings.${t} in a template, so it must be an identifier (letters, digits, _; not starting with a digit)`);continue}if(VI(t)){II(e,`${a}.${t}`,`setting "${t}" is one every placement already has — ${BI[t]}`);continue}let r=RI(e,`${a}.${t}`,n);r!==void 0&&(o[t]=r)}return o}}}const UI=ek.map(e=>e.replace(/\./g,`\\.`)).join(`|`);function WI(){return{required:!1,json:{type:`string`,minLength:1,pattern:`^(?!${UI})[^:/]+$`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return typeof i==`string`&&i.length>0&&!/[:/]/.test(i)&&!tk(i)?i:II(e,`${t}.${n}`,`a placement "id" must be a non-empty string without "/" or ":", outside the reserved ${ek.map(e=>`"${e}"`).join(`, `)} namespaces, got ${q(i)}`)}}}function GI(){return{required:!1,json:{type:`object`,propertyNames:jI,additionalProperties:MI},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!Qg(i))return II(e,a,`a placement's "settings" must be an object of setting name → value, got ${$g(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i))zI(n)?o[t]=n:II(e,`${a}.${t}`,`setting "${t}" must be a boolean, a word, or a number, got ${$g(n)}`);return o}}}function KI(e){return new Set(Object.keys(e.segments).filter(e=>!tk(e)))}function qI(e,t,n){if(t===void 0)return{};if(!Qg(t))return e.issues.push({path:`segments`,message:`segments must be an object, got ${$g(t)}`,line:K(e.source,[`segments`])}),{};let r={};for(let[i,a]of Object.entries(t)){let t=e_(e,n.has(i)?$I:QI,`segments.${i}`,a);t!==null&&(r[i]=t)}return r}function JI(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>r[n]===void 0?a_(e,`${t}.${n}`,`${t} declares no template — only a segment the bundled default declares may omit it (inheriting the bundled template); a segment of your own needs its own${kI(t.slice(9))}`)??void 0:qg(e,t,r,n)??void 0}}function YI(){return{required:!1,json:{anyOf:[{const:`auto`},{const:`fill`},{type:`integer`,minimum:1}]},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(i===`auto`)return`auto`;if(i===`fill`)return`fill`;if(typeof i==`number`&&Number.isInteger(i)&&i>0)return i;e.issues.push({path:`${t}.${n}`,message:`width must be "auto", "fill", or a positive integer, got ${q(i)}`,line:K(e.source,[...t.split(`.`),n])})}}}}function XI(){return{required:!1,json:DI(),parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return $F(e,`${t}.${n}`,i)}}}const ZI={template:JI(),description:d_(),group:y_(tA),width:YI(),justify:y_(Bg),truncate:y_(Vg),bg:d_(),fg:d_(),when:d_(),palette:h_(),vars:XI(),settings:HI(),missingData:y_(Eg)},QI={noun:`segment key`,fields:ZI},$I={noun:`segment key`,fields:{...ZI,template:d_()}},eL=`#/definitions/LayoutNode`,tL={kind:`container`,direction:`vertical`,children:[]};function nL(e){return{required:!0,json:{const:e},parse:()=>e}}function rL(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a segment node must have a non-empty "name" (a segment name), got ${q(i)}`,line:K(e.source,[`root`])}),``)}}}function iL(){return{required:!0,json:{enum:[...dg]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&dg.includes(i)?i:(e.issues.push({path:`${t}.${n}`,message:`a container "direction" must be one of: ${dg.join(`, `)} (got ${JSON.stringify(i)})`,line:K(e.source,[`root`])}),`vertical`)}}}function aL(e){return{required:!0,json:{type:`array`,items:{$ref:eL}},parse:(t,n,r,i)=>{let a=i[r];return Array.isArray(a)?a.map((i,a)=>e(t,`${n}.${r}[${a}]`,i)):(t.issues.push({path:`${n}.${r}`,message:`a container must have a "children" array of layout nodes, got ${$g(a)}`,line:K(t.source,[`root`])}),[])}}}const oL={noun:`layout-node key`,fields:{kind:nL(`segment`),name:rL(),when:d_(),id:WI(),settings:GI()}},sL=()=>y_(Am),cL={noun:`layout-node key`,fields:{kind:nL(`container`),direction:iL(),children:aL(l_(()=>pL)),when:d_(),distribution:sL()}};function lL(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a "seg" node must have a non-empty segment name, got ${q(i)}`,line:K(e.source,[`root`])}),``)}}}const uL={noun:`layout-node key`,fields:{seg:lL(),when:d_(),id:WI(),settings:GI()}},dL={noun:`layout-node key`,fields:{h:aL(l_(()=>pL)),when:d_(),distribution:sL()}},fL={noun:`layout-node key`,fields:{v:aL(l_(()=>pL)),when:d_(),distribution:sL()}},pL=(e,t,n)=>{if(typeof n==`string`)return n.length===0?(e.issues.push({path:t,message:`a bare-string layout node must be a non-empty segment name`,line:K(e.source,[`root`])}),tL):{kind:`segment`,name:n};if(!Qg(n))return e.issues.push({path:t,message:`a layout node must be a string (segment name) or an object with "kind" / "seg" / "h" / "v", got ${$g(n)}`,line:K(e.source,[`root`])}),tL;if(n.kind===`container`)return e_(e,cL,t,n)??tL;if(n.kind===`segment`)return e_(e,oL,t,n)??tL;if(n.kind===`cells`)return e.issues.push({path:t,message:`kind: "cells" is no longer supported — use the h-arm spelling instead:
181
+ `,KA=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`,qA={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function JA(e){let t=e[qA.socket]??``,n=e[qA.pane]??``;if(t===``||n===``)return null;let r=e[qA.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const YA=[`moves`,`can-move`,`still`];function XA(e){let t=e.context_window?.current_usage;return t===null?`no`:t===void 0?`unknown`:`yes`}const ZA=[`carried`,`missing`,`unanswered`];function QA(e){let t=e.rate_limits;return t?.five_hour!=null||t?.seven_day!=null?`carried`:XA(e)===`no`?`unanswered`:`missing`}function $A(e){return{path:e.transcript_path,answered:XA(e)===`yes`}}const ej=[...YA,`failed`,`drawing`],tj=[`statusline`,`frames`],nj=e=>e?.kind===`frames`?`frames`:`statusline`;var rj=class{seen=new Map;see(e,t,n,r){let i=nj(t.client),a=JSON.stringify([e,i]),o=this.seen.get(a);o!==void 0&&o.order>r||(this.seen.delete(a),this.seen.set(a,{sessionId:e,said:{...t,role:i},at:n,order:r}),this.seen.size>64&&this.seen.delete(this.seen.keys().next().value))}list(e){return[...this.seen.values()].map(({sessionId:t,said:n,at:r})=>({...n,sessionId:t,ago:e-r}))}ofSession(e,t){return this.list(t).filter(t=>t.sessionId===e)}};const ij={kitty:{label:`kitty`,xtversion:`kitty`,program:null,programVersion:!0,term:`xterm-kitty`,links:{since:`0.19.0`},glyphs:{kind:`bundled`,since:`0.36.0`}},wezterm:{label:`WezTerm`,xtversion:`WezTerm`,program:`WezTerm`,programVersion:!0,term:`wezterm`,links:{since:null},glyphs:{kind:`bundled`,since:`20230712`}},ghostty:{label:`Ghostty`,xtversion:`ghostty`,program:`ghostty`,programVersion:!0,term:`xterm-ghostty`,links:{since:null},glyphs:{kind:`bundled`,since:null}},iterm2:{label:`iTerm2`,xtversion:`iTerm2`,program:`iTerm.app`,programVersion:!0,term:null,links:{since:`3.1`},glyphs:{kind:`configured`}},alacritty:{label:`Alacritty`,xtversion:`alacritty`,program:null,programVersion:!0,term:`alacritty`,links:{since:`0.11.0`},glyphs:{kind:`configured`}},"apple-terminal":{label:`Terminal`,xtversion:null,program:`Apple_Terminal`,programVersion:!0,term:null,links:null,glyphs:{kind:`unread`}},vscode:{label:`VS Code`,xtversion:null,program:`vscode`,programVersion:!1,term:null,links:{since:`1.72`},glyphs:{kind:`unread`}}},aj=e=>ij[e];function oj(e){return aj(e).glyphs.kind===`bundled`}function sj(e){return aj(e).glyphs.kind===`configured`}const cj=e=>aj(e).label,lj=[{since:`3.5.0`,from:57504,to:57507},{since:`3.5.0`,from:57520,to:57554},{since:`3.5.0`,from:57556,to:57556},{since:`3.5.6`,from:57558,to:57559}];function uj(e,t){let n=t.codePointAt(0);return lj.some(({since:t,from:r,to:i})=>r<=n&&n<=i&&e!==null&&pj(e,t)===!0)}const dj=Object.keys(ij);function fj(e){let t=/^\d+(?:\.\d+)*/.exec(e);return t===null?null:t[0].split(`.`).map(Number)}function pj(e,t){let n=fj(e),r=fj(t);if(n===null)return null;for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]??0,i=r[e]??0;if(t!==i)return t>i}return!0}function mj(e){for(let t of dj){let n=aj(t).xtversion;if(n!==null&&e.toLowerCase().startsWith(n.toLowerCase())){let r=e.slice(n.length).replace(/^[\s(]+/,``);return{name:t,version:/^[^\s)]+/.exec(r)?.[0]??null}}}return null}function hj(e){let t=dj.find(t=>aj(t).term===e);return t===void 0?null:{name:t,version:null}}function gj(e){let t=mj(e.termtype)??hj(e.termname);if(t!==null)return{kind:`known`,terminal:t};let n=/^[^\s(]*/.exec(e.termtype)[0];return n===``?{kind:`unnamed`,term:e.termname}:{kind:`unknown`,called:n}}function _j(e){let t=e.TERM_PROGRAM,n=dj.find(e=>aj(e).program===t),r=n===void 0?hj(e.TERM):{name:n,version:aj(n).programVersion?e.TERM_PROGRAM_VERSION??null:null};return r===null?t===void 0||t===`tmux`?{kind:`unnamed`,term:e.TERM??``}:{kind:`unknown`,called:t}:{kind:`known`,terminal:r}}function vj(e){switch(e.kind){case`known`:return cj(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||null}}function yj(e){switch(e.kind){case`known`:return cj(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||`this terminal`}}function bj({name:e,version:t}){let n=aj(e).links;if(n===null)return{kind:`none`};if(n.since===null)return{kind:`draws`};if(t===null)return{kind:`unsaid`,since:n.since};let r=pj(t,n.since);return r===null?{kind:`unsaid`,since:n.since}:r?{kind:`draws`}:{kind:`older`,since:n.since,version:t}}const xj=dj.filter(e=>aj(e).links!==null).map(cj).join(`, `);function Sj(e){if(e.kind===`failed`)return{kind:`unread`,reason:e.reason};let t=e.value.flatMap(({scope:e,path:t,settings:n})=>`statusLine`in n?[{from:{scope:e,path:t},line:n.statusLine}]:[]),n=t[0];if(n===void 0)return{kind:`absent`,read:e.value.map(e=>e.path)};if(!Na(n.line))return{kind:`not-an-object`,value:n.line,from:n.from};for(let{from:e,line:r}of t){if(e.scope!==n.from.scope||!Na(r))break;if(`refreshInterval`in r)return{kind:`present`,refreshInterval:r.refreshInterval,from:e}}return{kind:`present`,refreshInterval:void 0,from:n.from}}function Cj(e,t){if(e.kind===`failed`)return e;let n=e.value.find(e=>Object.hasOwn(e.env,t));return{kind:`ok`,value:n===void 0?{kind:`unset`}:{kind:`set`,value:n.env[t],from:{scope:n.scope,path:n.path}}}}const wj=[`managed`,`project`],Tj=e=>!wj.includes(e.scope),Ej={managed:()=>null,"project-local":e=>({scope:`project-local`,path:e}),project:(e,t)=>({scope:`project-local`,path:Aa(t.projectDir)}),user:e=>({scope:`user`,path:e})},Dj=[`drawn`,`boxes`],Oj=1024*1024,kj=e=>e.kind===`session`?`session ${e.sessionId}'s statusline client`:`this command's terminal`;function Aj(e){switch(e.kind){case`claude-settings`:return`${e.kind} ${e.path.join(`.`)}=${JSON.stringify(e.value)} file=${JSON.stringify(e.file.path)} scope=${e.file.scope}`;case`post-mortems-read`:return`${e.kind} through=${e.through}`}}function jj(e){let[t,...n]=e;return t===void 0?{ok:!0}:{ok:!1,reason:t,more:n}}const Mj=qA.truecolor;function Nj(e,t){switch(e.kind){case`unreported`:return{ok:!1,reason:"the client reported no tmux facts — re-run `cc-candybar install` to stage a current client"};case`outside`:return{ok:!0};case`inside`:return e.client.kind===`failed`?{ok:!1,reason:`tmux could not be asked: ${e.client.reason}`}:e.client.value===null?{ok:!0}:t(e.client.value,e.hint)}}const Pj={name:`tmuxTruecolor`,label:`tmux truecolor`,takesMark:!1,probe:({tmux:e,claudeSettings:{origin:t}})=>Nj(e,(e,n)=>{if(!e.features.includes(`RGB`)||n.truecolor!==null)return{ok:!0};let r=Cj(t.sources,Mj);if(r.kind===`failed`)return{ok:!1,reason:r.reason};let i=r.value;if(i.kind===`set`&&typeof i.value==`string`&&i.value!==``)return{ok:!1,reason:`${Mj} is set in ${i.from.path} — restart Claude Code to apply`};let a=`Claude Code renders the bar in 256 colours inside tmux`,o=e=>({ok:!1,reason:a,fix:{kind:`claude-settings`,file:e,path:[`env`,Mj],value:`1`}});if(i.kind===`unset`)return o({scope:`user`,path:t.at.userFile});let s=Ej[i.from.scope](i.from.path,t.at);return s===null?{ok:!1,reason:`${a} — the value that counts is in managed settings, ${i.from.path}: set ${Mj} to "1" there`}:o(s)})},Fj={name:`utf8`,label:`UTF-8`,takesMark:!1,probe:({tmux:e})=>Nj(e,e=>e.utf8?{ok:!0}:{ok:!1,reason:"tmux draws this terminal without UTF-8, so every glyph on the bar arrives as `_` — attach with `tmux -u`, or set a UTF-8 LC_ALL/LC_CTYPE/LANG in the shell that runs tmux"})},Ij={name:`termWidth`,label:`terminal width`,takesMark:!1,probe:({width:e})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.columns===null?{ok:!1,reason:`${kj(e.value.of)} measured no width (no COLUMNS, and no terminal to ask — or the daemon refused the width sent, which the bar's red strip names), so the bar is laid out as if the terminal were 120 columns wide`}:{ok:!0,note:`${e.value.columns} columns, as ${kj(e.value.of)} measured`}},Lj={variable:`is never read`,action:`is never clicked`,helper:`is never called`,segment:`is in no preset`},Rj={name:`config`,label:`config`,takesMark:!1,probe:({config:e})=>{switch(e.kind){case`failed`:{let[t=`the config failed to load`,...n]=[...e.error.split(`
182
+ `).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return jj([...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${Lj[e]}`)])}}},zj="re-run `cc-candybar install`";function Bj(e){if(e.kind===`failed`)return[`Launch Services could not be asked which app opens cc-candybar:// — ${e.reason}`];if(e.value===null)return[`no app is registered for cc-candybar:// — ${zj}`];let{app:t,missing:n}=e.value;return n.kind===`failed`?[`${t} opens cc-candybar://, but ${n.reason} — ${zj}`]:n.value.map(e=>`${e} is missing, and ${t} runs it — ${zj}`)}const Vj={name:`urlHandler`,label:`URL handler`,takesMark:!1,probe:({urlHandler:e})=>{switch(e.kind){case`unsupported`:return{ok:!0};case`unprobed`:return{ok:!1,reason:e.reason};case`arrived`:return e.handler===e.bar?{ok:!0}:{ok:!1,reason:e.handler===null?`the URL handler does not report its version, so it is older than the bar (${e.bar}) — ${zj}`:`the URL handler runs cc-candybar ${e.handler}; the bar runs ${e.bar} — ${zj}`};case`lost`:return jj([...Bj(e.opener),e.unopened===null?`a cc-candybar:// link was opened and did not arrive at the daemon`:`a cc-candybar:// link could not be opened — ${e.unopened}`])}}};function Hj({bundle:e,checkout:t},n){return{bundle:n.bundle.kind===`failed`?{kind:`unresolved`,reason:n.bundle.reason}:n.bundle.value===e?{kind:`same`}:{kind:`other`,path:n.bundle.value},source:n.client!==`native`||t===null?{kind:`uncompared`}:t.rustSource.kind===`failed`?{kind:`unreadable`,root:t.root,reason:t.rustSource.reason}:n.source===null?{kind:`unstamped`}:n.source===t.rustSource.value?{kind:`same`}:{kind:`other`,root:t.root}}}function Uj(e,t){return t===`frames`?`run \`node ${e.bundle} frames --lane <${E_.join(`|`)}>\``:e.checkout===null?zj:`run \`just install-rust\` and point the statusLine command at ${e.checkout.root}/bin/cc-candybar-native`}function Wj(e,t,n){let{checkout:r}=e;if(n.kind===`unreported`)return[`the bar is drawn by a statusline client too old to say what it is — ${Uj(e,`native`)}`];let{bundle:i,source:a}=Hj(e,n);switch(i.kind){case`unresolved`:return[`the statusline client's bundle cannot be resolved: ${i.reason}`];case`other`:return[`the statusline client runs ${i.path}, not the daemon's ${e.bundle} — ${Uj(e,n.client)}`];case`same`:break}if(n.client===`node`&&(t||r!==null))return[`the bar is drawn by the Node fallback, which starts node on every render — ${Uj(e,`native`)}`];switch(a.kind){case`uncompared`:case`same`:return[];case`unreadable`:return[`${a.root}/rust-client could not be read: ${a.reason}`];case`unstamped`:return["the native client carries no source stamp, so which source it was built from is unknown — run `just install-rust`"];case`other`:return[`the native client was built from other source than ${a.root}/rust-client holds — run \`just install-rust\``]}}const Gj=e=>{let t=`restarted since the bar was drawn, or has served 64 newer sessions`;return e.kind===`clicked`?`this daemon holds no render of this bar (it ${t})`:`this daemon holds no render of session ${e.sessionId}'s bar (its statusLine does not run cc-candybar — a \`claude -p\` session draws none — or the daemon ${t}; unset CLAUDE_CODE_SESSION_ID to judge every bar drawn recently)`},Kj={name:`install`,label:`install`,takesMark:!1,probe:({install:e,sighted:t})=>{if(e.kind===`failed`)return{ok:!1,reason:`the daemon could not be asked which clients draw the bar: ${e.reason}`};let{daemon:n,nativeShipped:r,clients:i}=e.value;return i.length===0?{ok:!1,reason:t.kind===`recent`?`no statusline client has drawn a bar for this daemon in the last ${300/60} minutes — run the doctor again once the bar has redrawn; if it never does, the statusLine command does not run cc-candybar`:`${Gj(t)}, so which client draws it is unknown — run the doctor again once the bar has redrawn`}:jj([...new Set(i.flatMap(e=>Wj(n,r,e)))])}};function qj({postMortems:e},t){return e.kind===`ok`&&t.kind===`ok`?e.value.filter(e=>t.value.through===null||In(e.identity,t.value.through)):[]}function Jj(e,t){return e.kind===`failed`?t:t.filter(t=>t.pid!==e.value.pid)}const Yj={name:`daemon`,label:`daemon`,takesMark:!1,probe:({daemon:{serving:e,processes:t,read:n}})=>{let r=t.kind===`failed`?[`the process table could not be read: ${t.reason}`]:[],i=t.kind===`ok`?Jj(e,t.value):[];if(e.kind===`failed`){let t=i.length>0?` — daemon ${i.map(e=>e.pid).join(`, `)} running`:``;return jj([`${e.reason}${t}`,...r])}let{pid:a,memory:o,limit:s,postMortems:c}=e.value,l=qj(e.value,n),u=jj([...l.map(e=>`the daemon ran out of memory and restarted (${e.identity}) — post-mortem: ${Object.values(e.artifacts).join(`, `)}`),...c.kind===`failed`?[`the daemon's post-mortems could not be listed: ${c.reason}`]:[],...n.kind===`failed`&&!(c.kind===`ok`&&c.value.length===0)?[`which post-mortems were read could not be read: ${n.reason}`]:[],...r,...i.map(e=>`daemon ${e.pid} (started ${e.started}, rss ${Nn(e.rss)} MB${e.ppid===1?``:`, child of ${e.ppid}`}) runs beside the one serving the bar (${a}) — \`kill ${e.pid}\``),...o.kind===`measured`&&o.charge.kind===`stand-in`?[`the daemon could not read what macOS charges it (${o.charge.unread}), so its memory limit judges ${o.charge.gap===0?`RSS, which counts pages macOS has reclaimed`:`RSS less the ${Nn(o.charge.gap)} MB it last ran over that charge, an estimate`}`]:[],...o.kind===`measured`&&Rn(o.charge.bytes,s)?[`the daemon holds ${Hn(o.charge)} of its ${Nn(s)} MB limit — at the limit it records a post-mortem and restarts`]:[]]);if(u.ok&&o.kind===`unmeasured`)return{ok:!0,note:`the daemon has not measured its memory yet`};let d=l[0];return u.ok||d===void 0?u:{...u,fix:{kind:`post-mortems-read`,through:d.identity}}}},Xj=`click 🩺 doctor in the bar's settings menu: if it runs, links work`;function Zj(e,t){let n=vj(e);return t.kind===`ok`&&n!==null&&t.value.includes(n)?{kind:`draws`}:e.kind===`known`?bj(e.terminal):{kind:`unknown`}}function Qj({identified:e,tmuxClient:t},n){let r=yj(e),i=Zj(e,n),a=vj(e)===null?Xj:`${Xj}, and the doctor remembers it for this terminal`,o=(()=>{switch(i.kind){case`draws`:return[];case`none`:return[`${r} draws no links (OSC 8), so nothing on the bar can be clicked — run Claude Code in a terminal that draws them: ${xj}`];case`older`:return[`${r} ${i.version} draws no links (OSC 8 came in ${i.since}) — update ${r}`];case`unsaid`:return[`${r} draws links (OSC 8) since ${i.since}, and did not say which release this is — ${a}`];case`unknown`:return[`the doctor does not know whether ${r} draws links (OSC 8) — ${a}`]}})(),s=n.kind===`failed`&&i.kind!==`draws`?[`the terminals a doctor click came back from could not be read: ${n.reason}`]:[],c=i.kind===`none`||t===null||t.features.includes(`hyperlinks`)?[]:[`tmux does not pass links through to ${r} — add \`set -as terminal-features ",${t.termname}:hyperlinks"\` to tmux.conf, then detach and reattach (tmux 3.4 or later)`];return[...o,...s,...c]}const $j={name:`links`,label:`links`,takesMark:!1,probe:({sighted:e,terminal:t,clicked:n})=>{if(e.kind===`clicked`&&e.via===`link`)return{ok:!0};switch(t.kind){case`unreported`:return{ok:!1,reason:"the client reported no terminal — re-run `cc-candybar install` to stage a current client"};case`unasked`:return{ok:!1,reason:`tmux could not be asked which terminal is attached: ${t.reason}`};case`seen`:return jj(Qj(t,n))}}},eM=e=>e.filter(e=>e.role===`statusline`),tM={name:`effectRefresh`,label:`effect refresh`,takesMark:!1,probe:({frames:e,claudeSettings:{origin:t,elsewhere:n},sighted:r})=>{let i=[t,...n].flatMap(({sources:e,bars:t})=>iM(e,nM(t))??[]),[a]=i;if(a===void 0)return e.kind===`failed`?{ok:!1,reason:e.reason}:rM(r.kind===`recent`?`no session has drawn a statusline for this daemon in the last ${300/60} minutes`:Gj(r));let[o,...s]=i.flatMap(e=>e.ok?[]:[e]);if(o===void 0)return a;let c=[...new Set(s.map(e=>e.reason))].filter(e=>e!==o.reason);return c.length===0?o:{...o,more:c}}},nM=e=>{let t=eM(e).map(e=>e.frame);return t.includes(`moves`)?{kind:`moving`,wearing:`the bar moves (an effect, a fade, or an animated segment)`}:t.includes(`can-move`)?{kind:`moving`,wearing:`the bar can start moving (a globals.effect rule, placements that fade in and out, or a placement with an effect of its own that is not drawn now)`}:t.includes(`still`)?{kind:`still`}:t.includes(`drawing`)?{kind:`unknown`,unseen:`the bar's latest render has not finished`}:t.length>0?{kind:`unknown`,unseen:`the bar's recent renders failed`}:e.length>0?{kind:`unknown`,unseen:"only a `cc-candybar frames` display has drawn this bar, not Claude Code's statusline"}:{kind:`none`}},rM=e=>({ok:!1,reason:`${e}, so whether it moves is unknown — run the doctor again once the bar has redrawn`});function iM(e,t){let n=Sj(e);if(n.kind===`present`&&n.refreshInterval===1)return{ok:!0,note:`statusLine.refreshInterval is 1 in ${n.from.path}`};switch(t.kind){case`none`:return null;case`still`:return{ok:!0};case`unknown`:return rM(t.unseen);case`moving`:break}let{wearing:r}=t;switch(n.kind){case`unread`:return{ok:!1,reason:`${r}, and Claude Code's settings could not be read: ${n.reason}`};case`absent`:return{ok:!1,reason:`${r}, and no settings file Claude Code reads here sets a statusLine (read: ${n.read.join(`, `)||`none`}) — the one that runs the bar comes from --settings, MDM or server-managed settings, which the doctor cannot read; set "refreshInterval": 1 beside its command there`};case`not-an-object`:return{ok:!1,reason:`${r}, and ${n.from.path} sets statusLine to ${JSON.stringify(n.value)}, not a statusLine object — ${n.from.scope===`user`?"re-run `cc-candybar install` to write one":`replace it there with the statusLine object that runs cc-candybar`}`};case`present`:{let{from:e,refreshInterval:t}=n,i=t===void 0?`its statusLine sets no refreshInterval, so Claude Code redraws it only on events`:typeof t==`number`&&t>1?`its statusLine redraws it only every ${t} s`:`its statusLine.refreshInterval is ${JSON.stringify(t)}, not a number of seconds Claude Code accepts (its minimum is 1)`;return Tj(e)?{ok:!1,reason:`${r}, but ${i} (statusLine from ${e.path})`,fix:{kind:`claude-settings`,file:e,path:[`statusLine`,`refreshInterval`],value:1}}:{ok:!1,reason:`${r}, but ${i} — its statusLine is in ${e.scope===`managed`?`managed settings`:`the project's shared settings`}, ${e.path}: set "refreshInterval": 1 there`}}}}const aM=e=>[...e].map(e=>`U+${e.codePointAt(0).toString(16).toUpperCase()}`).join(` `);function oM(e){switch(e.kind){case`unreported`:case`unasked`:return`this terminal`;case`unknown`:case`unnamed`:return yj(e);case`bundling`:case`unread`:case`configured`:return[cj(e.name),e.version].filter(e=>e!==null).join(` `)}}function sM(e){switch(e.kind){case`unreported`:case`unasked`:return null;case`unknown`:case`unnamed`:return vj(e);case`bundling`:case`unread`:return cj(e.name);case`configured`:{let t=cj(e.name);return e.font.kind===`ok`?`${t} with ${e.font.value.font} (${e.font.value.from})`:`${t}, its font unread: ${e.font.reason}`}}}function cM(e){let t=sM(e.terminal);return t===null?void 0:{glyphs:e.glyphs,id:`${t}|${aM(e.glyphs)}`}}const lM={name:`nerdFont`,label:`Nerd Font`,takesMark:!0,probe:({nerdFont:e,marks:t})=>{if(e.kind===`none`)return{ok:!0};let n=cM(e),r=e=>t.kind===`failed`&&n!==void 0?{ok:!1,reason:e,more:[`the mark book could not be read: ${t.reason}`]}:{ok:!1,reason:e,...n!==void 0&&{sighting:n}},i=e.terminal,a=oM(i);switch(n===void 0||t.kind===`failed`?null:t.value.nerdFont?.[n.id]??null){case`drawn`:return{ok:!0};case`boxes`:return r(`${a} draws ${aM(e.glyphs)} as boxes — set a Nerd Font as its font`);case null:break}switch(i.kind){case`unreported`:return r("the client reported no terminal — re-run `cc-candybar install` to stage a current client");case`unasked`:return r(`tmux could not be asked which terminal is attached: ${i.reason}`);case`unknown`:case`unnamed`:case`unread`:return r(`the doctor cannot read ${a}'s font`);case`bundling`:{let e=ij[i.name].glyphs.since;if(e===null)return{ok:!0};let t=i.version===null?null:pj(i.version,e);if(t===!0)return{ok:!0};let n=cj(i.name);return r(t===null?`${n} ships Nerd Font symbols since ${e}, and did not say which release this is`:`${a} ships no Nerd Font symbols (they came in ${e}) — update ${n}, or set a Nerd Font as its font`)}case`configured`:{if(i.font.kind===`failed`)return r(`the doctor cannot read ${a}'s font: ${i.font.reason}`);let{font:e,from:t,lacks:n}=i.font.value;return n===null?r(`${a} is set to ${e} (${t}), which is not installed — install it or set a Nerd Font`):n.length===0?{ok:!0}:r(`${a} draws with ${e} (${t}), which has no ${aM(n)} — set a Nerd Font as its font`)}}}};function uM(e){return e.join(`, `)}function dM(e){return`or set missingData: "ignore" on ${uM(e)}`}function fM(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;if(n.kind===`failed`)return[`${uM(t)}: whether the forge CLI is ready could not be asked: ${n.reason}`];if(n.value===null)return[];let{cli:r,host:i,status:a}=n.value;return a===`ready`?[]:a===`missing`?[`${uM(t)}: ${r} is not installed, so no pull request is ever shown — install it, ${dM(t)}`]:[`${uM(t)}: ${r} is not logged in to ${i} (${a.loggedOut}) — run \`${r} auth login --hostname ${i}\`, ${dM(t)}`]}function pM(e,t){if(e.kind===`unneeded`)return[];let{segments:n,fact:r}=e;return r.kind===`failed`?[`${uM(n)}: ${r.reason}`]:r.value.length===0?[t.kind===`recent`?`${uM(n)}: no session of this Claude Code has drawn a bar for this daemon in the last ${300/60} minutes, so whether it sends rate_limits is unseen — run the doctor again once the bar has redrawn`:`${uM(n)}: ${Gj(t)}, so whether Claude Code sends rate_limits is unseen — run the doctor again once the bar has redrawn`]:r.value.includes(`missing`)&&!r.value.includes(`carried`)?[`${uM(n)}: Claude Code sent no rate_limits — it sends them only to Claude.ai subscription sessions; on any other account, set missingData: "ignore" on ${uM(n)}`]:[]}function mM(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;switch(n.located.kind){case`ok`:return[];case`absent`:return[`${uM(t)}: memento is not installed (or is disabled) for ${n.claudeConfigDir} — install the memento plugin, ${dM(t)}`];case`failed`:return[`${uM(t)}: whether memento is installed could not be read: ${n.located.reason}`]}}const hM={name:`segmentData`,label:`segment data`,takesMark:!1,probe:({data:e,sighted:t})=>jj([...fM(e.pullRequests),...pM(e.rateLimits,t),...mM(e.memento)])};function gM({path:e,answered:t,read:n}){switch(n.kind){case`absent`:return t?[`the transcript ${e} does not exist, though Claude Code has answered in its session — the bar's session cost, metrics and activity read nothing`]:[];case`failed`:return[`the transcript ${e} cannot be read: ${n.reason}`];case`ok`:{let{lines:t,unparsed:r,whole:i}=n.value;return r===0?[]:[`${r} of the ${t} lines ${i?`in`:`in the last ${Oj/1024/1024} MiB of`} the transcript ${e} are not JSON objects — the bar skips them, so what it counts from them is missing`]}}}const _M=[Rj,Kj,Yj,Vj,$j,Pj,Fj,Ij,tM,lM,hM,{name:`sessionData`,label:`session data`,takesMark:!1,probe:({transcripts:e,sighted:t})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.length===0?{ok:!1,reason:t.kind===`recent`?`no session has drawn a bar for this daemon in the last ${300/60} minutes, so no transcript was named — run the doctor again once the bar has redrawn`:`${Gj(t)}, so which transcript it reads is unknown — run the doctor again once the bar has redrawn`}:jj(e.value.flatMap(gM))}],vM=_M.filter(e=>e.takesMark);function yM(e){return _M.map(t=>({check:t,verdict:t.probe(e)}))}function bM(e){return _M.find(t=>t.name===e)}const xM=/^[^\s"=\\]+$/,SM=e=>xM.test(e)?e:JSON.stringify(e),CM=`${X}doctor.`;function wM(e){let t=`${CM}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`,sighting:`${t}sighting`}}function TM(e,t){let n=e.kind===`seen`?e.tmuxClient:null,r=e.kind===`seen`?vj(e.identified):null,i=t.kind===`failed`?`unread`:r===null?`-`:t.value.includes(r)?`yes`:`no`;return`tmuxLinks=${n===null?`-`:n.features.includes(`hyperlinks`)?`yes`:`no`} clicked=${i}`}function EM(e,t){let n=e.kind===`seen`?e.tmuxClient:null;return`cols=${t.kind===`failed`?`failed widthOf=-`:`${t.value.columns??`-`} widthOf=${t.value.of.kind}`} clientUtf8=${n===null?`-`:n.utf8?`yes`:`no`}`}function DM(e){if(e.kind===`failed`)return`clients=unasked`;let{daemon:t,clients:n}=e.value;return`clients=${n.map(e=>{if(e.kind===`unreported`)return`unreported/-/-`;let{bundle:n,source:r}=Hj(t,e);return`${e.client}/${n.kind}/${r.kind===`uncompared`?`-`:r.kind}`}).join(`,`)||`-`}`}const OM=e=>`${e>=0?`+`:``}${Nn(e)}`;function kM({serving:e,processes:t,read:n}){let r=t.kind===`failed`?`daemons=unread others=-`:`daemons=${t.value.length} others=${Jj(e,t.value).map(e=>e.pid).join(`,`)||`-`}`;if(e.kind===`failed`)return`${r} memory=unasked postMortems=unasked`;let{memory:i,limit:a,postMortems:o}=e.value,s=o.kind===`failed`||n.kind===`failed`?`unread`:`${qj(e.value,n).length}/${o.value.length}`;return`${r} memory=${i.kind===`unmeasured`?`unmeasured`:`${Un(i.charge)}${i.charge.kind===`stand-in`?`(${OM(-i.charge.gap)})`:``}:${Nn(i.charge.bytes)}`}/${Nn(a)} postMortems=${s}`}function AM(e){let t=()=>{if(e.pullRequests.kind===`unneeded`)return`-`;let t=e.pullRequests.fact;if(t.kind===`failed`)return`failed`;if(t.value===null)return`no-forge`;let{status:n}=t.value;return typeof n==`string`?n:`logged-out`},n=()=>{if(e.rateLimits.kind===`unneeded`)return`-`;let t=e.rateLimits.fact;if(t.kind===`failed`)return`failed`;let n=e=>t.value.filter(t=>t===e).length;return`${n(`carried`)}/${n(`missing`)}/${n(`unanswered`)}`},r=e.memento.kind===`unneeded`?`-`:e.memento.fact.located.kind===`ok`?`located`:e.memento.fact.located.kind;return`data=pr:${t()},rateLimits:${n()},memento:${r}`}function jM(e,{origin:t,elsewhere:n}){let r=[t,...n],i=r.map(({sources:e})=>MM(e)).join(`,`);if(e.kind===`failed`)return`frames=failed chains=${SM(i)}`;let a=eM(r.flatMap(e=>e.bars));return`frames=${ej.map(e=>a.filter(t=>t.frame===e).length).join(`/`)} chains=${SM(i)}`}function MM(e){let t=Sj(e);switch(t.kind){case`unread`:return`failed`;case`absent`:case`not-an-object`:return t.kind;case`present`:return`${t.from.scope}:${t.refreshInterval===void 0?`-`:JSON.stringify(t.refreshInterval)}`}}function NM(e){let t=Cj(e,Mj);return t.kind===`failed`?`truecolorEnv=failed`:t.value.kind===`unset`?`truecolorEnv=unset`:`truecolorEnv=${SM(`${t.value.from.scope}:${JSON.stringify(t.value.value)}`)}`}function PM(e){if(e.kind===`failed`)return`transcripts=failed`;let t=t=>e.value.filter(e=>e.read.kind===t).length,n=e.value.reduce((e,t)=>e+(t.read.kind===`ok`?t.read.value.unparsed:0),0);return`transcripts=${t(`ok`)}/${t(`absent`)}/${t(`failed`)} unparsed=${n}`}function FM(e,t){if(e.kind===`none`)return`glyphs=- terminal=- font=- mark=-`;let{glyphs:n,terminal:r}=e,i=[...n].map(e=>e.codePointAt(0).toString(16)),a=(()=>{switch(r.kind){case`unreported`:case`unasked`:return r.kind;case`unknown`:return`unknown:${JSON.stringify(r.called)}`;case`unnamed`:return`unnamed:${JSON.stringify(r.term)}`;case`bundling`:case`unread`:case`configured`:return`${r.name}@${r.version??`-`}`}})(),o=(()=>{if(r.kind!==`configured`)return`-`;if(r.font.kind===`failed`)return`failed`;let{font:e,lacks:t}=r.font.value;return`${JSON.stringify(e)}:${t===null?`not-installed`:`lacks${t.length}`}`})(),s=cM(e),c=t.kind===`failed`?`unread`:s===void 0?`-`:t.value.nerdFont?.[s.id]??`-`;return`glyphs=${i.join(`,`)} terminal=${a} font=${o} mark=${c}`}function IM(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function LM(e){return e.flatMap(({check:e,verdict:t})=>{let n=wM(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:t.note??``},{key:n.fixable,value:og},{key:n.sighting,value:``}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:IM(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?og:ag},{key:n.sighting,value:t.sighting?.glyphs??``}]})}const RM={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function zM(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }}{{ if ne .resume_command "" }} {{ action "${t(`copyResume`)}" "⎘ resume" }}{{ end }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}{{ if ne .config_path "" }} {{ action "${t(`openConfig`)}" "↗ config" }}{{ end }}`,actions:Object.fromEntries(Object.entries(RM).map(([t,n])=>[`${e}${t}`,n]))}}const BM=`armed`,VM=`disarmed`,HM=`.armed`,UM=e=>e.endsWith(HM);function WM(e,t,n){let r=`${e}${HM}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${BM}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:BM},[a]:{set:r,to:VM},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:VM}},disarm:a}}const GM=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function KM(e){return typeof e==`string`&&GM.test(e)?{kind:`line`,line:e}:{kind:`refused`,reason:`a slash command is "/" then its name, e.g. "/compact" or "/model opus", on one line with no control characters, got ${JSON.stringify(e)}`}}function qM(e){let t=KM(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const JM=[`/compact`,`/model`],YM=`/clear`;function XM(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=WM(`${e}clear`,{arm:YM,confirm:`${YM} ✓ confirm`},[n]);return{template:JM.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${qO} }}`,actions:{...Object.fromEntries(JM.map(e=>[t(e),{slash:qM(e)}])),...r.actions,[n]:{slash:qM(YM)}},variables:r.variables,disarm:r.disarm}}const ZM=Array.from({length:10},(e,t)=>(t+1)*1e5),QM=ZM[0],$M=ZM[ZM.length-1];function eN(e){let t;try{t=Da(e)}catch(e){return L(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?F(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=QM&&n<=$M?F(n):L(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${QM}–${$M} tokens)`)}function tN(e,t){let n=Math.min(t??$M,$M),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:ZM.filter(e=>e<r).at(-1)??0,higher:ZM.find(e=>e>r&&e<=n)??0}}function nN(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${qO} }}{{ if gt .autocompact.lower 0 }} {{ action (printf "${e}%d" .autocompact.lower) "−" }}{{ end }}{{ if gt .autocompact.higher 0 }} {{ action (printf "${e}%d" .autocompact.higher) "+" }}{{ end }}{{ if gt .autocompact.window 0 }} {{ action "${e}auto" "↺" }}{{ end }}{{ end }}{{ end }}`,bg:`{{ if ne .autocompact.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .autocompact.window 0) (ne .autocompact.error "") }}`,actions:{[`${e}auto`]:{slash:qM(`/autocompact auto`)},...Object.fromEntries(ZM.map(t=>[`${e}${t}`,{slash:qM(`/autocompact ${t}`)}]))}}}const rN=e=>`{{ if ge ${e} 1000000 }}{{ printf "%.1f" (divf ${e} 1000000) }}M{{ else if ge ${e} 1000 }}{{ printf "%.1f" (divf ${e} 1000) }}K{{ else }}{{ ${e} }}{{ end }}`,iN=`${X}menu`,aN=`open`,oN=`${X}edit`,sN=`${X}toolbar`,cN=zM(X),lN=`${X}commands`,uN=XM(`${lN}.`),dN=`${X}autocompact`,fN=nN(`${dN}.`,rN),pN=e=>({kind:`segment`,name:e}),mN=`${X}tab`,hN=e=>`${mN}.${e}`,gN=e=>`${hN(e)}.toggle`,_N=e=>({variable:mN,key:mN,member:e}),vN=`${X}save`,yN=`${X}preset.save`,bN=`${X}preset.delete`,xN=e=>`${X}${e}`,SN=e=>`${X}apply.${e}`,CN=e=>`${X}reset.${e}`,wN=`${X}themeDefault.save`,TN=`${X}themeDefault.differs`,EN=`${X}themeDefault.theme`,DN={when:`{{ .${TN} }}`,template:`{{ action "${wN}" (printf "⤓ default for %s" .${EN}) }} {{ swatch "${SN(`theme`)}" .${EN} }}`},ON=`${X}resetAll`,kN=`${iN}.toggle`,AN={variable:iN,key:iN,member:aN},jN=`${X}undo`,MN=`${X}back`,NN=`${MN}.step`,PN=`${X}navigation.back`,FN=MN,IN={template:`{{ if gt .${PN} 0 }}{{ action "${MN}" "◁" }}{{ else }}{{ fg (${KA}) "◁" }}{{ end }}`},LN=`${X}redo`,RN=`${X}doctor`,zN=`${RN}.run`,BN=e=>`${RN}.fix.${e}`,VN=(e,t)=>`${RN}.mark.${e}.${t}`,HN=e=>`${RN}.${e}`,UN={drawn:`[✓ shapes]`,boxes:`[✗ boxes]`},WN=ok(`${X}pickers`),GN=e=>`${X}${e}`,KN=e=>`${GN(e)}.toggle`,qN=e=>FA(e)?ok(`${X}${e}Pickers`):WN,JN=e=>{let t=qN(PA[MA[e].beside]);return{variable:t,key:t,member:e}},YN={layout:{template:`{{ layoutPreview }}`},palette:{template:`{{ themePreview }}`},presetDelete:{when:`{{ not .preset.bundled }}`,template:`{{ action "${bN}" (printf "🚮 delete %s" .${sv.preset.effectiveVar}) }}`}},XN=(e,t)=>`${X}list.${e}.${t}`,ZN=e=>`${X}resettable.${e}`,QN=e=>e.length===0?`false`:`(or ${e.map(e=>`.${ZN(e)}`).join(` `)})`,$N=E_.map(e=>[T_[e].setting,e]),eP={variables:{},actions:{},segments:{}},tP=Object.fromEntries($N.map(([e,t])=>[e,bA(`${X}help.${e}`,WA[t],[],eP)])),nP=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],rP=e=>{let t=t=>`.${A_(e,t)}`,n=nP.map(e=>`${1/30} "${e}"`).join(` `);return`{{ if .${sv[T_[e].setting].effectiveVar} }} {{ if ${t(`subscribers`)} }}{{ frames ${n} }} {{ ${t(`fps`)} }} fps{{ if not ${t(`shown`)} }} · off screen{{ end }}{{ else }}no subscriber{{ end }}{{ end }}`},iP=`{{ if eq .${O_(`by`)} "feed" }} {{ printf "%2d" (int .${O_(`fps`)}) }} fps{{ end }}`,aP=Object.fromEntries($N.map(([e,t])=>[e,rP(t)])),oP=Object.keys(sv).map(e=>{let t=sv[e],n=xk(t.configKey),r=vk({label:t.label,domain:n},t.sessionKey,t.effectiveVar,SN(e),qN(PA[e]));return{...t,name:e,control:r,beneath:t.previews.map(e=>YN[e])}}),sP=e=>oP.filter(t=>PA[t.name]===e),cP=e=>oP.filter(t=>IA(PA[t.name],e)),lP=e=>t=>`(print ${ri(t)} (ternary ${ri(` •`)} "" ${QN(cP(e).map(e=>e.name))}))`,uP=e=>NA.filter(t=>MA[t].beside===e),dP=e=>sP(e).flatMap(e=>[CP(e),...[tP[e.name]].filter(e=>e!==void 0),...uP(e.name).map(e=>Qr(GN(e),JN(e),AP(e),`drop`))]);new Set(oP.flatMap(e=>[e.sessionKey,e.configKey]));const fP=WM(ON,{arm:`⟲`,confirm:`⟲ reset all?`},oP.map(e=>CN(e.name))),pP=[`unsaved`,`history.undo`,`history.redo`],mP=e=>`${X}${e}`,hP=mP(`unsaved`),gP=(e,t)=>({body:t,shown:`(gt .${mP(e)} 0)`}),_P=[gP(`unsaved`,`{{ action "${vN}" (printf "💾 save %d" .${hP}) }}`),gP(`history.undo`,`{{ action "${jN}" "↶" }}`),gP(`history.redo`,`{{ action "${LN}" "↷" }}`),{body:fP.template,shown:`(or ${QN(oP.map(e=>e.name))} ${fP.armed})`}],vP={when:`{{ or ${_P.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+_P.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},yP=[{step:fP,place:`door`},{step:uN,place:`session`}],bP=e=>e.map(e=>e.step.disarm),xP=bP(yP),SP=bP(yP.filter(e=>e.place!==`door`));function CP(e){let t=xN(e.name);return e.control.kind===`inline`?pN(t):Qr(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[...e.control.list.rows,...e.beneath].map((t,n)=>pN(XN(e.name,n)))},`drop`)}function wP(e){return e===iN}function TP(e){let t=pN(iN);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[TP(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function EP(e){return DP(e)>0?e:TP(e)}function DP(e){let t=0;for(let n of _g(e))n.kind===`segment`&&wP(n.name)&&(t+=1);return t}function OP(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&wP(e.name)||e.opens!==void 0&&OP(e.opens.body,!0):e.children.some(e=>OP(e,n))}const kP={door:{direction:`horizontal`,content:[pN(FN)],after:[pN(oN),pN(vN)]},session:{direction:`vertical`,content:[pN(sN),{kind:`container`,direction:`horizontal`,children:[pN(lN),pN(dN)]}],after:[]},look:{direction:`horizontal`,content:[],after:[]},layout:{direction:`horizontal`,content:[pN(yN)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[pN(RN),..._M.map(e=>pN(HN(e.name)))],after:[]},gear:{direction:`horizontal`,content:[],after:[pN(wN)]},toggles:{direction:`horizontal`,content:[],after:[]}};function AP(e){let{direction:t,content:n,after:r}=kP[e];return{kind:`container`,direction:t,children:[...n,...dP(e),...r]}}function jP(e){return e.kind===`segment`?wP(e.name)?Qr(e.name,AN,NP,`above`):e:FP(e)}function MP(){return{kind:`container`,direction:`vertical`,children:[AP(`door`),{kind:`container`,direction:`horizontal`,children:AA.map(({member:e})=>Qr(hN(e),_N(e),AP(e),`drop`))}]}}const NP=MP();function PP(e){let t=new Map;for(let e of _g(NP))e.kind===`segment`&&e.opens!==void 0&&t.set(e.opens.ref.key,e.opens.ref.variable);return[...t].map(([t,n])=>{let r=e.variables[n];if(r?.kind!==`state`||r.default===void 0)throw Error(`settings menu: the door folds "${t}", but "${n}" is not a state variable the menu declares with a default`);let i=`${iN}.fold.${XO(t)}`;return e.actions[i]={set:t,to:r.default},i})}function FP(e){return{...e,children:e.children.map(e=>jP(e))}}function IP(e){let t={variables:{[iN]:ii(iN,P)},actions:{[kN]:ai(iN,aN),[zN]:{doctor:`run`},[oN]:{do:[...lA]},...cN.actions,...uN.actions,...fN.actions,[vN]:{save:!0},[jN]:{undo:!0},[NN]:{back:!0},[MN]:{do:[NN,...xP]},[LN]:{redo:!0},[yN]:{preset:`save`},[wN]:{themeDefault:`save`},[bN]:{preset:`delete`,name:`{{ .${sv.preset.effectiveVar} }}`}},segments:{[iN]:{template:`{{ $door := ${ni(iN,ri(e),ri(`✖`))} }}{{ if ${ei(AN)} }}{{ fg (keptOn (color "error") (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`+iP},[sN]:{template:cN.template},[lN]:{template:uN.template,when:uN.when},[dN]:{template:fN.template,bg:fN.bg,when:fN.when},[FN]:IN,[vN]:vP,[wN]:DN,[yN]:{template:`{{ action "${yN}" "+ preset" }}`},[RN]:{template:`{{ action "${zN}" "🩺 doctor" }}`},[oN]:{template:`{{ action "${oN}" "✎ arrange" "✎ done" }}`}}};t.variables[TN]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[EN]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[PN]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of pP)t.variables[mP(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[mN]=ii(mN,`session`);for(let{member:e,label:n}of AA){t.actions[gN(e)]=ai(mN,e),t.actions[hN(e)]={do:[gN(e),...SP]};let r=lP(e);t.segments[hN(e)]={template:`{{ ${ni(hN(e),r(n),r(`▾ ${n}`))} }}`}}return Object.assign(t.variables,uN.variables,fP.variables),RP(t),LP(t),t.actions[iN]={do:[kN,...xP,...PP(t)]},t}function LP(e){for(let t of _M){let n=wM(t.name),r=BN(t.name);for(let t of Object.values(n))e.variables[t]={kind:`state`,key:t,default:``};e.actions[r]={doctor:`fix`,check:t.name};let i=t.takesMark?Dj:[];for(let n of i)e.actions[VN(t.name,n)]={doctor:`mark`,check:t.name,mark:n};let a=i.map(e=>` {{ action "${VN(t.name,e)}" "${UN[e]}" }}`).join(``);e.segments[HN(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ if ne .${n.reason} "" }} — {{ .${n.reason} }}{{ end }}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${ag}" }} {{ action "${r}" "[fix]" }}{{ end }}`+(a===``?``:`{{ if ne .${n.sighting} "" }} {{ .${n.sighting} }}${a}{{ end }}`)+`{{ end }}`}}}function RP(e){for(let t of oP){Object.assign(e.actions,t.control.actions);let n=CN(t.name);e.actions[n]={reset:t.configKey},e.variables[ZN(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${ZN(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[xN(t.name)]={template:`${t.control.template}${aP[t.name]??``}${r}`},t.control.kind===`picker`&&[...t.control.list.rows.map(e=>({template:e})),...t.beneath].forEach((n,r)=>{e.segments[XN(t.name,r)]=n})}Object.assign(e.actions,fP.actions),Object.assign(e.variables,eP.variables),Object.assign(e.actions,eP.actions),Object.assign(e.segments,eP.segments);for(let t of NA){let n=JN(t);e.actions[KN(t)]=ai(n.key,n.member),e.segments[GN(t)]={template:`{{ action "${KN(t)}" ${lP(t)(MA[t].trigger)} }}`}}}function zP(e){let{variables:t,actions:n}=vA();Object.assign(e.variables,t),Object.assign(e.actions,n)}function BP(e){let t=IP(e.globals.menuGlyph??`🍫`);zP(t);let n={...e.presets},r=[];for(let t of Iy(e.presets)){let{node:i}=zy(e,t),a=jP(EP(i));r.push(a),n[t]={...Ry(e.presets,t),root:a}}let i=YO(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const VP=`${$O}live`,HP=[`☐ live`,`☑ live`],UP=`${$O}done`,WP=`${$O}cancel`,GP=`${$O}rewind`,KP=`${$O}changes`,qP=`(gt .${KP} 0)`,JP=`(or ${qP} (gt .${hP} 0))`,YP={variable:VP,key:VP,member:`open`};function XP(e){return`${$O}configuring.p${e}`}function ZP(e){return`and ${ei(pA)} (not ${ei(YP)}) (ne .${XP(e)} "true")`}function QP(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${oA} "${Zr(e)}")`).join(` `)} false }}`}}function $P(e,t,n){return`{{ if ${ZP(e)} }}${t}{{ else }}${n}{{ end }}`}const eF=`{{ and ${ei(pA)} .preset.customized }}`,tF=tk;function nF(e){return new Map([...Wy(e),...iF(e)])}const rF=`${$O}addable`;function iF(e){return new Map([[rF,{members:Object.keys(e.segments).filter(e=>!tF(e)),library:{groups:nA.map(e=>({id:e,label:rA[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function aF(e,t,n){return n.segments[e]={template:t,when:mA,bg:SA},{kind:`segment`,name:e}}function oF(e,t,n){let r=`${$O}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${eh}`}) (action "${r}" "✖") }}`}function sF(e){return`{{ if ${ei(pA)} }}${e}{{ end }}`}function cF(e,t){return e.reduce((e,t)=>`{{ if and ${ei(pA)} ${ei(t)} }}true{{ else }}${e}{{ end }}`,t)}function lF(e){return e.flatMap(e=>[..._g(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function uF(e,t,n){return`${dA}${e}.${t}.${n}`}function dF(e,t,n,r){let i=pg(n),a=`${$O}${e.presetIdent}`,o=fA(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=ok(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:P},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:oA,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=uF(e.presetIdent,i,r),l=`${dA}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:Ig(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=vk(gk(o),s,l,d,c);if(Object.assign(e.artifacts.actions,f.actions),Object.assign(e.artifacts.variables,f.variables),f.kind===`inline`)return e.artifacts.segments[d]={template:f.template},{kind:`segment`,name:d};e.artifacts.segments[d]={template:f.template};let p=f.list.rows.map((t,n)=>{let r=`${d}.list.${n}`;return e.artifacts.segments[r]={template:t},{kind:`segment`,name:r}});return Qr(d,f.list.ref,{kind:`container`,direction:`vertical`,children:p},`drop`)});return{term:`{{ action "${s}" "${OA}" }}`,ref:{variable:oA,key:oA,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const fF=`${$O}label:`;function pF(e){if(e.startsWith(fF)){let t=e.slice(fF.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function mF(e,t,n,r){let{artifacts:i}=n,a=pg(e),o=`${fF}${a}:${e.name}`;i.segments[o]={template:`{{ "${Zr(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=Object.fromEntries(jg.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...Qr(o,r.ref,r.body,`drop`,cF([r.ref],`{{ ${ZP(n.presetIdent)} }}`)),...Object.keys(s).length>0&&{settings:s},drafts:Object.fromEntries(jg.map(e=>[e,r.drafts[e]]))}}function hF(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${$O}${i}.insert.${t}`,s=`${$O}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:rF,anchor:n,relation:r};let c=ik(o),l=ak(s,o,void 0),u=ck(l),d=sk(l,c);return a.variables[l]=ii(l,P),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=ai(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${ei({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${eh}`}) $m }}{{ end }}`}}function gF(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!tF(e.name)),i=e=>gF(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=gg(o,i);if(tF(o.name)){n.push(s);continue}let c=pg(o),l=a===r?[hF(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=hF(t,u,c,`after`),f=oF(t,u,c),p=t.segments[o.name],m=dF(t,u,o,Mg(p)),h=sF(f),g=sF(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>aF(e.host,e.template,t.artifacts)),{...mF(o,p,t,m),lead:h,trail:g},{...s,when:$P(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},aF(d.host,d.template,t.artifacts)]};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[_]}:_)}return{...e,children:n,...e.when!==void 0&&{when:cF(lF(n),$P(t.presetIdent,`true`,e.when))}}}function _F(e,t,n,r,i,a,o){let s=`${$O}${t}.resetLayout`,c=`${$O}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:eF},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},vF(e,o)]}}function vF(e,t){if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[e,t]};let n=e.children.at(-1);return e.direction===`vertical`&&n!==void 0&&(n.kind===`segment`||n.when===void 0)?{...e,children:[...e.children.slice(0,-1),vF(n,t)]}:{...e,children:[...e.children,t]}}function yF(e,t,n,r,i,a){let{node:o}=zy(e,t),s={presetIdent:XO(t),rootKey:Yk(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=gF(o,s);return n.variables[XP(s.presetIdent)]=QP(s.configured),_F(c,s.presetIdent,s.rootKey,n,r,i,a)}function bF(e){let t={variables:{},actions:{},segments:{}},n=bA(`${$O}help`,UA,[pA],t);t.variables[VP]=ii(VP,P),t.actions[VP]=ai(VP,YP.member),t.segments[VP]={template:ti(VP,...HP),when:mA};let r={kind:`segment`,name:VP},i=n;t.variables[KP]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[UP]={do:[vN,...lA]},t.segments[UP]={template:`{{ if ${JP} }}{{ action "${UP}" "✓ save" }}{{ else }}{{ action "${UP}" "✓ done" }}{{ end }}`,when:mA},t.actions[GP]={rewind:!0},t.actions[WP]={do:[GP,...lA]},t.segments[WP]={template:`{{ action "${WP}" "↩ cancel" }}`,when:`{{ and ${ei(pA)} ${qP} }}`};let a=[{kind:`segment`,name:UP},{kind:`segment`,name:WP}],o={...e.presets},s=[];for(let n of Iy(e.presets)){let c=yF(e,n,t,a,r,i);s.push(c),o[n]={...Ry(e.presets,n),root:c}}let c=YO(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}function xF(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function SF(e){let t=e.split(`:`);return t[0]===`remove`&&t.length===2&&t[1]?{op:`remove`,target:t[1]}:t[0]===`insert`&&t.length===4&&t[1]&&t[2]&&(t[3]===`before`||t[3]===`after`)?{op:`insert`,segment:t[1],anchor:t[2],relation:t[3]}:null}function CF(e,t,n){let r=hg(e,new Set(n.map(mg).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const wF=/^-?\d+$/;function TF(e,t,n=`set-state`){let r=e.filter(e=>e.includes(`/`));if(r.length>0)throw Error(`makeAllowListValidator(${t}): values contain "/" — the ${n} wire shape splits values on "/" so slash-bearing options cannot be addressed. Offending values: ${r.join(`, `)}`);if(e.includes(``))throw Error(`makeAllowListValidator(${t}): empty string is not a writable option — the validator rejects empty input before the allow-list check, so an "" in the allowed list could be rendered but never delivered. Remove "" from the allowed list.`);let i=new Set(e),a=[...e];return e=>e?i.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown ${t} "${e}" (have: ${a.join(`, `)})`}:{ok:!1,reason:`${t} value is required`}}function EF(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!wF.test(t))return{ok:!1,reason:`${e} must be an integer, got "${t}"`};let n=t[0]===`-`,r=(n?t.slice(1):t).replace(/^0+/,``);return r===``?{ok:!0,value:`0`}:{ok:!0,value:n?`-${r}`:r}}}function DF(e,t,n){return r=>r?wF.test(r)?{ok:!0,value:String(Math.max(e,Math.min(t,parseInt(r,10))))}:{ok:!1,reason:`${n} must be an integer, got "${r}"`}:{ok:!1,reason:`${n} value is required`}}function OF(e,t,n=`state`){let r=t.filter(e=>e.kind===`range`),i=t.some(e=>e.kind===`int`),a=t.flatMap(e=>e.kind===`allow-list`?e.allowed:[]);if(r.length===0&&!i)return{kind:`allow-list`,allowed:[...new Set(a)]};let o=a.filter(e=>!wF.test(e));if(o.length>0)throw Error(`${n} action table: key "${e}" is an integer spec (a paged cursor or a bounded value) but a click writes non-integer value(s) to it (${o.join(`, `)}). A ${n} key has one key shape — point that click at a distinct key, or write an integer.`);if(i&&r.length>0)throw Error(`${n} action table: key "${e}" is declared as both a paged cursor (int) and a bounded value (range) — a ${n} key has one key shape. Use distinct keys.`);if(r.length>0){let t=Math.min(...r.map(e=>e.min)),i=Math.max(...r.map(e=>e.max)),o=a.filter(e=>{let n=parseInt(e,10);return n<t||n>i});if(o.length>0)throw Error(`${n} action table: key "${e}" is a bounded range [${t},${i}] but a click writes out-of-range value(s) to it (${o.join(`, `)}). The range gate would clamp them, storing a different value than the click renders — write an in-range integer, or point that click at a distinct key.`);return{kind:`range`,min:t,max:i}}return{kind:`int`}}function kF(e){return e===`config`?`set-config`:`set-state`}function AF(e,t,n){return t.kind===`int`?EF(`menu page "${e}"`):t.kind===`range`?DF(t.min,t.max,`${n} stepper "${e}"`):TF(t.allowed,`${n} "${e}"`,kF(n))}function jF(e,t=`state`){let n=new Map;for(let{key:t,spec:r}of e){let e=n.get(t);e?e.push(r):n.set(t,[r])}return[...n].map(([e,n])=>({key:e,spec:OF(e,n,t)}))}function MF(e,t,n,r){let i=new Map(Object.entries(e)),a=new Map,o=new Set(t.map(e=>e.key));for(let{key:e,spec:t}of n)if(o.has(e)&&t.kind!==`allow-list`)throw Error(`${r} gate: key "${e}" is written by the daemon's own links as one of a list of values, and cannot be declared as ${t.kind===`int`?`a paged cursor (int)`:`a bounded value (range)`}. Use a distinct key.`);let s=[...t.map(({key:e,allowed:t})=>({key:e,spec:{kind:`allow-list`,allowed:t}})),...n];for(let{key:t,spec:n}of jF(s,r)){if(!t)throw Error(`${r} gate: key is required`);if(t.includes(`/`))throw Error(`${r} gate: key "${t}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);if(Object.hasOwn(e,t))throw Error(`${r} gate: key "${t}" is a built-in ${r} key and cannot be re-claimed (built-in keys: ${Object.keys(e).join(`, `)})`);i.set(t,AF(t,n,r)),n.kind===`range`&&a.set(t,{min:n.min,max:n.max})}return{validate(e,t){let n=i.get(e);return n?n(t):{ok:!1,reason:`unknown ${r} key "${e}" (have: ${[...i.keys()].join(`, `)})`}},listKeys:()=>[...i.keys()],rangeParamsFor:e=>a.get(e)??null}}function NF(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};MF(e,[o],[],t),r.push(o),i++;let s=!0;return()=>{s&&(s=!1,r.splice(r.indexOf(o),1),i++)}},gateFor(o){let s=a.get(o);if(s?.epoch===i)return s.gate;let c=MF(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const PF=NF({},`config`,VF);function FF(e,t){return PF.register(e,t)}function IF(e){return PF.gateFor(e)}function LF(e,t){return`persist`in e?`to`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Ky(e.from,t).members}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[xF({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[xF({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Ky(e.insertSegmentFrom,t).members.map(t=>xF({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function RF(e,t){let n=Wk(e).get(t);return n===void 0?null:String(n)}function zF(e){let t=new Set;for(let n of Object.values(e.actions)){`reset`in n&&t.add(n.reset);let e=`persist`in n?$k(n.persist):null;e?.scope===`preset-root`&&t.add(Yk(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function BF(e){let t=nF(e);return[...zF(e),...Object.values(e.actions).flatMap(e=>LF(e,t))]}function VF(e){return jF(BF(e),`config`)}function HF(e,t){return{globals:{...t.globals,...e.globals??{}},variables:{...t.variables,...e.variables??{}},segments:GF(t.segments,UF(t.segments,e.segments??{})),root:My(e.root??Ty,t.root),actions:{...t.actions,...e.actions??{}},styles:{...t.styles,...e.styles??{}},presets:GF(t.presets,WF(t.presets,e.presets??{})),themeDefaults:GF(t.themeDefaults,e.themeDefaults??{}),editGlobals:{...t.editGlobals,...e.editGlobals??{}},helpers:{...t.helpers,...e.helpers??{}}}}function UF(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.settings===void 0?n:{...n,settings:{...e[t]?.settings,...n.settings}}]))}function WF(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.globals===void 0?n:{...n,globals:{...e[t]?.globals,...n.globals}}]))}function GF(e,t){return{...e,...Object.fromEntries(Object.entries(t).map(([t,n])=>[t,{...e[t],...n}]))}}function KF(e,t,n,r){return n.cache===void 0?(e.issues.push({path:`${t}.cache`,message:`${r} variables must declare a cache policy (one of: ${Cg.join(`, `)})`,line:K(e.source,t.split(`.`))}),null):YF(e,`${t}.cache`,n.cache)}function qF(e){return{required:!0,json:XF(),parse:(t,n,r,i)=>KF(t,n,i,e)??void 0}}const JF={noun:`cache`,arms:{ttl:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&QF(n)?{ttl:n}:a_(e,t,`cache.ttl must be a duration string like "5s", "100ms", "2m", "1h"; got ${q(n)}`)},watch_file:{json:{type:`string`,pattern:`^/`},parse:(e,t,n)=>{if(typeof n!=`string`)return a_(e,t,`cache.watch_file must be a path string, got ${q(n)}`);let r=__(`cache.watch_file`,n);return r===null?{watch_file:n}:a_(e,t,r)}},depends_on:{json:{type:`array`,items:{type:`string`}},parse:(e,t,n)=>Array.isArray(n)&&n.every(e=>typeof e==`string`)?{depends_on:n}:a_(e,t,`cache.depends_on must be an array of variable-name strings, got ${q(n)}`)},key:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&n!==``?{key:n}:a_(e,t,`cache.key must be a non-empty template string, got ${q(n)}`)},never:{json:{const:!0},parse:(e,t,n)=>n===!0?{never:!0}:a_(e,t,`cache.never must be the literal boolean true, got ${q(n)}`)}}};function YF(e,t,n){return o_(e,JF,t,n)}function XF(){return w_(JF)}const ZF=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/;function QF(e){return ZF.test(e)}function $F(e,t,n){if(n===void 0)return{};if(!Qg(n))return e.issues.push({path:t,message:`${t} must be an object, got ${$g(n)}`,line:K(e.source,t.split(`.`))}),{};let r={};for(let[i,a]of Object.entries(n)){let n=s_(e,TI,`${t}.${i}`,a);n!==null&&(r[i]=n)}return r}function eI(){return{required:!0,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.value;if(typeof i!=`string`&&typeof i!=`number`&&typeof i!=`boolean`){e.issues.push({path:`${t}.value`,message:`literal value must be string|number|boolean, got ${$g(i)}`,line:K(e.source,t.split(`.`))});return}return i}}}function tI(){return{required:!0,json:{enum:[...Tg]},parse:(e,t,n,r)=>{let i=r.field;if(typeof i!=`string`||!Tg.includes(i)){e.issues.push({path:`${t}.field`,message:`git field must be one of: ${Tg.join(`, `)}, got ${JSON.stringify(i)}`,line:K(e.source,[...t.split(`.`),`field`])});return}return i}}}function nI(){return{required:!1,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.type;return Jg(e,t,r,i===`number`||i===`boolean`||i===`string`?i:`string`)}}}const rI={noun:`parse`,arms:{text:{json:{const:!0},parse:(e,t,n)=>n===!0?{text:!0}:a_(e,t,`parse.text must be the literal boolean true, got ${q(n)}`)},regex:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`?iI(e,t,n):a_(e,t,`parse.regex must be a pattern string, got ${q(n)}`)},json:{json:{const:!0},parse:(e,t,n)=>n===!0?{json:!0}:a_(e,t,`parse.json must be the literal boolean true, got ${q(n)}`)}}};function iI(e,t,n){let r;try{new RegExp(n),r=RegExp(`${n}|`).exec(``).length-1}catch(n){return a_(e,t,`parse.regex is not a valid regular expression: ${n.message}`)}return r>=1?{regex:n}:a_(e,t,`parse.regex must contain a capture group — its group 1 is the value; got ${JSON.stringify(n)}`)}function aI(){return{required:!1,json:w_(rI),parse:(e,t,n,r)=>(r.regex!==void 0&&e.issues.push({path:`${t}.regex`,message:`${t}.regex was retired; the regex is the parse step's regex arm now: parse: { regex: ${JSON.stringify(r.regex)} }`,line:K(e.source,[...t.split(`.`),`regex`])}),r.parse===void 0?void 0:o_(e,rI,`${t}.parse`,r.parse)??void 0)}}function oI(){return{required:!1,json:{type:[`string`,`number`,`boolean`,`array`,`object`],description:`The value published when the source fails: a string under the text/regex parse arms, any non-null JSON value under the json arm`},parse:(e,t,n,r)=>Qg(r.parse)&&`json`in r.parse?sI(e,t,r.default):Yg(e,t,r,`default`)}}function sI(e,t,n){if(n!==void 0)return cI(n)?n:a_(e,`${t}.default`,`${t}.default must be a JSON value (a json-parsed source's document), got ${q(n)}`)??void 0}function cI(e){return e!==null&&lI(e)}function lI(e){if(e===null)return!0;switch(typeof e){case`string`:case`boolean`:return!0;case`number`:return Number.isFinite(e);case`object`:{if(Array.isArray(e))return e.every(lI);let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&Object.values(e).every(lI)}default:return!1}}const uI={value:eI(),default:d_()},dI={path:g_(),type:y_([`string`,`number`,`boolean`]),default:nI()},fI={name:g_(),default:d_()},pI={path:v_(),readMode:y_([`whole`,`first-line`]),parse:aI(),cache:qF(`file`),default:oI()},mI={command:g_(),parse:aI(),cache:qF(`shell`),default:oI()};function hI(e){return{cache:`${e}, so it takes no cache policy — delete the key`}}const gI={template:g_(),default:d_()},_I=hI(`a template variable recomputes whenever a variable it reads changes`),vI={layout:g_(),default:d_()},yI=hI(`a time variable reads the instant its render is drawn at`),bI={field:tI(),default:d_()},xI=hI(`a git variable is refreshed by the daemon's own watch on the repository`),SI={key:g_(),default:d_()},CI=`kind`;function wI(e,t,n={}){return{...c_(CI,e,t),parse:(r,i,a)=>{t_(r,n,i,a);let o=n_(r,t,i,a);return o===null?null:{kind:e,...o}}}}const TI={tag:CI,noun:`source kind`,memberNoun:`variable`,arms:{literal:wI(`literal`,uI),input:wI(`input`,dI),env:wI(`env`,fI),file:wI(`file`,pI),shell:wI(`shell`,mI),template:wI(`template`,gI,_I),time:wI(`time`,vI,yI),git:wI(`git`,bI,xI),state:wI(`state`,SI)}};function EI(){return C_(TI)}function DI(){return{type:`object`,additionalProperties:EI()}}const OI=new Map([[`gitTaculous`,{kind:`built-in`,to:`gitaculous`}],[`git`,{kind:`built-in`,to:`gitaculous`}],[`settings.menu`,{kind:`built-in`,to:`candybar.menu`}],[`ticket`,{kind:`plugin`,to:`plugins.lit.ticket`,source:`promptctl/links-issue-tracker`}]]);function kI(e){let t=OI.get(e);if(t===void 0)return``;switch(t.kind){case`built-in`:return` (the built-in segment "${e}" was renamed to "${t.to}" — update this reference)`;case`plugin`:return` (the built-in segment "${e}" became "${t.to}", a segment of the plugin \`cc-candybar plugin install ${t.source}\` installs — update this reference)`}}const AI=/^[A-Za-z_][A-Za-z0-9_]*$/,jI={pattern:AI.source},MI={anyOf:[{type:`boolean`},{type:`string`},{type:`integer`}]},NI={type:`object`,additionalProperties:!1,required:[`label`,`domain`,`default`],properties:{label:{type:`string`,pattern:`^[^\\n\\r]+$`},domain:{anyOf:[{const:`bool`},{type:`array`,items:{type:`string`,pattern:`^[^/\\n\\r]+$`},minItems:1,uniqueItems:!0},{type:`object`,additionalProperties:!1,required:[`min`,`max`],properties:{min:{type:`integer`},max:{type:`integer`},step:{type:`integer`,minimum:1},atLeast:{type:`string`,...jI}}}]},default:MI}},PI=[`label`,`domain`,`default`],FI=[`min`,`max`,`step`,`atLeast`];function II(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))})}function LI(e,t,n){if(n===`bool`)return`bool`;if(Array.isArray(n)){let r=n.filter(e=>typeof e==`string`);if(n.length===0||r.length!==n.length)return II(e,t,`a list domain must be a non-empty list of words, got ${JSON.stringify(n)}`);if(new Set(r).size!==r.length)return II(e,t,`a list domain names each word once, got ${JSON.stringify(n)}`);let i=r.filter(e=>e===``||e.includes(`/`)||/[\n\r]/.test(e));return i.length>0?II(e,t,`a list domain's words must be non-empty, slash-free, and newline-free — configure mode writes each on the set-state wire — got ${JSON.stringify(i)}`):r}if(Qg(n)){let{min:r,max:i,step:a=1,atLeast:o}=n;return Object.keys(n).filter(e=>!FI.includes(e)).length===0&&Number.isInteger(r)&&Number.isInteger(i)&&r<=i&&Number.isInteger(a)&&a>=1&&(o===void 0||typeof o==`string`)?{min:r,max:i,step:a,...o!==void 0&&{atLeast:o}}:II(e,t,`a range domain is { min, max, step?, atLeast? } with integers min ≤ max, a whole step ≥ 1, and atLeast naming another range setting, got ${JSON.stringify(n)}`)}return II(e,t,`domain must be "bool", a list of words, or { min, max }, got ${q(n)}`)}function RI(e,t,n){if(!Qg(n))return II(e,t,`${t} must be { label, domain, default }, got ${$g(n)}`);for(let r of Object.keys(n))PI.includes(r)||II(e,`${t}.${r}`,`Unknown setting key "${r}". Expected one of: ${PI.join(`, `)}`);let{label:r}=n,i=typeof r==`string`&&r.length>0&&!/[\n\r]/.test(r);i||II(e,`${t}.label`,`a setting needs a one-line, non-empty "label" — the name its control shows, spliced into a synthesized template string — got ${q(r)}`);let a=LI(e,`${t}.domain`,n.domain);if(!i||a===void 0)return;let o={label:r,domain:a,default:n.default};return!zI(n.default)||!Fg(o,n.default)?II(e,`${t}.default`,`default must be ${zg(o)}, got ${q(n.default)}`):o}function zI(e){return typeof e==`boolean`||typeof e==`string`||typeof e==`number`}const BI={theme:`its default for this segment is segments.<name>.palette, and a placement sets its own with settings: { ${kg}: "<theme>" }`,effect:`a placement follows the bar's effect, or sets its own with settings: { effect: "<effect>" }`};function VI(e){return jg.includes(e)}function HI(){return{required:!1,json:{type:`object`,propertyNames:{...jI,not:{enum:[...jg]}},additionalProperties:NI},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!Qg(i))return II(e,a,`${a} must be an object of name → { label, domain, default }, got ${$g(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i)){if(!AI.test(t)){II(e,`${a}.${t}`,`setting name "${t}" is read as .settings.${t} in a template, so it must be an identifier (letters, digits, _; not starting with a digit)`);continue}if(VI(t)){II(e,`${a}.${t}`,`setting "${t}" is one every placement already has — ${BI[t]}`);continue}let r=RI(e,`${a}.${t}`,n);r!==void 0&&(o[t]=r)}return o}}}const UI=ek.map(e=>e.replace(/\./g,`\\.`)).join(`|`);function WI(){return{required:!1,json:{type:`string`,minLength:1,pattern:`^(?!${UI})[^:/]+$`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return typeof i==`string`&&i.length>0&&!/[:/]/.test(i)&&!tk(i)?i:II(e,`${t}.${n}`,`a placement "id" must be a non-empty string without "/" or ":", outside the reserved ${ek.map(e=>`"${e}"`).join(`, `)} namespaces, got ${q(i)}`)}}}function GI(){return{required:!1,json:{type:`object`,propertyNames:jI,additionalProperties:MI},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!Qg(i))return II(e,a,`a placement's "settings" must be an object of setting name → value, got ${$g(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i))zI(n)?o[t]=n:II(e,`${a}.${t}`,`setting "${t}" must be a boolean, a word, or a number, got ${$g(n)}`);return o}}}function KI(e){return new Set(Object.keys(e.segments).filter(e=>!tk(e)))}function qI(e,t,n){if(t===void 0)return{};if(!Qg(t))return e.issues.push({path:`segments`,message:`segments must be an object, got ${$g(t)}`,line:K(e.source,[`segments`])}),{};let r={};for(let[i,a]of Object.entries(t)){let t=e_(e,n.has(i)?$I:QI,`segments.${i}`,a);t!==null&&(r[i]=t)}return r}function JI(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>r[n]===void 0?a_(e,`${t}.${n}`,`${t} declares no template — only a segment the bundled default declares may omit it (inheriting the bundled template); a segment of your own needs its own${kI(t.slice(9))}`)??void 0:qg(e,t,r,n)??void 0}}function YI(){return{required:!1,json:{anyOf:[{const:`auto`},{const:`fill`},{type:`integer`,minimum:1}]},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(i===`auto`)return`auto`;if(i===`fill`)return`fill`;if(typeof i==`number`&&Number.isInteger(i)&&i>0)return i;e.issues.push({path:`${t}.${n}`,message:`width must be "auto", "fill", or a positive integer, got ${q(i)}`,line:K(e.source,[...t.split(`.`),n])})}}}}function XI(){return{required:!1,json:DI(),parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return $F(e,`${t}.${n}`,i)}}}const ZI={template:JI(),description:d_(),group:y_(tA),width:YI(),justify:y_(Bg),truncate:y_(Vg),bg:d_(),fg:d_(),when:d_(),palette:h_(),vars:XI(),settings:HI(),missingData:y_(Eg)},QI={noun:`segment key`,fields:ZI},$I={noun:`segment key`,fields:{...ZI,template:d_()}},eL=`#/definitions/LayoutNode`,tL={kind:`container`,direction:`vertical`,children:[]};function nL(e){return{required:!0,json:{const:e},parse:()=>e}}function rL(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a segment node must have a non-empty "name" (a segment name), got ${q(i)}`,line:K(e.source,[`root`])}),``)}}}function iL(){return{required:!0,json:{enum:[...dg]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&dg.includes(i)?i:(e.issues.push({path:`${t}.${n}`,message:`a container "direction" must be one of: ${dg.join(`, `)} (got ${JSON.stringify(i)})`,line:K(e.source,[`root`])}),`vertical`)}}}function aL(e){return{required:!0,json:{type:`array`,items:{$ref:eL}},parse:(t,n,r,i)=>{let a=i[r];return Array.isArray(a)?a.map((i,a)=>e(t,`${n}.${r}[${a}]`,i)):(t.issues.push({path:`${n}.${r}`,message:`a container must have a "children" array of layout nodes, got ${$g(a)}`,line:K(t.source,[`root`])}),[])}}}const oL={noun:`layout-node key`,fields:{kind:nL(`segment`),name:rL(),when:d_(),id:WI(),settings:GI()}},sL=()=>y_(Am),cL={noun:`layout-node key`,fields:{kind:nL(`container`),direction:iL(),children:aL(l_(()=>pL)),when:d_(),distribution:sL()}};function lL(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a "seg" node must have a non-empty segment name, got ${q(i)}`,line:K(e.source,[`root`])}),``)}}}const uL={noun:`layout-node key`,fields:{seg:lL(),when:d_(),id:WI(),settings:GI()}},dL={noun:`layout-node key`,fields:{h:aL(l_(()=>pL)),when:d_(),distribution:sL()}},fL={noun:`layout-node key`,fields:{v:aL(l_(()=>pL)),when:d_(),distribution:sL()}},pL=(e,t,n)=>{if(typeof n==`string`)return n.length===0?(e.issues.push({path:t,message:`a bare-string layout node must be a non-empty segment name`,line:K(e.source,[`root`])}),tL):{kind:`segment`,name:n};if(!Qg(n))return e.issues.push({path:t,message:`a layout node must be a string (segment name) or an object with "kind" / "seg" / "h" / "v", got ${$g(n)}`,line:K(e.source,[`root`])}),tL;if(n.kind===`container`)return e_(e,cL,t,n)??tL;if(n.kind===`segment`)return e_(e,oL,t,n)??tL;if(n.kind===`cells`)return e.issues.push({path:t,message:`kind: "cells" is no longer supported — use the h-arm spelling instead:
178
183
  Old: { kind: "cells", segments: ["seg1", "seg2"] }
179
- New: { h: ["seg1", "seg2"] }`,line:K(e.source,[`root`])}),tL;if(n.kind===`group`){let r=e_(e,bL,t,n);return r===null?tL:(e.groups.push({name:r.name,label:r.label,...r.open!==void 0&&{open:r.open},...r.direction!==void 0&&{direction:r.direction},...r.key!==void 0&&{key:r.key},...r.bg!==void 0&&{bg:r.bg},...r.fg!==void 0&&{fg:r.fg},...r.when!==void 0&&{when:r.when},path:t}),SL(r))}let r=`h`in n,i=`v`in n,a=`seg`in n;if(+!!r+ +!!i+ +!!a>1){let r=[`seg`,`h`,`v`].filter(e=>e in n);return e.issues.push({path:t,message:`a layout node may have exactly one of "seg", "h", or "v" — got ${r.map(e=>`"${e}"`).join(` and `)} together`,line:K(e.source,[`root`])}),tL}if(a){let r=e_(e,uL,t,n);return r===null?tL:{kind:`segment`,name:r.seg,...r.when!==void 0&&{when:r.when},...r.id!==void 0&&{id:r.id},...r.settings!==void 0&&{settings:r.settings}}}if(r){let r=e_(e,dL,t,n);return r===null?tL:{kind:`container`,direction:`horizontal`,children:r.h,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}if(i){let r=e_(e,fL,t,n);return r===null?tL:{kind:`container`,direction:`vertical`,children:r.v,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}return e.issues.push({path:`${t}.kind`,message:`a layout node "kind" must be "container", "segment", or "group", or use the terse A-grammar: a bare string, or an object with "seg", "h", or "v" (got ${JSON.stringify(n.kind)})`,line:K(e.source,[`root`])}),tL};function mL(){return{required:!0,json:{type:`object`,propertyNames:{pattern:Cy.source},additionalProperties:{$ref:eL}},parse:(e,t,n,r)=>{let i=r[n];if(!Qg(i))return e.issues.push({path:`${t}.${n}`,message:`"rows" must be an object of row name → layout node, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),n])}),{};let a={};for(let[r,o]of Object.entries(i)){if(!Cy.test(r)){e.issues.push({path:`${t}.${n}.${r}`,message:`row name "${r}" must be an identifier (letters, digits, _; not starting with a digit) — it names the row in the config file and merges by name over the bundled default's rows`,line:K(e.source,[...t.split(`.`),n,r])});continue}a[r]=pL(e,`${t}.${n}.${r}`,o)}return a}}}const hL={noun:`root key`,fields:{rows:mL(),when:d_(),distribution:sL()}};function gL(e,t,n){return Qg(n)&&`rows`in n?e_(e,hL,t,n)??{rows:{}}:pL(e,t,n)}function _L(){return{required:!0,json:{type:`string`,pattern:Cy.source},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`string`||!Cy.test(i)||i===`closed`){e.issues.push({path:`${t}.${n}`,message:`a group "name" must be an identifier (letters, digits, _; not starting with a digit) and not the reserved "${P}", got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}function vL(){return{required:!1,json:{type:`string`,minLength:1},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`string`||i===``||i.includes(`/`)){e.issues.push({path:`${t}.${n}`,message:`a group "key" must be a non-empty, slash-free SessionState key, got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}}function yL(){return{required:!0,json:{type:`string`,pattern:`^[^\\n\\r]*$`},parse:(e,t,n,r)=>{let i=qg(e,t,r,n);if(i!==null){if(/[\n\r]/.test(i)){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: group label must not contain newlines`,line:K(e.source,[...t.split(`.`),n])});return}return i}}}}const bL={noun:`layout-node key`,fields:{kind:nL(`group`),name:_L(),label:yL(),open:f_(),direction:y_(dg),key:vL(),bg:d_(),fg:d_(),when:d_(),distribution:sL(),children:aL(l_(()=>pL))}};function xL(e){return e.key??`groups.`+e.name}function SL(e){let t=ZO+e.name;return Qr(t,{variable:t,key:xL(e),member:e.name},{kind:`container`,direction:e.direction??`vertical`,children:e.children,...e.distribution!==void 0&&{distribution:e.distribution}},`drop`,e.when)}function CL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function wL(e,t){rk(e,t,ZO,`group nodes`);let n=e.groups;if(n.length===0)return;let r=new Set;for(let t of n)r.has(t.name)&&CL(e,t.path,`duplicate group name "${t.name}" — group names must be unique (they name the synthesized state var, action, and toggle segment)`),r.add(t.name);for(let t of n)for(let r of n)t!==r&&t.path.startsWith(`${r.path}.`)&&xL(t)===xL(r)&&CL(e,t.path,`group "${t.name}" shares key "${xL(t)}" with its ancestor group "${r.name}" — a shared key holds ONE open group, so an ancestor and a descendant cannot share one. Sibling accordions share a key; nested groups use distinct keys.`);let i=new Map;for(let t of n){let n=xL(t);if(i.has(n)||i.set(n,P),t.open===!0){let r=i.get(n);r!==`closed`&&CL(e,t.path,`groups "${r}" and "${t.name}" share key "${n}" and both declare open: true — a shared key holds one open group; pick one`),i.set(n,t.name)}}let a={},o={},s={};for(let e of n){let t=ZO+e.name,r=xL(e),c=n.filter(t=>t!==e&&e.path.startsWith(t.path+`.`)).length,l=` `.repeat(c);a[t]=ii(r,i.get(r)),o[t]=ai(r,e.name),s[t]={template:ti(t,`${l}${e.label} ▸`,`${l}${e.label} ▾`),...e.bg!==void 0&&{bg:e.bg},...e.fg!==void 0&&{fg:e.fg}}}t.variables={...t.variables??{},...a},t.actions={...t.actions??{},...o},t.segments={...t.segments??{},...s}}const TL=`menu`,EL=`a menu binds its trigger text the way a cycle action binds a display — write {{ menu "applyTheme" "▸" "▾" }} (one per state) or {{ menu "insertHere" "+" }} (one static display for both), with the rare knobs in ONE trailing dict: {{ menu "applyTheme" "▸" "▾" (dict "closeOnPick" true "paged" false "key" "pickers") }} (defaults: closeOnPick false, paged true, no key). The renderer no longer appends ▸/▾ of its own (candybar-settings-ui-aok.4), and the older positional tail ("pageAction" closeOnPick paged "key") was removed — the page cursor is synthesized from the menu's identity`,DL=e=>e.kind===`call`&&e.name===`dict`,OL=e=>e.kind===`literal`&&typeof e.value!=`object`,kL=e=>Yr(``,e,2)===void 0;function AL(e){let t=e=>({kind:`issue`,message:e}),[n,...r]=e.argExprs;if(n===void 0)return t(`with no arguments — it takes an apply-action name and its trigger text (e.g. {{ menu "applyTheme" "▸" "▾" }})`);if(n.kind!==`literal`||typeof n.value!=`string`)return t(`whose apply action is not a string literal — a menu's identity is its apply-action name, which must be a literal so it can be gated at load (e.g. {{ menu "applyTheme" "▸" "▾" }})`);let i=r[r.length-1],a=i!==void 0&&DL(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(DL))return t(`whose options (dict …) is not its last argument — ${EL}`);if(i!==void 0&&a===void 0&&!OL(i)&&kL(o.length-1))return t(`whose last argument is neither a literal nor a literal (dict …) — the renderer tells a display from the options dict by the value it evaluates to, so this call could be read as ${o.length} displays or as ${o.length-1} plus options, and both are legal. Make the options explicit as a trailing (dict …) — {{ menu "${n.value}" (printf "…") (printf "…") (dict) }} binds dynamic displays unambiguously — or bind the trigger text as literals`);let s=Yr(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${EL}`);let c=a===void 0?{}:fw(a);if(c===null)return t(`whose options (dict …) is not fully literal — every option value must be a literal so the menu can be gated at load (a dynamic entry like (dict "key" .x) cannot)`);let l;try{l=fk(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=nk(u);if(e!==void 0)return t(`whose accordion key "${u}" lands in the reserved "${e}" namespace — a key is collapsed to an identifier (${JSON.stringify(u)} becomes "${ok(u)}"), so it would share one open-state key with the synthesized accordion that owns that namespace instead of grouping only your own menus. Name the group without the reserved prefix`)}return{kind:`ok`,apply:n.value,options:l}}function jL(e){let t=xS({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===TL).map(AL)}catch{return`parse-failed`}}function ML(e){let t=xS({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(TL)}catch{return!1}}function NL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function PL(e,t){rk(e,t,QO,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))ML(r)&&e.issues.push({path:`helpers.${n}`,message:`helper "${n}" uses {{ menu }}, but a menu must live directly in a segment template — its identity is derived from the segment it sits in, which a shared helper does not have. Inline the {{ menu }} call into each segment that needs it.`,line:K(e.source,[`helpers`,n])});let n=t.segments??{};for(let[t,r]of Object.entries(n))for(let n of[`bg`,`fg`,`when`]){let i=r[n];typeof i==`string`&&ML(i)&&NL(e,`segments.${t}.${n}`,`segment "${t}" uses {{ menu }} in its "${n}" — a menu is only valid in a segment's "template" (its placement is published only there; "${n}" needs a ${n===`when`?`predicate`:`color`}). Move the {{ menu }} into the template.`)}if(t.root!==void 0)for(let n of _g(Ay(t.root)))typeof n.when==`string`&&ML(n.when)&&NL(e,`root`,`a layout node's "when" predicate uses {{ menu }} — a menu is only valid in a segment's "template", not a node predicate. Move it into a segment.`);for(let[t,{template:r}]of Object.entries(n)){if(r===void 0||!ML(r))continue;let n=jL(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:FL(r.apply);n!==void 0&&NL(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function FL(e){if(e===``)return`with an empty apply-action name — an empty member aliases the absent-state sentinel ("") so the menu would render open before any click. Name the apply action`;if(ik(e)===`closed`)return`whose apply action is named "${P}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function IL(e,t){let n={},r={},i=new Map,a=new Set,o=(e,n)=>{let r=`segments.${e}`;a.has(`${r}\0${n}`)||(a.add(`${r}\0${n}`),t.push({path:r,message:n}))};for(let t of Iy(e.presets)){let a=new Map,s=new Map;for(let c of _g(zy(e,t).node)){if(c.kind!==`segment`)continue;let t=e.segments[c.name];if(t===void 0)continue;i.has(c.name)||i.set(c.name,jL(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=pg(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||FL(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=ik(i),f=ak(u,i,l.key),p=ck(f),m=l.key===void 0?`ind ${u} ${i}`:`key ${l.key}`,h=[f,p].find(e=>{let t=a.get(e);return t!==void 0&&t!==m});if(h!==void 0){o(c.name,`two {{ menu }} disclosures normalize to the same state key ("${h}") but were declared differently — distinct names that differ only by non-alphanumeric characters (e.g. "a-b" vs "a_b") collapse to one key and would silently share open-state. Rename so they don't collide.`);continue}a.set(f,m),a.set(p,m);let g=sk(f,d),_=`${c.name}\0${e}`,v=s.get(g);if(v!==void 0&&v!==_){o(c.name,`two {{ menu }} disclosures resolve to the same identity ("${g}") — ${l.key===void 0?`a segment cannot contain two menus over the same apply action "${i}"`:`menus sharing key "${l.key}" must have distinct apply actions`}.`);continue}s.set(g,_),r[g]=ai(f,d),n[f]=ii(f,P),n[p]={kind:`state`,key:p,default:`0`},r[p]={set:p,int:!0}}}}return{...e,variables:{...e.variables,...n},actions:{...e.actions,...r}}}const LL=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`ceiling`,`slash`,`do`];function RL(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function zL(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function BL(e,t){if(t===void 0)return{};if(!Qg(t))return Z(e,`actions`,`actions must be an object, got ${$g(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=VL(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Z(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))})}function VL(e,t,n){if(!Qg(n))return Z(e,t,`${t} must be an action object, got ${$g(n)}`),null;if(`persistWhen`in n)return Z(e,t,`${t}.persistWhen was removed: declare the \`set\` alone — a session pick is a draft until a \`{ save: true }\` action writes every unsaved setting to the config file`),null;let r=LL.filter(e=>e in n);return r.length===1?HL[r[0]](e,t,n):(Z(e,t,`action must declare exactly one of: ${LL.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const HL={set:(e,t,n)=>SR(e,t,n,`set`,vR),persist:(e,t,n)=>SR(e,t,n,`persist`,yR),copy:UL(`copy`),open:UL(`open`),reset:WL,undo:KL(`undo`),redo:KL(`redo`),back:KL(`back`),rewind:KL(`rewind`),save:KL(`save`),preset:qL,themeDefault:JL,doctor:XL,ceiling:ZL,slash:QL,do:$L};function UL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=qg(t,n,r,e);return i===null?null:{[e]:i}}}function WL(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=eR(e,t,`reset`,n,`reset key must be non-empty (the config globals field to clear)`,e=>`reset key "${e}" contains "/" — keys must be slash-free`);return r===null?null:{reset:r}}const GL={undo:`it steps the session's settings history`,redo:`it steps the session's settings history`,back:`it steps the session's navigation history`,rewind:`it steps the session's settings history back to where edit mode opened`,save:`it saves the session's unsaved settings`};function KL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Z(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${GL[e]}), got ${q(r[e])}`),null)}}function qL(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Z(e,`${t}.preset`,`preset must be "save" or "delete", got ${q(r)}`),null;if(r===`save`)return{preset:`save`};let a=qg(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function JL(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(Z(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${q(n.themeDefault)}`),null)}const YL={run:[`doctor`],fix:[`doctor`,`check`],mark:[`doctor`,`check`,`mark`]};function XL(e,t,n){let r=n.doctor,i=typeof r==`string`&&Object.hasOwn(YL,r),a=i?YL[r]:[...new Set(Object.values(YL).flat())];for(let r of Object.keys(n))a.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${a.join(`, `)}`);if(!i)return Z(e,`${t}.doctor`,`doctor must be ${Object.keys(YL).map(e=>`"${e}"`).join(`, `)}, got ${q(r)}`),null;if(r===`run`)return{doctor:`run`};let o=n.check,s=r===`mark`?yM:vM;if(typeof o!=`string`||!s.some(e=>e.name===o))return Z(e,`${t}.check`,`doctor ${r} must name a check (have: ${s.map(e=>e.name).join(`, `)}), got ${q(o)}`),null;if(r===`fix`)return{doctor:`fix`,check:o};let c=n.mark;return Aj.includes(c)?{doctor:`mark`,check:o,mark:c}:(Z(e,`${t}.mark`,`doctor mark must be ${Aj.map(e=>`"${e}"`).join(` or `)}, got ${q(c)}`),null)}function ZL(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Z(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${q(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Z(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${q(a)}`),null):{ceiling:`set`,to:a}}function QL(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=qM(n.slash);return r.kind===`refused`?(Z(e,`${t}.slash`,r.reason),null):{slash:r.line}}function $L(e,t,n){for(let r of Object.keys(n))r!==`do`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(Z(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${q(r)}`),null):{do:r}}function eR(e,t,n,r,i,a){let o=qg(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Z(e,s,i),null):o.includes(`/`)?(Z(e,s,a(o)),null):o}const tR={set:`the SessionState key to write`,persist:`the config globals field to write`};function nR(e,t,n,r){let i=tR[r],a=eR(e,t,r,n,`${r} key must be non-empty (${i})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);return a===null?null:{[r]:a}}function rR(e){return e===`set`?`set-state`:`set-config`}const iR={to:CR(`set`)},aR={to:CR(`persist`)},oR={from:wR(`set`)},sR={from:wR(`persist`)},cR={min:kR(),max:kR(),by:kR()},lR={int:ER()},uR={cycle:TR(`set`)},dR={cycle:TR(`persist`)},fR={removeSegment:DR(`removeSegment`)},pR={insertSegment:DR(`insertSegment`),anchor:DR(`anchor`),relation:OR()},mR={insertSegmentFrom:wR(`persist`),anchor:DR(`anchor`),relation:OR()},hR={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},gR={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function _R(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>n_(e,t,n,r),c=b_(t);return{detect:a,allowed:[...o,...i],label:i.join(`/`),json:{type:`object`,properties:{...Object.fromEntries(o.map(e=>[e,{type:`string`}])),...c.properties},required:[...o,...c.required??[]],additionalProperties:!1},parse:n.length?u_(s,...n):s}}const vR=[_R(`set`,iR),_R(`set`,oR),_R(`set`,cR,[hR,gR]),_R(`set`,lR),_R(`set`,uR)],yR=[_R(`persist`,aR),_R(`persist`,sR),_R(`persist`,cR,[hR,gR]),_R(`persist`,dR),_R(`persist`,fR),_R(`persist`,pR,[],[`insertSegment`]),_R(`persist`,mR,[],[`insertSegmentFrom`])];function bR(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"endcaps"/"styles", or an inline array of literal values)`,`"min"/"max"/"by" (a bounded step)`];return e===`set`&&t.push(`"int" (an unbounded integer cursor)`),t.push(`"cycle" (an enumerated domain stepped in order)`),e===`persist`&&t.push(`"removeSegment" (remove a named segment from the layout)`,`"insertSegment"/"anchor"/"relation" (insert a named segment before/after an existing one)`,`"insertSegmentFrom"/"anchor"/"relation" (insert a segment PICKED from an option domain before/after an existing one)`),t}function xR(e){let t=bR(e),n=t[t.length-1];return`a ${e} action declares exactly one value source: ${t.length===1?n:`${t.slice(0,-1).join(`, `)}, or ${n}`}`}function SR(e,t,n,r,i){let a=nR(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Z(e,t,`${xR(r)}${o.length>1?` — found: ${o.map(e=>e.label).join(`, `)}`:``}`),null;let s=o[0];for(let i of Object.keys(n))s.allowed.includes(i)||Z(e,`${t}.${i}`,`Unknown key "${i}" on this ${r} action. Expected one of: ${s.allowed.join(`, `)}`);let c=s.parse(e,t,n);return a===null||c===null?null:{...a,...c}}function CR(e){let t=rR(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>eR(n,r,i,a,`${e} value must be non-empty — an empty value cannot be delivered on the ${t} wire`,t=>`${e} value "${t}" contains "/" — ${e} values must be slash-free`)??void 0}}function wR(e){let t=rR(e);return{required:!0,json:{anyOf:[{type:`string`,minLength:1},{type:`array`,items:{type:`string`,minLength:1},minItems:1,uniqueItems:!0}]},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(typeof o==`string`){if(o===``){Z(n,s,`${i} must be a non-empty domain name`);return}return o}if(Array.isArray(o)&&o.every(e=>typeof e==`string`)){let r=o;if(r.length===0){Z(n,s,`${i} must name a domain (a non-empty string) or declare an inline domain (a non-empty array of values)`);return}if(r.some(e=>e===``)){Z(n,s,`${i} array members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}let a=r.filter(e=>e.includes(`/`));if(a.length>0){Z(n,s,`${i} array member(s) ${a.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(r).size!==r.length){Z(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Z(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${q(o)}`)}}}function TR(e){let t=rR(e);return{required:!0,json:{type:`array`,items:{type:`string`,minLength:1},minItems:2,uniqueItems:!0},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(!Array.isArray(o)||o.some(e=>typeof e!=`string`)){Z(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${$g(o)}`);return}let c=o;if(c.length<2){Z(n,s,`cycle needs at least two members (one member has no successor — use a literal "to")`);return}let l=c.some(e=>e===``),u=c.filter(e=>e.includes(`/`));if(l){Z(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Z(n,s,`cycle member(s) ${u.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(c).size!==c.length){Z(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function ER(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Z(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${q(r[n])}`);return}return!0}}}function DR(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=qg(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Z(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Z(t,o,`${e} "${a}" contains "/" or ":" — segment names in a layout op must be free of both (the click wire's own delimiter and layout-ops.ts's op-token delimiter)`);return}return a}}}function OR(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Z(e,`${t}.${n}`,`relation must be "before" or "after", got ${q(i)}`);return}return i}}}function kR(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Z(e,`${t}.${n}`,`${n} must be an integer, got ${q(i)}`);return}return i}}}function AR(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const jR={noun:`style key`,fields:{hueShift:m_(),chromaScale:m_({min:0}),lightnessScale:m_(),lightnessShift:m_()}};function MR(e,t){if(!Qg(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${$g(t)}`,line:K(e.source,[`styles`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`styles.${r}`,message:`style name ${JSON.stringify(r)} must be non-empty and slash-free — a style picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:K(e.source,[`styles`,r])});continue}if(eg(r)){e.issues.push({path:`styles.${r}`,message:AR(`styles.${r}`,r,`globals.endcaps`),line:K(e.source,[`styles`,r])});continue}let t=e_(e,jR,`styles.${r}`,i);t!==null&&(n[r]={...xc,...t})}return n}const NR={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:gL(e,`${t}.${n}`,r[n])},globals:{required:!1,json:Lk(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Ik(e,`${t}.${n}`,r[n])}}};function PR(e,t){if(!Qg(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${$g(t)}`,line:K(e.source,[`presets`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)||/[\n\r]/.test(r)){e.issues.push({path:`presets.${r}`,message:`preset name ${JSON.stringify(r)} must be non-empty, slash-free, and newline-free — a preset picker writes the name on the set-state wire (which rejects empty values and splits on "/"), and edit mode splices it into a synthesized template string`,line:K(e.source,[`presets`,r])});continue}let t=e_(e,NR,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function FR(e,t){if(t===void 0)return{};if(!Qg(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${$g(t)}`,line:K(e.source,[`helpers`])}),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){if(typeof i!=`string`){e.issues.push({path:`helpers.${r}`,message:`helpers.${r} must be a string template body, got ${q(i)}`,line:K(e.source,[`helpers`,r])});continue}n[r]=i}return n}const IR=new Map([[`session.budget.amount`,{segment:`session`,setting:`budget`}],[`session.budget.warningThreshold`,{segment:`session`,setting:`warnAt`}],[`today.budget.amount`,{segment:`today`,setting:`budget`}],[`today.budget.warningThreshold`,{segment:`today`,setting:`warnAt`}],[`block.budget.heatThreshold`,{segment:`block`,setting:`warnAt`}],[`block.budget.warningThreshold`,{segment:`block`,setting:`errorAt`}],[`weekly.budget.heatThreshold`,{segment:`weekly`,setting:`warnAt`}],[`weekly.budget.warningThreshold`,{segment:`weekly`,setting:`errorAt`}],[`burn.eta.errorMinutes`,{segment:`burnrate`,setting:`errorWithin`}],[`burn.eta.warnMinutes`,{segment:`burnrate`,setting:`warnWithin`}]]);function LR(e){return`it became the "${e.setting}" setting of each "${e.segment}" placement — set it on the placement where a row places "${e.segment}" ({ seg: "${e.segment}", settings: { ${e.setting}: <value> } }), or redeclare segments.${e.segment}.settings.${e.setting} with the default every placement should start from`}function RR(e){let t=IR.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${LR(t)}`}function zR(e){let t=IR.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${LR(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function BR(e,t){let n=new Map;for(let e of Object.keys(t)){let t=XO(e),r=n.get(t);r?r.push(e):n.set(t,[e])}for(let[t,r]of n)r.length<2||e.issues.push({path:`presets`,message:`preset names ${r.map(e=>JSON.stringify(e)).join(` and `)} both collapse to the same synthesis identifier "${t}" — edit mode's synthesized reset affordance would silently steal one preset's action for the other. Rename one.`,line:K(e.source,[`presets`])})}function VR(e,t,n){let r=[[[`globals`],t.globals.style,`globals.endcaps`],[[`editGlobals`],t.editGlobals.style,`editGlobals.endcaps`],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style,`presets.${e}.globals.endcaps`]),...Object.entries(t.themeDefaults).map(([e,t])=>[[`themeDefaults`,e],t.style,`globals.endcaps`])];for(let[n,i,a]of r){if(i===void 0||Lh(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:eg(i)?AR(r,i,a):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:K(e.source,[...n,`style`])})}t.globals.preset!==void 0&&!Object.prototype.hasOwnProperty.call(t.presets,t.globals.preset)&&e.issues.push({path:`globals.preset`,message:`globals.preset "${t.globals.preset}" does not match any declared preset (have: ${Object.keys(t.presets).join(`, `)})`,line:K(e.source,[`globals`,`preset`])}),BR(e,t.presets);let i=hb(t);for(let t of i.names)t!==`settings`&&!t.startsWith(WR)||e.issues.push({path:`variables`,message:`variable "${t}" is named under "settings", which a segment's templates read as its placement's own settings (.settings.<name>) — rename it`,line:K(e.source,[`variables`,t])});let a=(t,n,r)=>{DP(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${aN}" ${DP(t)} times — it may appear at most once per layout (it is one disclosure, and one state key holds one open state). Remove all but the placement you want; removing every placement puts the menu at its default position.`,line:r}),OP(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${aN}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r}),o(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and shade, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of _g(t)){if(e.kind!==`segment`)continue;let t=pg(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=hg(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.length} placements with the id "${t}" — an id names one placement (its settings, its menus' open state, and edit mode all address it), so give each its own: { seg: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function o(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>o(n,t||fg[e.direction]===`cell`))}let s=(n,r)=>{for(let[a,o]of jy(n,r)){let n=K(e.source,o.split(`.`));if(a.when!==void 0&&(nz(e,`${o}.when`,a.when,i,{line:n}),tz(e,`${o}.when`,a.when,n)),a.kind===`segment`){if(wP(a.name)){(a.id!==void 0||a.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${aN}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${aN}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,a.name)||e.issues.push({path:o,message:`${r} entry "${a.name}" does not match any declared segment${kI(a.name)}`,line:n}),QR(e,t,a,o,n)}}};n.root!==void 0&&s(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&s(t.root,`presets.${e}.root`);let c=new Map([[`root`,ky(t.root)]]);for(let e of Iy(t.presets)){let{node:n,path:r}=zy(t,e);c.set(r,n)}for(let[t,n]of c)a(n,t,K(e.source,t.split(`.`)));lz(e,t,i,()=>!0)}const HR=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function UR(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=K(e.source,[`actions`,n,r]);if(!Iy(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${Iy(t.presets).join(`, `)})`,line:c});return}if(r===`reset`)return;let l=`removeSegment`in o,u=`insertSegment`in o,d=`insertSegmentFrom`in o;if(!l&&!u&&!d){e.issues.push({path:s,message:`actions.${n}: "${i}" is a "presets.<name>.root" target and can only be paired with "removeSegment", "insertSegment", or "insertSegmentFrom" (not "to"/"from"/"cycle"/bounded — those have no meaning as a tree op)`,line:c});return}let f=(r,i)=>{Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})${kI(i)}`,line:c})},p=new Set(mg(zy(t,a).node)),m=(r,i)=>{!OI.has(i)||p.has(i)||Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" names no placement${kI(i)}`,line:c})};`removeSegment`in o&&m(`removeSegment`,o.removeSegment),`insertSegment`in o&&f(`insertSegment`,o.insertSegment),(`insertSegment`in o||`insertSegmentFrom`in o)&&m(`anchor`,o.anchor)}const WR=`settings.`;function GR(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>WR+e)])}}function KR(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:K(e.source,[`segments`,t,`settings`,n])})},a=YR(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of Pg(n,JR(n)))i(e,`the defaults do not stand together: ${t}`)}function qR(e){return YR(e).length>0||Pg(e,JR(e)).length>0}function JR(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function YR(e){let t=t=>Ng(XR(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||Ng(XR(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${ZR(e,n).join(`, `)||`none`})`}];let i=[n];for(let e=r;e!==void 0;e=t(e)){if(e===n)return i.every(e=>n<=e)?[{setting:n,message:`atLeast closes a cycle (${[...i,n].join(` ≥ `)}) — every setting on it could only ever equal the rest`}]:[];if(i.includes(e))return[];i.push(e)}return[]})}function XR(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function ZR(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&Ng(n)!==void 0).map(([e])=>e)}function QR(e,t,n,r,i){let a=Object.prototype.hasOwnProperty.call(t.segments,n.name)?t.segments[n.name]:void 0;if(a===void 0)return;let o=Mg(a),s=`${r}: placement "${pg(n)}" of segment "${n.name}"`;for(let[t,a]of Object.entries(n.settings??{})){let c=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0,l=c===void 0?`sets "${t}", which segment "${n.name}" does not declare (it has: ${Object.keys(o).join(`, `)})`:Fg(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?Oh(a):``}, but it must be ${zg(c)}`;l!==void 0&&e.issues.push({path:r,message:`${s} ${l}`,line:i})}let c=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,n.settings?.[e]??t.default]));if(!(!Object.entries(c).every(([e,t])=>Fg(o[e],t))||qR(o)))for(let{message:t}of Pg(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function $R(e,t,n,r,i){n.kind===`template`&&nz(e,`${t}.template`,n.template,r,{segCtx:i}),wg(n)&&`key`in n.cache&&nz(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function ez(e,t,n,r,i){if(!(!wg(n)||!(`depends_on`in n.cache)))for(let a=0;a<n.cache.depends_on.length;a++){let o=n.cache.depends_on[a];if(r.names.has(o))continue;let s=i===void 0?void 0:`${i}.${o}`,c=s!==void 0&&r.names.has(s)?` (segment-local vars are namespaced — write "${s}")`:``;e.issues.push({path:`${t}.cache.depends_on[${a}]`,message:`cache.depends_on references unknown variable "${o}"${c}`,line:K(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function tz(e,t,n,r){try{iA.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function nz(e,t,n,r,i){for(let[a,o]of sb(n,r.helpers)){if(mb(a,r))continue;if(a.startsWith(WR)){let n=o===null?``:` through helper "${o}"`,r=a.slice(9),s=i?.segCtx===void 0||i.settings===void 0?`Template reads ".${a}"${n}, but only a segment's own templates have settings — call it from a segment that declares "${r}"`:`Template reads ".${a}"${n}, but segment "${i.segCtx}" has no setting "${r}" (it has: ${Object.keys(i.settings).join(`, `)}) — declare it under segments.${i.segCtx}.settings`;e.issues.push({path:t,message:s,line:i?.line??K(e.source,t.split(`.`))});continue}if(o!==null){rz(e,o,`Template references unknown variable ".${a}"${zR(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&mb(n,r)?` (segment-local vars are namespaced — write ".${n}")`:zR(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??K(e.source,t.split(`.`))})}}function rz(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:K(e.source,[`helpers`,t])})}function iz(e,t,n,r,i){let a=n.set,o=xk(sv[r].configKey),s=`${a} takes ${hk(o,i)}`;if(`min`in n&&(o===`bool`||!(`min`in o))){e.issues.push({path:`actions.${t}.min`,message:`actions.${t}: a stepper writes the integers from ${n.min} to ${n.max}, and ${a} is not an integer range; ${s}`,line:K(e.source,[`actions`,t,`min`])});return}let c=sz(n,i);if(c===oz){e.issues.push({path:`actions.${t}.int`,message:`actions.${t}.int: an int cursor writes whatever integer the template binds, and a click outside the ${a} domain would change nothing; ${s}`,line:K(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!mk(o,e.value,i));if(l.length!==0){if(a===sv.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>eg(e.value)))){let r=sv.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:AR(`actions.${t}.to`,n.to,`set: "${r}", to`),line:K(e.source,[`actions`,t,`to`])}:{path:`actions.${t}.set`,message:`actions.${t}.set: "${a}" here writes only endcaps shapes, not styles — endcaps were renamed from "style" to "endcaps"; write set: "${r}"`,line:K(e.source,[`actions`,t,`set`])});return}for(let n of new Set(l.map(e=>e.field))){let r=l.filter(e=>e.field===n).map(e=>JSON.stringify(e.value)),i=r.length<=az?r.join(`, `):`${r.slice(0,az).join(`, `)} and ${r.length-az} more`,o=`actions.${t}.${n}`;e.issues.push({path:o,message:`${o}: ${i} ${r.length===1?`is`:`are`} outside the ${a} domain — a click would write it and nothing would change; ${s}`,line:K(e.source,[`actions`,t,n])})}}}const az=3,oz=Symbol(`any integer`);function sz(e,t){return`to`in e?[{field:`to`,value:e.to}]:`cycle`in e?e.cycle.map(e=>({field:`cycle`,value:e})):`from`in e?Ky(e.from,t).members.map(e=>({field:`from`,value:e})):`min`in e?[{field:`min`,value:String(e.min)},{field:`max`,value:String(e.max)}]:oz}function cz(e,t){return Object.entries(e).filter(([e])=>t(e))}function lz(e,t,n,r){let i=nF(t),a=Gy(i);for(let[n,o]of cz(t.actions,r)){let[t,r]=`from`in o?[`from`,o.from]:`insertSegmentFrom`in o?[`insertSegmentFrom`,o.insertSegmentFrom]:[null,null];if(t!==null&&typeof r==`string`&&!a.includes(r)){e.issues.push({path:`actions.${n}.${t}`,message:`actions.${n} ${t}: references ${Jy(r,i)}`,line:K(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;dv.has(o.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${o.set}", which has no session pick — globals.${o.set} is set in the config file only, so a click would change nothing; write it with { persist: "${o.set}", … } instead`,line:K(e.source,[`actions`,n,`set`])});let s=hv.get(o.set);s!==void 0&&iz(e,n,o,s,i)}for(let[n,i]of cz(t.actions,r))`do`in i&&i.do.forEach((r,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,r)?t.actions[r]:void 0,s=o===void 0?`references unknown action "${r}"`:`do`in o?`"${r}" is itself a do action — list its members here instead`:i.do.indexOf(r)===a?a>0&&zL(o)?`"${r}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${r}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:K(e.source,[`actions`,n,`do`])})});for(let[n,i]of cz(t.actions,r)){let r=`persist`in i?i.persist:`reset`in i?i.reset:null;if(r===null)continue;let a=`persist`in i?`persist`:`reset`,o=$k(r);if(o===null){let t=Vk(r);e.issues.push({path:`actions.${n}.${a}`,message:t===void 0?`actions.${n}: "${r}" is not a config globals field (have: ${Hk().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, a "themeDefaults.<theme>.<shade|variation|style>" target, or a "presets.<name>.root" target`:`actions.${n}: the globals field "${r}" was removed: ${t}`,line:K(e.source,[`actions`,n,a])});continue}let s=HR.filter(e=>e in i);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){UR(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!Iy(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names preset "${o.preset}" which is not declared (have: ${Iy(t.presets).join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`theme-default`&&!e.allowedPalettes.has(o.theme)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names theme "${o.theme}" which is not installed${Oh(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`segment-palette`){if(!Object.prototype.hasOwnProperty.call(t.segments,o.segment)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${kI(o.segment)}`,line:K(e.source,[`actions`,n,a])});continue}`min`in i&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:K(e.source,[`actions`,n,a])})}}for(let[i,a]of cz(t.variables,r)){$R(e,`variables.${i}`,a,n);let t=RR(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:K(e.source,[`variables`,i])})}for(let[i,a]of cz(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))$R(e,`segments.${i}.vars.${t}`,r,n,i);let r=Mg(a);KR(e,i,r);let o=GR(n,r);for(let n of[`template`,`bg`,`fg`,`when`]){let s=a[n];if(typeof s==`string`){nz(e,`segments.${i}.${n}`,s,o,{segCtx:i,settings:r});for(let{name:r,site:a,via:o}of db(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=a===`options`?` (in a picker, menu, carousel, swatch, swatches or themePreview)`:``;if(o!==null){rz(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${i}.${n}`,message:`${n} references unknown action "${r}"${s}`,line:K(e.source,[`segments`,i,n])})}}}}for(let[i,a]of cz(t.variables,r))ez(e,`variables.${i}`,a,n);for(let[i,a]of cz(t.segments,r))if(a.vars)for(let[t,r]of Object.entries(a.vars))ez(e,`segments.${i}.vars.${t}`,r,n,i)}function uz(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=dz(t),a=new Map,o=[];for(let e of r.keys())a.set(e,0);for(let e of r.keys())if(!(!n(e)||a.get(e)!==0)&&s(e))return;function s(t){a.set(t,1),o.push(t);for(let c of r.get(t)??[]){if(!n(c))continue;let t=a.get(c);if(t===1){let t=o.indexOf(c),n=[...o.slice(t),c],r=n[0],a=i.get(r);return e.issues.push({path:a?.declarationPath??`variables.${r}`,message:`Dependency cycle: ${n.join(` → `)}`,line:K(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function dz(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of sb(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),wg(n)&&(`key`in n.cache&&i(e,n.cache.key),`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}function fz(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?C.homedir()+e.slice(1):e}function pz(e,t){return s.resolve(e,fz(t))}function mz(e,t){return typeof t==`string`&&t!==``?pz(e,t):void 0}function hz(e){return`plugin ${e.path} was not loaded: ${e.reason}`}const gz=new Set([`data`,`segments`,`helpers`,`actions`]),_z=`plugin.json5`,vz=/^[a-z][a-z0-9_]*$/;function yz(e){let t=s.basename(s.dirname(e));return vz.test(t)?t:void 0}const bz=`plugins.`;function xz(e){return`${bz}${e}.data`}function Sz(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,reason:Cz(e)}}}function Cz(e){return e instanceof Hg?e.issues.map(e=>e.path===``||e.message.includes(e.path)?e.message:`${e.path}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function wz(e,t){return e.map(e=>pz(s.dirname(t),e))}function Tz(e,t,n,r){let i=new Map;return e.reduce((e,n)=>{let a=yz(n),o=(t,r)=>{let i=new Map(e.rendering);return a!==void 0&&r!==e.config&&i.delete(a),{...e,config:r,rendering:i,dropped:[...e.dropped,{path:n,plugin:a,reason:t}]}};if(s.basename(n)!==`plugin.json5`){let t=`a plugin is a folder holding its ${_z}, and the folder's name is the plugin's: move this file to <dir>/<name>/${_z} and list that`;return o(t,a===void 0?e.config:Oz(Dz(e.config,a),a,{path:n,plugin:a,reason:t}))}if(a===void 0)return o(`its folder "${s.basename(s.dirname(n))}" is not a plugin name (one matching ${vz}: it prefixes every name the plugin declares)`,e.config);let c=i.get(a);if(c!==void 0)return o(`plugin "${a}" is already listed, from ${c}`,e.config);i.set(a,n);let l=Dz(e.config,a),u=Sz(()=>{let i=p.readFileSync(n,`utf-8`),o=HF(Pz(n,a,{source:i,json:ui.default.parse(i)},t),l);return r(o,a,l!==e.config),o});if(u.ok)return{...e,config:u.value,loaded:[...e.loaded,n],rendering:new Map([...e.rendering,[a,n]])};let d={path:n,plugin:a,reason:u.reason};return o(u.reason,Oz(l,a,d))},{config:n.config,rendering:n.rendering,loaded:[],dropped:[]})}function Ez(e){let t=`${bz}${e}.`;return e=>e.startsWith(t)}function Dz(e,t){let n=Ez(t),r=e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n(e)));return[e.variables,e.segments,e.helpers,e.actions].some(e=>Object.keys(e).some(n))?{...e,variables:r(e.variables),segments:r(e.segments),helpers:r(e.helpers),actions:r(e.actions)}:e}function Oz(e,t,n){return{...e,variables:{...e.variables,[xz(t)]:{kind:`dropped`,reason:hz(n),definition:n.path}}}}function kz(e){return e.startsWith(`plugins.`)?e.slice(8).split(`.`)[0]:void 0}function Az(e,t){let n=new Set([...Object.keys(e.config.variables),...Object.keys(e.config.segments)].map(kz)),r=[...t,...e.dropped].filter(e=>e.plugin===void 0).map(e=>({definition:e.path,notice:hz(e)}));return t=>{let i=kz(t);if(i===void 0)return[];let a=e.config.variables[xz(i)];return a?.kind===`dropped`?[{definition:a.definition,notice:a.reason}]:n.has(i)?[]:r}}function jz(e,t){let n=Iy(e.presets).flatMap(t=>[..._g(zy(e,t).node)]).flatMap(e=>e.kind===`segment`?[e]:[]),r=[...new Set([...n.map(e=>e.name),...Object.keys(e.segments)])].map(e=>({name:e,cause:t(e)})).filter(({cause:e})=>e.length>0),i=Object.fromEntries(r.map(({name:e,cause:t})=>[e,Mz(e,t.map(e=>e.notice),n.filter(t=>t.name===e))])),a=t=>{let n=kz(t),r=n===void 0?void 0:e.variables[xz(n)];return r?.kind===`dropped`?{definition:r.definition,notice:r.reason}:void 0},o=Object.values(e.variables).some(e=>e.kind===`dropped`),s=o?Object.values(e.segments).flatMap(e=>[`template`,`bg`,`fg`,`when`].flatMap(t=>e[t]===void 0?[]:[e[t]])):[],c=o?Object.values(e.actions).flatMap(e=>`do`in e?[...e.do]:[]):[],l=(e,t)=>[...new Set(e)].flatMap(e=>{let n=e in t?void 0:a(e);return n===void 0?[]:[[e,n]]}),u=l([...s.flatMap(t=>db(t,e.helpers).map(e=>e.name)),...c],e.actions),d=l(s.flatMap(t=>[...pb(t,e.helpers)]),e.helpers),f=new Set([...r.flatMap(({cause:e})=>e.map(e=>e.definition)),...[...u,...d].map(([,e])=>e.definition)]);return{config:{...e,segments:{...e.segments,...i},actions:{...e.actions,...Object.fromEntries(u.map(([e])=>[e,{copy:`{{ .${xz(kz(e)??``)} }}`}]))},helpers:{...e.helpers,...Object.fromEntries(d.map(([e,t])=>[e,`{{ fail ${JSON.stringify(t.notice)} }}`]))}},reached:f}}function Mz(e,t,n){let r=`⚠ ${e}: ${t.join(`; `)}`,i=new Map;for(let e of n)for(let[t,n]of Object.entries(e.settings??{})){let e=i.get(t);i.set(t,e===void 0?[n]:[...e,n])}let a=Object.fromEntries([...i].map(([e,t])=>[e,Nz(e,t)]));return{template:`{{ ${JSON.stringify(r)} }}`,bg:`error`,description:`stands in for a segment whose plugin did not load`,settings:a}}function Nz(e,t){let[n]=t,r=t.filter(e=>typeof e==`number`);return typeof n==`boolean`?{label:e,domain:`bool`,default:n}:typeof n==`number`?{label:e,domain:{min:Math.min(...r),max:Math.max(...r),step:1},default:n}:{label:e,domain:[...new Set(t.map(String))],default:n}}function Pz(e,t,{source:n,json:r},{checkout:i}){let a=[],o=()=>{throw new Hg(e,a)};if(!Qg(r))return a.push({path:``,message:`a plugin definition must be an object, got ${$g(r)}`}),o();for(let e of Object.keys(r))gz.has(e)||a.push({path:e,message:e===`plugin`?`a plugin definition does not name itself: its name is its folder's ("${t}") — remove "plugin"`:`a plugin definition may not declare "${e}". Expected only: ${[...gz].join(`, `)}`});let s=Bz(r.data,e,i,a);if(Qg(r.segments)||a.push({path:`segments`,message:`"segments" must be an object naming the plugin's segments`}),a.length>0||s===void 0)return o();let c={source:n,issues:a,allowedPalettes:new Set(jh()),groups:[]},l=$F(c,`data`,{[xz(t)]:{kind:`file`,path:s,parse:{json:!0},cache:{watch_file:s},default:{}}});for(let[e,t]of Object.entries(r.segments))if(!(!Qg(t)||!Qg(t.vars)))for(let[n,r]of Object.entries(t.vars)){let t=Qg(r)?r.kind:void 0;typeof t!=`string`||t===`state`||a.push({path:`segments.${e}.vars.${n}`,message:`a plugin segment's vars may declare only state variables (kind: "state"), never a source such as ${JSON.stringify(t)}: a plugin's only source is its data file`})}let u={variables:l,segments:Iz(t,Rz(t,qI(c,r.segments,new Set))),helpers:Iz(t,FR(c,r.helpers)),actions:Iz(t,zz(t,BL(c,r.actions)))};for(let[e,t]of Fz(u))try{iA.parse(t)}catch(t){a.push({path:e,message:`Template parse error in ${e}: ${t.message}`})}return a.length>0&&o(),u}function*Fz(e){for(let[t,n]of Object.entries(e.segments??{}))for(let e of[`template`,`bg`,`fg`,`when`]){let r=n[e];r!==void 0&&(yield[`segments.${t}.${e}`,r])}for(let[t,n]of Object.entries(e.helpers??{}))yield[`helpers.${t}`,`{{ define "${t}" }}${n}{{ end }}`];for(let[t,n]of Object.entries(e.actions??{}))`copy`in n&&(yield[`actions.${t}.copy`,n.copy]),`open`in n&&(yield[`actions.${t}.open`,n.open]),`preset`in n&&n.preset===`delete`&&(yield[`actions.${t}.name`,n.name])}function Iz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[`${bz}${e}.${t}`,n]))}function Lz(e,t){return`${bz}${e}.${t}`}function Rz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.vars===void 0?n:{...n,vars:Object.fromEntries(Object.entries(n.vars).map(([t,n])=>[t,n.kind===`state`?{...n,key:Lz(e,n.key)}:n]))}]))}function zz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,`set`in n?{...n,set:Lz(e,n.set)}:n]))}function Bz(e,t,n,r){if(typeof e==`string`&&e!==``)return pz(s.dirname(t),e);if(Qg(e)&&Object.keys(e).length===1&&typeof e.checkout==`string`&&e.checkout!==``){let t=e.checkout;if(s.isAbsolute(t)||t.startsWith(`~`)||s.normalize(t).split(s.sep)[0]===`..`){r.push({path:`data.checkout`,message:`data.checkout "${t}" must be a path inside the checkout, relative to its root (like ".lit/statusline.json"): no absolute path, "~" or ".."`});return}if(n===null){r.push({path:`data.checkout`,message:`data is read from the session's checkout, and this load has no session`});return}return s.resolve(n.root,t)}if(Qg(e)&&`project`in e){r.push({path:`data.project`,message:`data: { project } is now data: { checkout }: the same path, relative to the root of the git checkout the session works in (a linked worktree is its own checkout)`});return}r.push({path:`data`,message:`"data" must be the path of the plugin's JSON data file relative to this definition, or { checkout: "<path>" } relative to the root of the session's checkout`})}function Vz(e){let t=[...[...(process.env.XDG_DATA_DIRS||Wz()).split(`:`).filter(e=>e!==``)].reverse().map(e=>s.join(e,`cc-candybar`,`plugins`)),Hz(),...e===null?[]:[s.join(e,Uz)]];return t.filter((e,n)=>t.lastIndexOf(e)===n)}function Hz(){let e=process.env.XDG_DATA_HOME||s.join(C.homedir(),`.local`,`share`);return s.join(e,`cc-candybar`,`plugins`)}const Uz=s.join(`.cc-candybar`,`plugins`);function Wz(){let e=`/usr/local/share:/usr/share`;return process.platform===`darwin`?`${s.join(process.env.HOMEBREW_PREFIX||`/opt/homebrew`,`share`)}:${e}`:e}function Gz(e){let t=Vz(e),n=new Map,r=[],i=[];for(let e of t){let t=Kz(e);if(`error`in t){r.push(t);continue}for(let r of t.folders)n.delete(r),n.set(r,s.join(e,r,_z));for(let n of t.files)i.push({path:s.join(e,n),plugin:void 0,reason:`a plugin is a folder holding its ${_z}: move this file to ${s.join(e,`<name>`,_z)}`})}return{roots:t,definitions:[...n.values()],unchecked:r,strays:i}}function Kz(e){try{let t=p.readdirSync(e,{withFileTypes:!0}).filter(e=>!e.name.startsWith(`.`)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),n=t=>t.isDirectory()||qz(e,t);return{folders:t.filter(n).map(e=>e.name),files:t.filter(e=>!n(e)).map(e=>e.name)}}catch(t){return t.code===`ENOENT`?{folders:[],files:[]}:{path:e,error:t.message}}}function qz(e,t){if(!t.isSymbolicLink())return!1;try{return p.statSync(s.join(e,t.name)).isDirectory()}catch{return!0}}function Jz(e){try{return p.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}const Yz=[`json5`,`json`];function Xz(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Yz.map(t=>s.join(e,`.cc-candybar.${t}`)):[],...Yz.map(e=>s.join(r,`.cc-candybar.${e}`)),...Yz.map(e=>`${Zz()}.${e}`)])]}function Zz(){let e=process.env.XDG_CONFIG_HOME??s.join(C.homedir(),`.config`);return s.join(e,`cc-candybar`,`config`)}function Qz(e,t,n){let r=[],i=new Map;for(let a of Xz(e,t,n)){let e=Jz(a);if(e===`absent`)continue;if(e!==`present`){r.push(e);continue}let t=s.join(p.realpathSync(s.dirname(a)),s.basename(a).replace(/\.(json5|json)$/,``));i.has(t)||i.set(t,a)}let a=[...i.values()].reverse();if(n===void 0)return{kind:`chain`,layers:a,home:$z(a),unchecked:r};let[o]=r,c=n;return a.length>0?{kind:`chain`,layers:a,home:c,unchecked:r}:o===void 0?{kind:`missing`,path:n,home:c}:{kind:`unreadable`,...o,home:c}}function $z(e){let t=Zz();return e.find(e=>Yz.some(n=>e===`${t}.${n}`))??`${t}.${Yz[0]}`}function eB(e,t,n){let r=Qz(e,t,n),i=r.kind===`chain`?r.layers:[];return{path:r.home,above:i.filter(e=>e!==r.home),projectDir:e??null,cwd:t??null}}function tB(e){return nB(e).join(`
184
+ New: { h: ["seg1", "seg2"] }`,line:K(e.source,[`root`])}),tL;if(n.kind===`group`){let r=e_(e,bL,t,n);return r===null?tL:(e.groups.push({name:r.name,label:r.label,...r.open!==void 0&&{open:r.open},...r.direction!==void 0&&{direction:r.direction},...r.key!==void 0&&{key:r.key},...r.bg!==void 0&&{bg:r.bg},...r.fg!==void 0&&{fg:r.fg},...r.when!==void 0&&{when:r.when},path:t}),SL(r))}let r=`h`in n,i=`v`in n,a=`seg`in n;if(+!!r+ +!!i+ +!!a>1){let r=[`seg`,`h`,`v`].filter(e=>e in n);return e.issues.push({path:t,message:`a layout node may have exactly one of "seg", "h", or "v" — got ${r.map(e=>`"${e}"`).join(` and `)} together`,line:K(e.source,[`root`])}),tL}if(a){let r=e_(e,uL,t,n);return r===null?tL:{kind:`segment`,name:r.seg,...r.when!==void 0&&{when:r.when},...r.id!==void 0&&{id:r.id},...r.settings!==void 0&&{settings:r.settings}}}if(r){let r=e_(e,dL,t,n);return r===null?tL:{kind:`container`,direction:`horizontal`,children:r.h,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}if(i){let r=e_(e,fL,t,n);return r===null?tL:{kind:`container`,direction:`vertical`,children:r.v,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}return e.issues.push({path:`${t}.kind`,message:`a layout node "kind" must be "container", "segment", or "group", or use the terse A-grammar: a bare string, or an object with "seg", "h", or "v" (got ${JSON.stringify(n.kind)})`,line:K(e.source,[`root`])}),tL};function mL(){return{required:!0,json:{type:`object`,propertyNames:{pattern:Cy.source},additionalProperties:{$ref:eL}},parse:(e,t,n,r)=>{let i=r[n];if(!Qg(i))return e.issues.push({path:`${t}.${n}`,message:`"rows" must be an object of row name → layout node, got ${$g(i)}`,line:K(e.source,[...t.split(`.`),n])}),{};let a={};for(let[r,o]of Object.entries(i)){if(!Cy.test(r)){e.issues.push({path:`${t}.${n}.${r}`,message:`row name "${r}" must be an identifier (letters, digits, _; not starting with a digit) — it names the row in the config file and merges by name over the bundled default's rows`,line:K(e.source,[...t.split(`.`),n,r])});continue}a[r]=pL(e,`${t}.${n}.${r}`,o)}return a}}}const hL={noun:`root key`,fields:{rows:mL(),when:d_(),distribution:sL()}};function gL(e,t,n){return Qg(n)&&`rows`in n?e_(e,hL,t,n)??{rows:{}}:pL(e,t,n)}function _L(){return{required:!0,json:{type:`string`,pattern:Cy.source},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`string`||!Cy.test(i)||i===`closed`){e.issues.push({path:`${t}.${n}`,message:`a group "name" must be an identifier (letters, digits, _; not starting with a digit) and not the reserved "${P}", got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}function vL(){return{required:!1,json:{type:`string`,minLength:1},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`string`||i===``||i.includes(`/`)){e.issues.push({path:`${t}.${n}`,message:`a group "key" must be a non-empty, slash-free SessionState key, got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}}function yL(){return{required:!0,json:{type:`string`,pattern:`^[^\\n\\r]*$`},parse:(e,t,n,r)=>{let i=qg(e,t,r,n);if(i!==null){if(/[\n\r]/.test(i)){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: group label must not contain newlines`,line:K(e.source,[...t.split(`.`),n])});return}return i}}}}const bL={noun:`layout-node key`,fields:{kind:nL(`group`),name:_L(),label:yL(),open:f_(),direction:y_(dg),key:vL(),bg:d_(),fg:d_(),when:d_(),distribution:sL(),children:aL(l_(()=>pL))}};function xL(e){return e.key??`groups.`+e.name}function SL(e){let t=ZO+e.name;return Qr(t,{variable:t,key:xL(e),member:e.name},{kind:`container`,direction:e.direction??`vertical`,children:e.children,...e.distribution!==void 0&&{distribution:e.distribution}},`drop`,e.when)}function CL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function wL(e,t){rk(e,t,ZO,`group nodes`);let n=e.groups;if(n.length===0)return;let r=new Set;for(let t of n)r.has(t.name)&&CL(e,t.path,`duplicate group name "${t.name}" — group names must be unique (they name the synthesized state var, action, and toggle segment)`),r.add(t.name);for(let t of n)for(let r of n)t!==r&&t.path.startsWith(`${r.path}.`)&&xL(t)===xL(r)&&CL(e,t.path,`group "${t.name}" shares key "${xL(t)}" with its ancestor group "${r.name}" — a shared key holds ONE open group, so an ancestor and a descendant cannot share one. Sibling accordions share a key; nested groups use distinct keys.`);let i=new Map;for(let t of n){let n=xL(t);if(i.has(n)||i.set(n,P),t.open===!0){let r=i.get(n);r!==`closed`&&CL(e,t.path,`groups "${r}" and "${t.name}" share key "${n}" and both declare open: true — a shared key holds one open group; pick one`),i.set(n,t.name)}}let a={},o={},s={};for(let e of n){let t=ZO+e.name,r=xL(e),c=n.filter(t=>t!==e&&e.path.startsWith(t.path+`.`)).length,l=` `.repeat(c);a[t]=ii(r,i.get(r)),o[t]=ai(r,e.name),s[t]={template:ti(t,`${l}${e.label} ▸`,`${l}${e.label} ▾`),...e.bg!==void 0&&{bg:e.bg},...e.fg!==void 0&&{fg:e.fg}}}t.variables={...t.variables??{},...a},t.actions={...t.actions??{},...o},t.segments={...t.segments??{},...s}}const TL=`menu`,EL=`a menu binds its trigger text the way a cycle action binds a display — write {{ menu "applyTheme" "▸" "▾" }} (one per state) or {{ menu "insertHere" "+" }} (one static display for both), with the rare knobs in ONE trailing dict: {{ menu "applyTheme" "▸" "▾" (dict "closeOnPick" true "paged" false "key" "pickers") }} (defaults: closeOnPick false, paged true, no key). The renderer no longer appends ▸/▾ of its own (candybar-settings-ui-aok.4), and the older positional tail ("pageAction" closeOnPick paged "key") was removed — the page cursor is synthesized from the menu's identity`,DL=e=>e.kind===`call`&&e.name===`dict`,OL=e=>e.kind===`literal`&&typeof e.value!=`object`,kL=e=>Yr(``,e,2)===void 0;function AL(e){let t=e=>({kind:`issue`,message:e}),[n,...r]=e.argExprs;if(n===void 0)return t(`with no arguments — it takes an apply-action name and its trigger text (e.g. {{ menu "applyTheme" "▸" "▾" }})`);if(n.kind!==`literal`||typeof n.value!=`string`)return t(`whose apply action is not a string literal — a menu's identity is its apply-action name, which must be a literal so it can be gated at load (e.g. {{ menu "applyTheme" "▸" "▾" }})`);let i=r[r.length-1],a=i!==void 0&&DL(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(DL))return t(`whose options (dict …) is not its last argument — ${EL}`);if(i!==void 0&&a===void 0&&!OL(i)&&kL(o.length-1))return t(`whose last argument is neither a literal nor a literal (dict …) — the renderer tells a display from the options dict by the value it evaluates to, so this call could be read as ${o.length} displays or as ${o.length-1} plus options, and both are legal. Make the options explicit as a trailing (dict …) — {{ menu "${n.value}" (printf "…") (printf "…") (dict) }} binds dynamic displays unambiguously — or bind the trigger text as literals`);let s=Yr(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${EL}`);let c=a===void 0?{}:fw(a);if(c===null)return t(`whose options (dict …) is not fully literal — every option value must be a literal so the menu can be gated at load (a dynamic entry like (dict "key" .x) cannot)`);let l;try{l=fk(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=nk(u);if(e!==void 0)return t(`whose accordion key "${u}" lands in the reserved "${e}" namespace — a key is collapsed to an identifier (${JSON.stringify(u)} becomes "${ok(u)}"), so it would share one open-state key with the synthesized accordion that owns that namespace instead of grouping only your own menus. Name the group without the reserved prefix`)}return{kind:`ok`,apply:n.value,options:l}}function jL(e){let t=xS({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===TL).map(AL)}catch{return`parse-failed`}}function ML(e){let t=xS({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(TL)}catch{return!1}}function NL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function PL(e,t){rk(e,t,QO,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))ML(r)&&e.issues.push({path:`helpers.${n}`,message:`helper "${n}" uses {{ menu }}, but a menu must live directly in a segment template — its identity is derived from the segment it sits in, which a shared helper does not have. Inline the {{ menu }} call into each segment that needs it.`,line:K(e.source,[`helpers`,n])});let n=t.segments??{};for(let[t,r]of Object.entries(n))for(let n of[`bg`,`fg`,`when`]){let i=r[n];typeof i==`string`&&ML(i)&&NL(e,`segments.${t}.${n}`,`segment "${t}" uses {{ menu }} in its "${n}" — a menu is only valid in a segment's "template" (its placement is published only there; "${n}" needs a ${n===`when`?`predicate`:`color`}). Move the {{ menu }} into the template.`)}if(t.root!==void 0)for(let n of _g(Ay(t.root)))typeof n.when==`string`&&ML(n.when)&&NL(e,`root`,`a layout node's "when" predicate uses {{ menu }} — a menu is only valid in a segment's "template", not a node predicate. Move it into a segment.`);for(let[t,{template:r}]of Object.entries(n)){if(r===void 0||!ML(r))continue;let n=jL(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:FL(r.apply);n!==void 0&&NL(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function FL(e){if(e===``)return`with an empty apply-action name — an empty member aliases the absent-state sentinel ("") so the menu would render open before any click. Name the apply action`;if(ik(e)===`closed`)return`whose apply action is named "${P}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function IL(e,t){let n={},r={},i=new Map,a=new Set,o=(e,n)=>{let r=`segments.${e}`;a.has(`${r}\0${n}`)||(a.add(`${r}\0${n}`),t.push({path:r,message:n}))};for(let t of Iy(e.presets)){let a=new Map,s=new Map;for(let c of _g(zy(e,t).node)){if(c.kind!==`segment`)continue;let t=e.segments[c.name];if(t===void 0)continue;i.has(c.name)||i.set(c.name,jL(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=pg(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||FL(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=ik(i),f=ak(u,i,l.key),p=ck(f),m=l.key===void 0?`ind ${u} ${i}`:`key ${l.key}`,h=[f,p].find(e=>{let t=a.get(e);return t!==void 0&&t!==m});if(h!==void 0){o(c.name,`two {{ menu }} disclosures normalize to the same state key ("${h}") but were declared differently — distinct names that differ only by non-alphanumeric characters (e.g. "a-b" vs "a_b") collapse to one key and would silently share open-state. Rename so they don't collide.`);continue}a.set(f,m),a.set(p,m);let g=sk(f,d),_=`${c.name}\0${e}`,v=s.get(g);if(v!==void 0&&v!==_){o(c.name,`two {{ menu }} disclosures resolve to the same identity ("${g}") — ${l.key===void 0?`a segment cannot contain two menus over the same apply action "${i}"`:`menus sharing key "${l.key}" must have distinct apply actions`}.`);continue}s.set(g,_),r[g]=ai(f,d),n[f]=ii(f,P),n[p]={kind:`state`,key:p,default:`0`},r[p]={set:p,int:!0}}}}return{...e,variables:{...e.variables,...n},actions:{...e.actions,...r}}}const LL=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`ceiling`,`slash`,`do`];function RL(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function zL(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function BL(e,t){if(t===void 0)return{};if(!Qg(t))return Z(e,`actions`,`actions must be an object, got ${$g(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=VL(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Z(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))})}function VL(e,t,n){if(!Qg(n))return Z(e,t,`${t} must be an action object, got ${$g(n)}`),null;if(`persistWhen`in n)return Z(e,t,`${t}.persistWhen was removed: declare the \`set\` alone — a session pick is a draft until a \`{ save: true }\` action writes every unsaved setting to the config file`),null;let r=LL.filter(e=>e in n);return r.length===1?HL[r[0]](e,t,n):(Z(e,t,`action must declare exactly one of: ${LL.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const HL={set:(e,t,n)=>SR(e,t,n,`set`,vR),persist:(e,t,n)=>SR(e,t,n,`persist`,yR),copy:UL(`copy`),open:UL(`open`),reset:WL,undo:KL(`undo`),redo:KL(`redo`),back:KL(`back`),rewind:KL(`rewind`),save:KL(`save`),preset:qL,themeDefault:JL,doctor:XL,ceiling:ZL,slash:QL,do:$L};function UL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=qg(t,n,r,e);return i===null?null:{[e]:i}}}function WL(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=eR(e,t,`reset`,n,`reset key must be non-empty (the config globals field to clear)`,e=>`reset key "${e}" contains "/" — keys must be slash-free`);return r===null?null:{reset:r}}const GL={undo:`it steps the session's settings history`,redo:`it steps the session's settings history`,back:`it steps the session's navigation history`,rewind:`it steps the session's settings history back to where edit mode opened`,save:`it saves the session's unsaved settings`};function KL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Z(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${GL[e]}), got ${q(r[e])}`),null)}}function qL(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Z(e,`${t}.preset`,`preset must be "save" or "delete", got ${q(r)}`),null;if(r===`save`)return{preset:`save`};let a=qg(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function JL(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(Z(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${q(n.themeDefault)}`),null)}const YL={run:[`doctor`],fix:[`doctor`,`check`],mark:[`doctor`,`check`,`mark`]};function XL(e,t,n){let r=n.doctor,i=typeof r==`string`&&Object.hasOwn(YL,r),a=i?YL[r]:[...new Set(Object.values(YL).flat())];for(let r of Object.keys(n))a.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${a.join(`, `)}`);if(!i)return Z(e,`${t}.doctor`,`doctor must be ${Object.keys(YL).map(e=>`"${e}"`).join(`, `)}, got ${q(r)}`),null;if(r===`run`)return{doctor:`run`};let o=n.check,s=r===`mark`?vM:_M;if(typeof o!=`string`||!s.some(e=>e.name===o))return Z(e,`${t}.check`,`doctor ${r} must name a check (have: ${s.map(e=>e.name).join(`, `)}), got ${q(o)}`),null;if(r===`fix`)return{doctor:`fix`,check:o};let c=n.mark;return Dj.includes(c)?{doctor:`mark`,check:o,mark:c}:(Z(e,`${t}.mark`,`doctor mark must be ${Dj.map(e=>`"${e}"`).join(` or `)}, got ${q(c)}`),null)}function ZL(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Z(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${q(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Z(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${q(a)}`),null):{ceiling:`set`,to:a}}function QL(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=KM(n.slash);return r.kind===`refused`?(Z(e,`${t}.slash`,r.reason),null):{slash:r.line}}function $L(e,t,n){for(let r of Object.keys(n))r!==`do`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(Z(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${q(r)}`),null):{do:r}}function eR(e,t,n,r,i,a){let o=qg(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Z(e,s,i),null):o.includes(`/`)?(Z(e,s,a(o)),null):o}const tR={set:`the SessionState key to write`,persist:`the config globals field to write`};function nR(e,t,n,r){let i=tR[r],a=eR(e,t,r,n,`${r} key must be non-empty (${i})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);return a===null?null:{[r]:a}}function rR(e){return e===`set`?`set-state`:`set-config`}const iR={to:CR(`set`)},aR={to:CR(`persist`)},oR={from:wR(`set`)},sR={from:wR(`persist`)},cR={min:kR(),max:kR(),by:kR()},lR={int:ER()},uR={cycle:TR(`set`)},dR={cycle:TR(`persist`)},fR={removeSegment:DR(`removeSegment`)},pR={insertSegment:DR(`insertSegment`),anchor:DR(`anchor`),relation:OR()},mR={insertSegmentFrom:wR(`persist`),anchor:DR(`anchor`),relation:OR()},hR={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},gR={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function _R(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>n_(e,t,n,r),c=b_(t);return{detect:a,allowed:[...o,...i],label:i.join(`/`),json:{type:`object`,properties:{...Object.fromEntries(o.map(e=>[e,{type:`string`}])),...c.properties},required:[...o,...c.required??[]],additionalProperties:!1},parse:n.length?u_(s,...n):s}}const vR=[_R(`set`,iR),_R(`set`,oR),_R(`set`,cR,[hR,gR]),_R(`set`,lR),_R(`set`,uR)],yR=[_R(`persist`,aR),_R(`persist`,sR),_R(`persist`,cR,[hR,gR]),_R(`persist`,dR),_R(`persist`,fR),_R(`persist`,pR,[],[`insertSegment`]),_R(`persist`,mR,[],[`insertSegmentFrom`])];function bR(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"endcaps"/"styles", or an inline array of literal values)`,`"min"/"max"/"by" (a bounded step)`];return e===`set`&&t.push(`"int" (an unbounded integer cursor)`),t.push(`"cycle" (an enumerated domain stepped in order)`),e===`persist`&&t.push(`"removeSegment" (remove a named segment from the layout)`,`"insertSegment"/"anchor"/"relation" (insert a named segment before/after an existing one)`,`"insertSegmentFrom"/"anchor"/"relation" (insert a segment PICKED from an option domain before/after an existing one)`),t}function xR(e){let t=bR(e),n=t[t.length-1];return`a ${e} action declares exactly one value source: ${t.length===1?n:`${t.slice(0,-1).join(`, `)}, or ${n}`}`}function SR(e,t,n,r,i){let a=nR(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Z(e,t,`${xR(r)}${o.length>1?` — found: ${o.map(e=>e.label).join(`, `)}`:``}`),null;let s=o[0];for(let i of Object.keys(n))s.allowed.includes(i)||Z(e,`${t}.${i}`,`Unknown key "${i}" on this ${r} action. Expected one of: ${s.allowed.join(`, `)}`);let c=s.parse(e,t,n);return a===null||c===null?null:{...a,...c}}function CR(e){let t=rR(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>eR(n,r,i,a,`${e} value must be non-empty — an empty value cannot be delivered on the ${t} wire`,t=>`${e} value "${t}" contains "/" — ${e} values must be slash-free`)??void 0}}function wR(e){let t=rR(e);return{required:!0,json:{anyOf:[{type:`string`,minLength:1},{type:`array`,items:{type:`string`,minLength:1},minItems:1,uniqueItems:!0}]},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(typeof o==`string`){if(o===``){Z(n,s,`${i} must be a non-empty domain name`);return}return o}if(Array.isArray(o)&&o.every(e=>typeof e==`string`)){let r=o;if(r.length===0){Z(n,s,`${i} must name a domain (a non-empty string) or declare an inline domain (a non-empty array of values)`);return}if(r.some(e=>e===``)){Z(n,s,`${i} array members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}let a=r.filter(e=>e.includes(`/`));if(a.length>0){Z(n,s,`${i} array member(s) ${a.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(r).size!==r.length){Z(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Z(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${q(o)}`)}}}function TR(e){let t=rR(e);return{required:!0,json:{type:`array`,items:{type:`string`,minLength:1},minItems:2,uniqueItems:!0},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(!Array.isArray(o)||o.some(e=>typeof e!=`string`)){Z(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${$g(o)}`);return}let c=o;if(c.length<2){Z(n,s,`cycle needs at least two members (one member has no successor — use a literal "to")`);return}let l=c.some(e=>e===``),u=c.filter(e=>e.includes(`/`));if(l){Z(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Z(n,s,`cycle member(s) ${u.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(c).size!==c.length){Z(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function ER(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Z(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${q(r[n])}`);return}return!0}}}function DR(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=qg(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Z(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Z(t,o,`${e} "${a}" contains "/" or ":" — segment names in a layout op must be free of both (the click wire's own delimiter and layout-ops.ts's op-token delimiter)`);return}return a}}}function OR(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Z(e,`${t}.${n}`,`relation must be "before" or "after", got ${q(i)}`);return}return i}}}function kR(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Z(e,`${t}.${n}`,`${n} must be an integer, got ${q(i)}`);return}return i}}}function AR(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const jR={noun:`style key`,fields:{hueShift:m_(),chromaScale:m_({min:0}),lightnessScale:m_(),lightnessShift:m_()}};function MR(e,t){if(!Qg(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${$g(t)}`,line:K(e.source,[`styles`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`styles.${r}`,message:`style name ${JSON.stringify(r)} must be non-empty and slash-free — a style picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:K(e.source,[`styles`,r])});continue}if(eg(r)){e.issues.push({path:`styles.${r}`,message:AR(`styles.${r}`,r,`globals.endcaps`),line:K(e.source,[`styles`,r])});continue}let t=e_(e,jR,`styles.${r}`,i);t!==null&&(n[r]={...Sc,...t})}return n}const NR={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:gL(e,`${t}.${n}`,r[n])},globals:{required:!1,json:Lk(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Ik(e,`${t}.${n}`,r[n])}}};function PR(e,t){if(!Qg(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${$g(t)}`,line:K(e.source,[`presets`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)||/[\n\r]/.test(r)){e.issues.push({path:`presets.${r}`,message:`preset name ${JSON.stringify(r)} must be non-empty, slash-free, and newline-free — a preset picker writes the name on the set-state wire (which rejects empty values and splits on "/"), and edit mode splices it into a synthesized template string`,line:K(e.source,[`presets`,r])});continue}let t=e_(e,NR,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function FR(e,t){if(t===void 0)return{};if(!Qg(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${$g(t)}`,line:K(e.source,[`helpers`])}),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){if(typeof i!=`string`){e.issues.push({path:`helpers.${r}`,message:`helpers.${r} must be a string template body, got ${q(i)}`,line:K(e.source,[`helpers`,r])});continue}n[r]=i}return n}const IR=new Map([[`session.budget.amount`,{segment:`session`,setting:`budget`}],[`session.budget.warningThreshold`,{segment:`session`,setting:`warnAt`}],[`today.budget.amount`,{segment:`today`,setting:`budget`}],[`today.budget.warningThreshold`,{segment:`today`,setting:`warnAt`}],[`block.budget.heatThreshold`,{segment:`block`,setting:`warnAt`}],[`block.budget.warningThreshold`,{segment:`block`,setting:`errorAt`}],[`weekly.budget.heatThreshold`,{segment:`weekly`,setting:`warnAt`}],[`weekly.budget.warningThreshold`,{segment:`weekly`,setting:`errorAt`}],[`burn.eta.errorMinutes`,{segment:`burnrate`,setting:`errorWithin`}],[`burn.eta.warnMinutes`,{segment:`burnrate`,setting:`warnWithin`}]]);function LR(e){return`it became the "${e.setting}" setting of each "${e.segment}" placement — set it on the placement where a row places "${e.segment}" ({ seg: "${e.segment}", settings: { ${e.setting}: <value> } }), or redeclare segments.${e.segment}.settings.${e.setting} with the default every placement should start from`}function RR(e){let t=IR.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${LR(t)}`}function zR(e){let t=IR.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${LR(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function BR(e,t){let n=new Map;for(let e of Object.keys(t)){let t=XO(e),r=n.get(t);r?r.push(e):n.set(t,[e])}for(let[t,r]of n)r.length<2||e.issues.push({path:`presets`,message:`preset names ${r.map(e=>JSON.stringify(e)).join(` and `)} both collapse to the same synthesis identifier "${t}" — edit mode's synthesized reset affordance would silently steal one preset's action for the other. Rename one.`,line:K(e.source,[`presets`])})}function VR(e,t,n){let r=[[[`globals`],t.globals.style,`globals.endcaps`],[[`editGlobals`],t.editGlobals.style,`editGlobals.endcaps`],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style,`presets.${e}.globals.endcaps`]),...Object.entries(t.themeDefaults).map(([e,t])=>[[`themeDefaults`,e],t.style,`globals.endcaps`])];for(let[n,i,a]of r){if(i===void 0||Lh(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:eg(i)?AR(r,i,a):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:K(e.source,[...n,`style`])})}t.globals.preset!==void 0&&!Object.prototype.hasOwnProperty.call(t.presets,t.globals.preset)&&e.issues.push({path:`globals.preset`,message:`globals.preset "${t.globals.preset}" does not match any declared preset (have: ${Object.keys(t.presets).join(`, `)})`,line:K(e.source,[`globals`,`preset`])}),BR(e,t.presets);let i=hb(t);for(let t of i.names)t!==`settings`&&!t.startsWith(WR)||e.issues.push({path:`variables`,message:`variable "${t}" is named under "settings", which a segment's templates read as its placement's own settings (.settings.<name>) — rename it`,line:K(e.source,[`variables`,t])});let a=(t,n,r)=>{DP(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${iN}" ${DP(t)} times — it may appear at most once per layout (it is one disclosure, and one state key holds one open state). Remove all but the placement you want; removing every placement puts the menu at its default position.`,line:r}),OP(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${iN}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r}),o(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and shade, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of _g(t)){if(e.kind!==`segment`)continue;let t=pg(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=hg(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.length} placements with the id "${t}" — an id names one placement (its settings, its menus' open state, and edit mode all address it), so give each its own: { seg: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function o(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>o(n,t||fg[e.direction]===`cell`))}let s=(n,r)=>{for(let[a,o]of jy(n,r)){let n=K(e.source,o.split(`.`));if(a.when!==void 0&&(nz(e,`${o}.when`,a.when,i,{line:n}),tz(e,`${o}.when`,a.when,n)),a.kind===`segment`){if(wP(a.name)){(a.id!==void 0||a.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${iN}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${iN}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,a.name)||e.issues.push({path:o,message:`${r} entry "${a.name}" does not match any declared segment${kI(a.name)}`,line:n}),QR(e,t,a,o,n)}}};n.root!==void 0&&s(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&s(t.root,`presets.${e}.root`);let c=new Map([[`root`,ky(t.root)]]);for(let e of Iy(t.presets)){let{node:n,path:r}=zy(t,e);c.set(r,n)}for(let[t,n]of c)a(n,t,K(e.source,t.split(`.`)));lz(e,t,i,()=>!0)}const HR=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function UR(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=K(e.source,[`actions`,n,r]);if(!Iy(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${Iy(t.presets).join(`, `)})`,line:c});return}if(r===`reset`)return;let l=`removeSegment`in o,u=`insertSegment`in o,d=`insertSegmentFrom`in o;if(!l&&!u&&!d){e.issues.push({path:s,message:`actions.${n}: "${i}" is a "presets.<name>.root" target and can only be paired with "removeSegment", "insertSegment", or "insertSegmentFrom" (not "to"/"from"/"cycle"/bounded — those have no meaning as a tree op)`,line:c});return}let f=(r,i)=>{Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})${kI(i)}`,line:c})},p=new Set(mg(zy(t,a).node)),m=(r,i)=>{!OI.has(i)||p.has(i)||Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" names no placement${kI(i)}`,line:c})};`removeSegment`in o&&m(`removeSegment`,o.removeSegment),`insertSegment`in o&&f(`insertSegment`,o.insertSegment),(`insertSegment`in o||`insertSegmentFrom`in o)&&m(`anchor`,o.anchor)}const WR=`settings.`;function GR(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>WR+e)])}}function KR(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:K(e.source,[`segments`,t,`settings`,n])})},a=YR(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of Pg(n,JR(n)))i(e,`the defaults do not stand together: ${t}`)}function qR(e){return YR(e).length>0||Pg(e,JR(e)).length>0}function JR(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function YR(e){let t=t=>Ng(XR(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||Ng(XR(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${ZR(e,n).join(`, `)||`none`})`}];let i=[n];for(let e=r;e!==void 0;e=t(e)){if(e===n)return i.every(e=>n<=e)?[{setting:n,message:`atLeast closes a cycle (${[...i,n].join(` ≥ `)}) — every setting on it could only ever equal the rest`}]:[];if(i.includes(e))return[];i.push(e)}return[]})}function XR(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function ZR(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&Ng(n)!==void 0).map(([e])=>e)}function QR(e,t,n,r,i){let a=Object.prototype.hasOwnProperty.call(t.segments,n.name)?t.segments[n.name]:void 0;if(a===void 0)return;let o=Mg(a),s=`${r}: placement "${pg(n)}" of segment "${n.name}"`;for(let[t,a]of Object.entries(n.settings??{})){let c=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0,l=c===void 0?`sets "${t}", which segment "${n.name}" does not declare (it has: ${Object.keys(o).join(`, `)})`:Fg(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?Oh(a):``}, but it must be ${zg(c)}`;l!==void 0&&e.issues.push({path:r,message:`${s} ${l}`,line:i})}let c=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,n.settings?.[e]??t.default]));if(!(!Object.entries(c).every(([e,t])=>Fg(o[e],t))||qR(o)))for(let{message:t}of Pg(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function $R(e,t,n,r,i){n.kind===`template`&&nz(e,`${t}.template`,n.template,r,{segCtx:i}),wg(n)&&`key`in n.cache&&nz(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function ez(e,t,n,r,i){if(!(!wg(n)||!(`depends_on`in n.cache)))for(let a=0;a<n.cache.depends_on.length;a++){let o=n.cache.depends_on[a];if(r.names.has(o))continue;let s=i===void 0?void 0:`${i}.${o}`,c=s!==void 0&&r.names.has(s)?` (segment-local vars are namespaced — write "${s}")`:``;e.issues.push({path:`${t}.cache.depends_on[${a}]`,message:`cache.depends_on references unknown variable "${o}"${c}`,line:K(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function tz(e,t,n,r){try{iA.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function nz(e,t,n,r,i){for(let[a,o]of sb(n,r.helpers)){if(mb(a,r))continue;if(a.startsWith(WR)){let n=o===null?``:` through helper "${o}"`,r=a.slice(9),s=i?.segCtx===void 0||i.settings===void 0?`Template reads ".${a}"${n}, but only a segment's own templates have settings — call it from a segment that declares "${r}"`:`Template reads ".${a}"${n}, but segment "${i.segCtx}" has no setting "${r}" (it has: ${Object.keys(i.settings).join(`, `)}) — declare it under segments.${i.segCtx}.settings`;e.issues.push({path:t,message:s,line:i?.line??K(e.source,t.split(`.`))});continue}if(o!==null){rz(e,o,`Template references unknown variable ".${a}"${zR(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&mb(n,r)?` (segment-local vars are namespaced — write ".${n}")`:zR(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??K(e.source,t.split(`.`))})}}function rz(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:K(e.source,[`helpers`,t])})}function iz(e,t,n,r,i){let a=n.set,o=xk(sv[r].configKey),s=`${a} takes ${hk(o,i)}`;if(`min`in n&&(o===`bool`||!(`min`in o))){e.issues.push({path:`actions.${t}.min`,message:`actions.${t}: a stepper writes the integers from ${n.min} to ${n.max}, and ${a} is not an integer range; ${s}`,line:K(e.source,[`actions`,t,`min`])});return}let c=sz(n,i);if(c===oz){e.issues.push({path:`actions.${t}.int`,message:`actions.${t}.int: an int cursor writes whatever integer the template binds, and a click outside the ${a} domain would change nothing; ${s}`,line:K(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!mk(o,e.value,i));if(l.length!==0){if(a===sv.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>eg(e.value)))){let r=sv.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:AR(`actions.${t}.to`,n.to,`set: "${r}", to`),line:K(e.source,[`actions`,t,`to`])}:{path:`actions.${t}.set`,message:`actions.${t}.set: "${a}" here writes only endcaps shapes, not styles — endcaps were renamed from "style" to "endcaps"; write set: "${r}"`,line:K(e.source,[`actions`,t,`set`])});return}for(let n of new Set(l.map(e=>e.field))){let r=l.filter(e=>e.field===n).map(e=>JSON.stringify(e.value)),i=r.length<=az?r.join(`, `):`${r.slice(0,az).join(`, `)} and ${r.length-az} more`,o=`actions.${t}.${n}`;e.issues.push({path:o,message:`${o}: ${i} ${r.length===1?`is`:`are`} outside the ${a} domain — a click would write it and nothing would change; ${s}`,line:K(e.source,[`actions`,t,n])})}}}const az=3,oz=Symbol(`any integer`);function sz(e,t){return`to`in e?[{field:`to`,value:e.to}]:`cycle`in e?e.cycle.map(e=>({field:`cycle`,value:e})):`from`in e?Ky(e.from,t).members.map(e=>({field:`from`,value:e})):`min`in e?[{field:`min`,value:String(e.min)},{field:`max`,value:String(e.max)}]:oz}function cz(e,t){return Object.entries(e).filter(([e])=>t(e))}function lz(e,t,n,r){let i=nF(t),a=Gy(i);for(let[n,o]of cz(t.actions,r)){let[t,r]=`from`in o?[`from`,o.from]:`insertSegmentFrom`in o?[`insertSegmentFrom`,o.insertSegmentFrom]:[null,null];if(t!==null&&typeof r==`string`&&!a.includes(r)){e.issues.push({path:`actions.${n}.${t}`,message:`actions.${n} ${t}: references ${Jy(r,i)}`,line:K(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;dv.has(o.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${o.set}", which has no session pick — globals.${o.set} is set in the config file only, so a click would change nothing; write it with { persist: "${o.set}", … } instead`,line:K(e.source,[`actions`,n,`set`])});let s=hv.get(o.set);s!==void 0&&iz(e,n,o,s,i)}for(let[n,i]of cz(t.actions,r))`do`in i&&i.do.forEach((r,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,r)?t.actions[r]:void 0,s=o===void 0?`references unknown action "${r}"`:`do`in o?`"${r}" is itself a do action — list its members here instead`:i.do.indexOf(r)===a?a>0&&zL(o)?`"${r}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${r}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:K(e.source,[`actions`,n,`do`])})});for(let[n,i]of cz(t.actions,r)){let r=`persist`in i?i.persist:`reset`in i?i.reset:null;if(r===null)continue;let a=`persist`in i?`persist`:`reset`,o=$k(r);if(o===null){let t=Vk(r);e.issues.push({path:`actions.${n}.${a}`,message:t===void 0?`actions.${n}: "${r}" is not a config globals field (have: ${Hk().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, a "themeDefaults.<theme>.<shade|variation|style>" target, or a "presets.<name>.root" target`:`actions.${n}: the globals field "${r}" was removed: ${t}`,line:K(e.source,[`actions`,n,a])});continue}let s=HR.filter(e=>e in i);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){UR(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!Iy(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names preset "${o.preset}" which is not declared (have: ${Iy(t.presets).join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`theme-default`&&!e.allowedPalettes.has(o.theme)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names theme "${o.theme}" which is not installed${Oh(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`segment-palette`){if(!Object.prototype.hasOwnProperty.call(t.segments,o.segment)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${kI(o.segment)}`,line:K(e.source,[`actions`,n,a])});continue}`min`in i&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:K(e.source,[`actions`,n,a])})}}for(let[i,a]of cz(t.variables,r)){$R(e,`variables.${i}`,a,n);let t=RR(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:K(e.source,[`variables`,i])})}for(let[i,a]of cz(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))$R(e,`segments.${i}.vars.${t}`,r,n,i);let r=Mg(a);KR(e,i,r);let o=GR(n,r);for(let n of[`template`,`bg`,`fg`,`when`]){let s=a[n];if(typeof s==`string`){nz(e,`segments.${i}.${n}`,s,o,{segCtx:i,settings:r});for(let{name:r,site:a,via:o}of db(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=a===`options`?` (in a picker, menu, carousel, swatch, swatches or themePreview)`:``;if(o!==null){rz(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${i}.${n}`,message:`${n} references unknown action "${r}"${s}`,line:K(e.source,[`segments`,i,n])})}}}}for(let[i,a]of cz(t.variables,r))ez(e,`variables.${i}`,a,n);for(let[i,a]of cz(t.segments,r))if(a.vars)for(let[t,r]of Object.entries(a.vars))ez(e,`segments.${i}.vars.${t}`,r,n,i)}function uz(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=dz(t),a=new Map,o=[];for(let e of r.keys())a.set(e,0);for(let e of r.keys())if(!(!n(e)||a.get(e)!==0)&&s(e))return;function s(t){a.set(t,1),o.push(t);for(let c of r.get(t)??[]){if(!n(c))continue;let t=a.get(c);if(t===1){let t=o.indexOf(c),n=[...o.slice(t),c],r=n[0],a=i.get(r);return e.issues.push({path:a?.declarationPath??`variables.${r}`,message:`Dependency cycle: ${n.join(` → `)}`,line:K(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function dz(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of sb(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),wg(n)&&(`key`in n.cache&&i(e,n.cache.key),`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}function fz(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?C.homedir()+e.slice(1):e}function pz(e,t){return s.resolve(e,fz(t))}function mz(e,t){return typeof t==`string`&&t!==``?pz(e,t):void 0}function hz(e){return`plugin ${e.path} was not loaded: ${e.reason}`}const gz=new Set([`data`,`segments`,`helpers`,`actions`]),_z=`plugin.json5`,vz=/^[a-z][a-z0-9_]*$/;function yz(e){let t=s.basename(s.dirname(e));return vz.test(t)?t:void 0}const bz=`plugins.`;function xz(e){return`${bz}${e}.data`}function Sz(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,reason:Cz(e)}}}function Cz(e){return e instanceof Hg?e.issues.map(e=>e.path===``||e.message.includes(e.path)?e.message:`${e.path}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function wz(e,t){return e.map(e=>pz(s.dirname(t),e))}function Tz(e,t,n,r){let i=new Map;return e.reduce((e,n)=>{let a=yz(n),o=(t,r)=>{let i=new Map(e.rendering);return a!==void 0&&r!==e.config&&i.delete(a),{...e,config:r,rendering:i,dropped:[...e.dropped,{path:n,plugin:a,reason:t}]}};if(s.basename(n)!==`plugin.json5`){let t=`a plugin is a folder holding its ${_z}, and the folder's name is the plugin's: move this file to <dir>/<name>/${_z} and list that`;return o(t,a===void 0?e.config:Oz(Dz(e.config,a),a,{path:n,plugin:a,reason:t}))}if(a===void 0)return o(`its folder "${s.basename(s.dirname(n))}" is not a plugin name (one matching ${vz}: it prefixes every name the plugin declares)`,e.config);let c=i.get(a);if(c!==void 0)return o(`plugin "${a}" is already listed, from ${c}`,e.config);i.set(a,n);let l=Dz(e.config,a),u=Sz(()=>{let i=p.readFileSync(n,`utf-8`),o=HF(Pz(n,a,{source:i,json:ui.default.parse(i)},t),l);return r(o,a,l!==e.config),o});if(u.ok)return{...e,config:u.value,loaded:[...e.loaded,n],rendering:new Map([...e.rendering,[a,n]])};let d={path:n,plugin:a,reason:u.reason};return o(u.reason,Oz(l,a,d))},{config:n.config,rendering:n.rendering,loaded:[],dropped:[]})}function Ez(e){let t=`${bz}${e}.`;return e=>e.startsWith(t)}function Dz(e,t){let n=Ez(t),r=e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n(e)));return[e.variables,e.segments,e.helpers,e.actions].some(e=>Object.keys(e).some(n))?{...e,variables:r(e.variables),segments:r(e.segments),helpers:r(e.helpers),actions:r(e.actions)}:e}function Oz(e,t,n){return{...e,variables:{...e.variables,[xz(t)]:{kind:`dropped`,reason:hz(n),definition:n.path}}}}function kz(e){return e.startsWith(`plugins.`)?e.slice(8).split(`.`)[0]:void 0}function Az(e,t){let n=new Set([...Object.keys(e.config.variables),...Object.keys(e.config.segments)].map(kz)),r=[...t,...e.dropped].filter(e=>e.plugin===void 0).map(e=>({definition:e.path,notice:hz(e)}));return t=>{let i=kz(t);if(i===void 0)return[];let a=e.config.variables[xz(i)];return a?.kind===`dropped`?[{definition:a.definition,notice:a.reason}]:n.has(i)?[]:r}}function jz(e,t){let n=Iy(e.presets).flatMap(t=>[..._g(zy(e,t).node)]).flatMap(e=>e.kind===`segment`?[e]:[]),r=[...new Set([...n.map(e=>e.name),...Object.keys(e.segments)])].map(e=>({name:e,cause:t(e)})).filter(({cause:e})=>e.length>0),i=Object.fromEntries(r.map(({name:e,cause:t})=>[e,Mz(e,t.map(e=>e.notice),n.filter(t=>t.name===e))])),a=t=>{let n=kz(t),r=n===void 0?void 0:e.variables[xz(n)];return r?.kind===`dropped`?{definition:r.definition,notice:r.reason}:void 0},o=Object.values(e.variables).some(e=>e.kind===`dropped`),s=o?Object.values(e.segments).flatMap(e=>[`template`,`bg`,`fg`,`when`].flatMap(t=>e[t]===void 0?[]:[e[t]])):[],c=o?Object.values(e.actions).flatMap(e=>`do`in e?[...e.do]:[]):[],l=(e,t)=>[...new Set(e)].flatMap(e=>{let n=e in t?void 0:a(e);return n===void 0?[]:[[e,n]]}),u=l([...s.flatMap(t=>db(t,e.helpers).map(e=>e.name)),...c],e.actions),d=l(s.flatMap(t=>[...pb(t,e.helpers)]),e.helpers),f=new Set([...r.flatMap(({cause:e})=>e.map(e=>e.definition)),...[...u,...d].map(([,e])=>e.definition)]);return{config:{...e,segments:{...e.segments,...i},actions:{...e.actions,...Object.fromEntries(u.map(([e])=>[e,{copy:`{{ .${xz(kz(e)??``)} }}`}]))},helpers:{...e.helpers,...Object.fromEntries(d.map(([e,t])=>[e,`{{ fail ${JSON.stringify(t.notice)} }}`]))}},reached:f}}function Mz(e,t,n){let r=`⚠ ${e}: ${t.join(`; `)}`,i=new Map;for(let e of n)for(let[t,n]of Object.entries(e.settings??{})){let e=i.get(t);i.set(t,e===void 0?[n]:[...e,n])}let a=Object.fromEntries([...i].map(([e,t])=>[e,Nz(e,t)]));return{template:`{{ ${JSON.stringify(r)} }}`,bg:`error`,description:`stands in for a segment whose plugin did not load`,settings:a}}function Nz(e,t){let[n]=t,r=t.filter(e=>typeof e==`number`);return typeof n==`boolean`?{label:e,domain:`bool`,default:n}:typeof n==`number`?{label:e,domain:{min:Math.min(...r),max:Math.max(...r),step:1},default:n}:{label:e,domain:[...new Set(t.map(String))],default:n}}function Pz(e,t,{source:n,json:r},{checkout:i}){let a=[],o=()=>{throw new Hg(e,a)};if(!Qg(r))return a.push({path:``,message:`a plugin definition must be an object, got ${$g(r)}`}),o();for(let e of Object.keys(r))gz.has(e)||a.push({path:e,message:e===`plugin`?`a plugin definition does not name itself: its name is its folder's ("${t}") — remove "plugin"`:`a plugin definition may not declare "${e}". Expected only: ${[...gz].join(`, `)}`});let s=Bz(r.data,e,i,a);if(Qg(r.segments)||a.push({path:`segments`,message:`"segments" must be an object naming the plugin's segments`}),a.length>0||s===void 0)return o();let c={source:n,issues:a,allowedPalettes:new Set(jh()),groups:[]},l=$F(c,`data`,{[xz(t)]:{kind:`file`,path:s,parse:{json:!0},cache:{watch_file:s},default:{}}});for(let[e,t]of Object.entries(r.segments))if(!(!Qg(t)||!Qg(t.vars)))for(let[n,r]of Object.entries(t.vars)){let t=Qg(r)?r.kind:void 0;typeof t!=`string`||t===`state`||a.push({path:`segments.${e}.vars.${n}`,message:`a plugin segment's vars may declare only state variables (kind: "state"), never a source such as ${JSON.stringify(t)}: a plugin's only source is its data file`})}let u={variables:l,segments:Iz(t,Rz(t,qI(c,r.segments,new Set))),helpers:Iz(t,FR(c,r.helpers)),actions:Iz(t,zz(t,BL(c,r.actions)))};for(let[e,t]of Fz(u))try{iA.parse(t)}catch(t){a.push({path:e,message:`Template parse error in ${e}: ${t.message}`})}return a.length>0&&o(),u}function*Fz(e){for(let[t,n]of Object.entries(e.segments??{}))for(let e of[`template`,`bg`,`fg`,`when`]){let r=n[e];r!==void 0&&(yield[`segments.${t}.${e}`,r])}for(let[t,n]of Object.entries(e.helpers??{}))yield[`helpers.${t}`,`{{ define "${t}" }}${n}{{ end }}`];for(let[t,n]of Object.entries(e.actions??{}))`copy`in n&&(yield[`actions.${t}.copy`,n.copy]),`open`in n&&(yield[`actions.${t}.open`,n.open]),`preset`in n&&n.preset===`delete`&&(yield[`actions.${t}.name`,n.name])}function Iz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[`${bz}${e}.${t}`,n]))}function Lz(e,t){return`${bz}${e}.${t}`}function Rz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.vars===void 0?n:{...n,vars:Object.fromEntries(Object.entries(n.vars).map(([t,n])=>[t,n.kind===`state`?{...n,key:Lz(e,n.key)}:n]))}]))}function zz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,`set`in n?{...n,set:Lz(e,n.set)}:n]))}function Bz(e,t,n,r){if(typeof e==`string`&&e!==``)return pz(s.dirname(t),e);if(Qg(e)&&Object.keys(e).length===1&&typeof e.checkout==`string`&&e.checkout!==``){let t=e.checkout;if(s.isAbsolute(t)||t.startsWith(`~`)||s.normalize(t).split(s.sep)[0]===`..`){r.push({path:`data.checkout`,message:`data.checkout "${t}" must be a path inside the checkout, relative to its root (like ".lit/statusline.json"): no absolute path, "~" or ".."`});return}if(n===null){r.push({path:`data.checkout`,message:`data is read from the session's checkout, and this load has no session`});return}return s.resolve(n.root,t)}if(Qg(e)&&`project`in e){r.push({path:`data.project`,message:`data: { project } is now data: { checkout }: the same path, relative to the root of the git checkout the session works in (a linked worktree is its own checkout)`});return}r.push({path:`data`,message:`"data" must be the path of the plugin's JSON data file relative to this definition, or { checkout: "<path>" } relative to the root of the session's checkout`})}function Vz(e){let t=[...[...(process.env.XDG_DATA_DIRS||Wz()).split(`:`).filter(e=>e!==``)].reverse().map(e=>s.join(e,`cc-candybar`,`plugins`)),Hz(),...e===null?[]:[s.join(e,Uz)]];return t.filter((e,n)=>t.lastIndexOf(e)===n)}function Hz(){let e=process.env.XDG_DATA_HOME||s.join(C.homedir(),`.local`,`share`);return s.join(e,`cc-candybar`,`plugins`)}const Uz=s.join(`.cc-candybar`,`plugins`);function Wz(){let e=`/usr/local/share:/usr/share`;return process.platform===`darwin`?`${s.join(process.env.HOMEBREW_PREFIX||`/opt/homebrew`,`share`)}:${e}`:e}function Gz(e){let t=Vz(e),n=new Map,r=[],i=[];for(let e of t){let t=Kz(e);if(`error`in t){r.push(t);continue}for(let r of t.folders)n.delete(r),n.set(r,s.join(e,r,_z));for(let n of t.files)i.push({path:s.join(e,n),plugin:void 0,reason:`a plugin is a folder holding its ${_z}: move this file to ${s.join(e,`<name>`,_z)}`})}return{roots:t,definitions:[...n.values()],unchecked:r,strays:i}}function Kz(e){try{let t=p.readdirSync(e,{withFileTypes:!0}).filter(e=>!e.name.startsWith(`.`)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),n=t=>t.isDirectory()||qz(e,t);return{folders:t.filter(n).map(e=>e.name),files:t.filter(e=>!n(e)).map(e=>e.name)}}catch(t){return t.code===`ENOENT`?{folders:[],files:[]}:{path:e,error:t.message}}}function qz(e,t){if(!t.isSymbolicLink())return!1;try{return p.statSync(s.join(e,t.name)).isDirectory()}catch{return!0}}function Jz(e){try{return p.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}const Yz=[`json5`,`json`];function Xz(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Yz.map(t=>s.join(e,`.cc-candybar.${t}`)):[],...Yz.map(e=>s.join(r,`.cc-candybar.${e}`)),...Yz.map(e=>`${Zz()}.${e}`)])]}function Zz(){let e=process.env.XDG_CONFIG_HOME??s.join(C.homedir(),`.config`);return s.join(e,`cc-candybar`,`config`)}function Qz(e,t,n){let r=[],i=new Map;for(let a of Xz(e,t,n)){let e=Jz(a);if(e===`absent`)continue;if(e!==`present`){r.push(e);continue}let t=s.join(p.realpathSync(s.dirname(a)),s.basename(a).replace(/\.(json5|json)$/,``));i.has(t)||i.set(t,a)}let a=[...i.values()].reverse();if(n===void 0)return{kind:`chain`,layers:a,home:$z(a),unchecked:r};let[o]=r,c=n;return a.length>0?{kind:`chain`,layers:a,home:c,unchecked:r}:o===void 0?{kind:`missing`,path:n,home:c}:{kind:`unreadable`,...o,home:c}}function $z(e){let t=Zz();return e.find(e=>Yz.some(n=>e===`${t}.${n}`))??`${t}.${Yz[0]}`}function eB(e,t,n){let r=Qz(e,t,n),i=r.kind===`chain`?r.layers:[];return{path:r.home,above:i.filter(e=>e!==r.home),projectDir:e??null,cwd:t??null}}function tB(e){return nB(e).join(`
180
185
  `)||null}function nB(e){switch(e.kind){case`chain`:return e.unchecked.map(e=>`Config location could not be checked: ${e.path} — ${e.error}`);case`missing`:return[`Config file not found: ${e.path} — rendering the bundled default until it appears`];case`unreadable`:return[`Config file could not be read: ${e.path} — ${e.error} — rendering the bundled default until it can be`]}}function rB(e,t){let n=Xz(e,t).filter(e=>Jz(e)===`present`),r=new Map;for(let e of n){let t=s.dirname(e),n=s.basename(e).replace(/\.(json5|json)$/,``),i=s.join(t,n);r.has(i)||r.set(i,[]),r.get(i).push(e)}let i=[...r.values()].filter(e=>e.length>1);return i.length===0?null:`config-extension collision: ${i.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function iB(e,t,n,r){return e===null?{...mB,config:HF(mB.raw,t)}:oB(e,p.readFileSync(e,`utf-8`),t,n,r)}const aB={projectDir:null,checkout:null,beneath:{dropped:[],rendering:new Map}};function oB(e,t,n,r,i){let a=_B(e,t,i,(t,a)=>{let o=Tz(wz(t,e),r,{config:n,rendering:r.beneath.rendering},(t,n,r)=>fB(t,n,r,e,i)),s=Az(o,r.beneath.dropped);return{inherited:new Set([...KI(o.config),...a.filter(e=>s(e).length>0)]),layer:{plugins:o,owning:s}}}),{plugins:o,owning:s}=a.layer,c=jz(HF(a.raw,o.config),s);return{source:t,raw:a.raw,warnings:[...a.warnings,...o.dropped.map(hz)],plugins:{loaded:o.loaded,dropped:o.dropped,reached:c.reached,rendering:o.rendering},config:c.config}}const sB=new WeakMap;function cB(e,t,n,r){let i=JSON.stringify([[...r??[]].sort(),e.map(e=>[e,uB(e)])]),a=sB.get(n)??new Map;sB.set(n,a);let o=JSON.stringify([t.projectDir,t.checkout?.root??null]),s=a.get(o);if(s?.key===i)return s.layer;let c=Tz(e,t,{config:n,rendering:new Map},(e,t,n)=>fB(e,t,n,`<installed plugins>`,r));return a.set(o,{key:i,layer:c}),c}function lB(e,t,n){return Tz(e,{projectDir:null,checkout:n},{config:t,rendering:new Map},(e,t,n)=>fB(e,t,n,`<plugin install>`,void 0)).dropped}function uB(e){try{let t=p.statSync(e);return`${t.ino}:${t.size}:${t.mtimeMs}`}catch(e){return e.code??`unreadable`}}function dB(e,t,n,r,i=e=>p.readFileSync(e,`utf-8`),a){let o={projectDir:r.projectDir,checkout:r.cwd===null?null:wD(r.cwd)},s=Gz(o.projectDir),c=cB(s.definitions,o,t,a),l={...c,dropped:[...c.dropped,...s.strays]};n.warned(s.unchecked.map(e=>`Plugin folder could not be listed: ${e.path} — ${e.error}`));let u=l.config,d=[];for(let t of e){n.entered(t);let e=d.at(-1)?.plugins,r=oB(t,i(t),d.at(-1)?.config??u,{...o,beneath:{dropped:[...l.dropped,...d.flatMap(e=>e.plugins.dropped)],rendering:e?.rendering??l.rendering}},a);n.warned(r.warnings),d.push({...r,path:t})}let f=new Set(d.flatMap(e=>[...e.plugins.reached])),m=e=>f.has(e.path),h=l.dropped.filter(m),g=l.dropped.filter(e=>!m(e));n.warned(h.map(hz));let _={checkout:o.checkout,roots:s.roots,loaded:l.loaded,dropped:h,unreached:g,reached:f,rendering:d.at(-1)?.plugins.rendering??l.rendering},v=d.at(-1);if(v===void 0)return{layers:d,base:u,installed:_,config:hB(iB(null,u,aB),`<default>`,a)};try{return{layers:d,base:u,installed:_,config:hB(v,v.path,a)}}catch(e){for(let e of d.slice(0,-1))n.entered(e.path),hB(e,e.path,a);throw n.entered(v.path),e}}function fB(e,t,n,r,i){if(n){hB(pB(e),r,i);return}let a=Ez(t),o=[],s={source:``,issues:o,allowedPalettes:new Set,groups:[]};if(lz(s,e,hb(e),a),uz(s,e,a),o.length>0)throw new Hg(r,o)}function pB(e){return{config:e,raw:{root:e.root,presets:e.presets},source:``}}const mB={raw:{},source:``,warnings:[],plugins:{loaded:[],dropped:[],reached:new Set,rendering:new Map}};function hB({config:e,raw:t,source:n},r=`<config>`,i=new Set(jh())){let a=[],o={source:n,issues:a,allowedPalettes:i,groups:[]};if(VR(o,e,t),uz(o,e),a.length>0)throw new Hg(r,a);let s=IL(e,a);if(a.length>0)throw new Hg(r,a);return bF(BP(s))}function gB(e,t,n=new Set(jh()),r=vB){return _B(e,t,n,()=>({inherited:r,layer:null})).raw}function _B(e,t,n,r){let i=yB(e,t),a=Gg(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(jh()),groups:[]};if(!Qg(i))throw new Hg(e,[{path:``,message:`Config root must be an object, got ${$g(i)}`}],o);let{inherited:l,layer:u}=r(i.plugins===void 0?[]:SB({...c,issues:[]},i.plugins)??[],Qg(i.segments)?Object.keys(i.segments):[]),d=bB(c,i,l);if(s.length>0)throw new Hg(e,s,o);return{raw:d,warnings:o,layer:u}}const vB=new Set;function yB(e,t){try{return ui.default.parse(t)}catch(t){let n=t;throw new Hg(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function bB(e,t,n){for(let n of Object.keys(t))xB.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...xB].join(`, `)}`,line:K(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=Fk(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=$F(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=qI(e,t.segments,n)),t.layout!==void 0&&e.issues.push({path:`layout`,message:`"layout" is no longer supported — use "root" with the A-grammar instead.
181
186
  Replace: layout: [["seg1", "seg2"], ["seg3"]]
182
187
  With: root: { v: [{ h: ["seg1", "seg2"] }, "seg3"] }
183
- Single-row example: root: { h: ["seg1", "seg2"] }`,line:K(e.source,[`layout`])}),t.root!==void 0&&(r.root=gL(e,`root`,t.root)),t.actions!==void 0&&(r.actions=BL(e,t.actions)),t.looks!==void 0&&e.issues.push({path:`looks`,message:`"looks" was renamed "styles" — move the block under styles: { … } (and globals.look to globals.style)`,line:K(e.source,[`looks`])}),t.styles!==void 0&&(r.styles=MR(e,t.styles)),t.themeDefaults!==void 0&&(r.themeDefaults=Pk(e,t.themeDefaults)),t.presets!==void 0&&(r.presets=PR(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=Rk(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=FR(e,t.helpers)),t.plugins!==void 0&&(r.plugins=SB(e,t.plugins)),wL(e,r),PL(e,r),_A(e,r),rk(e,r,X,`the global settings menu`),r}const xB=new Set([`globals`,`variables`,`segments`,`layout`,`looks`,`root`,`actions`,`styles`,`themeDefaults`,`presets`,`editGlobals`,`helpers`,`plugins`]);function SB(e,t){if(Array.isArray(t)&&t.every(e=>typeof e==`string`&&e!==``))return t;e.issues.push({path:`plugins`,message:`"plugins" must be a list of plugin definition paths, got ${$g(t)}`,line:K(e.source,[`plugins`])})}const CB={},wB=ZM(`commands.`),TB=rN(`autocompact.`,e=>`{{ template "formatTokenCount" ${e} }}`),EB=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,DB=`{{ \$dir := .current_dir }}{{ if and (ne .home "") (or (eq .home .current_dir) (hasPrefix (printf "%s/" .home) .current_dir)) }}{{ \$dir = printf "~%s" (trimPrefix .home .current_dir) }}{{ else }}{{ if or (eq .project_dir .current_dir) (hasPrefix (printf "%s/" .project_dir) .current_dir) }}{{ $dir = ternary (${EB}) (basename .project_dir) (ne (${EB}) "") }}{{ end }}{{ end }}{{ action "copyDir" (abbreviatePath \$dir) }}`,OB=`{{ ${WA} }}`,kB={min:0,max:100,step:5},AB={warnAt:{label:`warning at %`,domain:kB,default:50},errorAt:{label:`error at %`,domain:{...kB,atLeast:`warnAt`},default:80}};function jB(e){return{budget:{label:`budget $`,domain:{min:0,max:1e4,step:5},default:e},warnAt:{label:`warning at %`,domain:kB,default:80}}}const MB={globals:{palette:`tokyo-night`},variables:{...wB.variables,...KO,current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},"effort.level":{kind:`input`,path:`effort.level`,default:``},"effort.glyphs":{kind:`literal`,value:`? 󰅃 󰅃 󰄿 󰶼`},version:{kind:`input`,path:`version`,default:``},home:{kind:`input`,path:`home`,default:``},"tmux.session":{kind:`input`,path:`tmux.session`,default:``},"host.name":{kind:`input`,path:`host.name`,default:``},"host.user":{kind:`input`,path:`host.user`,default:``},"host.ssh":{kind:`input`,path:`host.ssh`,type:`boolean`,default:!1},"git.repoName":{kind:`input`,path:`git.repoName`,default:``},"git.branch":{kind:`input`,path:`git.branch`,default:``},"git.sha":{kind:`input`,path:`git.sha`,default:``},"git.ahead":{kind:`input`,path:`git.ahead`,type:`number`,default:0},"git.behind":{kind:`input`,path:`git.behind`,type:`number`,default:0},"git.staged":{kind:`input`,path:`git.staged`,type:`number`,default:0},"git.unstaged":{kind:`input`,path:`git.unstaged`,type:`number`,default:0},"git.untracked":{kind:`input`,path:`git.untracked`,type:`number`,default:0},"git.conflicts":{kind:`input`,path:`git.conflicts`,type:`number`,default:0},"git.upstream":{kind:`input`,path:`git.upstream`,default:``},"git.tracking":{kind:`input`,path:`git.tracking`,default:``},"git.stash":{kind:`input`,path:`git.stash`,type:`number`,default:0},"git.status":{kind:`input`,path:`git.status`,default:`clean`},"git.operation":{kind:`input`,path:`git.operation`,default:``},"git.timeSinceCommit":{kind:`input`,path:`git.timeSinceCommit`,type:`number`,default:0},"git.color.branch":{kind:`literal`,value:`primary`},"git.color.staged":{kind:`literal`,value:`success`},"git.color.unstaged":{kind:`literal`,value:`warning`},"git.color.untracked":{kind:`literal`,value:`accent`},"git.color.conflicts":{kind:`literal`,value:`error`},"git.color.ahead":{kind:`literal`,value:`success`},"git.color.behind":{kind:`literal`,value:`warning`},"git.color.stash":{kind:`literal`,value:`accent`},"git.detail":{kind:`state`,key:`git-detail`,default:`collapsed`},"git.prNumber":{kind:`input`,path:`git.prNumber`,type:`number`,default:0},"git.prState":{kind:`input`,path:`git.prState`,default:``},"git.prUrl":{kind:`input`,path:`git.prUrl`,default:``},"git.prError":{kind:`input`,path:`git.prError`,default:``},"cache.expiresAt":{kind:`input`,path:`cache.expiresAt`,type:`number`,default:0},"session.cost":{kind:`input`,path:`session.cost`,type:`number`,default:0},"session.tokens":{kind:`input`,path:`session.tokens`,type:`number`,default:0},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"burn.costPerHour":{kind:`input`,path:`burn.costPerHour`,type:`number`,default:-1},"block.etaMinutes":{kind:`input`,path:`block.etaMinutes`,type:`number`,default:-1},"weekly.etaMinutes":{kind:`input`,path:`weekly.etaMinutes`,type:`number`,default:-1},"speed.input":{kind:`input`,path:`speed.input`,type:`number`,default:-1},"speed.output":{kind:`input`,path:`speed.output`,type:`number`,default:-1},"speed.total":{kind:`input`,path:`speed.total`,type:`number`,default:-1},"speed.history":{kind:`input`,path:`speed.history`,type:`string`,default:``},"context.totalTokens":{kind:`input`,path:`context.totalTokens`,type:`number`,default:0},"context.contextLeft":{kind:`input`,path:`context.contextLeft`,type:`number`,default:100},"memento.ceiling":{kind:`input`,path:`memento.ceiling`,type:`number`,default:-1},"memento.off":{kind:`input`,path:`memento.off`,type:`boolean`,default:!1},"memento.session":{kind:`input`,path:`memento.session`,default:``},"memento.error":{kind:`input`,path:`memento.error`,default:``},"metrics.lastResponseTime":{kind:`input`,path:`metrics.lastResponseTime`,type:`number`,default:0},"metrics.responseTime":{kind:`input`,path:`metrics.responseTime`,type:`number`,default:0},"metrics.sessionDuration":{kind:`input`,path:`metrics.sessionDuration`,type:`number`,default:0},"metrics.messageCount":{kind:`input`,path:`metrics.messageCount`,type:`number`,default:0},"metrics.linesAdded":{kind:`input`,path:`metrics.linesAdded`,type:`number`,default:0},"metrics.linesRemoved":{kind:`input`,path:`metrics.linesRemoved`,type:`number`,default:0},"activity.command":{kind:`input`,path:`activity.command`,type:`string`,default:``},"activity.todo.total":{kind:`input`,path:`activity.todo.total`,type:`number`,default:0},"activity.todo.completed":{kind:`input`,path:`activity.todo.completed`,type:`number`,default:0},"activity.todo.position":{kind:`input`,path:`activity.todo.position`,type:`number`,default:0},"activity.todo.active":{kind:`input`,path:`activity.todo.active`,type:`string`,default:``},"activity.tool.running":{kind:`input`,path:`activity.tool.running`,type:`string`,default:``},"activity.tool.done":{kind:`input`,path:`activity.tool.done`,type:`string`,default:``}},segments:{directory:{group:`location`,description:"The current directory, shortened fish-style — `~` under home, project-relative inside the project. Click to copy the full path.",template:DB},model:{group:`model-context`,description:`The active model's display name, followed by the effort gauge (a chevron ladder, climbing on a bubble at max) when an effort level is set.`,template:`✱ {{ formatModelName .model.display_name }}{{ if ne .effort.level "" }} {{ template "effortGauge" . }}{{ end }}`,when:`{{ ne .model.display_name "" }}`},sessionId:{group:`session-tools`,description:`The session id, truncated to 8 characters.`,template:`⌗{{ trunc 8 .session.id }}`,when:`{{ ne .session.id "" }}`},version:{group:`model-context`,description:`The Claude Code version reported in the hook payload.`,template:`◈ v{{ .version }}`,when:`{{ ne .version "" }}`},tmux:{group:`location`,description:`The tmux session name; hidden when not inside tmux.`,template:`tmux:{{ .tmux.session | default "none" }}`,when:`{{ ne .tmux.session "" }}`},host:{group:`location`,description:`user@host on a warning background, shown only over SSH.`,template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,when:`{{ .host.ssh }}`},gitaculous:{group:`git`,description:`The git state: a summary (branch, ahead/behind, S/U/? flags) that the arrow at its right edge expands to every fact — repo, in-progress operation, sha, upstream ±, stash count, time since the last commit.`,template:`{{ if eq .git.detail "expanded" }}{{ template "gitExpanded" . }}{{ else }}{{ template "gitCollapsed" . }}{{ end }} {{ action "gitDetail" "▸" "◂" }}`,fg:OB,when:`{{ ne .git.branch "" }}`,settings:{aheadBehind:{label:`ahead/behind`,domain:`bool`,default:!0},flags:{label:`dirty flags`,domain:`bool`,default:!0},operation:{label:`operation`,domain:`bool`,default:!0},repo:{label:`repo name`,domain:`bool`,default:!0},sha:{label:`commit hash`,domain:`bool`,default:!0},stash:{label:`stash`,domain:`bool`,default:!0},upstream:{label:`upstream`,domain:`bool`,default:!0},age:{label:`time since commit`,domain:`bool`,default:!0}}},gitPr:{group:`git`,description:"The pull request open for this branch, as a link; `⚠ PR` when the forge lookup failed.",template:`{{ if eq .git.prState "open" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,when:`{{ or (eq .git.prState "open") (ne .git.prError "") }}`},toolbar:{group:`session-tools`,description:`Quick actions: copy the session id, and open the project, transcript or repo.`,template:BM(``).template},commands:{group:`session-tools`,description:`Type /compact, /model or /clear into this session; /clear asks for a second click. Hidden when not inside tmux.`,template:wB.template,when:wB.when},themeSwitcher:{group:`session-tools`,description:"`◀ <theme> ▶`: the theme the bar is wearing; ◀ and ▶ switch this session to the previous or next theme, wrapping at the ends.",template:`{{ carousel "stepTheme" 0 }}`},session:{group:`cost-limits`,description:`This session's cost and token total, with a budget warning once a budget is configured.`,template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:jB(0)},today:{group:`cost-limits`,description:`Today's cost and tokens across every session, with a budget warning once a budget is configured.`,template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:jB(50)},block:{group:`cost-limits`,description:`The 5-hour rate-limit block: percent used and time to reset, heating to warning then error.`,template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:AB,when:`{{ gt .block.resetsAt 0 }}`},weekly:{group:`cost-limits`,description:`The weekly rate-limit quota: percent used and time to reset, heating to warning then error.`,template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:AB,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{group:`cost-limits`,description:`Spend per hour, with the projected time to the 5-hour and weekly limits.`,template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 (tint) 0 "error" .settings.errorWithin "warning" .settings.warnWithin (tint) }}`,settings:{errorWithin:{label:`error within (min)`,domain:{min:0,max:300,step:5},default:30},warnWithin:{label:`warning within (min)`,domain:{min:0,max:300,step:5,atLeast:`errorWithin`},default:60}},when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{group:`activity`,description:`Token throughput for the latest exchange: output, input, and total.`,template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{group:`activity`,description:`A sparkline of recent token throughput.`,template:`⚡ {{ sparkline .speed.history 24 }}`,when:`{{ ne .speed.history "" }}`},cacheTimer:{group:`activity`,description:"Minutes until the prompt cache expires, or `cold` once it has.",template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ readableOn (color (cascade (minutesUntilReset .cache.expiresAt) "0:error" "9:warning" "21:foreground")) (bgOf) ${eh} }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{group:`model-context`,description:`Context used, in tokens and percent remaining, heating as it fills.`,template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 (tint) }}`,when:`{{ gt .context.totalTokens 0 }}`},ceiling:{group:`model-context`,description:`The memento plugin's context ceiling for this session: − and + move it by 100K, ∞ lifts it, ↺ drops this session's own setting.`,template:`{{ if ne .memento.error "" }}⌈ ⚠ {{ .memento.error }} {{ action "ceiling.clear" "↺" }}{{ else }}⌈ {{ if .memento.off }}off{{ else }}{{ template "formatTokenCount" .memento.ceiling }} {{ action "ceiling.lower" "−" }} {{ action "ceiling.raise" "+" }} {{ action "ceiling.off" "∞" }}{{ end }}{{ if ne .memento.session "" }} {{ action "ceiling.clear" "↺" }}{{ end }}{{ end }}`,bg:`{{ if ne .memento.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .memento.ceiling 0) (ne .memento.error "") }}`},autocompact:{group:`model-context`,description:`Claude Code's auto-compact window: − and + move it by 100K, ↺ returns it to auto. Clicks type /autocompact into this session, so the controls show only inside tmux.`,template:TB.template,bg:TB.bg,when:TB.when},metrics:{group:`activity`,description:`Response times, session duration, message count, and lines added/removed.`,template:`{{ if .metrics.lastResponseTime }} Δ {{ template "formatResponseTime" .metrics.lastResponseTime }}{{ end }}{{ if .metrics.responseTime }} ⧖ {{ template "formatResponseTime" .metrics.responseTime }}{{ end }}{{ if .metrics.sessionDuration }} ⧗ {{ template "formatDuration" .metrics.sessionDuration }}{{ end }}{{ if .metrics.messageCount }} ◆ {{ .metrics.messageCount }}{{ end }}{{ if .metrics.linesAdded }} + {{ .metrics.linesAdded }}{{ end }}{{ if .metrics.linesRemoved }} - {{ .metrics.linesRemoved }}{{ end }} `,when:`{{ or (gt .metrics.lastResponseTime 0.0) (gt .metrics.responseTime 0.0) (gt .metrics.sessionDuration 0.0) (gt .metrics.messageCount 0) (gt .metrics.linesAdded 0) (gt .metrics.linesRemoved 0) }}`},activity:{group:`activity`,description:`What Claude is doing: the slash command that opened the turn, the in-progress todo, and the tools in flight.`,template:`{{ if .activity.command }} ⌘ {{ .activity.command }}{{ end }}{{ if .activity.todo.total }}{{ if .activity.todo.active }} ☐ {{ .activity.todo.position }}/{{ .activity.todo.total }} {{ abbrev 32 .activity.todo.active }}{{ else }} ☑ {{ .activity.todo.completed }}/{{ .activity.todo.total }}{{ end }}{{ end }}{{ if .activity.tool.running }} ⟳ {{ template "formatToolTally" .activity.tool.running }}{{ end }}{{ if .activity.tool.done }} ✓ {{ template "formatToolTally" .activity.tool.done }}{{ end }} `,when:`{{ or (ne .activity.command "") (gt .activity.todo.total 0) (ne .activity.tool.running "") (ne .activity.tool.done "") }}`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`activity`}]}}},actions:{...BM(``).actions,...wB.actions,copyDir:{copy:`{{ .current_dir }}`},stepTheme:{set:`theme`,from:`themes`},gitDetail:{set:`git-detail`,cycle:[`collapsed`,`expanded`]},"ceiling.raise":{ceiling:`set`,to:`+100_000`},"ceiling.lower":{ceiling:`set`,to:`-100_000`},"ceiling.off":{ceiling:`set`,to:`off`},"ceiling.clear":{ceiling:`clear`},...TB.actions},styles:{none:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0},vivid:{hueShift:0,chromaScale:1.35,lightnessScale:1,lightnessShift:0},muted:{hueShift:0,chromaScale:.55,lightnessScale:1,lightnessShift:0},dim:{hueShift:0,chromaScale:1,lightnessScale:.85,lightnessShift:0},bright:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:.08},inverted:{hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1}},themeDefaults:CB,presets:{default:{},compact:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`context`}]},globals:{padding:0}},verbose:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},zen:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`context`}]},globals:{endcaps:`plain`,style:`dim`}},git:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`activity`}]}]}},usage:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`session`},{kind:`segment`,name:`today`},{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},dense:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`session`},{kind:`segment`,name:`activity`}]},globals:{padding:0}}},editGlobals:{endcaps:`plain`,default_separator:` | `},helpers:{effortGauge:`{{ \$ord := default 0 (get (dict "low" 1 "medium" 2 "high" 3 "xhigh" 4 "max" 5) .effort.level) }}{{ \$glyphs := compact (splitList " " .effort.glyphs) }}{{ $bubble := readableOn (mix (bgOf) (color "accent") 40) (bgOf) 1.08 }}{{ $climbing := readableOn (stepped 1 (color "primary") 1 (color "secondary") 1 (color "accent")) $bubble ${eh} }}{{ \$climb := frames 1 (index \$glyphs 1) 1 (index \$glyphs 3) 1 (index \$glyphs 4) }}{{ if eq \$ord 5 }}{{ fg \$bubble "" }}{{ bg \$bubble (fg \$climbing \$climb) }}{{ fg \$bubble "" }}{{ else }}{{ fg (ramp $ord "step" 0 (${WA}) 2 (readableOn (color "accent") (bgOf) ${eh})) (index $glyphs $ord) }}{{ end }}`,gitPaint:`{{ fg (readableOn (color .color) (bgOf) ${eh}) .text }}`,gitCollapsed:`{{ template "gitBranch" . }}{{ template "gitAheadBehind" . }}{{ template "gitFlags" . }}`,gitExpanded:`(git){{ template "gitRepo" . }}{{ template "gitOperation" . }}{{ template "gitSha" . }}{{ template "gitFlags" . }} {{ template "gitBranch" . }}{{ template "gitUpstream" . }}{{ template "gitStash" . }}{{ template "gitAge" . }}`,gitBranch:`⎇ {{ template "gitPaint" (dict "color" .git.color.branch "text" .git.branch) }}`,gitRepo:`{{ if and .settings.repo (ne .git.repoName "") }} {{ .git.repoName }}{{ end }}`,gitOperation:`{{ if and .settings.operation (ne .git.operation "") }} [{{ .git.operation }}]{{ end }}`,gitSha:`{{ if and .settings.sha (ne .git.sha "") }} {{ .git.sha }}{{ end }}`,gitFlags:`{{ if and .settings.flags (or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0)) }} {{ if gt .git.staged 0 }}{{ template "gitPaint" (dict "color" .git.color.staged "text" "S") }}{{ end }}{{ if gt .git.unstaged 0 }}{{ template "gitPaint" (dict "color" .git.color.unstaged "text" "U") }}{{ end }}{{ if gt .git.untracked 0 }}{{ template "gitPaint" (dict "color" .git.color.untracked "text" "?") }}{{ end }}{{ if gt .git.conflicts 0 }}{{ template "gitPaint" (dict "color" .git.color.conflicts "text" (printf "!%v" .git.conflicts)) }}{{ end }}{{ end }}`,gitAheadBehind:`{{ if and .settings.aheadBehind (or (gt .git.ahead 0) (gt .git.behind 0)) }} {{ if gt .git.ahead 0 }}{{ template "gitPaint" (dict "color" .git.color.ahead "text" (printf "+%v" .git.ahead)) }}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}{{ template "gitPaint" (dict "color" .git.color.behind "text" (printf "-%v" .git.behind)) }}{{ end }}{{ end }}`,gitUpstream:`{{ if and .settings.upstream (ne .git.upstream "") }} [{{ .git.upstream }}{{ template "gitAheadBehind" . }}]{{ end }}`,gitStash:`{{ if and .settings.stash (gt .git.stash 0) }} {{ template "gitPaint" (dict "color" .git.color.stash "text" (printf "(%v stashed)" .git.stash)) }}{{ end }}`,gitAge:`{{ if and .settings.age (gt .git.timeSinceCommit 0) }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:iN(`.`),formatTokens:`{{ template "formatTokenCount" . }} tokens`,formatToolTally:`{{ $names := splitList "," . }}{{ range $i, $pair := $names }}{{ if lt $i 2 }}{{ if $i }} {{ end }}{{ $kv := splitList ":" $pair }}{{ index $kv 0 }}{{ if ne (index $kv 1) "1" }}×{{ index $kv 1 }}{{ end }}{{ end }}{{ end }}{{ if gt (len $names) 2 }} +{{ sub (len $names) 2 }}{{ end }}`,formatRate:`{{ if lt . 0 }}—/hr{{ else }}{{ template "formatCost" . }}/hr{{ end }}`,formatEta:`{{ if lt . 0 }}—{{ else }}{{ template "formatLongTimeRemaining" . }}{{ end }}`,formatSpeed:`{{ if lt . 0 }}—{{ else }}{{ template "formatTokenCount" (round .) }}/s{{ end }}`,formatTokenBreakdown:`{{ $first := true }}{{ if gt .input 0 }}{{ template "formatTokenCount" .input }} in{{ $first = false }}{{ end }}{{ if gt .output 0 }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" .output }} out{{ $first = false }}{{ end }}{{ if or (gt .cacheCreation 0) (gt .cacheRead 0) }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" (add .cacheCreation .cacheRead) }} cached{{ $first = false }}{{ end }}{{ if $first }}0 tokens{{ end }}`,budgetStatus:`{{ if or (le .budget 0) (lt .cost 0) }}{{ else }}{{ $pct := minf 100 (mulf (divf .cost .budget) 100) }}{{ $p := printf "%.0f%%" $pct }}{{ if ge $pct .warn }} !{{ $p }}{{ else }}{{ if ge $pct 50 }} +{{ $p }}{{ else }} {{ $p }}{{ end }}{{ end }}{{ end }}`,formatTimeSince:`{{ if lt . 60 }}{{ . }}s{{ else if lt . 3600 }}{{ div . 60 }}m{{ else if lt . 86400 }}{{ div . 3600 }}h{{ else if lt . 604800 }}{{ div . 86400 }}d{{ else }}{{ div . 604800 }}w{{ end }}`,formatDuration:`{{ if lt . 60 }}{{ printf "%.0f" . }}s{{ else if lt . 3600 }}{{ printf "%.0f" (divf . 60) }}m{{ else if lt . 86400 }}{{ printf "%.1f" (divf . 3600) }}h{{ else }}{{ printf "%.1f" (divf . 86400) }}d{{ end }}`,formatResponseTime:`{{ if lt . 60 }}{{ printf "%.1f" . }}s{{ else }}{{ printf "%.1f" (divf . 60) }}m{{ end }}`,formatLongTimeRemaining:`{{ if ge . 1440 }}{{ $d := div . 1440 }}{{ $h := div (mod . 1440) 60 }}{{ if gt $h 0 }}{{ $d }}d {{ $h }}h{{ else }}{{ $d }}d{{ end }}{{ else if ge . 60 }}{{ $h := div . 60 }}{{ $m := mod . 60 }}{{ if gt $m 0 }}{{ $h }}h {{ $m }}m{{ else }}{{ $h }}h{{ end }}{{ else }}{{ . }}m{{ end }}`,formatResetCountdown:`{{ template "formatLongTimeRemaining" (add 1 (minutesUntilReset .)) }}`}},NB=new Set([MB.globals.palette,...Object.keys(MB.themeDefaults),...Object.values(MB.segments).map(e=>e.palette)].filter(e=>e!==void 0)),PB=HF(gB(`<default>`,JSON.stringify(MB),NB),MB),FB=Iy(PB.presets);function IB(e){return FB.includes(e)}const LB=Object.freeze({});function RB(e,t){return e.kind===`decided`?t[e.name]??LB:LB}function zB(e,t){return{...e,...Object.fromEntries(ev.map(n=>[n,e[n]??t[n]]))}}const BB=e=>j_(t=>e[T_[t].setting]);function VB(e,t,n,r){let i=nv(e);return Ah(t[e],i.kind===`session`?n(e):null,r[e],i.floor,i.parse)}function HB(e,t,n){let r=Ly(t(`preset`),e.globals.preset,e.presets),i=By(e,r),a=t(`edit.mode`)===`arrange`?e.editGlobals:{},o=xy(a.palette,t(`theme`),i.palette),s=zB(i,RB(o,e.themeDefaults));return{...Object.fromEntries(Q_.map(e=>[e,VB(e,a,t,s)])),preset:r,presetCustomized:n(r),theme:o,style:Uh(a.style,t(`style`),s.style,e.styles),effect:Zh(a.effect,t(`effect`),s.effect),separator:a.default_separator??s.default_separator}}function UB(e,t){let n=e[t];switch(typeof n){case`boolean`:return n?ag:og;case`number`:return String(n);case`string`:return n;default:return n.kind===`decided`?n.name:null}}const WB=Object.entries(sv),GB=new Set(lv.map(e=>e.sessionKey)),KB=()=>!1;function qB(e,t){return HB(e,e=>GB.has(e)?t(e):null,KB)}const JB=[`preset`,`theme`];function YB(e,t,n){let r=new Set(JB.slice(0,n).map(e=>sv[e].sessionKey));return HB(e,e=>r.has(e)?t(e):null,KB)}function XB(e,t){let n=Array.from({length:JB.length+1},(n,r)=>YB(e,t,r));return e=>{let t=JB.indexOf(e);return n[t===-1?JB.length:t]}}function ZB(e,t,n,r){return e.flatMap(([e,i])=>{let a=UB(t,e);return a===null||a===UB(n(e),e)?[]:[{...i,value:a,target:r(i)}]})}function QB(e,t,n){return UB(qB(e,t),n)}function $B(e,t){let n=qB(e,t);return ZB(WB,n,XB(e,t),t=>eV(e,n.preset,t.configKey))}function eV(e,t,n){return n in(Ry(e.presets,t).globals??{})?Qk(t,n):n}function tV(e,t,n){let r=Ly(t(sv.preset.sessionKey),e.globals.preset,e.presets),i=$k(n);return{key:i?.scope===`globals`?eV(e,r,i.field):n,globals:By(e,r)}}function nV(e,t){let{preset:n}=qB(e,t);return aV(e,n).flatMap(({id:e,setting:r,key:i,decl:a,saved:o})=>{let s=t(i),c=s===null?void 0:Lg(a,s);return c===void 0||Ig(c)===Ig(o)?[]:[{preset:n,id:e,setting:r,key:i,value:c}]})}function rV(e,t,n){let r=new Map(n.map(e=>[e.key,e.value]));return Iy(e.presets).flatMap(n=>{let i=aV(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 Pg(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:Lg(e.decl,n);return[e.setting,i??e.saved]}))).map(({message:t})=>`placement "${e}": ${t}`)})})}const iV=new WeakMap;function aV(e,t){let n=iV.get(e)??new Map;iV.set(e,n);let r=n.get(t);if(r!==void 0)return r;let i=[..._g(zy(e,t).node)].flatMap(t=>t.kind!==`segment`||t.drafts===void 0?[]:Object.entries(t.drafts).map(([n,{id:r,key:i}])=>{let a=Mg(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 oV(e,t){let n=qB(e,t);return{from:n.preset,globals:Ry(e.presets,n.preset).globals??{},picks:ZB(WB.filter(([e])=>e!==`preset`),n,XB(e,t),e=>e.configKey),placements:nV(e,t)}}function sV(e,t){return HB({...e,globals:{palette:t},presets:{}},()=>null,KB)}function cV(e,t){let n=qB(e,t),r=UB(n,`theme`);if(r===null)return{kind:`rule`};let i=sV(e,r),a=By(e,n.preset),o=Object.fromEntries(ev.map(e=>[e,UB(a[e]===void 0?n:i,e)]));return{kind:`look`,theme:r,look:o,differs:ev.some(e=>o[e]!==UB(i,e))}}function lV(e){return{sessionKeys:lv.filter(t=>t.configKey===e).map(e=>e.sessionKey),fileKeys:[e,...Ak(e)?FB.map(t=>Qk(t,e)):[],...Zk(e)?jh().map(t=>Xk(t,e)):[]]}}function uV(e){return new Set(lv.map(e=>e.configKey).filter(t=>lV(t).fileKeys.some(t=>pV(e,fV(t)))))}function dV(e,t,n){let r=$B(e,n),i=new Set(r.map(e=>e.configKey)),a=mv(e=>i.has(sv[e].configKey)||t.has(sv[e].configKey)),o=cV(e,n);return{unsaved:r.length+nV(e,n).length,resettable:a,themeDefault:o.kind===`look`&&o.differs?{differs:!0,theme:o.theme}:{differs:!1}}}function fV(e){let t=$k(e);if(t===null||t.scope===`preset-root`)throw Error(`reset layer "${e}" is not a value path`);return eA(t)}function pV(e,t){let[n,...r]=t;return n===void 0?e!==void 0:typeof e==`object`&&!!e&&pV(e[n],r)}const mV=jh(),hV=new Set(mV),gV=new Set(Qh),_V=e=>e?hV.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${mV.join(`, `)})`}:{ok:!1,reason:`theme name is required`},vV=e=>e?gV.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown endcaps "${e}" (have: ${Qh.join(`, `)})`}:{ok:!1,reason:`endcaps name is required`},yV=new Set([`1`,`true`]),bV=new Set([`0`,`false`]),xV={endcaps:vV,theme:_V,"toolbar-expanded":e=>yV.has(e)?{ok:!0,value:`1`}:bV.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}},SV=NF(xV,`state`,kV);function CV(e,t){return SV.register(e,t)}function wV(e){return SV.gateFor(e)}function TV(e,t){return`set`in e?`to`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:Ky(e.from,t).members}}]:`int`in e?[{key:e.set,spec:{kind:`int`}}]:`cycle`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:e.cycle}}]:[{key:e.set,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function EV(e){return e.filter(e=>e.spec.kind!==`allow-list`||!Object.hasOwn(xV,e.key))}function DV(e,t,n){let r=hv.get(n);if(r!==void 0)return QB(e,t,r);for(let[,t]of Og(e))if(t.key===n)return t.default??null;return null}function OV(e){let t=nF(e);return EV(Object.values(e.actions).flatMap(e=>TV(e,t)))}function kV(e){return jF(OV(e))}const AV=`update.dismissed`,jV=`updateNotice`,MV=sv.updateNotice.sessionKey;function NV(e){return e.kind===`source`?e.newer.digest:La(e.newer)}const PV=e=>`${e.version} [${Ke(e.digest)}]`;function FV(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:PV(e.newer),running:PV(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:La(e.newer),running:La(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${za}@${La(e.newer)}`,`install`]}}}}const IV={kind:`idle`},LV={kind:`running`};function RV(e,t,n){if(e===null)return[];let r=NV(e);if(!n.enabled||n.dismissed===r)return[];let i=FV(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[`${i.act} failed: ${t.reason}`]:[],s=[a,...o].join(`
188
+ Single-row example: root: { h: ["seg1", "seg2"] }`,line:K(e.source,[`layout`])}),t.root!==void 0&&(r.root=gL(e,`root`,t.root)),t.actions!==void 0&&(r.actions=BL(e,t.actions)),t.looks!==void 0&&e.issues.push({path:`looks`,message:`"looks" was renamed "styles" — move the block under styles: { … } (and globals.look to globals.style)`,line:K(e.source,[`looks`])}),t.styles!==void 0&&(r.styles=MR(e,t.styles)),t.themeDefaults!==void 0&&(r.themeDefaults=Pk(e,t.themeDefaults)),t.presets!==void 0&&(r.presets=PR(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=Rk(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=FR(e,t.helpers)),t.plugins!==void 0&&(r.plugins=SB(e,t.plugins)),wL(e,r),PL(e,r),_A(e,r),rk(e,r,X,`the global settings menu`),r}const xB=new Set([`globals`,`variables`,`segments`,`layout`,`looks`,`root`,`actions`,`styles`,`themeDefaults`,`presets`,`editGlobals`,`helpers`,`plugins`]);function SB(e,t){if(Array.isArray(t)&&t.every(e=>typeof e==`string`&&e!==``))return t;e.issues.push({path:`plugins`,message:`"plugins" must be a list of plugin definition paths, got ${$g(t)}`,line:K(e.source,[`plugins`])})}const CB={},wB=XM(`commands.`),TB=nN(`autocompact.`,e=>`{{ template "formatTokenCount" ${e} }}`),EB=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,DB=`{{ \$dir := .current_dir }}{{ if and (ne .home "") (or (eq .home .current_dir) (hasPrefix (printf "%s/" .home) .current_dir)) }}{{ \$dir = printf "~%s" (trimPrefix .home .current_dir) }}{{ else }}{{ if or (eq .project_dir .current_dir) (hasPrefix (printf "%s/" .project_dir) .current_dir) }}{{ $dir = ternary (${EB}) (basename .project_dir) (ne (${EB}) "") }}{{ end }}{{ end }}{{ action "copyDir" (abbreviatePath \$dir) }}`,OB=`{{ ${KA} }}`,kB={min:0,max:100,step:5},AB={warnAt:{label:`warning at %`,domain:kB,default:50},errorAt:{label:`error at %`,domain:{...kB,atLeast:`warnAt`},default:80}};function jB(e){return{budget:{label:`budget $`,domain:{min:0,max:1e4,step:5},default:e},warnAt:{label:`warning at %`,domain:kB,default:80}}}const MB={globals:{palette:`tokyo-night`},variables:{...wB.variables,...KO,current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},"effort.level":{kind:`input`,path:`effort.level`,default:``},"effort.glyphs":{kind:`literal`,value:`? 󰅃 󰅃 󰄿 󰶼`},version:{kind:`input`,path:`version`,default:``},home:{kind:`input`,path:`home`,default:``},"tmux.session":{kind:`input`,path:`tmux.session`,default:``},"host.name":{kind:`input`,path:`host.name`,default:``},"host.user":{kind:`input`,path:`host.user`,default:``},"host.ssh":{kind:`input`,path:`host.ssh`,type:`boolean`,default:!1},"git.repoName":{kind:`input`,path:`git.repoName`,default:``},"git.branch":{kind:`input`,path:`git.branch`,default:``},"git.sha":{kind:`input`,path:`git.sha`,default:``},"git.ahead":{kind:`input`,path:`git.ahead`,type:`number`,default:0},"git.behind":{kind:`input`,path:`git.behind`,type:`number`,default:0},"git.staged":{kind:`input`,path:`git.staged`,type:`number`,default:0},"git.unstaged":{kind:`input`,path:`git.unstaged`,type:`number`,default:0},"git.untracked":{kind:`input`,path:`git.untracked`,type:`number`,default:0},"git.conflicts":{kind:`input`,path:`git.conflicts`,type:`number`,default:0},"git.upstream":{kind:`input`,path:`git.upstream`,default:``},"git.tracking":{kind:`input`,path:`git.tracking`,default:``},"git.stash":{kind:`input`,path:`git.stash`,type:`number`,default:0},"git.status":{kind:`input`,path:`git.status`,default:`clean`},"git.operation":{kind:`input`,path:`git.operation`,default:``},"git.timeSinceCommit":{kind:`input`,path:`git.timeSinceCommit`,type:`number`,default:0},"git.color.branch":{kind:`literal`,value:`primary`},"git.color.staged":{kind:`literal`,value:`success`},"git.color.unstaged":{kind:`literal`,value:`warning`},"git.color.untracked":{kind:`literal`,value:`accent`},"git.color.conflicts":{kind:`literal`,value:`error`},"git.color.ahead":{kind:`literal`,value:`success`},"git.color.behind":{kind:`literal`,value:`warning`},"git.color.stash":{kind:`literal`,value:`accent`},"git.detail":{kind:`state`,key:`git-detail`,default:`collapsed`},"git.prNumber":{kind:`input`,path:`git.prNumber`,type:`number`,default:0},"git.prState":{kind:`input`,path:`git.prState`,default:``},"git.prUrl":{kind:`input`,path:`git.prUrl`,default:``},"git.prError":{kind:`input`,path:`git.prError`,default:``},"cache.expiresAt":{kind:`input`,path:`cache.expiresAt`,type:`number`,default:0},"session.cost":{kind:`input`,path:`session.cost`,type:`number`,default:0},"session.tokens":{kind:`input`,path:`session.tokens`,type:`number`,default:0},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"burn.costPerHour":{kind:`input`,path:`burn.costPerHour`,type:`number`,default:-1},"block.etaMinutes":{kind:`input`,path:`block.etaMinutes`,type:`number`,default:-1},"weekly.etaMinutes":{kind:`input`,path:`weekly.etaMinutes`,type:`number`,default:-1},"speed.input":{kind:`input`,path:`speed.input`,type:`number`,default:-1},"speed.output":{kind:`input`,path:`speed.output`,type:`number`,default:-1},"speed.total":{kind:`input`,path:`speed.total`,type:`number`,default:-1},"speed.history":{kind:`input`,path:`speed.history`,type:`string`,default:``},"context.totalTokens":{kind:`input`,path:`context.totalTokens`,type:`number`,default:0},"context.contextLeft":{kind:`input`,path:`context.contextLeft`,type:`number`,default:100},"memento.ceiling":{kind:`input`,path:`memento.ceiling`,type:`number`,default:-1},"memento.off":{kind:`input`,path:`memento.off`,type:`boolean`,default:!1},"memento.session":{kind:`input`,path:`memento.session`,default:``},"memento.error":{kind:`input`,path:`memento.error`,default:``},"metrics.lastResponseTime":{kind:`input`,path:`metrics.lastResponseTime`,type:`number`,default:0},"metrics.responseTime":{kind:`input`,path:`metrics.responseTime`,type:`number`,default:0},"metrics.sessionDuration":{kind:`input`,path:`metrics.sessionDuration`,type:`number`,default:0},"metrics.messageCount":{kind:`input`,path:`metrics.messageCount`,type:`number`,default:0},"metrics.linesAdded":{kind:`input`,path:`metrics.linesAdded`,type:`number`,default:0},"metrics.linesRemoved":{kind:`input`,path:`metrics.linesRemoved`,type:`number`,default:0},"activity.command":{kind:`input`,path:`activity.command`,type:`string`,default:``},"activity.todo.total":{kind:`input`,path:`activity.todo.total`,type:`number`,default:0},"activity.todo.completed":{kind:`input`,path:`activity.todo.completed`,type:`number`,default:0},"activity.todo.position":{kind:`input`,path:`activity.todo.position`,type:`number`,default:0},"activity.todo.active":{kind:`input`,path:`activity.todo.active`,type:`string`,default:``},"activity.tool.running":{kind:`input`,path:`activity.tool.running`,type:`string`,default:``},"activity.tool.done":{kind:`input`,path:`activity.tool.done`,type:`string`,default:``}},segments:{directory:{group:`location`,description:"The current directory, shortened fish-style — `~` under home, project-relative inside the project. Click to copy the full path.",template:DB},model:{group:`model-context`,description:`The active model's display name, followed by the effort gauge (a chevron ladder, climbing on a bubble at max) when an effort level is set.`,template:`✱ {{ formatModelName .model.display_name }}{{ if ne .effort.level "" }} {{ template "effortGauge" . }}{{ end }}`,when:`{{ ne .model.display_name "" }}`},sessionId:{group:`session-tools`,description:`The session id, truncated to 8 characters.`,template:`⌗{{ trunc 8 .session.id }}`,when:`{{ ne .session.id "" }}`},version:{group:`model-context`,description:`The Claude Code version reported in the hook payload.`,template:`◈ v{{ .version }}`,when:`{{ ne .version "" }}`},tmux:{group:`location`,description:`The tmux session name; hidden when not inside tmux.`,template:`tmux:{{ .tmux.session | default "none" }}`,when:`{{ ne .tmux.session "" }}`},host:{group:`location`,description:`user@host on a warning background, shown only over SSH.`,template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,when:`{{ .host.ssh }}`},gitaculous:{group:`git`,description:`The git state: a summary (branch, ahead/behind, S/U/? flags) that the arrow at its right edge expands to every fact — repo, in-progress operation, sha, upstream ±, stash count, time since the last commit.`,template:`{{ if eq .git.detail "expanded" }}{{ template "gitExpanded" . }}{{ else }}{{ template "gitCollapsed" . }}{{ end }} {{ action "gitDetail" "▸" "◂" }}`,fg:OB,when:`{{ ne .git.branch "" }}`,settings:{aheadBehind:{label:`ahead/behind`,domain:`bool`,default:!0},flags:{label:`dirty flags`,domain:`bool`,default:!0},operation:{label:`operation`,domain:`bool`,default:!0},repo:{label:`repo name`,domain:`bool`,default:!0},sha:{label:`commit hash`,domain:`bool`,default:!0},stash:{label:`stash`,domain:`bool`,default:!0},upstream:{label:`upstream`,domain:`bool`,default:!0},age:{label:`time since commit`,domain:`bool`,default:!0}}},gitPr:{group:`git`,description:"The pull request open for this branch, as a link; `⚠ PR` when the forge lookup failed.",template:`{{ if eq .git.prState "open" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,when:`{{ or (eq .git.prState "open") (ne .git.prError "") }}`},toolbar:{group:`session-tools`,description:`Quick actions: copy the session id, and open the project, transcript or repo.`,template:zM(``).template},commands:{group:`session-tools`,description:`Type /compact, /model or /clear into this session; /clear asks for a second click. Hidden when not inside tmux.`,template:wB.template,when:wB.when},themeSwitcher:{group:`session-tools`,description:"`◀ <theme> ▶`: the theme the bar is wearing; ◀ and ▶ switch this session to the previous or next theme, wrapping at the ends.",template:`{{ carousel "stepTheme" 0 }}`},session:{group:`cost-limits`,description:`This session's cost and token total, with a budget warning once a budget is configured.`,template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:jB(0)},today:{group:`cost-limits`,description:`Today's cost and tokens across every session, with a budget warning once a budget is configured.`,template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:jB(50)},block:{group:`cost-limits`,description:`The 5-hour rate-limit block: percent used and time to reset, heating to warning then error.`,template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:AB,when:`{{ gt .block.resetsAt 0 }}`},weekly:{group:`cost-limits`,description:`The weekly rate-limit quota: percent used and time to reset, heating to warning then error.`,template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:AB,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{group:`cost-limits`,description:`Spend per hour, with the projected time to the 5-hour and weekly limits.`,template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 (tint) 0 "error" .settings.errorWithin "warning" .settings.warnWithin (tint) }}`,settings:{errorWithin:{label:`error within (min)`,domain:{min:0,max:300,step:5},default:30},warnWithin:{label:`warning within (min)`,domain:{min:0,max:300,step:5,atLeast:`errorWithin`},default:60}},when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{group:`activity`,description:`Token throughput for the latest exchange: output, input, and total.`,template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{group:`activity`,description:`A sparkline of recent token throughput.`,template:`⚡ {{ sparkline .speed.history 24 }}`,when:`{{ ne .speed.history "" }}`},cacheTimer:{group:`activity`,description:"Minutes until the prompt cache expires, or `cold` once it has.",template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ readableOn (color (cascade (minutesUntilReset .cache.expiresAt) "0:error" "9:warning" "21:foreground")) (bgOf) ${eh} }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{group:`model-context`,description:`Context used, in tokens and percent remaining, heating as it fills.`,template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 (tint) }}`,when:`{{ gt .context.totalTokens 0 }}`},ceiling:{group:`model-context`,description:`The memento plugin's context ceiling for this session: − and + move it by 100K, ∞ lifts it, ↺ drops this session's own setting.`,template:`{{ if ne .memento.error "" }}⌈ ⚠ {{ .memento.error }} {{ action "ceiling.clear" "↺" }}{{ else }}⌈ {{ if .memento.off }}off{{ else }}{{ template "formatTokenCount" .memento.ceiling }} {{ action "ceiling.lower" "−" }} {{ action "ceiling.raise" "+" }} {{ action "ceiling.off" "∞" }}{{ end }}{{ if ne .memento.session "" }} {{ action "ceiling.clear" "↺" }}{{ end }}{{ end }}`,bg:`{{ if ne .memento.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .memento.ceiling 0) (ne .memento.error "") }}`},autocompact:{group:`model-context`,description:`Claude Code's auto-compact window: − and + move it by 100K, ↺ returns it to auto. Clicks type /autocompact into this session, so the controls show only inside tmux.`,template:TB.template,bg:TB.bg,when:TB.when},metrics:{group:`activity`,description:`Response times, session duration, message count, and lines added/removed.`,template:`{{ if .metrics.lastResponseTime }} Δ {{ template "formatResponseTime" .metrics.lastResponseTime }}{{ end }}{{ if .metrics.responseTime }} ⧖ {{ template "formatResponseTime" .metrics.responseTime }}{{ end }}{{ if .metrics.sessionDuration }} ⧗ {{ template "formatDuration" .metrics.sessionDuration }}{{ end }}{{ if .metrics.messageCount }} ◆ {{ .metrics.messageCount }}{{ end }}{{ if .metrics.linesAdded }} + {{ .metrics.linesAdded }}{{ end }}{{ if .metrics.linesRemoved }} - {{ .metrics.linesRemoved }}{{ end }} `,when:`{{ or (gt .metrics.lastResponseTime 0.0) (gt .metrics.responseTime 0.0) (gt .metrics.sessionDuration 0.0) (gt .metrics.messageCount 0) (gt .metrics.linesAdded 0) (gt .metrics.linesRemoved 0) }}`},activity:{group:`activity`,description:`What Claude is doing: the slash command that opened the turn, the in-progress todo, and the tools in flight.`,template:`{{ if .activity.command }} ⌘ {{ .activity.command }}{{ end }}{{ if .activity.todo.total }}{{ if .activity.todo.active }} ☐ {{ .activity.todo.position }}/{{ .activity.todo.total }} {{ abbrev 32 .activity.todo.active }}{{ else }} ☑ {{ .activity.todo.completed }}/{{ .activity.todo.total }}{{ end }}{{ end }}{{ if .activity.tool.running }} ⟳ {{ template "formatToolTally" .activity.tool.running }}{{ end }}{{ if .activity.tool.done }} ✓ {{ template "formatToolTally" .activity.tool.done }}{{ end }} `,when:`{{ or (ne .activity.command "") (gt .activity.todo.total 0) (ne .activity.tool.running "") (ne .activity.tool.done "") }}`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`activity`}]}}},actions:{...zM(``).actions,...wB.actions,copyDir:{copy:`{{ .current_dir }}`},stepTheme:{set:`theme`,from:`themes`},gitDetail:{set:`git-detail`,cycle:[`collapsed`,`expanded`]},"ceiling.raise":{ceiling:`set`,to:`+100_000`},"ceiling.lower":{ceiling:`set`,to:`-100_000`},"ceiling.off":{ceiling:`set`,to:`off`},"ceiling.clear":{ceiling:`clear`},...TB.actions},styles:{none:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0},vivid:{hueShift:0,chromaScale:1.35,lightnessScale:1,lightnessShift:0},muted:{hueShift:0,chromaScale:.55,lightnessScale:1,lightnessShift:0},dim:{hueShift:0,chromaScale:1,lightnessScale:.85,lightnessShift:0},bright:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:.08},inverted:{hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1}},themeDefaults:CB,presets:{default:{},compact:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`context`}]},globals:{padding:0}},verbose:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},zen:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`context`}]},globals:{endcaps:`plain`,style:`dim`}},git:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`activity`}]}]}},usage:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`session`},{kind:`segment`,name:`today`},{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},dense:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`session`},{kind:`segment`,name:`activity`}]},globals:{padding:0}}},editGlobals:{endcaps:`plain`,default_separator:` | `},helpers:{effortGauge:`{{ \$ord := default 0 (get (dict "low" 1 "medium" 2 "high" 3 "xhigh" 4 "max" 5) .effort.level) }}{{ \$glyphs := compact (splitList " " .effort.glyphs) }}{{ $bubble := readableOn (mix (bgOf) (color "accent") 40) (bgOf) 1.08 }}{{ $climbing := readableOn (stepped 1 (color "primary") 1 (color "secondary") 1 (color "accent")) $bubble ${eh} }}{{ \$climb := frames 1 (index \$glyphs 1) 1 (index \$glyphs 3) 1 (index \$glyphs 4) }}{{ if eq \$ord 5 }}{{ fg \$bubble "" }}{{ bg \$bubble (fg \$climbing \$climb) }}{{ fg \$bubble "" }}{{ else }}{{ fg (ramp $ord "step" 0 (${KA}) 2 (readableOn (color "accent") (bgOf) ${eh})) (index $glyphs $ord) }}{{ end }}`,gitPaint:`{{ fg (readableOn (color .color) (bgOf) ${eh}) .text }}`,gitCollapsed:`{{ template "gitBranch" . }}{{ template "gitAheadBehind" . }}{{ template "gitFlags" . }}`,gitExpanded:`(git){{ template "gitRepo" . }}{{ template "gitOperation" . }}{{ template "gitSha" . }}{{ template "gitFlags" . }} {{ template "gitBranch" . }}{{ template "gitUpstream" . }}{{ template "gitStash" . }}{{ template "gitAge" . }}`,gitBranch:`⎇ {{ template "gitPaint" (dict "color" .git.color.branch "text" .git.branch) }}`,gitRepo:`{{ if and .settings.repo (ne .git.repoName "") }} {{ .git.repoName }}{{ end }}`,gitOperation:`{{ if and .settings.operation (ne .git.operation "") }} [{{ .git.operation }}]{{ end }}`,gitSha:`{{ if and .settings.sha (ne .git.sha "") }} {{ .git.sha }}{{ end }}`,gitFlags:`{{ if and .settings.flags (or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0)) }} {{ if gt .git.staged 0 }}{{ template "gitPaint" (dict "color" .git.color.staged "text" "S") }}{{ end }}{{ if gt .git.unstaged 0 }}{{ template "gitPaint" (dict "color" .git.color.unstaged "text" "U") }}{{ end }}{{ if gt .git.untracked 0 }}{{ template "gitPaint" (dict "color" .git.color.untracked "text" "?") }}{{ end }}{{ if gt .git.conflicts 0 }}{{ template "gitPaint" (dict "color" .git.color.conflicts "text" (printf "!%v" .git.conflicts)) }}{{ end }}{{ end }}`,gitAheadBehind:`{{ if and .settings.aheadBehind (or (gt .git.ahead 0) (gt .git.behind 0)) }} {{ if gt .git.ahead 0 }}{{ template "gitPaint" (dict "color" .git.color.ahead "text" (printf "+%v" .git.ahead)) }}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}{{ template "gitPaint" (dict "color" .git.color.behind "text" (printf "-%v" .git.behind)) }}{{ end }}{{ end }}`,gitUpstream:`{{ if and .settings.upstream (ne .git.upstream "") }} [{{ .git.upstream }}{{ template "gitAheadBehind" . }}]{{ end }}`,gitStash:`{{ if and .settings.stash (gt .git.stash 0) }} {{ template "gitPaint" (dict "color" .git.color.stash "text" (printf "(%v stashed)" .git.stash)) }}{{ end }}`,gitAge:`{{ if and .settings.age (gt .git.timeSinceCommit 0) }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:rN(`.`),formatTokens:`{{ template "formatTokenCount" . }} tokens`,formatToolTally:`{{ $names := splitList "," . }}{{ range $i, $pair := $names }}{{ if lt $i 2 }}{{ if $i }} {{ end }}{{ $kv := splitList ":" $pair }}{{ index $kv 0 }}{{ if ne (index $kv 1) "1" }}×{{ index $kv 1 }}{{ end }}{{ end }}{{ end }}{{ if gt (len $names) 2 }} +{{ sub (len $names) 2 }}{{ end }}`,formatRate:`{{ if lt . 0 }}—/hr{{ else }}{{ template "formatCost" . }}/hr{{ end }}`,formatEta:`{{ if lt . 0 }}—{{ else }}{{ template "formatLongTimeRemaining" . }}{{ end }}`,formatSpeed:`{{ if lt . 0 }}—{{ else }}{{ template "formatTokenCount" (round .) }}/s{{ end }}`,formatTokenBreakdown:`{{ $first := true }}{{ if gt .input 0 }}{{ template "formatTokenCount" .input }} in{{ $first = false }}{{ end }}{{ if gt .output 0 }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" .output }} out{{ $first = false }}{{ end }}{{ if or (gt .cacheCreation 0) (gt .cacheRead 0) }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" (add .cacheCreation .cacheRead) }} cached{{ $first = false }}{{ end }}{{ if $first }}0 tokens{{ end }}`,budgetStatus:`{{ if or (le .budget 0) (lt .cost 0) }}{{ else }}{{ $pct := minf 100 (mulf (divf .cost .budget) 100) }}{{ $p := printf "%.0f%%" $pct }}{{ if ge $pct .warn }} !{{ $p }}{{ else }}{{ if ge $pct 50 }} +{{ $p }}{{ else }} {{ $p }}{{ end }}{{ end }}{{ end }}`,formatTimeSince:`{{ if lt . 60 }}{{ . }}s{{ else if lt . 3600 }}{{ div . 60 }}m{{ else if lt . 86400 }}{{ div . 3600 }}h{{ else if lt . 604800 }}{{ div . 86400 }}d{{ else }}{{ div . 604800 }}w{{ end }}`,formatDuration:`{{ if lt . 60 }}{{ printf "%.0f" . }}s{{ else if lt . 3600 }}{{ printf "%.0f" (divf . 60) }}m{{ else if lt . 86400 }}{{ printf "%.1f" (divf . 3600) }}h{{ else }}{{ printf "%.1f" (divf . 86400) }}d{{ end }}`,formatResponseTime:`{{ if lt . 60 }}{{ printf "%.1f" . }}s{{ else }}{{ printf "%.1f" (divf . 60) }}m{{ end }}`,formatLongTimeRemaining:`{{ if ge . 1440 }}{{ $d := div . 1440 }}{{ $h := div (mod . 1440) 60 }}{{ if gt $h 0 }}{{ $d }}d {{ $h }}h{{ else }}{{ $d }}d{{ end }}{{ else if ge . 60 }}{{ $h := div . 60 }}{{ $m := mod . 60 }}{{ if gt $m 0 }}{{ $h }}h {{ $m }}m{{ else }}{{ $h }}h{{ end }}{{ else }}{{ . }}m{{ end }}`,formatResetCountdown:`{{ template "formatLongTimeRemaining" (add 1 (minutesUntilReset .)) }}`}},NB=new Set([MB.globals.palette,...Object.keys(MB.themeDefaults),...Object.values(MB.segments).map(e=>e.palette)].filter(e=>e!==void 0)),PB=HF(gB(`<default>`,JSON.stringify(MB),NB),MB),FB=Iy(PB.presets);function IB(e){return FB.includes(e)}const LB=Object.freeze({});function RB(e,t){return e.kind===`decided`?t[e.name]??LB:LB}function zB(e,t){return{...e,...Object.fromEntries(ev.map(n=>[n,e[n]??t[n]]))}}const BB=e=>j_(t=>e[T_[t].setting]);function VB(e,t,n,r){let i=nv(e);return Ah(t[e],i.kind===`session`?n(e):null,r[e],i.floor,i.parse)}function HB(e,t,n){let r=Ly(t(`preset`),e.globals.preset,e.presets),i=By(e,r),a=t(`edit.mode`)===`arrange`?e.editGlobals:{},o=xy(a.palette,t(`theme`),i.palette),s=zB(i,RB(o,e.themeDefaults));return{...Object.fromEntries(Q_.map(e=>[e,VB(e,a,t,s)])),preset:r,presetCustomized:n(r),theme:o,style:Uh(a.style,t(`style`),s.style,e.styles),effect:Zh(a.effect,t(`effect`),s.effect),separator:a.default_separator??s.default_separator}}function UB(e,t){let n=e[t];switch(typeof n){case`boolean`:return n?ag:og;case`number`:return String(n);case`string`:return n;default:return n.kind===`decided`?n.name:null}}const WB=Object.entries(sv),GB=new Set(lv.map(e=>e.sessionKey)),KB=()=>!1;function qB(e,t){return HB(e,e=>GB.has(e)?t(e):null,KB)}const JB=[`preset`,`theme`];function YB(e,t,n){let r=new Set(JB.slice(0,n).map(e=>sv[e].sessionKey));return HB(e,e=>r.has(e)?t(e):null,KB)}function XB(e,t){let n=Array.from({length:JB.length+1},(n,r)=>YB(e,t,r));return e=>{let t=JB.indexOf(e);return n[t===-1?JB.length:t]}}function ZB(e,t,n,r){return e.flatMap(([e,i])=>{let a=UB(t,e);return a===null||a===UB(n(e),e)?[]:[{...i,value:a,target:r(i)}]})}function QB(e,t,n){return UB(qB(e,t),n)}function $B(e,t){let n=qB(e,t);return ZB(WB,n,XB(e,t),t=>eV(e,n.preset,t.configKey))}function eV(e,t,n){return n in(Ry(e.presets,t).globals??{})?Qk(t,n):n}function tV(e,t,n){let r=Ly(t(sv.preset.sessionKey),e.globals.preset,e.presets),i=$k(n);return{key:i?.scope===`globals`?eV(e,r,i.field):n,globals:By(e,r)}}function nV(e,t){let{preset:n}=qB(e,t);return aV(e,n).flatMap(({id:e,setting:r,key:i,decl:a,saved:o})=>{let s=t(i),c=s===null?void 0:Lg(a,s);return c===void 0||Ig(c)===Ig(o)?[]:[{preset:n,id:e,setting:r,key:i,value:c}]})}function rV(e,t,n){let r=new Map(n.map(e=>[e.key,e.value]));return Iy(e.presets).flatMap(n=>{let i=aV(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 Pg(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:Lg(e.decl,n);return[e.setting,i??e.saved]}))).map(({message:t})=>`placement "${e}": ${t}`)})})}const iV=new WeakMap;function aV(e,t){let n=iV.get(e)??new Map;iV.set(e,n);let r=n.get(t);if(r!==void 0)return r;let i=[..._g(zy(e,t).node)].flatMap(t=>t.kind!==`segment`||t.drafts===void 0?[]:Object.entries(t.drafts).map(([n,{id:r,key:i}])=>{let a=Mg(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 oV(e,t){let n=qB(e,t);return{from:n.preset,globals:Ry(e.presets,n.preset).globals??{},picks:ZB(WB.filter(([e])=>e!==`preset`),n,XB(e,t),e=>e.configKey),placements:nV(e,t)}}function sV(e,t){return HB({...e,globals:{palette:t},presets:{}},()=>null,KB)}function cV(e,t){let n=qB(e,t),r=UB(n,`theme`);if(r===null)return{kind:`rule`};let i=sV(e,r),a=By(e,n.preset),o=Object.fromEntries(ev.map(e=>[e,UB(a[e]===void 0?n:i,e)]));return{kind:`look`,theme:r,look:o,differs:ev.some(e=>o[e]!==UB(i,e))}}function lV(e){return{sessionKeys:lv.filter(t=>t.configKey===e).map(e=>e.sessionKey),fileKeys:[e,...Ak(e)?FB.map(t=>Qk(t,e)):[],...Zk(e)?jh().map(t=>Xk(t,e)):[]]}}function uV(e){return new Set(lv.map(e=>e.configKey).filter(t=>lV(t).fileKeys.some(t=>pV(e,fV(t)))))}function dV(e,t,n){let r=$B(e,n),i=new Set(r.map(e=>e.configKey)),a=mv(e=>i.has(sv[e].configKey)||t.has(sv[e].configKey)),o=cV(e,n);return{unsaved:r.length+nV(e,n).length,resettable:a,themeDefault:o.kind===`look`&&o.differs?{differs:!0,theme:o.theme}:{differs:!1}}}function fV(e){let t=$k(e);if(t===null||t.scope===`preset-root`)throw Error(`reset layer "${e}" is not a value path`);return eA(t)}function pV(e,t){let[n,...r]=t;return n===void 0?e!==void 0:typeof e==`object`&&!!e&&pV(e[n],r)}const mV=jh(),hV=new Set(mV),gV=new Set(Qh),_V=e=>e?hV.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${mV.join(`, `)})`}:{ok:!1,reason:`theme name is required`},vV=e=>e?gV.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown endcaps "${e}" (have: ${Qh.join(`, `)})`}:{ok:!1,reason:`endcaps name is required`},yV=new Set([`1`,`true`]),bV=new Set([`0`,`false`]),xV={endcaps:vV,theme:_V,"toolbar-expanded":e=>yV.has(e)?{ok:!0,value:`1`}:bV.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}},SV=NF(xV,`state`,kV);function CV(e,t){return SV.register(e,t)}function wV(e){return SV.gateFor(e)}function TV(e,t){return`set`in e?`to`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:Ky(e.from,t).members}}]:`int`in e?[{key:e.set,spec:{kind:`int`}}]:`cycle`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:e.cycle}}]:[{key:e.set,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function EV(e){return e.filter(e=>e.spec.kind!==`allow-list`||!Object.hasOwn(xV,e.key))}function DV(e,t,n){let r=hv.get(n);if(r!==void 0)return QB(e,t,r);for(let[,t]of Og(e))if(t.key===n)return t.default??null;return null}function OV(e){let t=nF(e);return EV(Object.values(e.actions).flatMap(e=>TV(e,t)))}function kV(e){return jF(OV(e))}const AV=`update.dismissed`,jV=`updateNotice`,MV=sv.updateNotice.sessionKey;function NV(e){return e.kind===`source`?e.newer.digest:La(e.newer)}const PV=e=>`${e.version} [${Ke(e.digest)}]`;function FV(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:PV(e.newer),running:PV(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:La(e.newer),running:La(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${za}@${La(e.newer)}`,`install`]}}}}const IV={kind:`idle`},LV={kind:`running`};function RV(e,t,n){if(e===null)return[];let r=NV(e);if(!n.enabled||n.dismissed===r)return[];let i=FV(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[`${i.act} failed: ${t.reason}`]:[],s=[a,...o].join(`
184
189
  `),c=Hr([{verb:br,args:[s]}]),l=t.kind===`running`?ry(`[${i.busy}]`,c):ry(`[${i.act}]`,Hr([{verb:Nr,args:[n.sessionId]}]));return[{severity:ty,message:s,lines:[[ry(a,c),l,ry(`[dismiss]`,Hr([{verb:mr,args:[n.sessionId,AV,r]}])),ry(`[disable]`,Hr([{verb:xr,args:[n.sessionId,jV,`false`]},{verb:mr,args:[n.sessionId,MV,`false`]}]))],...o.map(e=>[ry(e,c)])]}]}function zV(e,t){return e.kind===`stale`?{kind:`source`,root:e.root,newer:e.source,running:e.running}:e.kind===`not-source-checkout`&&t!==null&&t.kind===`stale`?{kind:`release`,newer:t.latest,running:t.installed}:null}function BV(e){switch(e.kind){case`current`:return[`info`,`build: current ${PV(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${PV(e.source)}, running ${PV(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function VV(e){switch(e.kind){case`current`:return[`info`,`release: current ${La(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${La(e.latest)}, running ${La(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${La(e.installed)}, latest ${La(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function HV(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const UV=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function WV(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=UV(e.stderr)??e.error??UV(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function GV(){let e=[FF(jV,[`false`]),CV(MV,[`false`]),CV(AV,[])];return()=>e.forEach(e=>e())}function KV(e){let{entryUrl:t,intervalMs:n,releaseIntervalMs:r,registryUrl:i,fetchImpl:a,onApplied:o,log:s}=e,c={kind:`unchecked`,reason:`not sampled yet`},l=null,u=IV,d=null,f=HV(s),p=HV(s),m=()=>zV(c,l);function h(){let e=m(),t=e===null?null:NV(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:CV(AV,[t])})}function g(){c=Qe(t,Ye),f(BV(c)),h()}async function _(){l=Va(qe,await Ba(za,a,i)),p(VV(l)),h()}return{arm(){GV(),g(),setInterval(g,n).unref(),c.kind===`not-source-checkout`&&(_(),setInterval(()=>void _(),r).unref())},notice:e=>RV(m(),u,e),act(){let e=m();if(e===null)throw new J(`apply-update: nothing newer is known to apply`);let t=FV(e);if(u.kind===`running`)throw new J(`apply-update: already ${t.busy}`);u=LV,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),lt({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=IV,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=WV(n);u={kind:`failed`,identity:NV(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}function qV(e,t){try{return F(t(e).mtimeMs)}catch(e){let t=e.code;return t===`ENOENT`||t===`ENOTDIR`?I:L(e.message)}}function JV(e,t){return e.kind===`ok`&&t.kind===`ok`?e.value===t.value:e.kind===t.kind}function YV(e){let{targets:t,intervalMs:n,stat:r,exit:i,log:a}=e,o=t.map(e=>({path:e,stamp:qV(e,r)})),s=o.filter(({stamp:e})=>e.kind!==`failed`),c=null,l=()=>{for(let{path:e,stamp:t}of s){let n=qV(e,r);if(n.kind===`failed`){a(`warn`,`binary stat failed (${e}): ${n.reason}`);continue}if(!JV(t,n)){a(`info`,`binary ${n.kind===`absent`?`gone`:`changed`} (${e}); shutting down`),c&&clearInterval(c),i();return}}};return{arm(){for(let{path:e,stamp:t}of o)t.kind===`failed`&&a(`warn`,`binary stat failed at boot (${e}): ${t.reason}; not watched`);c=setInterval(l,n),c.unref()},checkNow:l}}const XV=`${xv}${bv}`;function ZV(e){return`${XV}⚠ cc-candybar: ${QV(e)}${Sv}\n`}function QV(e){switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:return`daemon rejected request: ${yv(e.message,60)}`;case`render_failed`:return`render failed: ${yv(e.message,60)}`;case`switched_off`:return`switched off: ${yv(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${yv(e.message,60)}`}}function $V(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
185
- `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:ZV(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}const eH=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`blackBright`,`redBright`,`greenBright`,`yellowBright`,`blueBright`,`magentaBright`,`cyanBright`,`whiteBright`];function tH(e){if(e===void 0||e.isDefault)return;let t=e.fixedValue;if(t!==void 0)return t.hex;let n=e.type===B.STANDARD&&e.number!==void 0?eH[e.number]:void 0;if(n===void 0)throw Error(`frames: no band colour for ${e.name}`);return n}const nH={bold:`bold`,dim:`dimColor`,italic:`italic`,underline:`underline`,strike:`strikethrough`,reverse:`inverse`,blink:null,blink2:null,conceal:null,underline2:null,frame:null,encircle:null,overline:null},rH=Object.keys(nH);function iH(e,t){let n=tH(t.color),r=tH(t.bgcolor),i={};for(let e of rH){if(t[e]!==!0)continue;let n=nH[e];if(n===null)throw Error(`frames: the band cannot draw ${e} text`);i[n]=!0}return{text:e,...n!==void 0&&{color:n},...r!==void 0&&{backgroundColor:r},...i,...t.link!==void 0&&{href:t.link}}}const aH=new H;function oH(e){return{ok:!0,band:new Kf().decode(e).map(e=>{let t=e.plain,n=[],r=0;for(let i of e.spans){if(!(i.style instanceof H))throw Error(`frames: the decoder gave a span a ${typeof i.style} style`);i.start>r&&n.push(iH(t.slice(r,i.start),aH)),n.push(iH(t.slice(i.start,i.end),i.style)),r=i.end}return r<t.length&&n.push(iH(t.slice(r),aH)),n})}}function sH(e){let t=$V(pn(e)).output;try{return oH(t)}catch(e){return oH(`${xv}${bv}⚠ cc-candybar ${vv(e instanceof Error?e.message:String(e))}${Sv}\n`)}}function cH(e){return`ccb`+te(`sha256`).update(e).digest(`hex`).slice(0,12)}const lH=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightblack`,`brightred`,`brightgreen`,`brightyellow`,`brightblue`,`brightmagenta`,`brightcyan`,`brightwhite`];function uH(e){if(e===void 0||e.isDefault)return`terminal`;switch(e.type){case B.STANDARD:{let t=e.number===void 0?void 0:lH[e.number];if(t!==void 0)return t;break}case B.EIGHT_BIT:if(e.number!==void 0)return`colour${e.number}`;break;case B.TRUECOLOR:{let t=e.fixedValue;if(t!==void 0)return t.hex;break}case B.DEFAULT:case B.WINDOWS:break}throw Error(`frames: no tmux colour for ${e.name}`)}const dH={bold:`bold`,dim:`dim`,italic:`italics`,underline:`underscore`,strike:`strikethrough`,reverse:`reverse`,blink:`blink`,conceal:`hidden`,underline2:`double-underscore`,overline:`overline`,blink2:null,frame:null,encircle:null},fH=Object.keys(dH);function pH(e){return e.replaceAll(`#`,`##`)}function mH(e){let t=fH.filter(t=>e[t]===!0).map(e=>{let t=dH[e];if(t===null)throw Error(`frames: a tmux status line cannot draw ${e} text`);return t});return`#[${[`none`,`fg=${uH(e.color)}`,`bg=${uH(e.bgcolor)}`,...t].join(`,`)}]`}const hH=new H;function gH(e){let t={},n=(e,n)=>{let r=mH(n)+pH(e);if(n.link===void 0)return r;let i=cH(n.link);return t[i]=n.link,`#[range=user|${i}]${r}#[norange]`};return{rows:new Kf().decode(e).map(e=>{let t=e.plain,r=[],i=0;for(let a of e.spans){if(!(a.style instanceof H))throw Error(`frames: the decoder gave a span a ${typeof a.style} style`);a.start>i&&r.push(n(t.slice(i,a.start),hH)),r.push(n(t.slice(a.start,a.end),a.style)),i=a.end}return i<t.length&&r.push(n(t.slice(i),hH)),r.join(``)}),links:t}}function _H(e){let t=$V(pn(e)).output;try{return gH(t)}catch(e){return gH(`${xv}${bv}⚠ cc-candybar ${vv(e instanceof Error?e.message:String(e))}${Sv}\n`)}}const vH={band:e=>JSON.stringify(sH(e)),statusline:(e,t)=>t,pane:(e,t)=>t,tmuxStatus:e=>JSON.stringify({ok:!0,tmuxStatus:_H(e)})};var yH=class{static CACHE_DIR=k();static USAGE_CACHE_DIR=s.join(this.CACHE_DIR,`usage`);static LOCKS_DIR=s.join(this.CACHE_DIR,`locks`);static isLocked(e){let t=s.join(this.LOCKS_DIR,e);if(!p.existsSync(t))return!1;try{let n=p.readFileSync(t,`utf-8`),r=parseInt(n.trim(),10);if(isNaN(r))return D(`Invalid PID in lock file ${e}, removing stale lock`),p.unlinkSync(t),!1;try{return process.kill(r,0),!0}catch(n){return n.code===`ESRCH`?(D(`Removing stale lock file ${e} for dead process ${r}`),p.unlinkSync(t),!1):(D(`Error checking process ${r} for lock ${e}:`,n),!0)}}catch(t){return D(`Error reading lock file ${e}:`,t),!0}}static async acquireLock(e,t=5e3){await this.ensureCacheDirectories();let n=s.join(this.LOCKS_DIR,e),r=Date.now(),i=String(process.pid);for(;Date.now()-r<t;)try{return await p.promises.writeFile(n,i,{flag:`wx`}),D(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await ge(50);else throw e}return D(`Failed to acquire lock for ${e} within ${t}ms`),!1}static async releaseLock(e){let t=s.join(this.LOCKS_DIR,e);try{await p.promises.unlink(t),D(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&D(`Error releasing lock for ${e}:`,t)}}static async ensureCacheDirectories(){try{await Promise.all([p.promises.mkdir(this.CACHE_DIR,{recursive:!0}),p.promises.mkdir(this.USAGE_CACHE_DIR,{recursive:!0}),p.promises.mkdir(this.LOCKS_DIR,{recursive:!0})])}catch(e){D(`Failed to create cache directories:`,e)}}static createProjectHash(e){return te(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t){await this.ensureCacheDirectories();let n=s.join(this.USAGE_CACHE_DIR,`${e}.json`),r=`${e}.usage.lock`;for(let i=0;i<3;i++){if(this.isLocked(r)){D(`Cache for ${e} is locked, waiting...`),await ge(75);continue}try{let r=await p.promises.readFile(n,`utf-8`),i=JSON.parse(r);return!t||i.timestamp>=t?(D(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(i.data)):(D(`${e} cache outdated: cache=${i.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return D(`No shared ${e} usage cache found`),null;D(`Attempt ${i+1} failed to read ${e} cache: ${t.message}. Retrying...`),await ge(75)}}return D(`Failed to read ${e} cache after 3 attempts.`),null}static deserializeDates(e){return Array.isArray(e)?e.map(e=>({...e,timestamp:new Date(e.timestamp)})):e}static async setUsageCache(e,t,n){let r=`${e}.usage.lock`;if(!await this.acquireLock(r)){D(`Could not acquire lock to set usage cache for ${e}`);return}try{await this.ensureCacheDirectories();let r=s.join(this.USAGE_CACHE_DIR,`${e}.json`),i=JSON.stringify({data:t,timestamp:n||Date.now()});await p.promises.writeFile(r,i,`utf-8`),D(`[CACHE-SET] ${e} disk cache stored`)}catch(t){D(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(r)}}};const bH={"claude-haiku-4-5-20251001":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-haiku-4-5":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-opus-4-20250514":{name:`Claude Opus 4`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1-20250805":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-sonnet-4-20250514":{name:`Claude Sonnet 4`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-4-opus-20250514":{name:`Claude 4 Opus`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-4-sonnet-20250514":{name:`Claude 4 Sonnet`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5-20250929":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-opus-4-5":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-5-20251101":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6-20260205":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-sonnet-4-6":{name:`Claude Sonnet 4.6`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3}};var xH=class{static executionCache=null;static modelPricingCache=new Map;static GITHUB_PRICING_URL=`https://raw.githubusercontent.com/promptctl/cc-candybar/main/pricing.json`;static async loadDiskCache(){let e=Date.now()-1440*60*1e3;return await yH.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await yH.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new n(this.GITHUB_PRICING_URL),r=he({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){D(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let n=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){D(`Response too large`),r.destroy(),e(null);return}n+=t}),t.on(`end`,()=>{try{let t=JSON.parse(n),r=t._meta,i={};for(let[e,n]of Object.entries(t))e!==`_meta`&&(i[e]=n);this.validatePricingData(i)?(D(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),D(`Pricing last updated: ${r?.updated||`unknown`}`),e(i)):(D(`Invalid pricing data structure`),e(null))}catch(t){D(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{D(`Response error:`,t),e(null)})});r.on(`error`,t=>{D(`Request error:`,t),e(null)}),r.on(`timeout`,()=>{D(`Request timeout`),r.destroy(),e(null)}),r.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return D(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return D(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),D(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(D(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(bH).length} models`),this.executionCache=bH,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(bH).length} models`),bH)}static validatePricingData(e){if(!e||typeof e!=`object`)return!1;for(let[,t]of Object.entries(e)){if(!t||typeof t!=`object`)return!1;let e=t;if(typeof e.input!=`number`||typeof e.output!=`number`||typeof e.cache_read!=`number`)return!1}return!0}static async getModelPricing(e){if(this.modelPricingCache.has(e))return D(`[CACHE-HIT] Model pricing cache: ${e}`),this.modelPricingCache.get(e);let t=await this.getCurrentPricing(),n;return n=t[e]?t[e]:this.fuzzyMatchModel(e,t),this.modelPricingCache.set(e,n),D(`[CACHE-SET] Model pricing cache: ${e}`),n}static fuzzyMatchModel(e,t){let n=e.toLowerCase();for(let[e,r]of Object.entries(t))if(e.toLowerCase()===n)return r;for(let{pattern:e,fallback:r}of[{pattern:[`opus-4-6`,`claude-opus-4-6`],fallback:`claude-opus-4-6-20260205`},{pattern:[`opus-4-5`,`claude-opus-4-5`],fallback:`claude-opus-4-5-20251101`},{pattern:[`opus-4-1`,`claude-opus-4-1`],fallback:`claude-opus-4-1-20250805`},{pattern:[`opus-4`,`claude-opus-4`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet-4-6`,`sonnet-4.6`,`claude-sonnet-4-6`],fallback:`claude-sonnet-4-6`},{pattern:[`sonnet-4.5`,`4-5-sonnet`,`sonnet-4-5`],fallback:`claude-sonnet-4-5-20250929`},{pattern:[`sonnet-4`,`claude-sonnet-4`],fallback:`claude-sonnet-4-20250514`},{pattern:[`haiku-4.5`,`4-5-haiku`,`haiku-4-5`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`haiku`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`opus`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet`],fallback:`claude-sonnet-4-5-20250929`}])if(e.some(e=>n.includes(e))&&t[r])return t[r];return t[`claude-sonnet-4-5-20250929`]||{name:`${e} (Unknown Model)`,input:3,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3,output:15}}static async calculateCostForEntry(e){let t=e.message?.usage;if(!t)return 0;let n=this.extractModelId(e),r=await this.getModelPricing(n),i=t.input_tokens||0,a=t.output_tokens||0,o=t.cache_creation_input_tokens||0,s=t.cache_read_input_tokens||0,c=i/1e6*r.input,l=a/1e6*r.output,u=s/1e6*r.cache_read,d=o/1e6*r.cache_write_5m;return c+l+d+u}static extractModelId(e){if(e.model&&typeof e.model==`string`)return e.model;let t=e.message;if(t?.model){let e=t.model;if(typeof e==`string`)return e;let n=e;return(typeof n?.id==`string`?n.id:null)||`claude-sonnet-4-5-20250929`}return e.model_id&&typeof e.model_id==`string`?e.model_id:`claude-sonnet-4-5-20250929`}};const SH=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function CH(e){if(typeof e==`string`)return SH.exec(e)?.[1]}function wH(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 TH(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 EH(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=wH(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`?CH(TH(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 DH(e){if(e!==void 0)return[e];let t=re();return[d(t,`.config`,`claude`),d(t,`.claude`)].filter(e=>g(e))}async function OH(e){let t=[];for(let n of e){let e=d(n,`projects`);if(g(e))try{let n=await sa(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=d(e,r.name);t.push(n)}}catch(t){D(`Failed to read projects directory ${e}:`,t)}}return t}async function kH(e,t,n){let r=[],i=[],a=d(t,e,`subagents`);try{let t=(await sa(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 pa(t,void 0,void 0);if(s.kind!==`ok`){D(`Failed to check agent file ${t}`);continue}i=LH(i,t,s.value);let c=PH(ma(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){D(`Failed to read subagents directory ${a}:`,e)}return{paths:r,longLines:i}}function AH(e){let t=e.message;if((e.type||t?.role||t?.type)!==`user`)return;if(MH(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=TH(t?.content).trimStart();return r.startsWith(`[Request interrupted by user`)?`interrupt`:e.isMeta===!0||e.isCompactSummary===!0||jH.test(r)?`claude-code`:`prompt`}const jH=/^<(?:command-name|local-command-std(?:out|err)|bash-(?:input|stdout|stderr))>/;function MH(e){let t=e?.content;return Array.isArray(t)&&typeof t[0]==`object`&&t[0]?t[0].type:void 0}function NH(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=AH(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:EH(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 PH(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 FH(e){let t=PH(e);if(t.kind===`unparsed`)return D(`Failed to parse JSONL line: ${t.reason}`),null;if(t.kind===`blank`)return null;try{return NH(t.value)}catch(e){return D(`Failed to project JSONL line: ${e}`),null}}function IH(e){let t=[];for(let n of e.split(`
190
+ `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:ZV(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}const eH=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`blackBright`,`redBright`,`greenBright`,`yellowBright`,`blueBright`,`magentaBright`,`cyanBright`,`whiteBright`];function tH(e){if(e===void 0||e.isDefault)return;let t=e.fixedValue;if(t!==void 0)return t.hex;let n=e.type===z.STANDARD&&e.number!==void 0?eH[e.number]:void 0;if(n===void 0)throw Error(`frames: no band colour for ${e.name}`);return n}const nH={bold:`bold`,dim:`dimColor`,italic:`italic`,underline:`underline`,strike:`strikethrough`,reverse:`inverse`,blink:null,blink2:null,conceal:null,underline2:null,frame:null,encircle:null,overline:null},rH=Object.keys(nH);function iH(e,t){let n=tH(t.color),r=tH(t.bgcolor),i={};for(let e of rH){if(t[e]!==!0)continue;let n=nH[e];if(n===null)throw Error(`frames: the band cannot draw ${e} text`);i[n]=!0}return{text:e,...n!==void 0&&{color:n},...r!==void 0&&{backgroundColor:r},...i,...t.link!==void 0&&{href:t.link}}}const aH=new H;function oH(e){return{ok:!0,band:new Kf().decode(e).map(e=>{let t=e.plain,n=[],r=0;for(let i of e.spans){if(!(i.style instanceof H))throw Error(`frames: the decoder gave a span a ${typeof i.style} style`);i.start>r&&n.push(iH(t.slice(r,i.start),aH)),n.push(iH(t.slice(i.start,i.end),i.style)),r=i.end}return r<t.length&&n.push(iH(t.slice(r),aH)),n})}}function sH(e){let t=$V(pn(e)).output;try{return oH(t)}catch(e){return oH(`${xv}${bv}⚠ cc-candybar ${vv(e instanceof Error?e.message:String(e))}${Sv}\n`)}}function cH(e){return`ccb`+te(`sha256`).update(e).digest(`hex`).slice(0,12)}const lH=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightblack`,`brightred`,`brightgreen`,`brightyellow`,`brightblue`,`brightmagenta`,`brightcyan`,`brightwhite`];function uH(e){if(e===void 0||e.isDefault)return`terminal`;switch(e.type){case z.STANDARD:{let t=e.number===void 0?void 0:lH[e.number];if(t!==void 0)return t;break}case z.EIGHT_BIT:if(e.number!==void 0)return`colour${e.number}`;break;case z.TRUECOLOR:{let t=e.fixedValue;if(t!==void 0)return t.hex;break}case z.DEFAULT:case z.WINDOWS:break}throw Error(`frames: no tmux colour for ${e.name}`)}const dH={bold:`bold`,dim:`dim`,italic:`italics`,underline:`underscore`,strike:`strikethrough`,reverse:`reverse`,blink:`blink`,conceal:`hidden`,underline2:`double-underscore`,overline:`overline`,blink2:null,frame:null,encircle:null},fH=Object.keys(dH);function pH(e){return e.replaceAll(`#`,`##`)}function mH(e){let t=fH.filter(t=>e[t]===!0).map(e=>{let t=dH[e];if(t===null)throw Error(`frames: a tmux status line cannot draw ${e} text`);return t});return`#[${[`none`,`fg=${uH(e.color)}`,`bg=${uH(e.bgcolor)}`,...t].join(`,`)}]`}const hH=new H;function gH(e){let t={},n=(e,n)=>{let r=mH(n)+pH(e);if(n.link===void 0)return r;let i=cH(n.link);return t[i]=n.link,`#[range=user|${i}]${r}#[norange]`};return{rows:new Kf().decode(e).map(e=>{let t=e.plain,r=[],i=0;for(let a of e.spans){if(!(a.style instanceof H))throw Error(`frames: the decoder gave a span a ${typeof a.style} style`);a.start>i&&r.push(n(t.slice(i,a.start),hH)),r.push(n(t.slice(a.start,a.end),a.style)),i=a.end}return i<t.length&&r.push(n(t.slice(i),hH)),r.join(``)}),links:t}}function _H(e){let t=$V(pn(e)).output;try{return gH(t)}catch(e){return gH(`${xv}${bv}⚠ cc-candybar ${vv(e instanceof Error?e.message:String(e))}${Sv}\n`)}}const vH={band:e=>JSON.stringify(sH(e)),statusline:(e,t)=>t,pane:(e,t)=>t,tmuxStatus:e=>JSON.stringify({ok:!0,tmuxStatus:_H(e)})};var yH=class{static CACHE_DIR=k();static USAGE_CACHE_DIR=s.join(this.CACHE_DIR,`usage`);static LOCKS_DIR=s.join(this.CACHE_DIR,`locks`);static isLocked(e){let t=s.join(this.LOCKS_DIR,e);if(!p.existsSync(t))return!1;try{let n=p.readFileSync(t,`utf-8`),r=parseInt(n.trim(),10);if(isNaN(r))return D(`Invalid PID in lock file ${e}, removing stale lock`),p.unlinkSync(t),!1;try{return process.kill(r,0),!0}catch(n){return n.code===`ESRCH`?(D(`Removing stale lock file ${e} for dead process ${r}`),p.unlinkSync(t),!1):(D(`Error checking process ${r} for lock ${e}:`,n),!0)}}catch(t){return D(`Error reading lock file ${e}:`,t),!0}}static async acquireLock(e,t=5e3){await this.ensureCacheDirectories();let n=s.join(this.LOCKS_DIR,e),r=Date.now(),i=String(process.pid);for(;Date.now()-r<t;)try{return await p.promises.writeFile(n,i,{flag:`wx`}),D(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await ge(50);else throw e}return D(`Failed to acquire lock for ${e} within ${t}ms`),!1}static async releaseLock(e){let t=s.join(this.LOCKS_DIR,e);try{await p.promises.unlink(t),D(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&D(`Error releasing lock for ${e}:`,t)}}static async ensureCacheDirectories(){try{await Promise.all([p.promises.mkdir(this.CACHE_DIR,{recursive:!0}),p.promises.mkdir(this.USAGE_CACHE_DIR,{recursive:!0}),p.promises.mkdir(this.LOCKS_DIR,{recursive:!0})])}catch(e){D(`Failed to create cache directories:`,e)}}static createProjectHash(e){return te(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t){await this.ensureCacheDirectories();let n=s.join(this.USAGE_CACHE_DIR,`${e}.json`),r=`${e}.usage.lock`;for(let i=0;i<3;i++){if(this.isLocked(r)){D(`Cache for ${e} is locked, waiting...`),await ge(75);continue}try{let r=await p.promises.readFile(n,`utf-8`),i=JSON.parse(r);return!t||i.timestamp>=t?(D(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(i.data)):(D(`${e} cache outdated: cache=${i.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return D(`No shared ${e} usage cache found`),null;D(`Attempt ${i+1} failed to read ${e} cache: ${t.message}. Retrying...`),await ge(75)}}return D(`Failed to read ${e} cache after 3 attempts.`),null}static deserializeDates(e){return Array.isArray(e)?e.map(e=>({...e,timestamp:new Date(e.timestamp)})):e}static async setUsageCache(e,t,n){let r=`${e}.usage.lock`;if(!await this.acquireLock(r)){D(`Could not acquire lock to set usage cache for ${e}`);return}try{await this.ensureCacheDirectories();let r=s.join(this.USAGE_CACHE_DIR,`${e}.json`),i=JSON.stringify({data:t,timestamp:n||Date.now()});await p.promises.writeFile(r,i,`utf-8`),D(`[CACHE-SET] ${e} disk cache stored`)}catch(t){D(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(r)}}};const bH={"claude-haiku-4-5-20251001":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-haiku-4-5":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-opus-4-20250514":{name:`Claude Opus 4`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1-20250805":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-sonnet-4-20250514":{name:`Claude Sonnet 4`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-4-opus-20250514":{name:`Claude 4 Opus`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-4-sonnet-20250514":{name:`Claude 4 Sonnet`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5-20250929":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-opus-4-5":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-5-20251101":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6-20260205":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-sonnet-4-6":{name:`Claude Sonnet 4.6`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3}};var xH=class{static executionCache=null;static modelPricingCache=new Map;static GITHUB_PRICING_URL=`https://raw.githubusercontent.com/promptctl/cc-candybar/main/pricing.json`;static async loadDiskCache(){let e=Date.now()-1440*60*1e3;return await yH.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await yH.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new n(this.GITHUB_PRICING_URL),r=he({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){D(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let n=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){D(`Response too large`),r.destroy(),e(null);return}n+=t}),t.on(`end`,()=>{try{let t=JSON.parse(n),r=t._meta,i={};for(let[e,n]of Object.entries(t))e!==`_meta`&&(i[e]=n);this.validatePricingData(i)?(D(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),D(`Pricing last updated: ${r?.updated||`unknown`}`),e(i)):(D(`Invalid pricing data structure`),e(null))}catch(t){D(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{D(`Response error:`,t),e(null)})});r.on(`error`,t=>{D(`Request error:`,t),e(null)}),r.on(`timeout`,()=>{D(`Request timeout`),r.destroy(),e(null)}),r.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return D(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return D(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),D(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(D(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(bH).length} models`),this.executionCache=bH,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(bH).length} models`),bH)}static validatePricingData(e){if(!e||typeof e!=`object`)return!1;for(let[,t]of Object.entries(e)){if(!t||typeof t!=`object`)return!1;let e=t;if(typeof e.input!=`number`||typeof e.output!=`number`||typeof e.cache_read!=`number`)return!1}return!0}static async getModelPricing(e){if(this.modelPricingCache.has(e))return D(`[CACHE-HIT] Model pricing cache: ${e}`),this.modelPricingCache.get(e);let t=await this.getCurrentPricing(),n;return n=t[e]?t[e]:this.fuzzyMatchModel(e,t),this.modelPricingCache.set(e,n),D(`[CACHE-SET] Model pricing cache: ${e}`),n}static fuzzyMatchModel(e,t){let n=e.toLowerCase();for(let[e,r]of Object.entries(t))if(e.toLowerCase()===n)return r;for(let{pattern:e,fallback:r}of[{pattern:[`opus-4-6`,`claude-opus-4-6`],fallback:`claude-opus-4-6-20260205`},{pattern:[`opus-4-5`,`claude-opus-4-5`],fallback:`claude-opus-4-5-20251101`},{pattern:[`opus-4-1`,`claude-opus-4-1`],fallback:`claude-opus-4-1-20250805`},{pattern:[`opus-4`,`claude-opus-4`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet-4-6`,`sonnet-4.6`,`claude-sonnet-4-6`],fallback:`claude-sonnet-4-6`},{pattern:[`sonnet-4.5`,`4-5-sonnet`,`sonnet-4-5`],fallback:`claude-sonnet-4-5-20250929`},{pattern:[`sonnet-4`,`claude-sonnet-4`],fallback:`claude-sonnet-4-20250514`},{pattern:[`haiku-4.5`,`4-5-haiku`,`haiku-4-5`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`haiku`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`opus`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet`],fallback:`claude-sonnet-4-5-20250929`}])if(e.some(e=>n.includes(e))&&t[r])return t[r];return t[`claude-sonnet-4-5-20250929`]||{name:`${e} (Unknown Model)`,input:3,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3,output:15}}static async calculateCostForEntry(e){let t=e.message?.usage;if(!t)return 0;let n=this.extractModelId(e),r=await this.getModelPricing(n),i=t.input_tokens||0,a=t.output_tokens||0,o=t.cache_creation_input_tokens||0,s=t.cache_read_input_tokens||0,c=i/1e6*r.input,l=a/1e6*r.output,u=s/1e6*r.cache_read,d=o/1e6*r.cache_write_5m;return c+l+d+u}static extractModelId(e){if(e.model&&typeof e.model==`string`)return e.model;let t=e.message;if(t?.model){let e=t.model;if(typeof e==`string`)return e;let n=e;return(typeof n?.id==`string`?n.id:null)||`claude-sonnet-4-5-20250929`}return e.model_id&&typeof e.model_id==`string`?e.model_id:`claude-sonnet-4-5-20250929`}};const SH=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function CH(e){if(typeof e==`string`)return SH.exec(e)?.[1]}function wH(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 TH(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 EH(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=wH(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`?CH(TH(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 DH(e){if(e!==void 0)return[e];let t=re();return[d(t,`.config`,`claude`),d(t,`.claude`)].filter(e=>g(e))}async function OH(e){let t=[];for(let n of e){let e=d(n,`projects`);if(g(e))try{let n=await sa(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=d(e,r.name);t.push(n)}}catch(t){D(`Failed to read projects directory ${e}:`,t)}}return t}async function kH(e,t,n){let r=[],i=[],a=d(t,e,`subagents`);try{let t=(await sa(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 pa(t,void 0,void 0);if(s.kind!==`ok`){D(`Failed to check agent file ${t}`);continue}i=LH(i,t,s.value);let c=PH(ma(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){D(`Failed to read subagents directory ${a}:`,e)}return{paths:r,longLines:i}}function AH(e){let t=e.message;if((e.type||t?.role||t?.type)!==`user`)return;if(MH(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=TH(t?.content).trimStart();return r.startsWith(`[Request interrupted by user`)?`interrupt`:e.isMeta===!0||e.isCompactSummary===!0||jH.test(r)?`claude-code`:`prompt`}const jH=/^<(?:command-name|local-command-std(?:out|err)|bash-(?:input|stdout|stderr))>/;function MH(e){let t=e?.content;return Array.isArray(t)&&typeof t[0]==`object`&&t[0]?t[0].type:void 0}function NH(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=AH(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:EH(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 PH(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 FH(e){let t=PH(e);if(t.kind===`unparsed`)return D(`Failed to parse JSONL line: ${t.reason}`),null;if(t.kind===`blank`)return null;try{return NH(t.value)}catch(e){return D(`Failed to project JSONL line: ${e}`),null}}function IH(e){let t=[];for(let n of e.split(`
186
191
  `)){let e=FH(n);e&&t.push(e)}return t}function LH(e,t,n){return n.longLine===0?e:[...e,{path:t,offset:n.start,bytes:n.longLine}]}function RH(e){return e.map(e=>`transcript long line path=${JSON.stringify(e.path)} offset=${e.offset} bytes=${e.bytes}`)}async function zH(e,t,n,r){let i=[],a=t?.cursor,o=t?.value??n,s;for(;;){let t=await pa(e,a===void 0?void 0:{offset:a.offset,ino:a.ino},s?.size);if(t.kind!==`ok`)return t;let c=t.value;c.reset&&(o=n),i=LH(c.reset?[]:i,e,c),(s===void 0||c.reset)&&(s={size:c.size,stamp:c.stamp});let l=c.start+c.lines.length;if(o=await r(o,ma(c,e=>IH(e.toString(`utf-8`)))),a={offset:l,stamp:s.stamp,ino:c.ino},c.atEnd)return F({folded:{cursor:a,value:o},longLines:i})}}var BH=class{inflight=new Map;run(e,t){return this.inflight.get(e)??this.start(e,t)}start(e,t){let n=t();this.inflight.set(e,n);let r=()=>{this.inflight.get(e)===n&&this.inflight.delete(e)};return n.then(r,r),n}get size(){return this.inflight.size}};function VH(e,t){let n=e?e.input+e.cacheCreation+e.cacheRead:0,r=e?e.output:0;return{input:n,output:r,total:n+r,atMs:t}}const HH=new Map,UH={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0},WH={cost:null,calculatedCost:null,officialCost:null,tokens:null,tokenBreakdown:null};function GH(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function KH(){let e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()-1),e.getTime()}function qH(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}const JH={entries:0,cost:0,breakdown:qH(),days:new Map};async function YH(e,t){let n=GH(new Date(KH())),r=e.entries,i=e.cost,a={...e.breakdown},o=new Map;for(let[t,r]of e.days)t>=n&&o.set(t,{...r});for(let e of t){let t=e.message?.usage;if(!t)continue;r++;let s=e.costUSD??await xH.calculateCostForEntry(e.raw);i+=s,a.input+=t.input_tokens||0,a.output+=t.output_tokens||0,a.cacheCreation+=t.cache_creation_input_tokens||0,a.cacheRead+=t.cache_read_input_tokens||0;let c=GH(new Date(e.timestamp));if(c<n)continue;let l=o.get(c)??{...UH};l.cost+=s,l.input+=t.input_tokens||0,l.output+=t.output_tokens||0,l.cacheCreation+=t.cache_creation_input_tokens||0,l.cacheRead+=t.cache_read_input_tokens||0,o.set(c,l)}return{entries:r,cost:i,breakdown:a,days:o}}function XH(e){let t=0,n=0,r=qH(),i=new Map;for(let{value:a}of e.values()){t+=a.entries,n+=a.cost,r.input+=a.breakdown.input,r.output+=a.breakdown.output,r.cacheCreation+=a.breakdown.cacheCreation,r.cacheRead+=a.breakdown.cacheRead;for(let[e,t]of a.days){let n=i.get(e)??{...UH};n.cost+=t.cost,n.input+=t.input,n.output+=t.output,n.cacheCreation+=t.cacheCreation,n.cacheRead+=t.cacheRead,i.set(e,n)}}if(t===0)return{sessionInfo:WH,days:i};let a=r.input+r.output+r.cacheCreation+r.cacheRead;return{sessionInfo:{cost:n,calculatedCost:n,officialCost:null,tokens:a,tokenBreakdown:r},days:i}}async function ZH(e,t,n){let r=0,i=async()=>{for(;r<e.length;){let t=e[r++];await n(t)}},a=Math.min(t,e.length);await Promise.all(Array.from({length:a},i))}var QH=class{sessions=new Map;flight=new BH;seeded=new Map;seededDay=``;rescanIntervalMs;speedFlight=new BH;staleAgeMs;log;renderTally={hits:0,misses:0};sweeps=0;scans={seed:0,rescan:0};sweepTimer=null;constructor(e={}){this.log=e.logger??Oe,this.staleAgeMs=e.staleAgeMs??864e5,this.rescanIntervalMs=e.rescanIntervalMs??6e4;let t=e.sweepIntervalMs??3e5;t>0&&(this.sweepTimer=setInterval(()=>this.sweepStale(),t),this.sweepTimer.unref())}getStats(){return{size:this.sessions.size,hits:this.renderTally.hits,misses:this.renderTally.misses,sweeps:this.sweeps,seeds:this.scans.seed,rescans:this.scans.rescan}}async getUsageInfo(e,t){let n=await this.ingest(e,t?.transcript_path,this.renderTally);if(n.kind===`failed`)return n;let r=n.kind===`ok`?n.value.sessionInfo:WH,i=t?.cost?.total_cost_usd??null;return F({session:{...r,cost:i??r.cost,officialCost:i}})}async getTodayInfo(e,t,n){let r=GH(vO(n)),i=DH(t);try{await this.ensureSeeded(r,i,n*1e3)}catch(e){return L(`usage seed: ${e instanceof Error?e.message:String(e)}`)}let a=await this.ingest(e?.session_id??``,e?.transcript_path,this.renderTally);if(a.kind===`failed`)return a;let o=i.map(e=>d(e,`projects`)+f),s={...UH},c=!1;for(let[t,{record:n}]of this.sessions){let i=n?.transcriptPath??``,a=t===e?.session_id||o.some(e=>i.startsWith(e))?n?.days??HH:HH;c||=a.has(r);let l=a.get(r)??UH;s.cost+=l.cost,s.input+=l.input,s.output+=l.output,s.cacheCreation+=l.cacheCreation,s.cacheRead+=l.cacheRead}return c?F({cost:s.cost,tokens:s.input+s.output+s.cacheCreation+s.cacheRead,tokenBreakdown:{input:s.input,output:s.output,cacheCreation:s.cacheCreation,cacheRead:s.cacheRead},date:r}):I}async observeSpeed(e,t,n){if(!e)return I;let r=ra(t);return this.speedFlight.run(`${e}:${r}`,async()=>{let i=await this.ingest(e,t,this.renderTally,r);if(i.kind===`failed`)return i;let a=VH(i.kind===`ok`?i.value.sessionInfo.tokenBreakdown:null,n),{ring:o}=this.hold(e),s;for(let e of o)e.atMs<a.atMs&&(s===void 0||e.atMs>s.atMs)&&(s=e);return o.push(a),o.sort((e,t)=>e.atMs-t.atMs),o.length>64&&o.shift(),F({...s!==void 0&&{prev:s},cur:a,samples:[...o]})})}async ingest(e,t,n,r){if(!e)return I;let i=r??ra(t),a=this.see(e)?.record;if(a&&i!==``&&a.transcriptStamp===i)return n.hits++,F(a);if(!t)return a?F(a):I;n.misses++;let o;try{o=await this.flight.run(`${e}:${i}`,async()=>{let n=this.sessions.get(e)?.record;return{prior:n,outcome:await this.refold(e,t,n)}})}catch(t){return L(`usage refold (${e}): ${t instanceof Error?t.message:String(t)}`)}let{prior:s,outcome:c}=o;if(c.kind!==`ok`)return c;let l={files:c.value.files,sessionInfo:c.value.sessionInfo,days:c.value.days,transcriptStamp:c.value.mainStamp,transcriptPath:t};return this.sessions.get(e)?.record===s&&(this.hold(e).record=l),F(l)}see(e){let t=this.sessions.get(e);return t&&(t.lastSeenAt=Date.now()),t}hold(e){let t=this.see(e);if(t)return t;let n={lastSeenAt:Date.now(),record:void 0,ring:[]};return this.sessions.set(e,n),n}async refold(e,t,n){let r=await kH(e,l(t),n===void 0?void 0:new Set(n.files.keys()));for(let e of RH(r.longLines))this.log(`info`,e);let i=new Map,a=``;for(let e of[t,...r.paths]){let r=n?.files.get(e),o=await zH(e,r,JH,YH);if(o.kind===`failed`)return o;if(o.kind===`absent`){r&&i.set(e,r);continue}let{folded:s,longLines:c}=o.value;for(let e of RH(c))this.log(`info`,e);i.set(e,s),e===t&&(a=s.cursor.stamp)}return F({files:i,...XH(i),mainStamp:a})}ensureSeeded(e,t,n){this.seededDay!==e&&(this.seeded.clear(),this.seededDay=e);let r=t.join(`\0`),i=this.seeded.get(r);if(!i){let e=this.seed(t,`seed`),i={done:e,scanning:e,startedAtMs:n};return this.seeded.set(r,i),this.settle(r,i,e),e}return i.scanning===void 0&&n-i.startedAtMs>=this.rescanIntervalMs&&(i.startedAtMs=n,i.scanning=this.seed(t,`rescan`),this.settle(r,i,i.scanning)),i.done}settle(e,t,n){n.then(()=>{t.scanning=void 0},n=>{this.log(`warn`,`usageStore scan: ${n instanceof Error?n.message:String(n)}`),this.seeded.get(e)===t&&this.seeded.delete(e)})}async scanned(){await Promise.allSettled([...this.seeded.values()].map(e=>e.scanning))}async seed(e,t){let n=Date.now(),r=KH(),i=await OH(e),a=[];for(let e of i){let t;try{t=await sa(e)}catch{continue}for(let n of t){if(!n.endsWith(`.jsonl`))continue;let t=d(e,n),i;try{i=await ca(t)}catch{continue}i.mtimeMs<r||a.push({sessionId:n.slice(0,-6),path:t,stamp:ia(i)})}}let o={hits:0,misses:0};await ZH(a,8,async e=>{let n=await this.ingest(e.sessionId,e.path,o,e.stamp);n.kind===`failed`&&this.log(`warn`,`usageStore ${t}: ${n.reason}`)}),this.log(`info`,`usageStore ${t} sessions=${a.length} read=${o.misses} dirs=${e.join(`,`)} ms=${Date.now()-n}`),this.scans[t]++}sweepStale(){let e=Date.now(),t=0,n=0,r=0;for(let[i,{lastSeenAt:a,record:o}]of this.sessions)if(!(e-a<=this.staleAgeMs)){if(o?.days.has(this.seededDay)){n++;continue}this.sessions.delete(i),t++,o===void 0&&r++}return t>0&&this.sweeps++,(t>0||n>0)&&this.log(`info`,`usageStore sweep dropped=${t} noRecord=${r} held=${n}`),t}close(){this.sweepTimer&&=(clearInterval(this.sweepTimer),null),this.sessions.clear(),this.seeded.clear()}},$H=class{states=new Map;constructor(e,t,n=Oe,r=256){this.empty=e,this.step=t,this.log=n,this.maxSessions=r}async read(e,t){let n=this.states.get(e),r=ra(t);if(n&&r!==``&&n.cursor.stamp===r)return this.touch(e,n),{kind:`ok`,value:n.value};let i=await zH(t,n,this.empty,(e,t)=>t.reduce(this.step,e));if(i.kind===`failed`)return i;if(i.kind===`absent`)return{kind:`ok`,value:n?.value??this.empty};let{folded:a,longLines:o}=i.value;for(let e of RH(o))this.log(`info`,e);for(this.touch(e,a);this.states.size>this.maxSessions;){let e=this.states.keys().next().value;if(e===void 0)break;this.states.delete(e)}return{kind:`ok`,value:a.value}}touch(e,t){this.states.delete(e),this.states.set(e,t)}};function eU(e,t){let n=t.message?.usage;return!n?.input_tokens||t.isSidechain===!0?e:n.input_tokens+(n.cache_read_input_tokens||0)+(n.cache_creation_input_tokens||0)}var tU=class{fold;constructor(e={}){this.fold=new $H(void 0,eU,e.logger)}thresholds={LOW:50,MEDIUM:80};getContextUsageThresholds(){return this.thresholds}ratioPercentages(e,t){let n=Math.min(100,Math.max(0,Math.round(e/t*100)));return{percentage:n,contextLeftPercentage:Math.max(0,100-n)}}calculateContextFromHookData(e){let t=e.context_window;if(!t?.current_usage)return D(`No current_usage in hook data, falling back to transcript parsing`),null;let n=t.current_usage,r=t.context_window_size,i=(n.input_tokens||0)+(n.cache_creation_input_tokens||0)+(n.cache_read_input_tokens||0);D(`Native current_usage: input=${n.input_tokens}, cache_create=${n.cache_creation_input_tokens}, cache_read=${n.cache_read_input_tokens}, total=${i} (limit: ${r})`);let a=this.ratioPercentages(i,r);return{totalTokens:i,maxTokens:r,percentage:t.used_percentage==null?a.percentage:Math.round(t.used_percentage),contextLeftPercentage:t.remaining_percentage==null?a.contextLeftPercentage:Math.round(t.remaining_percentage)}}async calculateContextTokensFromTranscript(e,t,n){let r=await this.fold.read(e,t);if(r.kind===`failed`)return L(`context transcript: ${r.reason}`);let i=r.value;return i===void 0?(D(`No main chain entries with usage data found`),I):(D(`Most recent main chain context: ${i} tokens (limit: ${n})`),F({totalTokens:i,maxTokens:n,...this.ratioPercentages(i,n)}))}async getContextInfo(e){let t=this.calculateContextFromHookData(e);if(t)return F(t);let n=e.context_window?.context_window_size??2e5;return this.calculateContextTokensFromTranscript(e.session_id,e.transcript_path,n)}};const nU={messageCount:0,nonPrompts:0,recent:[]},rU=new Set([`turn`,`interrupt`,`claude-code`]);function iU(e,t){if(t.isSidechain)return e;let n=[...e.recent,t];return{messageCount:e.messageCount+ +(t.userEntry===`prompt`),nonPrompts:e.nonPrompts+ +!!rU.has(t.userEntry),recent:n.length>20?n.slice(-20):n}}function aU(e){let t=null,n=null;for(let r of e){let e=r.type||r.message?.role||r.message?.type;if(r.userEntry===`prompt`||r.userEntry===`turn`)t=r.timestamp;else if(e===`assistant`&&t){let e=(r.timestamp.getTime()-t.getTime())/1e3;e>.1&&e<300&&(n=e)}}return n}var oU=class{fold;constructor(e={}){this.fold=new $H(nU,iU,e.logger)}async getMetricsInfo(e,t){if(D(`Getting metrics from hook data for session: ${e}`),!t.cost)return I;let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?L(`metrics (${e}): ${n.reason}`):F({responseTime:t.cost.total_api_duration_ms/1e3,lastResponseTime:aU(n.value.recent),sessionDuration:t.cost.total_duration_ms/1e3,messageCount:n.value.messageCount,nonPrompts:n.value.nonPrompts,linesAdded:t.cost.total_lines_added,linesRemoved:t.cost.total_lines_removed})}};const sU={command:null,todos:[],pending:[],done:[]};function cU(e,t){let n=e.findIndex(e=>e.name===t);return n<0?[...e,{name:t,count:1}]:e.map((e,t)=>t===n?{name:e.name,count:e.count+1}:e)}function lU(e,t){switch(t.userEntry){case`prompt`:return{...e,command:t.activity?.command??null,pending:[],done:[]};case`interrupt`:return{...e,pending:[]};case`turn`:case`tool-result`:case`claude-code`:case void 0:return e}}function uU(e,t){if(t.isSidechain)return e;let n=lU(e,t),r=t.activity;if(r===void 0)return n;let i=n.pending,a=n.done;r.started!==void 0&&(i=[...i,...r.started]);for(let e of r.finished??[]){let t=i.findIndex(t=>t.id===e);t<0||(a=cU(a,i[t].name),i=[...i.slice(0,t),...i.slice(t+1)])}return{...n,pending:i,done:a,todos:r.todos??n.todos}}function dU(e){return{command:e.command,todos:e.todos,running:e.pending.reduce((e,t)=>cU(e,t.name),[]),done:e.done}}var fU=class{fold;constructor(e={}){this.fold=new $H(sU,uU,e.logger)}async getActivityInfo(e,t){let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?L(`activity (${e}): ${n.reason}`):F(dU(n.value))}};function pU(e,t,n,r){return{bin:`tmux`,args:[`-S`,e.socket,...n],timeoutMs:2e3,category:t,stdinInput:r}}function mU(e,t){if(e.ok)return{kind:`ok`,stdout:e.stdout};if(e.reason===`rate-limited`)return{kind:`rate-limited`,reason:e.error??`rate-limited`};let n=e.error??[e.reason,e.stderr.trim()].filter(e=>e!==``).join(`: `);return{kind:`failed`,reason:`tmux ${t[0]} failed (${n})`}}function hU(e,t,n,r){return mU(ut(pU(e,t,n,r)),n)}async function gU(e,t,n,r){return mU(await lt(pU(e,t,n,r)),n)}const _U=e=>`${e.socket}\n${e.pane}`;var vU=class{names=new Map;asking=new BH;constructor(e=Date.now){this.now=e}getSessionName(e){let t=_U(e),n=this.names.get(t);if(n&&this.now()-n.at<3e4)return Promise.resolve(n.outcome);let r=this.asking.run(t,()=>this.ask(t,e));return n?Promise.resolve(n.outcome):r}async ask(e,t){D(`Getting tmux session name for pane ${t.pane} on ${t.socket}`);let n=await gU(t,`tmux`,[`display-message`,`-p`,`-t`,t.pane,`#S`]),r=n.kind===`ok`?n.stdout.trim():``,i=n.kind===`ok`?r?F(r):I:L(n.reason);for(this.names.delete(e),this.names.set(e,{outcome:i,at:this.now()});this.names.size>64;)this.names.delete(this.names.keys().next().value);return i}};const yU=e=>JSON.stringify([e.sessionId,e.projectDir,e.cwd,e.claudeConfigDir,e.env===void 0?null:Mt.map(t=>e.env?.[t]??null)]);var bU=class{readings=new Map;inFlight=new Map;constructor(e,t=Date.now){this.edge=e,this.now=t}getCeiling(e){let t=yU(e),n=this.readings.get(t);if(n&&this.now()-n.at<1e4)return Promise.resolve(n.outcome);let r=this.inFlight.get(t)??this.fetch(t,e);return n?Promise.resolve(n.outcome):r}fetch(e,t){let n=this.edge.locate(t),r=(n.kind===`ok`?this.edge.read(n.value,t):Promise.resolve(n)).then(t=>{if(this.inFlight.get(e)!==r)return t;for(this.readings.delete(e),this.readings.set(e,{outcome:t,at:this.now()});this.readings.size>64;)this.readings.delete(this.readings.keys().next().value);return t}).finally(()=>{this.inFlight.get(e)===r&&this.inFlight.delete(e)});return this.inFlight.set(e,r),r}move(e,t){let n=this.edge.locate(e);if(n.kind!==`ok`)throw Error(n.kind===`failed`?n.reason:`memento is not installed or not enabled for this project`);let r=yU(e);try{this.edge.move(n.value,e,t)}finally{this.readings.delete(r),this.inFlight.delete(r),this.fetch(r,e)}}};function xU(e,t){return{...e,claudeConfigDir:xa(t.claudeConfigDir),env:t.mementoEnv}}const SU=s.join(`lib`,`ceiling_config.py`),CU=s.join(`skills`,`ceiling`,`bin`,`ceiling`);function wU(e,t){let n=typeof e==`object`&&e?e.plugins:void 0;if(typeof n!=`object`||!n)throw Error(`${t} has no "plugins" object`);return Object.entries(n).filter(([e])=>e.split(`@`)[0]===`memento`).flatMap(([e,n])=>{if(!Array.isArray(n))throw Error(`${t}: "${e}" is not a list of installs`);return n.map(n=>{let{scope:r,installPath:i,projectPath:a}=n??{};if(typeof r!=`string`||typeof i!=`string`)throw Error(`${t}: an install of "${e}" has no scope/path`);return typeof a==`string`?{key:e,scope:r,installPath:i,projectPath:a}:{key:e,scope:r,installPath:i}})})}function TU(e,t){let n=!0;for(let r of e){if(!p.existsSync(r))continue;let e;try{e=JSON.parse(p.readFileSync(r,`utf8`))?.enabledPlugins?.[t]}catch(e){return L(`memento lookup: ${r}: ${e.message}`)}typeof e==`boolean`&&(n=e)}return F(n)}function EU(e,t){if(!p.existsSync(e))return I;let n;try{n=wU(JSON.parse(p.readFileSync(e,`utf8`)),e)}catch(e){return L(`memento lookup: ${e.message}`)}let r=n.find(e=>e.projectPath===t)??n.find(e=>e.scope===`user`);if(r===void 0)return I;let i=TU([s.join(s.dirname(s.dirname(e)),`settings.json`),s.join(t,`.claude`,`settings.json`),s.join(t,`.claude`,`settings.local.json`)],r.key);if(i.kind!==`ok`)return i;if(!i.value)return I;let a=[SU,CU].filter(e=>!p.existsSync(s.join(r.installPath,e)));return a.length===0?F(r.installPath):L(`memento at ${r.installPath} has no ${a.join(` or `)} — upgrade the plugin`)}function DU(e,t=process.env){let n=new Set([`CLAUDE_PROJECT_DIR`,`CLAUDE_CODE_SESSION_ID`,...e.env===void 0?[]:Mt]);return{...Object.fromEntries(Object.entries(t).filter(([e])=>!n.has(e))),...e.env,CLAUDE_CODE_SESSION_ID:e.sessionId,CLAUDE_PROJECT_DIR:e.projectDir||e.cwd}}function OU(e){return e.stderr.trim()||e.error||`${e.reason}${e.exitCode===null?``:` (exit ${e.exitCode})`}`}function kU(e){let t;try{t=JSON.parse(e)}catch{return L(`memento read: not JSON: ${e.trim()}`)}let{ceiling:n,session:r}=t??{},i=n===`off`||typeof n==`number`&&n>=0?n:void 0;return i!==void 0&&(r===null||typeof r==`string`)?F({ceiling:i,session:r}):L(`memento read: unexpected answer: ${e.trim()}`)}async function AU(e,t){let n=await lt({bin:`python3`,args:[`-c`,`
187
192
  import json, math, sys
188
193
  sys.path.insert(0, sys.argv[1])
@@ -192,17 +197,17 @@ ceiling = in_force(directory, anchored(sys.argv[3]))
192
197
  layer = ceiling_in(directory / CONFIG_NAME)
193
198
  print(json.dumps({"ceiling": "off" if ceiling == math.inf else ceiling,
194
199
  "session": layer.text if layer else None}))
195
- `,s.join(e,`lib`),t.sessionId,t.cwd],env:DU(t),timeoutMs:3e3,category:`memento.read`});return n.ok?kU(n.stdout):L(OU(n))}function jU(e,t,n){let r=ut({bin:s.join(e,CU),args:n.kind===`set`?[`set`,`session`,n.to]:[`clear`,`session`],env:DU(t),timeoutMs:5e3,category:`memento.move`});if(!r.ok)throw Error(OU(r))}function MU(e,t){return EU(Ca(e),t)}function NU(){return{locate:e=>MU(e.claudeConfigDir,e.projectDir),read:AU,move:jU}}function PU(e){return{gitProvider:new fO({watchers:e.watchers,logger:e.logger}),usageStore:new QH({logger:e.logger}),contextProvider:new tU({logger:e.logger}),metricsProvider:new oU({logger:e.logger}),activityProvider:new fU({logger:e.logger}),tmuxService:new vU,mementoProvider:new bU(NU()),autoCompact:tN,log:e.logger}}const FU=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function IU(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t.message?.usage;if(!((n?.cache_read_input_tokens??0)>0||(n?.cache_creation_input_tokens??0)>0))return null;let r=t.timestamp==null?NaN:Date.parse(t.timestamp);return Number.isNaN(r)?null:r}async function LU(e){let t=await RU(e);return t.kind===`ok`?F(Math.floor((t.value+36e5)/1e3)):t}async function RU(e){for(let t of[65536,1048576]){let n=await _a(e,t);if(n.kind!==`ok`)return n;let r=zU(n.value.buf,n.value.fromStart);if(r!=null)return F(r);if(n.value.fromStart)return I}return I}function zU(e,t){let n=e.toString(`utf8`).split(`
196
- `),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!FU.test(t))continue;let r=IU(t);if(r!=null)return r}return null}function BU(e,t,n){return Me({dir:e.project_dir,env:n===void 0?[]:[[ya,n]],program:`claude`,args:[`--resume`,t,...e.added_dirs.flatMap(e=>[`--add-dir`,e])]})}function VU(e,t){return{endcaps:e.endcaps,separator:e.separator,colorCompatibility:e.colorCompatibility,wrap:e.autoWrap,padding:e.padding,width:t}}function HU(e){return{...Object.fromEntries(Q_.map(t=>[t,{effective:e[t]}])),preset:{effective:e.preset,customized:e.presetCustomized,bundled:IB(e.preset)}}}const UU={prNumber:!0,prState:!0,prUrl:!0,prError:!0,prEarlier:!0};function WU(e){return e?.prState===void 0?e?.prError===void 0?e?.prEarlier===void 0?`-`:`earlier-${e.prEarlier}`:`failed`:e.prState}const GU=10*1e3;function KU(e,t,n,r){let i=n-(t*1e3-r);if(i<3e5||e<=0)return;let a=e/i,o=(100-e)/a;return Math.max(0,Math.round(o/6e4))}function qU(e,t){if(!(t<60))return e*3600/t}function JU(e,t,n,r){let i=r-t;if(i<50||i>GU)return;let a=n-e;if(!(a<=0))return a*1e3/i}function YU(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=JU(t.input,t.atMs,n.input,n.atMs),i=JU(t.output,t.atMs,n.output,n.atMs),a=JU(t.total,t.atMs,n.total,n.atMs);if(!(r===void 0&&i===void 0&&a===void 0))return{...r!==void 0&&{input:r},...i!==void 0&&{output:i},...a!==void 0&&{total:a}}}function XU(e){let{samples:t}=e,n=[];for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=i.atMs-r.atMs;if(a<50||a>GU)continue;let o=JU(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function ZU(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function QU(e){let t=[],n=(e,n)=>{try{let e=n();return e===``?void 0:e}catch(n){t.push(`host.${e}: ${String(n)}`);return}},r=n(`name`,()=>ZU(C.hostname())),i=n(`user`,()=>C.userInfo().username);return{host:{...r!==void 0&&{name:r},...i!==void 0&&{user:i},...e.ssh!==void 0&&{ssh:e.ssh}},failures:t}}function $U(e,t){let n=[],r=t=>sb(t,e.helpers).keys(),i=By(e,t);for(let e of Ih){let t=i[e];if(Lh(t))for(let e of r(t))n.push(e)}for(let i of _g(zy(e,t).node)){if(i.when)for(let e of r(i.when))n.push(e);i.kind===`segment`&&n.push(...eW(e,i.name))}return nW(e,n)}function eW(e,t){let n=e.segments[t];return n?[n.template,n.when,n.bg,n.fg].flatMap(t=>t?[...sb(t,e.helpers).keys()]:[]):[]}function tW(e,t,n){return nW(e,[...eW(e,t),...n.flatMap(t=>[...sb(t,e.helpers).keys()])])}function nW(e,t){let n=new Map;for(let[t,r]of Object.entries(e.variables))n.set(t,r);for(let[t,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))n.set(`${t}.${e}`,i);let r=[...t],i=new Set,a=t=>sb(t,e.helpers).keys(),o=new Set;for(;r.length>0;){let e=r.pop();for(let t of iW(n,e)){if(i.has(t))continue;i.add(t);let e=n.get(t);if(e){if(e.kind===`input`)o.add(e.path);else if(e.kind===`template`)for(let t of a(e.template))r.push(t)}}}return o}function rW(e){let t=new Map;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=$U(e,n);return t.set(n,i),i}}function iW(e,t){let n=t;for(;n.length>0;){if(e.has(n))return[n];let t=n.lastIndexOf(`.`);if(t<0)break;n=n.slice(0,t)}let r=`${t}.`,i=[];for(let t of e.keys())t.startsWith(r)&&i.push(t);return i}function aW(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function oW(e){let t=t=>e.has(t),n=t(`git.staged`)||t(`git.unstaged`)||t(`git.untracked`)||t(`git.conflicts`);return{...t(`git.sha`)&&{showSha:!0},...n&&{showWorkingTree:!0},...t(`git.stash`)&&{showStashCount:!0},...(t(`git.upstream`)||t(`git.tracking`))&&{showUpstream:!0},...t(`git.repoName`)&&{showRepoName:!0},...t(`git.repoUrl`)&&{showRepoUrl:!0},...t(`git.operation`)&&{showOperation:!0},...t(`git.timeSinceCommit`)&&{showTimeSinceCommit:!0},...Object.keys(UU).some(e=>t(`git.${e}`))&&{showPullRequest:!0}}}async function sW(e,t,n,r,i,a,o,{configPath:s,...c}){let l=e=>aW(i,e),u=vO(t).getTime(),d=o.tmux??null,f=(e,t,n)=>t?n().catch(t=>L(`${e}: ${String(t)}`)):Promise.resolve(I),[p,m,h,g,_,v,y,b,ee,x,S]=await Promise.all([f(`git`,l(`git`),()=>n.gitProvider.getGitInfo(r??e.workspace?.current_dir,oW(i),e.workspace?.project_dir)),f(`session`,l(`session.cost`)||l(`session.tokens`)||l(`burn`),()=>n.usageStore.getUsageInfo(e.session_id,e)),f(`today`,l(`today`),()=>n.usageStore.getTodayInfo(e,o.claudeConfigDir,t)),f(`context`,l(`context`)||l(`autocompact`),()=>n.contextProvider.getContextInfo(e)),f(`metrics`,l(`metrics`)||l(`burn`),()=>n.metricsProvider.getMetricsInfo(e.session_id,e)),f(`activity`,l(`activity`),()=>n.activityProvider.getActivityInfo(e.session_id,e)),f(`tmux`,l(`tmux.session`),()=>d===null?Promise.resolve(I):n.tmuxService.getSessionName(d)),f(`cache`,l(`cache`),()=>LU(e.transcript_path)),f(`speed`,l(`speed`),()=>n.usageStore.observeSpeed(e.session_id,e.transcript_path,u)),f(`memento`,l(`memento`),()=>n.mementoProvider.getCeiling(xU({sessionId:e.session_id,projectDir:e.workspace?.project_dir??``,cwd:r??e.workspace?.current_dir??``},o))),f(`autocompact`,l(`autocompact`),()=>Promise.resolve(n.autoCompact(Sa(xa(o.claudeConfigDir)))))]),te=[],ne=e=>{if(e.kind===`failed`){te.push(e.reason);return}return e.kind===`ok`?e.value:void 0},C=hW(p,u);te.push(...C.failures);let re=QU(o);te.push(...re.failures);let ie=ne(m),ae=ne(h),w=ne(g),T=ne(_),oe=ne(v),E=ne(y),se=ne(b),ce=uW(x);x.kind===`failed`&&te.push(`memento: ${x.reason}`);let le=cW(S,w?.maxTokens);S.kind===`failed`&&te.push(`autocompact: ${S.reason}`);for(let e of te)n.log(`warn`,`provider fetch failed: ${e}`);let ue=e.rate_limits?.five_hour,de=e.rate_limits?.seven_day,fe=ue?KU(ue.used_percentage,ue.resets_at,18e6,u):void 0,pe=de?KU(de.used_percentage,de.resets_at,6048e5,u):void 0,me=ie?.session.cost,he=T?.sessionDuration,ge=l(`burn`)&&me!=null&&he!=null?qU(me,he):void 0,_e=ne(ee),ve=_e===void 0?void 0:YU(_e),ye=_e===void 0?void 0:XU(_e),be=ve!==void 0||ye!==void 0?{...ve,...ye!==void 0&&{history:ye}}:void 0,xe=mW(process.env.HOME??process.env.USERPROFILE),Se=e.workspace?{...e.workspace,current_dir:mW(e.workspace.current_dir)??``,project_dir:mW(e.workspace.project_dir)??``,added_dirs:(e.workspace.added_dirs??[]).map(e=>mW(e)??e)}:e.workspace,Ce=ie===void 0?void 0:pW({cost:ie.session.cost,tokens:ie.session.tokens}),we=ae===void 0?void 0:{cost:ae.cost,tokens:ae.tokens},Te=T===void 0?void 0:pW({lastResponseTime:T.lastResponseTime,responseTime:T.responseTime,sessionDuration:T.sessionDuration,messageCount:T.messageCount,nonPrompts:T.nonPrompts,linesAdded:T.linesAdded,linesRemoved:T.linesRemoved}),Ee=oe===void 0?void 0:dW(oe);return{...e,...Se!==void 0&&{workspace:Se},...xe!==void 0&&{home:xe},...C.git!==void 0&&{git:C.git},...d!==null&&{tmux:{pane:d.pane,...E!==void 0&&{session:E}}},host:re.host,...HU(a),history:n.history(e.session_id),navigation:{back:n.navigation(e.session_id)},feeds:n.feeds(e.session_id),...c,...s!==null&&{configPath:s},resumeCommand:BU(Se,e.session_id,o.claudeConfigDir),...Ce!==void 0&&{session:Ce},...we!==void 0&&{today:we},...ge!==void 0&&{burn:{costPerHour:ge}},...be!==void 0&&{speed:be},...l(`block`)&&ue!==void 0&&{block:{nativeUtilization:ue.used_percentage,resetsAt:ue.resets_at,...fe!==void 0&&{etaMinutes:fe}}},...de!==void 0&&{weekly:{percentage:de.used_percentage,resetsAt:de.resets_at,...pe!==void 0&&{etaMinutes:pe}}},...se!==void 0&&{cache:{expiresAt:se}},...w!==void 0&&{context:{totalTokens:w.totalTokens,contextLeft:w.contextLeftPercentage}},...Te!==void 0&&{metrics:Te},...Ee!==void 0&&{activity:Ee},...ce!==void 0&&{memento:ce},...le!==void 0&&{autocompact:le}}}function cW(e,t){switch(e.kind){case`absent`:return;case`failed`:return{error:e.reason};case`ok`:return nN(e.value,t)}}const lW=e=>e.trim().split(`
200
+ `,s.join(e,`lib`),t.sessionId,t.cwd],env:DU(t),timeoutMs:3e3,category:`memento.read`});return n.ok?kU(n.stdout):L(OU(n))}function jU(e,t,n){let r=ut({bin:s.join(e,CU),args:n.kind===`set`?[`set`,`session`,n.to]:[`clear`,`session`],env:DU(t),timeoutMs:5e3,category:`memento.move`});if(!r.ok)throw Error(OU(r))}function MU(e,t){return EU(Ca(e),t)}function NU(){return{locate:e=>MU(e.claudeConfigDir,e.projectDir),read:AU,move:jU}}function PU(e){return{gitProvider:new fO({watchers:e.watchers,logger:e.logger}),usageStore:new QH({logger:e.logger}),contextProvider:new tU({logger:e.logger}),metricsProvider:new oU({logger:e.logger}),activityProvider:new fU({logger:e.logger}),tmuxService:new vU,mementoProvider:new bU(NU()),autoCompact:eN,log:e.logger}}const FU=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function IU(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t.message?.usage;if(!((n?.cache_read_input_tokens??0)>0||(n?.cache_creation_input_tokens??0)>0))return null;let r=t.timestamp==null?NaN:Date.parse(t.timestamp);return Number.isNaN(r)?null:r}async function LU(e){let t=await RU(e);return t.kind===`ok`?F(Math.floor((t.value+36e5)/1e3)):t}async function RU(e){for(let t of[65536,1048576]){let n=await _a(e,t);if(n.kind!==`ok`)return n;let r=zU(n.value.buf,n.value.fromStart);if(r!=null)return F(r);if(n.value.fromStart)return I}return I}function zU(e,t){let n=e.toString(`utf8`).split(`
201
+ `),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!FU.test(t))continue;let r=IU(t);if(r!=null)return r}return null}function BU(e,t,n){return Me({dir:e.project_dir,env:n===void 0?[]:[[ya,n]],program:`claude`,args:[`--resume`,t,...e.added_dirs.flatMap(e=>[`--add-dir`,e])]})}function VU(e,t){return{endcaps:e.endcaps,separator:e.separator,colorCompatibility:e.colorCompatibility,wrap:e.autoWrap,padding:e.padding,width:t}}function HU(e){return{...Object.fromEntries(Q_.map(t=>[t,{effective:e[t]}])),preset:{effective:e.preset,customized:e.presetCustomized,bundled:IB(e.preset)}}}const UU={prNumber:!0,prState:!0,prUrl:!0,prError:!0,prEarlier:!0};function WU(e){return e?.prState===void 0?e?.prError===void 0?e?.prEarlier===void 0?`-`:`earlier-${e.prEarlier}`:`failed`:e.prState}const GU=10*1e3;function KU(e,t,n,r){let i=n-(t*1e3-r);if(i<3e5||e<=0)return;let a=e/i,o=(100-e)/a;return Math.max(0,Math.round(o/6e4))}function qU(e,t){if(!(t<60))return e*3600/t}function JU(e,t,n,r){let i=r-t;if(i<50||i>GU)return;let a=n-e;if(!(a<=0))return a*1e3/i}function YU(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=JU(t.input,t.atMs,n.input,n.atMs),i=JU(t.output,t.atMs,n.output,n.atMs),a=JU(t.total,t.atMs,n.total,n.atMs);if(!(r===void 0&&i===void 0&&a===void 0))return{...r!==void 0&&{input:r},...i!==void 0&&{output:i},...a!==void 0&&{total:a}}}function XU(e){let{samples:t}=e,n=[];for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=i.atMs-r.atMs;if(a<50||a>GU)continue;let o=JU(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function ZU(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function QU(e){let t=[],n=(e,n)=>{try{let e=n();return e===``?void 0:e}catch(n){t.push(`host.${e}: ${String(n)}`);return}},r=n(`name`,()=>ZU(C.hostname())),i=n(`user`,()=>C.userInfo().username);return{host:{...r!==void 0&&{name:r},...i!==void 0&&{user:i},...e.ssh!==void 0&&{ssh:e.ssh}},failures:t}}function $U(e,t){let n=[],r=t=>sb(t,e.helpers).keys(),i=By(e,t);for(let e of Ih){let t=i[e];if(Lh(t))for(let e of r(t))n.push(e)}for(let i of _g(zy(e,t).node)){if(i.when)for(let e of r(i.when))n.push(e);i.kind===`segment`&&n.push(...eW(e,i.name))}return nW(e,n)}function eW(e,t){let n=e.segments[t];return n?[n.template,n.when,n.bg,n.fg].flatMap(t=>t?[...sb(t,e.helpers).keys()]:[]):[]}function tW(e,t,n){return nW(e,[...eW(e,t),...n.flatMap(t=>[...sb(t,e.helpers).keys()])])}function nW(e,t){let n=new Map;for(let[t,r]of Object.entries(e.variables))n.set(t,r);for(let[t,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))n.set(`${t}.${e}`,i);let r=[...t],i=new Set,a=t=>sb(t,e.helpers).keys(),o=new Set;for(;r.length>0;){let e=r.pop();for(let t of iW(n,e)){if(i.has(t))continue;i.add(t);let e=n.get(t);if(e){if(e.kind===`input`)o.add(e.path);else if(e.kind===`template`)for(let t of a(e.template))r.push(t)}}}return o}function rW(e){let t=new Map;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=$U(e,n);return t.set(n,i),i}}function iW(e,t){let n=t;for(;n.length>0;){if(e.has(n))return[n];let t=n.lastIndexOf(`.`);if(t<0)break;n=n.slice(0,t)}let r=`${t}.`,i=[];for(let t of e.keys())t.startsWith(r)&&i.push(t);return i}function aW(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function oW(e){let t=t=>e.has(t),n=t(`git.staged`)||t(`git.unstaged`)||t(`git.untracked`)||t(`git.conflicts`);return{...t(`git.sha`)&&{showSha:!0},...n&&{showWorkingTree:!0},...t(`git.stash`)&&{showStashCount:!0},...(t(`git.upstream`)||t(`git.tracking`))&&{showUpstream:!0},...t(`git.repoName`)&&{showRepoName:!0},...t(`git.repoUrl`)&&{showRepoUrl:!0},...t(`git.operation`)&&{showOperation:!0},...t(`git.timeSinceCommit`)&&{showTimeSinceCommit:!0},...Object.keys(UU).some(e=>t(`git.${e}`))&&{showPullRequest:!0}}}async function sW(e,t,n,r,i,a,o,{configPath:s,...c}){let l=e=>aW(i,e),u=vO(t).getTime(),d=o.tmux??null,f=(e,t,n)=>t?n().catch(t=>L(`${e}: ${String(t)}`)):Promise.resolve(I),[p,m,h,g,_,v,y,b,ee,x,S]=await Promise.all([f(`git`,l(`git`),()=>n.gitProvider.getGitInfo(r??e.workspace?.current_dir,oW(i),e.workspace?.project_dir)),f(`session`,l(`session.cost`)||l(`session.tokens`)||l(`burn`),()=>n.usageStore.getUsageInfo(e.session_id,e)),f(`today`,l(`today`),()=>n.usageStore.getTodayInfo(e,o.claudeConfigDir,t)),f(`context`,l(`context`)||l(`autocompact`),()=>n.contextProvider.getContextInfo(e)),f(`metrics`,l(`metrics`)||l(`burn`),()=>n.metricsProvider.getMetricsInfo(e.session_id,e)),f(`activity`,l(`activity`),()=>n.activityProvider.getActivityInfo(e.session_id,e)),f(`tmux`,l(`tmux.session`),()=>d===null?Promise.resolve(I):n.tmuxService.getSessionName(d)),f(`cache`,l(`cache`),()=>LU(e.transcript_path)),f(`speed`,l(`speed`),()=>n.usageStore.observeSpeed(e.session_id,e.transcript_path,u)),f(`memento`,l(`memento`),()=>n.mementoProvider.getCeiling(xU({sessionId:e.session_id,projectDir:e.workspace?.project_dir??``,cwd:r??e.workspace?.current_dir??``},o))),f(`autocompact`,l(`autocompact`),()=>Promise.resolve(n.autoCompact(Sa(xa(o.claudeConfigDir)))))]),te=[],ne=e=>{if(e.kind===`failed`){te.push(e.reason);return}return e.kind===`ok`?e.value:void 0},C=hW(p,u);te.push(...C.failures);let re=QU(o);te.push(...re.failures);let ie=ne(m),ae=ne(h),w=ne(g),T=ne(_),oe=ne(v),E=ne(y),se=ne(b),ce=uW(x);x.kind===`failed`&&te.push(`memento: ${x.reason}`);let le=cW(S,w?.maxTokens);S.kind===`failed`&&te.push(`autocompact: ${S.reason}`);for(let e of te)n.log(`warn`,`provider fetch failed: ${e}`);let ue=e.rate_limits?.five_hour,de=e.rate_limits?.seven_day,fe=ue?KU(ue.used_percentage,ue.resets_at,18e6,u):void 0,pe=de?KU(de.used_percentage,de.resets_at,6048e5,u):void 0,me=ie?.session.cost,he=T?.sessionDuration,ge=l(`burn`)&&me!=null&&he!=null?qU(me,he):void 0,_e=ne(ee),ve=_e===void 0?void 0:YU(_e),ye=_e===void 0?void 0:XU(_e),be=ve!==void 0||ye!==void 0?{...ve,...ye!==void 0&&{history:ye}}:void 0,xe=mW(process.env.HOME??process.env.USERPROFILE),Se=e.workspace?{...e.workspace,current_dir:mW(e.workspace.current_dir)??``,project_dir:mW(e.workspace.project_dir)??``,added_dirs:(e.workspace.added_dirs??[]).map(e=>mW(e)??e)}:e.workspace,Ce=ie===void 0?void 0:pW({cost:ie.session.cost,tokens:ie.session.tokens}),we=ae===void 0?void 0:{cost:ae.cost,tokens:ae.tokens},Te=T===void 0?void 0:pW({lastResponseTime:T.lastResponseTime,responseTime:T.responseTime,sessionDuration:T.sessionDuration,messageCount:T.messageCount,nonPrompts:T.nonPrompts,linesAdded:T.linesAdded,linesRemoved:T.linesRemoved}),Ee=oe===void 0?void 0:dW(oe);return{...e,...Se!==void 0&&{workspace:Se},...xe!==void 0&&{home:xe},...C.git!==void 0&&{git:C.git},...d!==null&&{tmux:{pane:d.pane,...E!==void 0&&{session:E}}},host:re.host,...HU(a),history:n.history(e.session_id),navigation:{back:n.navigation(e.session_id)},feeds:n.feeds(e.session_id),...c,...s!==null&&{configPath:s},resumeCommand:BU(Se,e.session_id,o.claudeConfigDir),...Ce!==void 0&&{session:Ce},...we!==void 0&&{today:we},...ge!==void 0&&{burn:{costPerHour:ge}},...be!==void 0&&{speed:be},...l(`block`)&&ue!==void 0&&{block:{nativeUtilization:ue.used_percentage,resetsAt:ue.resets_at,...fe!==void 0&&{etaMinutes:fe}}},...de!==void 0&&{weekly:{percentage:de.used_percentage,resetsAt:de.resets_at,...pe!==void 0&&{etaMinutes:pe}}},...se!==void 0&&{cache:{expiresAt:se}},...w!==void 0&&{context:{totalTokens:w.totalTokens,contextLeft:w.contextLeftPercentage}},...Te!==void 0&&{metrics:Te},...Ee!==void 0&&{activity:Ee},...ce!==void 0&&{memento:ce},...le!==void 0&&{autocompact:le}}}function cW(e,t){switch(e.kind){case`absent`:return;case`failed`:return{error:e.reason};case`ok`:return tN(e.value,t)}}const lW=e=>e.trim().split(`
197
202
  `).at(-1).trim();function uW(e){switch(e.kind){case`absent`:return;case`failed`:return{error:lW(e.reason)};case`ok`:{let{ceiling:t,session:n}=e.value;return{ceiling:t===`off`?0:t,off:t===`off`,session:n??``}}}}function dW(e){let t=e.todos.findIndex(e=>e.active),n=e.todos.length===0?void 0:{total:e.todos.length,completed:e.todos.filter(e=>e.done).length,...t>=0&&{position:t+1,active:e.todos[t].text}},r=fW(e.running),i=fW(e.done),a=r===void 0&&i===void 0?void 0:{...r!==void 0&&{running:r},...i!==void 0&&{done:i}};if(!(e.command===null&&n===void 0&&a===void 0))return{...e.command!==null&&{command:e.command},...n!==void 0&&{todo:n},...a!==void 0&&{tool:a}}}function fW(e){return e.length===0?void 0:e.map(e=>`${e.name}:${e.count}`).join(`,`)}function pW(e){let t={},n=!1;for(let r of Object.keys(e)){let i=e[r];i!=null&&(t[r]=i,n=!0)}return n?t:void 0}function mW(e){return e===void 0||e.length===0||s.sep!==`\\`?e:e.replace(/\\/g,`/`)}function hW(e,t){if(e.kind===`absent`)return{failures:[]};if(e.kind===`failed`)return{failures:[e.reason]};let n=e.value,r=[],i=(e,t)=>{if(!(t===void 0||t.kind===`absent`)){if(t.kind===`failed`){r.push(`git.${e}: ${t.reason}`);return}return t.value}},a=i(`aheadBehind`,n.aheadBehind),o=i(`sha`,n.sha),s=i(`operation`,n.operation),c=i(`timeSinceCommit`,n.committedAt),l=c===void 0?void 0:Math.floor((t-c)/1e3),u=i(`stash`,n.stashCount),d=i(`upstream`,n.upstream),f=n.upstream===void 0?void 0:i(`tracking`,TD(n.upstream,n.aheadBehind)),p=i(`repoName`,n.repoName),m=i(`repoUrl`,n.repoUrl),h=n.pullRequest===void 0?void 0:ED(n.pullRequest,n.head),g={};switch(h?.kind){case`ok`:g={prNumber:h.value.number,prState:h.value.state,prUrl:h.value.url};break;case`failed`:r.push(`git.pr: ${h.reason}`),g={prError:h.reason};break;case`earlier`:g={prEarlier:h.value.state};break;case`absent`:case void 0:break}return{git:{branch:n.branch,status:n.status,...a!==void 0&&{ahead:a.ahead,behind:a.behind},...n.workingTree!==void 0&&{staged:n.workingTree.staged,unstaged:n.workingTree.unstaged,untracked:n.workingTree.untracked,conflicts:n.workingTree.conflicts},...o!==void 0&&{sha:o},...s!==void 0&&{operation:s},...l!==void 0&&{timeSinceCommit:l},...u!==void 0&&{stash:u},...d!==void 0&&{upstream:d},...f!==void 0&&{tracking:f},...p!==void 0&&{repoName:p},...m!==void 0&&{repoUrl:m},...g},failures:r}}function gW(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}const _W={kind:`hidden`},vW={kind:`shown`};function yW(e,t){try{return gW(e,t)?vW:_W}catch(e){return{kind:`failed`,message:e instanceof Error?e.message:String(e)}}}function bW(e,t){let n=G.fromFragments(e);return n.end=``,n.overflow=`ignore`,t!==void 0&&!t.isNull&&(n.style=t),n}function xW(e,t,n){e.cellLength>t?e.truncate(t,{mode:n.truncate,marker:`…`}):e.cellLength<t&&e.align(n.justify,t)}function SW({lead:e,text:t,trail:n}){return[...e===void 0?[]:[e],t,...n===void 0?[]:[n]]}function CW({text:e,placement:t,lead:n,trail:r}){return{text:wW(e),placement:t,...n!==void 0&&{lead:wW(n)},...r!==void 0&&{trail:wW(r)}}}function wW(e){let t=e.blankCopy(e.plain);t.style=Dv(e.style).clearMetaAndLinks();for(let{start:n,end:r,style:i}of e.spans)t.stylize(Dv(i).clearMetaAndLinks(),n,r);return t}function TW(e){let t=SW(e);if(t.length===1)return e.text;let n=bW(t);return n.style=e.text.style,n}function EW(e,t){let{width:n,justify:r,truncate:i,baseStyle:a,padding:o,placement:s,lead:c=[],trail:l=[]}=t;if(e.length===0)return[];let u=bW(e,a).pad(o),d=new G(` `.repeat(o)),f={placement:s,...c.length>0&&{lead:bW([d,...c],a)},...l.length>0&&{trail:bW([...l,d],a)}};if(n===`auto`)return[{text:u,...f}];let p={justify:r,truncate:i};return n===`fill`?[{text:u,fill:p,...f}]:(xW(u,n,p),[{text:u,...f}])}const DW=RegExp(`\\x1b\\[[0-9;]*m|${ad.source}`,`g`);function OW(e){return Math.max(0,...e.split(`
198
- `).map(e=>R(e.replace(DW,``))))}function kW(e,t){let n=()=>e.map(e=>({owner:TW(e),placement:e.placement})),r=[];if(e.forEach(({fill:e},t)=>{e!==void 0&&r.push({at:t,how:e})}),r.length===0||!Number.isFinite(t.width))return n();let i=Zv(e.map(TW),t).split(`
199
- `);if(i.length>1)return n();let a=Math.max(0,t.width-OW(i[0]??``)),o=Math.floor(a/r.length),s=a-o*r.length;return r.forEach(({at:t,how:n},i)=>{let a=o+(i===r.length-1?s:0),{text:c}=e[t];xW(c,c.cellLength+a,n)}),n()}function AW(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=jW(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e){let e={frag:a,style:Dv(a.style)};if(e.style.link){i();let r=jW([e],t);r.plain.length>0&&n.push(r)}else r.push(e)}return i(),n}function jW(e,t){let n=t!==void 0&&!t.isNull?t:void 0,r=e.map(e=>MW(e.frag,n?n.add(e.style):e.style)),i=G.fromFragments(r);return i.end=``,i.overflow=`ignore`,r.length===1?i.style=r[0].style:n!==void 0&&(i.style=n),i}function MW(e,t){let n=e.copy();return n.style=t,n}function NW(e,t){if(e.bound===void 0)throw Error(`${t} ran outside a render: no render bound its store and clocks`);return e.bound}function PW(e,t){let{look:n}=NW(e,t);if(n===void 0)throw Error(`${t} read the render's look before it was resolved`);return n}function FW(e,t){let{layout:n}=NW(e,t);if(n===void 0)throw Error(`${t} read the render's rows before they were laid`);return n()}function IW(e,t){if(e.bound!==void 0)throw Error(`a render bound a compile another render holds`);return e.bound=t,{[Symbol.dispose]:()=>{e.bound=void 0}}}function LW(e,t,n,r){let i=new Map,a=Object.entries(t);for(let[t,o]of[...a.filter(([,e])=>!(`do`in e)),...a.filter(([,e])=>`do`in e)])i.set(t,RW(e,t,o,n,r,i));return i}function RW(e,t,n,r,i,a){if(`set`in n){let e=r.get(n.set)??n.set;if(`to`in n)return{kind:`set-literal`,key:n.set,value:n.to,stateVar:e};if(`from`in n){let t=Ky(n.from,i);return{kind:`set-option`,key:n.set,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,library:t.library}}return`int`in n?{kind:`set-int`,key:n.set,stateVar:e}:`cycle`in n?{kind:`set-cycle`,key:n.set,stateVar:e,members:n.cycle}:{kind:`set-bounded`,key:n.set,by:n.by}}if(`persist`in n){let e=fv.get(n.persist)??n.persist;if(`to`in n)return{kind:`persist-literal`,key:n.persist,value:n.to,stateVar:e};if(`from`in n){let t=Ky(n.from,i);return{kind:`persist-option`,key:n.persist,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,library:t.library}}if(`cycle`in n)return{kind:`persist-cycle`,key:n.persist,stateVar:e,members:n.cycle};if(`removeSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`remove`,target:n.removeSegment}};if(`insertSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`insert`,segment:n.insertSegment,anchor:n.anchor,relation:n.relation}};if(`insertSegmentFrom`in n){let e=Ky(n.insertSegmentFrom,i);return{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...e.members],paletteOf:e.paletteOf,library:e.library}}return{kind:`persist-bounded`,key:n.persist,by:n.by}}if(`copy`in n)return{kind:`copy`,text:VW(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:VW(e,n.open,t)};if(`reset`in n)return{kind:`reset`,key:n.reset};if(`doctor`in n)switch(n.doctor){case`run`:return{kind:`doctor-run`};case`fix`:return{kind:`doctor-fix`,check:n.check};case`mark`:return{kind:`doctor-mark`,check:n.check,mark:n.mark}}if(`ceiling`in n)return{kind:`ceiling`,args:RL(n)};if(`slash`in n)return{kind:`slash`,line:n.slash};if(`undo`in n)return{kind:`undo`};if(`redo`in n)return{kind:`redo`};if(`back`in n)return{kind:`back`};if(`rewind`in n)return{kind:`rewind`};if(`save`in n)return{kind:`save`};if(`preset`in n)return n.preset===`save`?{kind:`preset-save`}:{kind:`preset-delete`,name:VW(e,n.name,t)};if(`themeDefault`in n)return{kind:`theme-default-save`};let[o,...s]=n.do.map(e=>{let n=a.get(e);if(n===void 0)throw Error(`action "${t}" fires "${e}", which is not declared in this config`);return n});return{kind:`do`,head:o,rest:s}}function zW(e){return e.kind===`do`?zW(e.head):e}function BW(e){switch(zW(e).kind){case`set-option`:case`set-int`:case`persist-option`:case`layout-op-option`:return!0;case`set-literal`:case`set-bounded`:case`set-cycle`:case`copy`:case`open`:case`persist-literal`:case`persist-bounded`:case`persist-cycle`:case`reset`:case`layout-op`:case`undo`:case`redo`:case`back`:case`rewind`:case`save`:case`preset-save`:case`preset-delete`:case`theme-default-save`:case`doctor-run`:case`doctor-fix`:case`doctor-mark`:case`ceiling`:case`slash`:case`do`:return!1}}function VW(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function HW(e,t){return e.has(t)?wb(e.read(t)):``}function UW(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function WW(e,t,n,r){let i=new G(e,{style:H.combine([r,new H({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function GW(e,t,n=!1){let r=new H({link:t,bold:n?!0:void 0}),i=new G(e.plain,{style:H.combine([Dv(e.style),r])});for(let t of e.spans)i.stylize(H.combine([Dv(t.style),r]),t.start,t.end);return i.overflow=`ignore`,i.end=``,i}function KW(e,t){return Math.max(e.members.indexOf(HW(t,e.stateVar)),0)}function qW(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=HW(r,e.stateVar);return{effects:[{verb:mr,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=HW(r,e.stateVar);return{effects:[{verb:mr,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=HW(r,e.stateVar);return{effects:[{verb:mr,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(KW(e,r)+1)%e.members.length];return{effects:[{verb:mr,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:hr,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:gr,args:[UW(e.text,vD(r))]}],active:!1};case`open`:return{effects:[{verb:_r,args:[UW(e.target,vD(r))]}],active:!1};case`persist-literal`:{let t=HW(r,e.stateVar);return{effects:[{verb:xr,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=HW(r,e.stateVar);return{effects:[{verb:xr,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(KW(e,r)+1)%e.members.length];return{effects:[{verb:xr,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:Sr,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:Dr,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:kr,args:[i]}],active:!1};case`redo`:return{effects:[{verb:Ar,args:[i]}],active:!1};case`back`:return{effects:[{verb:jr,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:Mr,args:[i]}],active:!1};case`save`:return{effects:[{verb:Cr,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:wr,args:[i]}],active:!1};case`theme-default-save`:return{effects:[{verb:Tr,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:Er,args:[i,UW(e.name,vD(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:Pr,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:Fr,args:[i,e.check]}],active:!1};case`doctor-mark`:return{effects:[{verb:Ir,args:[i,e.check,e.mark]}],active:!1};case`ceiling`:return{effects:[{verb:Rr,args:[i,...e.args]}],active:!1};case`slash`:return{effects:[{verb:zr,args:[i,e.line]}],active:!1};case`layout-op`:return{effects:[{verb:Or,args:[i,e.key,xF(e.op)]}],active:!1};case`do`:{let a=qW(e.head,t,n,r,i);return{effects:[...a.effects,...e.rest.flatMap(e=>qW(e,t,void 0,r,i).effects)],active:a.active}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:Or,args:[i,e.key,xF(r)]}],active:!1}}}}function JW(e,t,n,r){if(n.length===0)throw Error(`action "${e}" needs a display (the clickable text)`);if(t.kind===`set-cycle`||t.kind===`persist-cycle`)return{display:Xr(`action "${e}"`,n,t.members.length,KW(t,r)),boundValue:void 0};if(n.length>2)throw Error(`action "${e}" takes a display and an optional bound value, got ${n.length} arguments (per-state displays are a cycle action's form)`);return{display:n[0],boundValue:n[1]?.plain}}function YW(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=NW(n,`action "${e}"`).store,{display:a,boundValue:o}=JW(e,zW(r),t,i),s=HW(i,`session.id`),{effects:c,active:l}=qW(r,a.plain,o,i,s);return GW(a,Hr(c),l)}function XW(e){return{action:{fn:(t,...n)=>YW(t,n,e),argTypes:[`string`,`liftable`],arity:{kind:`variadic`},returnType:`T`}}}function ZW(e,t){return WW(`✕`,Hr([{verb:mr,args:[HW(e,`session.id`),t,P]}]),!1)}function QW(e,t,n){return new H({bgcolor:V.fromRgba(t),color:V.fromRgba(th(e,t,n))})}function $W({tint:e,text:t}){return new H({bgcolor:V.fromRgba(e),color:V.fromRgba(t)})}function eG(e,t,n){return new H({color:V.fromRgba(Uc(Gm(e,`warning`),t,eh,n))})}function tG(e,t,n){return H.combine([QW(e,t,n),eG(e,t,n)])}function nG(e,t,n){return QW(e.palette,Sh(e.palette,e.disclosure,[t],n),n)}function rG(e){let t=V.fromRgba(Gm(e,`background`)),n=G.fromFragments(vm.map(n=>new G(`▀`,{style:new H({color:V.fromRgba(Gm(e,n)),bgcolor:t})})));return n.overflow=`ignore`,n.end=``,n}const iG=(e,t)=>{let n=typeof e==`string`?new G(e,{style:t}):e;return n.overflow=`ignore`,n.end=``,n},aG=e=>new H({bold:e});function oG(e,t,n,r,i,a){if(r===void 0)return(n,r,a,o)=>iG(a,H.combine([nG(e,{...n,distribution:t},i),aG(o)]));let o=QW(e.palette,a,i);return(e,t,i,a)=>sG(i,H.combine([o,aG(a)]),r(t,n))}const sG=(e,t,n)=>iG(G.fromFragments([iG(e,t),iG(` `,t),rG(n)]));function cG(e,t){return t===void 0?(e,t,n)=>iG(n):(n,r,i)=>sG(i,void 0,t(r,e))}function lG(e,t,n,r,i){let a=QW(e.palette,i,r);return(e,r,i,o)=>iG(G.fromFragments([iG(o?`[`:` `,a),rG(n(r,t)),iG(o?`]`:` `,a)]))}function uG(e,t,n){let r=t.map(t=>({label:t.label,indices:e.flatMap((e,n)=>e.group===t.id?[n]:[])})).filter(e=>e.indices.length>0);if(r.reduce((e,t)=>e+t.indices.length,0)!==e.length){let n=new Set(t.map(e=>e.id)),r=e.flatMap((e,t)=>n.has(e.group)?[]:[`#${t} (group "${e.group}")`]);throw Error(`library: ${r.join(`, `)} name a group the domain does not list (${[...n].join(`, `)})`)}return n?r.flatMap(e=>dG(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function dG(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function fG(e,t){return new G(e).truncate(t,{marker:`…`}).plain}function pG(e){return{current:null,drawnAt:e}}function mG(e,t,n,r,i,a,o){let s={segName:t,placementId:n,palette:r,disclosure:i,tint:a,text:o,bg:void 0,drops:[]};return e.current=s,s}function hG(e,t){let n=e.current;if(n===null)throw Error(`${t} is only available inside a segment's templates — there is no active segment here. Segment-scoped functions cannot be used in variable declarations or layout-node "when" predicates, which are evaluated outside any segment.`);return n}function gG(e){return new G(e).cellLength}function _G(e){let{width:t,chromeCols:n,padding:r}=NW(e,`a row fit`);return Math.max(1,t-n-2*r)}function vG(e){let{padding:t,seamCols:n}=NW(e,`a row fit`);return Math.max(1,_G(e)-(gG(`✕`)+2*t+n))}function yG(e,t,n){if(!Number.isFinite(t))return e.length>0?[e.map((e,t)=>t)]:[];let r=Math.max(1,t-n),i=[],a=[],o=0;for(let t=0;t<e.length;t++){let n=e[t];a.length===0?(a=[t],o=n):o+1+n<=r?(a.push(t),o+=1+n):(i.push(a),a=[t],o=n)}return a.length>0&&i.push(a),i}function bG(e,t,n){let r=gG(`←`)+1+gG(`→`)+1,i=yG(e,t,n);return(i.length>1?yG(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function xG(e,t){let n=[];for(let t of e)n.length>0&&n.push(new G(` `)),n.push(t);let r=G.fromFragments(n);return r.overflow=t?`ignore`:void 0,r.end=``,r}function SG(e,t,n,r,i){let a=e.compiled.get(t);if(!a||a.kind!==n)throw Error(`${i} references action "${t}" which must be ${r}, got ${a?`a ${a.kind} action`:`no such action`}`);return a}function CG(e,t,n){let r=e.compiled.get(t),i=r&&zW(r);if(!i||i.kind!==`set-option`&&i.kind!==`persist-option`&&i.kind!==`layout-op-option`)throw Error(`${n} references action "${t}" which must be a set-option, persist-option, or layout-op-option action ({ set, from }, { persist, from }, or { persist, insertSegmentFrom, anchor, relation }), got ${i?`a ${i.kind} action`:`no such action`}`);return i}function wG(e,t,n,r,i,a,o,s,c=[]){let l=a.compiled.get(e),u=NW(a,`picker`).store,d=HW(u,`session.id`),f=`stateVar`in t?HW(u,t.stateVar):void 0,p=(e,n)=>{let r=t.options[e];return o({index:e,count:t.options.length},r,n,r===f)},m=i?r.kind===`led`?vG(a):_G(a):1/0,h=(r.kind===`led`?0:gG(`✕`)+1)+c.reduce((e,t)=>e+gG(t.glyph)+1,0),g=t.library&&{groups:t.library.groups,entries:t.options.map(t.library.entry)},_=g===void 0?t.options.map((e,t)=>p(t,e)):[],v=g===void 0?bG(_.map(e=>e.cellLength),m,h):uG(g.entries,g.groups,i),y=parseInt(HW(u,n.stateVar),10),b=e=>Math.max(0,v.findIndex(t=>t.some(t=>t.indices.includes(e)))),ee=b(f===void 0?-1:t.options.indexOf(f)),x=Number.isInteger(y)?y<0?ee:Math.min(y,v.length-1):0,S=v[x]??[],te=e=>Hr([{verb:mr,args:[d,n.key,String(e)]}]),ne=r.kind===`led`?[]:[{verb:mr,args:[d,...r.writes.flatMap(([e,t])=>[e,t])]}],C=r.kind===`own`&&r.onPick?ne:[],re=e=>Hr([...qW(l,e,e,u,d).effects,...C]),ie=(e,n)=>GW(e,re(t.options[n])),ae=r.kind===`led`?[]:[WW(`✕`,Hr(ne),!1,s)];ae.push(...c.map(({glyph:e,option:r})=>WW(e,Hr([...qW(l,r,r,u,d).effects,{verb:mr,args:[d,n.key,String(b(t.options.indexOf(r)))]}]),!1))),x>0&&ae.push(WW(`←`,te(x-1),!1));let w=x<v.length-1?[WW(`→`,te(x+1),!1)]:[];if(g===void 0){let e=S.flatMap(e=>e.indices);return[xG([...ae,...e.map(e=>ie(_[e],e)),...w],i)]}let T=new H({bold:!0}),oe=v.length>1?` ${x+1}/${v.length}`:``,E=S.length===1?[new G(`${S[0].label}${oe}`,{style:T})]:[],se=[xG([...ae,...E,...w],i)];for(let e of S){S.length>1&&se.push(xG([new G(e.label,{style:T})],i));let n=Math.max(...e.indices.map(e=>gG(t.options[e])));for(let r of e.indices){let e=t.options[r],a=g.entries[r].description,o=a===void 0?void 0:vv(a),s=` `.repeat(n-gG(e)+2),c=o===void 0?e:`${e}${s}${o}`;se.push(xG([ie(p(r,fG(c,m)),r)],i))}}return se}function TG(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{fD(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=SG(e,r,`set-int`,`an int action ({ set, int: true })`,`picker`);if(o===!0&&i===!0)throw Error(`{{ picker "${n}" … }} sets both closeOnPick and inBody; a picker in a body is closed by the body's ✕, so it has no close to fold into a pick`);let l=CG(e,n,`picker`);if(l.library!==void 0)throw Error(`{{ picker "${n}" … }} ranges a catalogue domain, which lays out as one row per member; a catalogue renders in a {{ menu }} body`);let u=hG(t,`{{ picker }}`);if(u.bg===void 0)throw Error(`{{ picker }} is not available while segments.${u.segName}'s own "bg:" is being evaluated — a picker is drawn on that background`);let[d]=wG(n,l,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,oG(u,Nm(void 0),PW(e,`{{ picker }}`),l.paletteOf,t.drawnAt(),u.bg),eG(u.palette,u.bg,t.drawnAt()));return d},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function EG(e,t){let n=e.length,r=Math.max(e.indexOf(t),0);return e=>((r+e)%n+n)%n}function DG(e,t,n,r,i){let a=Math.min(Math.floor((t-1)/2),i),o=n,s=0;for(;s<a;){let t=o+e(-(s+1))+1+e(s+1)+1;if(t>r)break;o=t,s+=1}return s}function OG(e,t,n,r,i,a){if(!(`stateVar`in t))throw Error(`carousel references action "${e}", which inserts a segment and holds no current value to centre on — a carousel needs a { set, from } or { persist, from } action`);let o=NW(n,`carousel`).store;if(!o.has(t.stateVar))throw Error(`carousel references action "${e}", whose key "${t.stateVar}" no variable reads back, so there is no current value to centre on — declare { kind: "state", key: "${t.stateVar}" } among the variables`);let s=n.compiled.get(e),c=HW(o,`session.id`),{options:l}=t,u=l.length;if(u===0)return xG([],!0);let d=HW(o,t.stateVar),f=EG(l,d),p=e=>l[f(e)],m=new Map,h=e=>{let t=m.get(e);if(t!==void 0)return t;let n=Hr(qW(s,p(e),p(e),o,c).effects);return m.set(e,n),n},g=e=>r({index:f(e),count:u},p(e),p(e),p(e)===d),_=new Map,v=e=>{let t=_.get(e);if(t!==void 0)return t;let n=GW(g(e),h(e));return _.set(e,n),n},y=a===void 0?v(0):GW(cG(PW(n,`{{ carousel }}`),t.paletteOf)({index:f(0),count:u},p(0),p(0),!1),Hr(qW(n.compiled.get(a),p(0),void 0,o,c).effects)),b=DG(e=>v(e).cellLength,u,gG(`◀`)+1+y.cellLength+1+gG(`▶`),vG(n),i),ee=e=>Array.from({length:b},(t,n)=>v(e*(n+1)));return xG([...ee(-1).reverse(),WW(`◀`,h(-1),!1),y,WW(`▶`,h(1),!1),...ee(1)],!0)}function kG(e,t){return{carousel:{fn:(n,...r)=>{let[i,a,...o]=r;if(fD(`carousel "${n}"`,[`neighbours`,`centre`],o),i!==void 0&&!(Number.isInteger(i)&&i>=0))throw Error(`carousel "${n}": neighbours must be a whole number ≥ 0 (0 shows only ◀ CURRENT ▶), got ${String(i)}`);if(a!==void 0&&!(typeof a==`string`&&e.compiled.has(a)))throw Error(`carousel "${n}": centre must name a declared action, got ${JSON.stringify(a)}`);if(a!==void 0&&BW(e.compiled.get(a)))throw Error(`carousel "${n}": centre "${a}" writes a value the template binds, and the centre binds none — name an action that writes a fixed value, a cycle, or a do of them`);let s=i??1/0,c=CG(e,n,`carousel`),l=hG(t,`{{ carousel }}`);if(l.bg===void 0)throw Error(`{{ carousel }} is not available while segments.${l.segName}'s own "bg:" is being evaluated — a carousel is drawn on that background`);return OG(n,c,e,oG(l,Nm(void 0),PW(e,`{{ carousel }}`),c.paletteOf,t.drawnAt(),l.bg),s,a)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function AG(e,t,n){let r=CG(e,t,n);if(!(`stateVar`in r))throw Error(`${n} references action "${t}", which inserts a segment and holds no current value — a ${n} needs a { set, from } or { persist, from } action`);if(r.paletteOf===void 0)throw Error(`${n} references action "${t}", whose options are not colour-valued — a swatch draws the palette an option puts in force, as the "themes", "placementThemes" and "styles" domains do`);return r}function jG(e,t,n){let r=Math.imul(e^e>>>16,73244475);return r=Math.imul(r^r>>>16,73244475),r^=r>>>16,(n+1+(r>>>0)%Math.max(t-1,1))%t}function MG(e,t,n,r){let i=AG(e,t,n),a=r??HW(NW(e,n).store,i.stateVar);if(!i.options.includes(a))throw Error(`${n} "${t}": "${a}" is not one of its options, so it has no palette to draw`);return i.paletteOf(a,PW(e,`{{ ${n} }}`))}function NG(e,t,n){return{swatch:{fn:(t,...n)=>{let[r,...i]=n;if(fD(`swatch "${t}"`,[`option`],i),r!==void 0&&typeof r!=`string`)throw Error(`swatch "${t}": option must be text, got ${JSON.stringify(r)}`);return rG(MG(e,t,`swatch`,r))},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`},swatches:{fn:(r,i)=>{let a=AG(e,r,`swatches`),o=SG(e,i,`set-int`,`an int action ({ set, int: true })`,`swatches`),s=hG(t,`{{ swatches }}`);if(s.bg===void 0)throw Error(`{{ swatches }} is not available while segments.${s.segName}'s own "bg:" is being evaluated — a swatch row is drawn on that background`);let c=t.drawnAt(),{options:l}=a,u=l.length,[d]=wG(r,a,{key:o.key,stateVar:o.stateVar},{kind:`led`},!0,e,lG(s,PW(e,`{{ swatches }}`),a.paletteOf,c,s.bg),eG(s.palette,s.bg,c),u===0?[]:(()=>{let t=EG(l,HW(NW(e,`swatches`).store,a.stateVar));return[{glyph:`◀`,option:l[t(-1)]},{glyph:`?`,option:l[jG(n().getTime(),u,t(0))]},{glyph:`▶`,option:l[t(1)]}]})());return d},argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}const PG=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function FG(e,t,n,r){let i=ph(e,n,r),a=(t,n)=>({text:t,colour:n,ink:th(e,n,r)});return[[Om(t).map((n,i)=>{let a=Km(e,n);return{text:PG[i%PG.length],colour:a,ink:t.shade.text(e,n.hue,a,r)}})],[[a(`▾ open`,i.state),a(`menu`,i.plane)],[a(`warn`,Gm(e,`warning`)),a(`error`,Gm(e,`error`))]]]}function IG(e,t){let n=e.flatMap((e,t)=>e.map(({text:e,colour:n,ink:r},i)=>({gap:t>0&&i===0?` `:``,cell:new G(` ${e} `,{style:$W({tint:n,text:r})})}))),r=[],i=0;for(let{gap:e,cell:a}of n){if(i+=e.length+a.cellLength,i>t)break;e!==``&&r.push(new G(e)),r.push(a)}return r}function LG(e,t,n,r,i){let a=FG(e,t,n,r).map(e=>IG(e,i)),o=G.fromFragments(a.flatMap((e,t)=>t===0?e:[new G(`
203
+ `).map(e=>Zo(e.replace(DW,``))))}function kW(e,t){let n=()=>e.map(e=>({owner:TW(e),placement:e.placement})),r=[];if(e.forEach(({fill:e},t)=>{e!==void 0&&r.push({at:t,how:e})}),r.length===0||!Number.isFinite(t.width))return n();let i=Zv(e.map(TW),t).split(`
204
+ `);if(i.length>1)return n();let a=Math.max(0,t.width-OW(i[0]??``)),o=Math.floor(a/r.length),s=a-o*r.length;return r.forEach(({at:t,how:n},i)=>{let a=o+(i===r.length-1?s:0),{text:c}=e[t];xW(c,c.cellLength+a,n)}),n()}function AW(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=jW(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e){let e={frag:a,style:Dv(a.style)};if(e.style.link){i();let r=jW([e],t);r.plain.length>0&&n.push(r)}else r.push(e)}return i(),n}function jW(e,t){let n=t!==void 0&&!t.isNull?t:void 0,r=e.map(e=>MW(e.frag,n?n.add(e.style):e.style)),i=G.fromFragments(r);return i.end=``,i.overflow=`ignore`,r.length===1?i.style=r[0].style:n!==void 0&&(i.style=n),i}function MW(e,t){let n=e.copy();return n.style=t,n}function NW(e,t){if(e.bound===void 0)throw Error(`${t} ran outside a render: no render bound its store and clocks`);return e.bound}function PW(e,t){let{look:n}=NW(e,t);if(n===void 0)throw Error(`${t} read the render's look before it was resolved`);return n}function FW(e,t){let{layout:n}=NW(e,t);if(n===void 0)throw Error(`${t} read the render's rows before they were laid`);return n()}function IW(e,t){if(e.bound!==void 0)throw Error(`a render bound a compile another render holds`);return e.bound=t,{[Symbol.dispose]:()=>{e.bound=void 0}}}function LW(e,t,n,r){let i=new Map,a=Object.entries(t);for(let[t,o]of[...a.filter(([,e])=>!(`do`in e)),...a.filter(([,e])=>`do`in e)])i.set(t,RW(e,t,o,n,r,i));return i}function RW(e,t,n,r,i,a){if(`set`in n){let e=r.get(n.set)??n.set;if(`to`in n)return{kind:`set-literal`,key:n.set,value:n.to,stateVar:e};if(`from`in n){let t=Ky(n.from,i);return{kind:`set-option`,key:n.set,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,library:t.library}}return`int`in n?{kind:`set-int`,key:n.set,stateVar:e}:`cycle`in n?{kind:`set-cycle`,key:n.set,stateVar:e,members:n.cycle}:{kind:`set-bounded`,key:n.set,by:n.by}}if(`persist`in n){let e=fv.get(n.persist)??n.persist;if(`to`in n)return{kind:`persist-literal`,key:n.persist,value:n.to,stateVar:e};if(`from`in n){let t=Ky(n.from,i);return{kind:`persist-option`,key:n.persist,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,library:t.library}}if(`cycle`in n)return{kind:`persist-cycle`,key:n.persist,stateVar:e,members:n.cycle};if(`removeSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`remove`,target:n.removeSegment}};if(`insertSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`insert`,segment:n.insertSegment,anchor:n.anchor,relation:n.relation}};if(`insertSegmentFrom`in n){let e=Ky(n.insertSegmentFrom,i);return{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...e.members],paletteOf:e.paletteOf,library:e.library}}return{kind:`persist-bounded`,key:n.persist,by:n.by}}if(`copy`in n)return{kind:`copy`,text:VW(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:VW(e,n.open,t)};if(`reset`in n)return{kind:`reset`,key:n.reset};if(`doctor`in n)switch(n.doctor){case`run`:return{kind:`doctor-run`};case`fix`:return{kind:`doctor-fix`,check:n.check};case`mark`:return{kind:`doctor-mark`,check:n.check,mark:n.mark}}if(`ceiling`in n)return{kind:`ceiling`,args:RL(n)};if(`slash`in n)return{kind:`slash`,line:n.slash};if(`undo`in n)return{kind:`undo`};if(`redo`in n)return{kind:`redo`};if(`back`in n)return{kind:`back`};if(`rewind`in n)return{kind:`rewind`};if(`save`in n)return{kind:`save`};if(`preset`in n)return n.preset===`save`?{kind:`preset-save`}:{kind:`preset-delete`,name:VW(e,n.name,t)};if(`themeDefault`in n)return{kind:`theme-default-save`};let[o,...s]=n.do.map(e=>{let n=a.get(e);if(n===void 0)throw Error(`action "${t}" fires "${e}", which is not declared in this config`);return n});return{kind:`do`,head:o,rest:s}}function zW(e){return e.kind===`do`?zW(e.head):e}function BW(e){switch(zW(e).kind){case`set-option`:case`set-int`:case`persist-option`:case`layout-op-option`:return!0;case`set-literal`:case`set-bounded`:case`set-cycle`:case`copy`:case`open`:case`persist-literal`:case`persist-bounded`:case`persist-cycle`:case`reset`:case`layout-op`:case`undo`:case`redo`:case`back`:case`rewind`:case`save`:case`preset-save`:case`preset-delete`:case`theme-default-save`:case`doctor-run`:case`doctor-fix`:case`doctor-mark`:case`ceiling`:case`slash`:case`do`:return!1}}function VW(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function HW(e,t){return e.has(t)?wb(e.read(t)):``}function UW(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function WW(e,t,n,r){let i=new G(e,{style:H.combine([r,new H({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function GW(e,t,n=!1){let r=new H({link:t,bold:n?!0:void 0}),i=new G(e.plain,{style:H.combine([Dv(e.style),r])});for(let t of e.spans)i.stylize(H.combine([Dv(t.style),r]),t.start,t.end);return i.overflow=`ignore`,i.end=``,i}function KW(e,t){return Math.max(e.members.indexOf(HW(t,e.stateVar)),0)}function qW(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=HW(r,e.stateVar);return{effects:[{verb:mr,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=HW(r,e.stateVar);return{effects:[{verb:mr,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=HW(r,e.stateVar);return{effects:[{verb:mr,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(KW(e,r)+1)%e.members.length];return{effects:[{verb:mr,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:hr,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:gr,args:[UW(e.text,vD(r))]}],active:!1};case`open`:return{effects:[{verb:_r,args:[UW(e.target,vD(r))]}],active:!1};case`persist-literal`:{let t=HW(r,e.stateVar);return{effects:[{verb:xr,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=HW(r,e.stateVar);return{effects:[{verb:xr,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(KW(e,r)+1)%e.members.length];return{effects:[{verb:xr,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:Sr,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:Dr,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:kr,args:[i]}],active:!1};case`redo`:return{effects:[{verb:Ar,args:[i]}],active:!1};case`back`:return{effects:[{verb:jr,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:Mr,args:[i]}],active:!1};case`save`:return{effects:[{verb:Cr,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:wr,args:[i]}],active:!1};case`theme-default-save`:return{effects:[{verb:Tr,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:Er,args:[i,UW(e.name,vD(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:Pr,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:Fr,args:[i,e.check]}],active:!1};case`doctor-mark`:return{effects:[{verb:Ir,args:[i,e.check,e.mark]}],active:!1};case`ceiling`:return{effects:[{verb:Rr,args:[i,...e.args]}],active:!1};case`slash`:return{effects:[{verb:zr,args:[i,e.line]}],active:!1};case`layout-op`:return{effects:[{verb:Or,args:[i,e.key,xF(e.op)]}],active:!1};case`do`:{let a=qW(e.head,t,n,r,i);return{effects:[...a.effects,...e.rest.flatMap(e=>qW(e,t,void 0,r,i).effects)],active:a.active}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:Or,args:[i,e.key,xF(r)]}],active:!1}}}}function JW(e,t,n,r){if(n.length===0)throw Error(`action "${e}" needs a display (the clickable text)`);if(t.kind===`set-cycle`||t.kind===`persist-cycle`)return{display:Xr(`action "${e}"`,n,t.members.length,KW(t,r)),boundValue:void 0};if(n.length>2)throw Error(`action "${e}" takes a display and an optional bound value, got ${n.length} arguments (per-state displays are a cycle action's form)`);return{display:n[0],boundValue:n[1]?.plain}}function YW(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=NW(n,`action "${e}"`).store,{display:a,boundValue:o}=JW(e,zW(r),t,i),s=HW(i,`session.id`),{effects:c,active:l}=qW(r,a.plain,o,i,s);return GW(a,Hr(c),l)}function XW(e){return{action:{fn:(t,...n)=>YW(t,n,e),argTypes:[`string`,`liftable`],arity:{kind:`variadic`},returnType:`T`}}}function ZW(e,t){return WW(`✕`,Hr([{verb:mr,args:[HW(e,`session.id`),t,P]}]),!1)}function QW(e,t,n){return new H({bgcolor:B.fromRgba(t),color:B.fromRgba(th(e,t,n))})}function $W({tint:e,text:t}){return new H({bgcolor:B.fromRgba(e),color:B.fromRgba(t)})}function eG(e,t,n){return new H({color:B.fromRgba(Uc(Gm(e,`warning`),t,eh,n))})}function tG(e,t,n){return H.combine([QW(e,t,n),eG(e,t,n)])}function nG(e,t,n){return QW(e.palette,Sh(e.palette,e.disclosure,[t],n),n)}function rG(e){let t=B.fromRgba(Gm(e,`background`)),n=G.fromFragments(vm.map(n=>new G(`▀`,{style:new H({color:B.fromRgba(Gm(e,n)),bgcolor:t})})));return n.overflow=`ignore`,n.end=``,n}const iG=(e,t)=>{let n=typeof e==`string`?new G(e,{style:t}):e;return n.overflow=`ignore`,n.end=``,n},aG=e=>new H({bold:e});function oG(e,t,n,r,i,a){if(r===void 0)return(n,r,a,o)=>iG(a,H.combine([nG(e,{...n,distribution:t},i),aG(o)]));let o=QW(e.palette,a,i);return(e,t,i,a)=>sG(i,H.combine([o,aG(a)]),r(t,n))}const sG=(e,t,n)=>iG(G.fromFragments([iG(e,t),iG(` `,t),rG(n)]));function cG(e,t){return t===void 0?(e,t,n)=>iG(n):(n,r,i)=>sG(i,void 0,t(r,e))}function lG(e,t,n,r,i){let a=QW(e.palette,i,r);return(e,r,i,o)=>iG(G.fromFragments([iG(o?`[`:` `,a),rG(n(r,t)),iG(o?`]`:` `,a)]))}function uG(e,t,n){let r=t.map(t=>({label:t.label,indices:e.flatMap((e,n)=>e.group===t.id?[n]:[])})).filter(e=>e.indices.length>0);if(r.reduce((e,t)=>e+t.indices.length,0)!==e.length){let n=new Set(t.map(e=>e.id)),r=e.flatMap((e,t)=>n.has(e.group)?[]:[`#${t} (group "${e.group}")`]);throw Error(`library: ${r.join(`, `)} name a group the domain does not list (${[...n].join(`, `)})`)}return n?r.flatMap(e=>dG(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function dG(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function fG(e,t){return new G(e).truncate(t,{marker:`…`}).plain}function pG(e){return{current:null,drawnAt:e}}function mG(e,t,n,r,i,a,o){let s={segName:t,placementId:n,palette:r,disclosure:i,tint:a,text:o,bg:void 0,drops:[]};return e.current=s,s}function hG(e,t){let n=e.current;if(n===null)throw Error(`${t} is only available inside a segment's templates — there is no active segment here. Segment-scoped functions cannot be used in variable declarations or layout-node "when" predicates, which are evaluated outside any segment.`);return n}function gG(e){return new G(e).cellLength}function _G(e){let{width:t,chromeCols:n,padding:r}=NW(e,`a row fit`);return Math.max(1,t-n-2*r)}function vG(e){let{padding:t,seamCols:n}=NW(e,`a row fit`);return Math.max(1,_G(e)-(gG(`✕`)+2*t+n))}function yG(e,t,n){if(!Number.isFinite(t))return e.length>0?[e.map((e,t)=>t)]:[];let r=Math.max(1,t-n),i=[],a=[],o=0;for(let t=0;t<e.length;t++){let n=e[t];a.length===0?(a=[t],o=n):o+1+n<=r?(a.push(t),o+=1+n):(i.push(a),a=[t],o=n)}return a.length>0&&i.push(a),i}function bG(e,t,n){let r=gG(`←`)+1+gG(`→`)+1,i=yG(e,t,n);return(i.length>1?yG(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function xG(e,t){let n=[];for(let t of e)n.length>0&&n.push(new G(` `)),n.push(t);let r=G.fromFragments(n);return r.overflow=t?`ignore`:void 0,r.end=``,r}function SG(e,t,n,r,i){let a=e.compiled.get(t);if(!a||a.kind!==n)throw Error(`${i} references action "${t}" which must be ${r}, got ${a?`a ${a.kind} action`:`no such action`}`);return a}function CG(e,t,n){let r=e.compiled.get(t),i=r&&zW(r);if(!i||i.kind!==`set-option`&&i.kind!==`persist-option`&&i.kind!==`layout-op-option`)throw Error(`${n} references action "${t}" which must be a set-option, persist-option, or layout-op-option action ({ set, from }, { persist, from }, or { persist, insertSegmentFrom, anchor, relation }), got ${i?`a ${i.kind} action`:`no such action`}`);return i}function wG(e,t,n,r,i,a,o,s,c=[]){let l=a.compiled.get(e),u=NW(a,`picker`).store,d=HW(u,`session.id`),f=`stateVar`in t?HW(u,t.stateVar):void 0,p=(e,n)=>{let r=t.options[e];return o({index:e,count:t.options.length},r,n,r===f)},m=i?r.kind===`led`?vG(a):_G(a):1/0,h=(r.kind===`led`?0:gG(`✕`)+1)+c.reduce((e,t)=>e+gG(t.glyph)+1,0),g=t.library&&{groups:t.library.groups,entries:t.options.map(t.library.entry)},_=g===void 0?t.options.map((e,t)=>p(t,e)):[],v=g===void 0?bG(_.map(e=>e.cellLength),m,h):uG(g.entries,g.groups,i),y=parseInt(HW(u,n.stateVar),10),b=e=>Math.max(0,v.findIndex(t=>t.some(t=>t.indices.includes(e)))),ee=b(f===void 0?-1:t.options.indexOf(f)),x=Number.isInteger(y)?y<0?ee:Math.min(y,v.length-1):0,S=v[x]??[],te=e=>Hr([{verb:mr,args:[d,n.key,String(e)]}]),ne=r.kind===`led`?[]:[{verb:mr,args:[d,...r.writes.flatMap(([e,t])=>[e,t])]}],C=r.kind===`own`&&r.onPick?ne:[],re=e=>Hr([...qW(l,e,e,u,d).effects,...C]),ie=(e,n)=>GW(e,re(t.options[n])),ae=r.kind===`led`?[]:[WW(`✕`,Hr(ne),!1,s)];ae.push(...c.map(({glyph:e,option:r})=>WW(e,Hr([...qW(l,r,r,u,d).effects,{verb:mr,args:[d,n.key,String(b(t.options.indexOf(r)))]}]),!1))),x>0&&ae.push(WW(`←`,te(x-1),!1));let w=x<v.length-1?[WW(`→`,te(x+1),!1)]:[];if(g===void 0){let e=S.flatMap(e=>e.indices);return[xG([...ae,...e.map(e=>ie(_[e],e)),...w],i)]}let T=new H({bold:!0}),oe=v.length>1?` ${x+1}/${v.length}`:``,E=S.length===1?[new G(`${S[0].label}${oe}`,{style:T})]:[],se=[xG([...ae,...E,...w],i)];for(let e of S){S.length>1&&se.push(xG([new G(e.label,{style:T})],i));let n=Math.max(...e.indices.map(e=>gG(t.options[e])));for(let r of e.indices){let e=t.options[r],a=g.entries[r].description,o=a===void 0?void 0:vv(a),s=` `.repeat(n-gG(e)+2),c=o===void 0?e:`${e}${s}${o}`;se.push(xG([ie(p(r,fG(c,m)),r)],i))}}return se}function TG(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{fD(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=SG(e,r,`set-int`,`an int action ({ set, int: true })`,`picker`);if(o===!0&&i===!0)throw Error(`{{ picker "${n}" … }} sets both closeOnPick and inBody; a picker in a body is closed by the body's ✕, so it has no close to fold into a pick`);let l=CG(e,n,`picker`);if(l.library!==void 0)throw Error(`{{ picker "${n}" … }} ranges a catalogue domain, which lays out as one row per member; a catalogue renders in a {{ menu }} body`);let u=hG(t,`{{ picker }}`);if(u.bg===void 0)throw Error(`{{ picker }} is not available while segments.${u.segName}'s own "bg:" is being evaluated — a picker is drawn on that background`);let[d]=wG(n,l,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,oG(u,Nm(void 0),PW(e,`{{ picker }}`),l.paletteOf,t.drawnAt(),u.bg),eG(u.palette,u.bg,t.drawnAt()));return d},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function EG(e,t){let n=e.length,r=Math.max(e.indexOf(t),0);return e=>((r+e)%n+n)%n}function DG(e,t,n,r,i){let a=Math.min(Math.floor((t-1)/2),i),o=n,s=0;for(;s<a;){let t=o+e(-(s+1))+1+e(s+1)+1;if(t>r)break;o=t,s+=1}return s}function OG(e,t,n,r,i,a){if(!(`stateVar`in t))throw Error(`carousel references action "${e}", which inserts a segment and holds no current value to centre on — a carousel needs a { set, from } or { persist, from } action`);let o=NW(n,`carousel`).store;if(!o.has(t.stateVar))throw Error(`carousel references action "${e}", whose key "${t.stateVar}" no variable reads back, so there is no current value to centre on — declare { kind: "state", key: "${t.stateVar}" } among the variables`);let s=n.compiled.get(e),c=HW(o,`session.id`),{options:l}=t,u=l.length;if(u===0)return xG([],!0);let d=HW(o,t.stateVar),f=EG(l,d),p=e=>l[f(e)],m=new Map,h=e=>{let t=m.get(e);if(t!==void 0)return t;let n=Hr(qW(s,p(e),p(e),o,c).effects);return m.set(e,n),n},g=e=>r({index:f(e),count:u},p(e),p(e),p(e)===d),_=new Map,v=e=>{let t=_.get(e);if(t!==void 0)return t;let n=GW(g(e),h(e));return _.set(e,n),n},y=a===void 0?v(0):GW(cG(PW(n,`{{ carousel }}`),t.paletteOf)({index:f(0),count:u},p(0),p(0),!1),Hr(qW(n.compiled.get(a),p(0),void 0,o,c).effects)),b=DG(e=>v(e).cellLength,u,gG(`◀`)+1+y.cellLength+1+gG(`▶`),vG(n),i),ee=e=>Array.from({length:b},(t,n)=>v(e*(n+1)));return xG([...ee(-1).reverse(),WW(`◀`,h(-1),!1),y,WW(`▶`,h(1),!1),...ee(1)],!0)}function kG(e,t){return{carousel:{fn:(n,...r)=>{let[i,a,...o]=r;if(fD(`carousel "${n}"`,[`neighbours`,`centre`],o),i!==void 0&&!(Number.isInteger(i)&&i>=0))throw Error(`carousel "${n}": neighbours must be a whole number ≥ 0 (0 shows only ◀ CURRENT ▶), got ${String(i)}`);if(a!==void 0&&!(typeof a==`string`&&e.compiled.has(a)))throw Error(`carousel "${n}": centre must name a declared action, got ${JSON.stringify(a)}`);if(a!==void 0&&BW(e.compiled.get(a)))throw Error(`carousel "${n}": centre "${a}" writes a value the template binds, and the centre binds none — name an action that writes a fixed value, a cycle, or a do of them`);let s=i??1/0,c=CG(e,n,`carousel`),l=hG(t,`{{ carousel }}`);if(l.bg===void 0)throw Error(`{{ carousel }} is not available while segments.${l.segName}'s own "bg:" is being evaluated — a carousel is drawn on that background`);return OG(n,c,e,oG(l,Nm(void 0),PW(e,`{{ carousel }}`),c.paletteOf,t.drawnAt(),l.bg),s,a)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function AG(e,t,n){let r=CG(e,t,n);if(!(`stateVar`in r))throw Error(`${n} references action "${t}", which inserts a segment and holds no current value — a ${n} needs a { set, from } or { persist, from } action`);if(r.paletteOf===void 0)throw Error(`${n} references action "${t}", whose options are not colour-valued — a swatch draws the palette an option puts in force, as the "themes", "placementThemes" and "styles" domains do`);return r}function jG(e,t,n){let r=Math.imul(e^e>>>16,73244475);return r=Math.imul(r^r>>>16,73244475),r^=r>>>16,(n+1+(r>>>0)%Math.max(t-1,1))%t}function MG(e,t,n,r){let i=AG(e,t,n),a=r??HW(NW(e,n).store,i.stateVar);if(!i.options.includes(a))throw Error(`${n} "${t}": "${a}" is not one of its options, so it has no palette to draw`);return i.paletteOf(a,PW(e,`{{ ${n} }}`))}function NG(e,t,n){return{swatch:{fn:(t,...n)=>{let[r,...i]=n;if(fD(`swatch "${t}"`,[`option`],i),r!==void 0&&typeof r!=`string`)throw Error(`swatch "${t}": option must be text, got ${JSON.stringify(r)}`);return rG(MG(e,t,`swatch`,r))},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`},swatches:{fn:(r,i)=>{let a=AG(e,r,`swatches`),o=SG(e,i,`set-int`,`an int action ({ set, int: true })`,`swatches`),s=hG(t,`{{ swatches }}`);if(s.bg===void 0)throw Error(`{{ swatches }} is not available while segments.${s.segName}'s own "bg:" is being evaluated — a swatch row is drawn on that background`);let c=t.drawnAt(),{options:l}=a,u=l.length,[d]=wG(r,a,{key:o.key,stateVar:o.stateVar},{kind:`led`},!0,e,lG(s,PW(e,`{{ swatches }}`),a.paletteOf,c,s.bg),eG(s.palette,s.bg,c),u===0?[]:(()=>{let t=EG(l,HW(NW(e,`swatches`).store,a.stateVar));return[{glyph:`◀`,option:l[t(-1)]},{glyph:`?`,option:l[jG(n().getTime(),u,t(0))]},{glyph:`▶`,option:l[t(1)]}]})());return d},argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}const PG=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function FG(e,t,n,r){let i=ph(e,n,r),a=(t,n)=>({text:t,colour:n,ink:th(e,n,r)});return[[Om(t).map((n,i)=>{let a=Km(e,n);return{text:PG[i%PG.length],colour:a,ink:t.shade.text(e,n.hue,a,r)}})],[[a(`▾ open`,i.state),a(`menu`,i.plane)],[a(`warn`,Gm(e,`warning`)),a(`error`,Gm(e,`error`))]]]}function IG(e,t){let n=e.flatMap((e,t)=>e.map(({text:e,colour:n,ink:r},i)=>({gap:t>0&&i===0?` `:``,cell:new G(` ${e} `,{style:$W({tint:n,text:r})})}))),r=[],i=0;for(let{gap:e,cell:a}of n){if(i+=e.length+a.cellLength,i>t)break;e!==``&&r.push(new G(e)),r.push(a)}return r}function LG(e,t,n,r,i){let a=FG(e,t,n,r).map(e=>IG(e,i)),o=G.fromFragments(a.flatMap((e,t)=>t===0?e:[new G(`
200
205
  `),...e]));return o.overflow=`ignore`,o.end=``,o}function RG(e,t){return{themePreview:{fn:(...n)=>{let[r,...i]=n;if(fD(`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}=PW(e,`{{ themePreview }}`);return LG(r===void 0?a:MG(e,r,`themePreview`),o,{...hG(t,`{{ themePreview }}`).disclosure,depth:0},t.drawnAt(),vG(e))},argTypes:[`value`],arity:{kind:`variadic`},returnType:`T`}}}const zG=e=>e.slice(e.lastIndexOf(`.`)+1),BG=(e,t)=>{let n=new G(zG(e));return n.truncate(t,{marker:`…`}),n.plain};function VG(e,t){let n=e.map(e=>e.map(({name:e})=>gG(zG(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 HG(e,t,n,r){let i=VG(e,r),a=e.map(e=>{let a=[],o=0;for(let{name:s,address:c,palette:l}of e){let e=new G(` ${BG(s,i)} `,{style:$W(Eh(l,{kind:`bar`,decor:t,address:c},n))});if(o+=e.cellLength,o>r)break;a.push(e)}return a}),o=G.fromFragments(a.flatMap((e,t)=>t===0?e:[new G(`
201
- `),...e]));return o.overflow=`ignore`,o.end=``,o}function UG(e,t){return{layoutPreview:{fn:()=>HG(FW(e,`{{ layoutPreview }}`),PW(e,`{{ layoutPreview }}`).decor,t.drawnAt(),vG(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function WG(e,t,n,r){let i=hG(r.activeSegment,`{{ menu }}`),a=r.action,o=ak(i.placementId,e,n.key),s=ck(o),c=ik(e),l=NW(a,`menu`).store,u=HW(l,o)===c,d=HW(l,`session.id`),f=u?P:c,p=WW(Xr(`{{ menu "${e}" }}`,t,2,+!!u),Hr([{verb:mr,args:[d,o,f,s,`0`]}]),!1);return i.drops.push(...u?(()=>{let t=r.activeSegment.drawnAt(),c=ph(i.palette,i.disclosure,t).plane,l=CG(a,e,`menu`);return wG(e,l,{key:s,stateVar:s},{kind:`own`,writes:[[o,P],[s,`0`]],onPick:n.closeOnPick},n.paged,a,oG(i,n.distribution,PW(a,`{{ menu }}`),l.paletteOf,t,c),eG(i.palette,c,t))})():[]),p}const GG=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function KG(e,t){let n=t[t.length-1],r=GG(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:fk(r??{})}}function qG(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=KG(t,n);return WG(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function JG(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=YG(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 G(t?i:a,{style:l===void 0?void 0:new H({color:l})}))}let l=G.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function YG(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 XG(e){let t={fn:(()=>{let t=hG(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:(()=>hG(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r={fn:((t,n)=>{let{palette:r}=hG(e,`{{ keptOn }}`),i=Pc(r,t),a=Pc(r,n),o=ws(Gc(i,B.TRUECOLOR),Gc(a,B.TRUECOLOR)),s=Math.min(eh,Math.max(o,3));return(Wc(i,e.drawnAt(),(e,t)=>ws(e,t(a))>=s)??i).hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},i=XE(()=>hG(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),a={fn:((e,t,n,r,a,o,...s)=>{let c=o===void 0?void 0:[o,...ZG(s)];return JG({value:e,max:t,width:n,filled:r,empty:a,colourAt:c===void 0?void 0:e=>String(i.ramp.fn(e,...c))})}),argTypes:[`float`,`float`,`int`,`string`,`string`,`string`],arity:{kind:`variadic`},returnType:`T`};return{...i,bgOf:t,tint:n,keptOn:r,gauge:a}}function ZG(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)]})}function QG(e){let t=[],n=[];for(let r of e){if(!r.contains(`
206
+ `),...e]));return o.overflow=`ignore`,o.end=``,o}function UG(e,t){return{layoutPreview:{fn:()=>HG(FW(e,`{{ layoutPreview }}`),PW(e,`{{ layoutPreview }}`).decor,t.drawnAt(),vG(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function WG(e,t,n,r){let i=hG(r.activeSegment,`{{ menu }}`),a=r.action,o=ak(i.placementId,e,n.key),s=ck(o),c=ik(e),l=NW(a,`menu`).store,u=HW(l,o)===c,d=HW(l,`session.id`),f=u?P:c,p=WW(Xr(`{{ menu "${e}" }}`,t,2,+!!u),Hr([{verb:mr,args:[d,o,f,s,`0`]}]),!1);return i.drops.push(...u?(()=>{let t=r.activeSegment.drawnAt(),c=ph(i.palette,i.disclosure,t).plane,l=CG(a,e,`menu`);return wG(e,l,{key:s,stateVar:s},{kind:`own`,writes:[[o,P],[s,`0`]],onPick:n.closeOnPick},n.paged,a,oG(i,n.distribution,PW(a,`{{ menu }}`),l.paletteOf,t,c),eG(i.palette,c,t))})():[]),p}const GG=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function KG(e,t){let n=t[t.length-1],r=GG(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:fk(r??{})}}function qG(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=KG(t,n);return WG(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function JG(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=YG(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 G(t?i:a,{style:l===void 0?void 0:new H({color:l})}))}let l=G.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function YG(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 XG(e){let t={fn:(()=>{let t=hG(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:(()=>hG(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r={fn:((t,n)=>{let{palette:r}=hG(e,`{{ keptOn }}`),i=Pc(r,t),a=Pc(r,n),o=Ts(Gc(i,z.TRUECOLOR),Gc(a,z.TRUECOLOR)),s=Math.min(eh,Math.max(o,3));return(Wc(i,e.drawnAt(),(e,t)=>Ts(e,t(a))>=s)??i).hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},i=XE(()=>hG(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),a={fn:((e,t,n,r,a,o,...s)=>{let c=o===void 0?void 0:[o,...ZG(s)];return JG({value:e,max:t,width:n,filled:r,empty:a,colourAt:c===void 0?void 0:e=>String(i.ramp.fn(e,...c))})}),argTypes:[`float`,`float`,`int`,`string`,`string`,`string`],arity:{kind:`variadic`},returnType:`T`};return{...i,bgOf:t,tint:n,keptOn:r,gauge:a}}function ZG(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)]})}function QG(e){let t=[],n=[];for(let r of e){if(!r.contains(`
202
207
  `)){n.push(r);continue}let e=r.split(`
203
208
  `);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function $G(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}`}})}function eK(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:r.length===0?n:[],ground:i},deeper:r}}function tK(e){return{...e,cells:e.cells.map(CW)}}function nK(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,...rK(e,r)]}function rK(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 iK(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:nK(e.direction,e.children.map((t,i)=>n(t,[...r,aK(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function aK(e,t){return{index:t,count:e.children.length,distribution:e.distribution,axis:fg[e.direction]}}const oK={compile(e,t){return{kind:`container`,direction:e.direction,when:t.when,distribution:Nm(e.distribution),children:e.children.map((e,n)=>t.compileChild(e,vg(t.path,n)))}},render(e,t){return t.gate.kind===`failed`&&t.gate.report(),nK(e.direction,e.children.map((n,r)=>t.renderChild(n,t.gate.kind===`shown`,aK(e,r))))}},sK={drop:e=>e.place,above:()=>`above`},cK={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},lK={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:pg(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse($r(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,yg(t.path)),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,uK(e,t))};function uK(e,t){let n=t.lookupSegment(e.name);if(!n)throw Error(`Layout segment "${e.name}" has no matching segment`);let{seg:r,compiled:i}=n;if(t.gate.kind===`hidden`)return[];let a=bD(t.scope,e.settings);if(t.gate.kind===`failed`)return dK(e,a,t,t.gate.message);try{if(!gW(i.when,a))return[];let n=hy(e.settings.theme,t.palette),o={id:e.id,effect:e.settings.effect,ground:CA(n)},s=e.opens!==void 0&&gW(e.opens.open,t.scope),{styles:c,fragments:l,lead:u,trail:d,drops:f,open:p}=t.evaluateSegment(e,a,n,t.region,{bg:i.bg,fg:i.fg,body:i.template,lead:e.lead,trail:e.trail},s),m=p?c.trigger:c.closed,h={width:r.width??`auto`,justify:r.justify??`left`,truncate:r.truncate??`right`,baseStyle:m,padding:t.padding,placement:o},g=e.opens,_=g===void 0?[]:t.renderBody(g.body,s,c.disclosure).map(e=>({...e,place:sK[g.placement](e)})),v=QG(AW(l,m)).map((e,t)=>({cells:EW(e,{...h,lead:t===0?AW(u,m):[],trail:t===0?AW(d,m):[]}),band:`own`,place:`flow`})),y=f.map(e=>({cells:EW(AW([e],c.band),{...h,baseStyle:c.band}),band:`deeper`,place:`flow`})),b=(e,t,n)=>EW(AW([e],t),{...h,width:`auto`,baseStyle:t,padding:n}),ee=_.findIndex(e=>e.band===`own`),{lead:x,stays:S}=g!==void 0&&ee!==-1?cK[g.placement](v,()=>b(t.closeDisclosure(g.key),c.close,t.padding)):{lead:[],stays:v},te=x.flatMap(e=>b(new G(` `.repeat(SW(e).reduce((e,t)=>e+t.cellLength,0))),c.trigger,0)),ne=(e,t)=>e.band===`own`?t===ee?x:te:[],C=_.map((e,t)=>({cells:[...ne(e,t),...e.cells],band:`deeper`,place:e.place})),re=[...S,...y];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...re.flatMap(e=>e.cells),..._.flatMap(ne)].flatMap(SW)),[...re,...C]}catch(n){return dK(e,a,t,n.message??String(n))}}function dK(e,t,n,r){n.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:EW([new G(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,placement:{id:e.id,effect:`bar`,ground:CA(n.palette)},lead:fK(e.lead,e,t,n),trail:fK(e.trail,e,t,n)}),band:`own`,place:`flow`}]}function fK(e,t,n,r){if(e===void 0)return[];try{return r.evaluateSegment(t,n,r.palette,r.region,{bg:void 0,fg:void 0,body:e,lead:void 0,trail:void 0},!1).fragments}catch(e){return r.onSegmentError?.(t.id,e.message??String(e)),[]}}const pK={container:oK,segment:lK};function mK(e){return pK[e]}function hK(e){if(`ttl`in e)return{kind:`ttl`,durationMs:bO(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 gK(e,t){switch(Sg(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 _K(e,t,n,r){switch(n.kind){case`literal`:e.declareLiteral(t,n.value);break;case`dropped`:e.declareFailedDocument(t,n.reason);break;case`input`:e.declareInput(t,n.path,n.type??`string`,n.default);break;case`env`:e.declareEnv(t,n.name,n.default);break;case`file`:e.declareFile(t,n.path,{readMode:n.readMode,cache:hK(n.cache),parse:gK(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:hK(n.cache),parse:gK(n.parse,n.default)});break;case`template`:e.declareTemplate(t,n.template,{varDefault:n.default});break;case`time`:e.declareTime(t,{format:n.layout,varDefault:n.default});break;case`git`:e.declareGit(t,{field:n.field,cwd:r,varDefault:n.default});break;case`state`:e.declareState(t,{key:n.key,...n.default!==void 0&&{varDefault:n.default}});break}}function vK(e,t){let n=rx.EMPTY;for(let[r,i]of Object.entries(t))try{n=e.parse(`{{ define "${r}" }}${i}{{ end }}`,n).defines()}catch(e){throw Error(`Template parse error in helpers.${r}: ${e.message}`,{cause:e})}return n}function yK(e,t,n){let{compiled:r,loadWarnings:i}=xK(e,t,n.cwd,bK);return{...r,loadWarnings:i}}const bK=(e,t)=>TK(t);function xK(e,t,n,r){let i=SK(e),a=CK(i);return{compiled:r(a,i),compileKey:a,loadWarnings:wK(e,t,n)}}function SK(e){let{variables:t,...n}=e,r=new Map;for(let[e,n]of pv)n in t&&r.set(e,n);for(let[t,n]of Og(e))r.has(n.key)||r.set(n.key,t);return{config:n,stateReads:[...r].sort(([e],[t])=>e<t?-1:1)}}function CK(e){return te(`sha256`).update(JSON.stringify(e)).digest(`hex`)}function wK(e,t,n){let r=[];for(let[i,a]of Object.entries(e.variables))try{_K(t,i,a,n)}catch(e){r.push(`Variable "${i}": ${e.message??String(e)}`)}for(let[i,a]of Object.entries(e.segments))if(a.vars)for(let[e,o]of Object.entries(a.vars))try{_K(t,`${i}.${e}`,o,n)}catch(t){r.push(`Variable "${i}.${e}": ${t.message??String(t)}`)}return r}function TK({config:e,stateReads:t}){let n={bound:void 0,compiled:new Map},r=()=>NW(n,`now`).registry.now(),i=()=>NW(n,`drawnAt`).registry.drawnAt(),a=pG(i),o={action:n,activeSegment:a},s=Object.keys(e.styles),c=Iy(e.presets),l=nF(e),u=_D({extraFuncs:{...XW(n),...TG(n,a),...kG(n,a),...RG(n,a),...NG(n,a,r),...UG(n,a),...qG(o),...XG(a),styles:{fn:()=>s,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>c,argTypes:[],arity:{kind:`exact`}}},clock:r,drawnAt:i}),d=vK(u,e.helpers),f=e=>u.parse(e,d),p=new Map,m=e=>{let t=p.get(e);if(t!==void 0)return t;let n=f(e);return p.set(e,n),n},h=new Map(t);n.compiled=LW(f,e.actions,h,l);let g=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=(e,n,r=f)=>{try{return r(e)}catch(e){throw Error(`Template parse error in segments.${t}.${n}: ${e.message}`,{cause:e})}};g[t]={when:n.when===void 0?void 0:e(n.when,`when`,m),template:e(n.template,`template`),bg:n.bg===void 0?void 0:e(n.bg,`bg`),fg:n.fg===void 0?void 0:e(n.fg,`fg`)}}let _=(e,t,n)=>{try{return m(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},v=t=>{let r=Mg(e.segments[t.name]),i=Object.create(null);for(let[e,a]of Object.entries(r))Object.defineProperty(i,e,{enumerable:!0,get:()=>Rg(t,e,a,t=>String(NW(n,`setting ${e}`).store.read(t.variable)))});return Object.freeze(i)},y=(e,t)=>{let n={path:t,when:e.when===void 0?void 0:_(e.when,t,`when`),parse:(e,n)=>_(e,t,n),compileChild:y,placementSettings:v};return mK(e.kind).compile(e,n)},b=new Map;for(let t of c){let{node:n,path:r}=zy(e,t);b.set(t,y(n,r))}let ee=new Map(Ih.map(e=>[e,new Map])),x=[[`globals`,e.globals],...Object.entries(e.presets).map(([e,t])=>[`presets.${e}.globals`,t.globals??{}])];for(let[e,t]of x)for(let n of Ih){let r=t[n];if(!Lh(r))continue;let i=`${e}.${n}`,a=ee.get(n),o=a.get(r);a.set(r,o===void 0?{where:i,template:EK(f,i,r)}:{where:`${o.where}, ${i}`,template:o.template})}return{segments:g,roots:b,activeSegment:a,menuRuntime:o,globalExpressions:ee}}function EK(e,t,n){try{return e(n)}catch(e){throw Error(`${t} is not a valid template: ${e instanceof Error?e.message:String(e)}`)}}function DK(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 render but no compiled template exists — registerDslConfig and the resolution disagree about isExpression`);return r}function OK(e,t,n,r){try{return t.template.evaluate(n).map(e=>e.plain).join(``)}catch(n){return r({kind:`rule`,slot:e,message:Kh(t.where,e,`the rule failed — ${n instanceof Error?n.message:String(n)}`)}),Gh[e]}}function kK(e,t){return e.kind===`decided`?e.name:Gh[t]}function AK(e){return jK(e).filter(e=>!e.name.startsWith($O)).map(e=>e.id)}function jK(e){return e.kind===`container`?e.children.flatMap(jK):[e,...e.opens===void 0?[]:jK(e.opens.body)]}function MK(...e){return NK(...e).text}function NK(e,t,n,r,i,a,o,s,c=HB(e,()=>null,()=>!1)){try{var l=na();let{perSegmentSink:u,onSegmentError:d,onRenderWarning:f}=s??{},p=e=>f?.(e),m=new Set;r.renderAt(a),r.drawAt(ng(o.colorCompatibility));let h={store:n,registry:r,width:o.width,chromeCols:Gv(o),padding:o.padding,seamCols:Kv(o),look:void 0,layout:void 0};l.u(IW(t.menuRuntime.action,h));let{preset:g,theme:_,style:v,effect:y,transitions:b}=c,ee={variation:Dm[c.variation],shade:Tm[c.shade]},x=(e,t,n)=>({...i,term:{cols:o.width},theme:{effective:e},style:{effective:t},effect:{effective:n}});r.applyInput(x(kK(_,`palette`),kK(v,`style`),kK(y,`effect`)));let S=vD(n),te=zh(_,e=>{let n=DK(t,`palette`,e);return by(OK(`palette`,n,S,p),n.where,e=>p({kind:`rule`,slot:`palette`,message:e}))}),ne=zh(v,n=>Hh(OK(`style`,DK(t,`style`,n),S,p),e.styles)),C=zh(y,e=>Xh(OK(`effect`,DK(t,`effect`,e),S,p)));(te!==_||ne!==v||C!==y)&&r.applyInput(x(te.name,ne.name,C.name));let re=te.value,ie=_y(re,ne.value);h.look={basePalette:re,palette:ie,decor:ee};let ae=(c.effects??new Lv(``)).motion(C.value,a,{transitions:b,source:{config:e,preset:g,revision:r.stateRevision(),width:o.width},returned:eK,hold:tK});u?.clear();let w=n=>{let r=e.segments[n],i=t.segments[n];return r!==void 0&&i!==void 0?{seg:r,compiled:i}:void 0},T=(e,n,i,a,o,s)=>{try{let c=r.drawnAt(),{tint:l,text:u,disclosure:d}=Eh(i,a,c),f=mG(t.activeSegment,e.name,e.id,i,d,l,u),p=TA(f,c,o.bg,o.fg,n),h=()=>ph(i,d,c);s&&(f.bg=h().state);let g=o.body.evaluate(n),_=f.drops.length>0||s;if(_){let e=h();f.bg=e.state;for(let t of e.shortfalls)m.add(t)}let v=o.lead?.evaluate(n)??[],y=o.trail?.evaluate(n)??[];return{styles:{closed:p,get trigger(){return QW(i,h().state,c)},get band(){return QW(i,h().plane,c)},get close(){return tG(i,h().state,c)},disclosure:d},fragments:g,lead:v,trail:y,drops:f.drops,open:_}}finally{t.activeSegment.current=null}},oe=(e,t,r)=>{let i=t?yW(e.when,S):_W,a=i.kind===`failed`?{...i,report:()=>{let t=`when over ${AK(e).join(`, `)||`no placement`}`;p({kind:`when`,where:t,error:i.message,message:`${t}: ${i.message} — what it gates is hidden`})}}:i,s={scope:S,palette:ie,gate:a,padding:o.padding,region:r,perSegmentSink:u,onSegmentError:d,evaluateSegment:T,lookupSegment:w,renderChild:(e,t,n)=>oe(e,t,wh(r,n)),renderBody:(e,t,n)=>oe(e,a.kind===`shown`&&t,Th(n)),closeDisclosure:e=>ZW(n,e),placed:ae.placed};return mK(e.kind).render(e,s)},E=t.roots.get(g);if(E===void 0)throw Error(`Preset "${g}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${Py}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let se=e=>{let n=yW(e.when,S);if(e.kind===`container`)return n.kind===`shown`;if(pF(e.name)===void 0)return!1;if(n.kind!==`shown`)return n.kind===`failed`;try{return gW(t.segments[e.name].when,bD(S,e.settings))}catch{return!0}};h.layout=()=>iK(E,se).map(e=>e.flatMap(({name:e,address:t,settings:n})=>{let r=pF(e);return r===void 0?[]:[{name:r,address:t,palette:hy(n.theme,ie)}]}));let ce=$G(oe(E,!0,Ch(ee))).map(({line:e,row:t})=>{let n=kW(e.cells,o);return Xv(n.map(e=>e.owner),o,ae.row(t,n))});ae.drawn();let le=ce.some(e=>e.moves)?`moves`:y.kind===`expression`||b||jK(E).some(({settings:e})=>e.effect!==`bar`&&e.effect!==`none`)?`can-move`:`still`;for(let e of m)p({kind:`band-floor`,message:e});for(let[e,t]of r.cachePolicyFaults())p({kind:`refresh`,variable:e,error:t.message,message:`variable "${e}" cannot refresh: ${t.message}`});return{text:ce.map(e=>e.text).join(`
204
209
  `),motion:le}}catch(e){l.e=e}finally{l.d()}}function*PK(e){yield*Object.entries(e.variables??{});for(let[t,n]of Object.entries(e.segments??{}))for(let[e,r]of Object.entries(n.vars??{}))yield[`${t}.${e}`,r]}function*FK(e){for(let t of Object.values(e.segments))for(let e of[t.template,t.bg,t.fg,t.when])e!==void 0&&(yield e);for(let t of Iy(e.presets)){for(let n of _g(zy(e,t).node))n.when!==void 0&&(yield n.when);let n=By(e,t);for(let e of Ih){let t=n[e];Lh(t)&&(yield t)}}for(let[,t]of PK(e))t.kind===`template`&&(yield t.template),wg(t)&&`key`in t.cache&&(yield t.cache.key);for(let t of Object.values(e.actions))`copy`in t&&(yield t.copy),`open`in t&&(yield t.open),`preset`in t&&t.preset===`delete`&&(yield t.name)}function IK(e,t){return e===t||t.startsWith(`${e}.`)||e.startsWith(`${t}.`)}function LK(e,t){let n=new Set,r=new Set,i=new Set;for(let e of FK(t)){for(let r of sb(e,t.helpers).keys())n.add(r);for(let{name:n}of db(e,t.helpers))r.add(n);for(let n of fb(e,t.helpers))i.add(n)}for(let[,e]of PK(t))if(wg(e)&&`depends_on`in e.cache)for(let t of e.cache.depends_on)n.add(t);let a=new Set(r);for(let e of r){let n=t.actions[e];if(n!==void 0&&`do`in n)for(let e of n.do)a.add(e)}let o=new Set,s=new Set;for(let e of a){let n=t.actions[e];if(n!==void 0&&(`set`in n&&o.add(n.set),`insertSegment`in n&&s.add(n.insertSegment),`insertSegmentFrom`in n&&Array.isArray(n.insertSegmentFrom)))for(let e of n.insertSegmentFrom)s.add(e)}for(let e of Iy(t.presets))for(let n of _g(zy(t,e).node))n.kind===`segment`&&s.add(n.name);let c=(e,t)=>[...n].some(t=>IK(t,e))||t.kind===`state`&&o.has(t.key),l=e=>[...e].filter(e=>!tk(e)),u=(e,t,n)=>l(t).filter(e=>!n(e)).map(t=>({kind:e,name:t})),d=new Map(PK(e));return[...u(`variable`,d.keys(),e=>c(e,d.get(e))),...u(`action`,Object.keys(e.actions??{}),e=>a.has(e)),...u(`helper`,Object.keys(e.helpers??{}),e=>i.has(e)),...u(`segment`,Object.keys(e.segments??{}),e=>s.has(e))]}var RK=class{kind=`box`;cell;lastChangedAt;constructor(e,t,n){this.name=e,this.type=t,WK(e,t,n,`initial value`),this.cell=xb.observable.box(n,{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){WK(this.name,this.type,e,`set value`),!Object.is(this.cell.get(),e)&&(this.cell.set(e),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}},zK=class{kind=`computed`;cell;constructor(e,t,n){if(this.name=e,this.type=t,this.cell=(0,xb.computed)(()=>{let e=n();return WK(this.name,this.type,e,`computed result`),e},{keepAlive:!0}),typeof this.cell.suspend_!=`function`)throw TypeError(`Variable "${e}": this MobX's computed has no suspend_; release() cannot unsubscribe it`);if(typeof this.cell.keepAlive_!=`boolean`)throw TypeError(`Variable "${e}": this MobX's computed has no keepAlive_ flag; release() cannot lift it`)}read(){return this.cell.get()}release(){this.cell.keepAlive_=!1,this.cell.suspend_()}lastUpdatedMs(){return null}},BK=class{kind=`document`;cell;lastChangedAt;constructor(e,t){this.name=e,this.cell=xb.observable.box(UK(t),{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){let t=UK(e);HK(this.cell.get(),t)||(this.cell.set(t),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}};function VK(e){return JSON.stringify(e)}function HK(e,t){return VK(e)===VK(t)}function UK(e){return e.kind===`ok`?{kind:`ok`,value:Sb(e.value)}:e}function WK(e,t,n,r){let i=Cb(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var GK=class{nodes=xb.observable.map(void 0,{deep:!1});defineBox(e,t,n){this.declare(e,new RK(e,t,n))}defineDocument(e,t){this.declare(e,new BK(e,t))}defineComputed(e,t,n){let r=e=>this.read(e);this.declare(e,new zK(e,t,()=>n(r)))}read(e){return this.requireVar(e).read()}readDocument(e){let t=this.requireNode(e);if(t.kind!==`document`)throw TypeError(`Variable "${e}" is a ${t.kind}, not a document`);return t.read()}setDocument(e,t){let n=this.requireNode(e);if(n.kind!==`document`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a document (use defineDocument to create one)`);(0,xb.runInAction)(()=>n.set(t))}setBox(e,t){let n=this.requireNode(e);if(n.kind!==`box`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a box (use defineBox to create a settable variable)`);(0,xb.runInAction)(()=>n.set(t))}runInAction(e){(0,xb.runInAction)(e)}has(e){return this.nodes.has(e)}getType(e){return this.requireVar(e).type}getKind(e){return this.requireNode(e).kind}changeKey(e){let t=this.requireNode(e);if(t.kind===`document`)return VK(t.read());try{return String(t.read())}catch(e){return`failed:${e instanceof Error?e.message:String(e)}`}}getNode(e){let t=this.requireNode(e);return t.kind===`document`?{name:t.name,kind:t.kind,read:()=>t.read(),lastUpdatedMs:()=>t.lastUpdatedMs()}:{name:t.name,type:t.type,kind:t.kind,read:()=>t.read(),lastUpdatedMs:()=>t.lastUpdatedMs()}}names(){return[...this.nodes.keys()]}dispose(){if(this.disposed)return 0;this.disposed=!0;let e=0;return(0,xb.runInAction)(()=>{for(let t of this.nodes.values())t instanceof zK&&(t.release(),e++)}),e}disposed=!1;requireNode(e){let t=this.nodes.get(e);if(!t)throw ReferenceError(`Unknown variable "${e}"`);return t}requireVar(e){let t=this.requireNode(e);if(t.kind===`document`)throw TypeError(`Variable "${e}" is a document; read its fields by path (.${e}.<field>)`);return t}declare(e,t){if(this.disposed)throw Error(`Variable "${e}": cannot declare on a disposed store`);if(this.nodes.has(e))throw Error(`Variable "${e}" is already declared`);(0,xb.runInAction)(()=>this.nodes.set(e,t))}};function KK(e){return Math.floor(e/4)}function qK(e,{plugins:t,config:n}){let{checkout:r,loaded:i,dropped:a,unreached:o}=t,s=r===null?`-`:`${r.git?`git`:`dir`}:${r.root}`,c=e=>{let t=yz(e),r=t===void 0?void 0:n.variables[xz(t)];return r?.kind===`file`?r.path:`none`};return`config load ${e.join(` < `)||`<default>`}: plugins loaded=${i.length} dropped=${a.length} unplaced=${o.length} checkout=${s}`+i.map(e=>` +${e} data=${c(e)}`).join(``)+a.map(e=>` -${e.path} (${e.reason})`).join(``)+o.map(e=>` ~${e.path} (${e.reason})`).join(``)}function JK(e,t){return`config disposed reason=${e.reason} released=${t} held=${e.held}`}function YK(e,t,n){return e+`\0`+t+`\0`+(n??``)}function XK(e,t){return new Set(Iy(e.presets).filter(n=>zy(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function ZK(e,t){let n=new Map,{roots:r,loaded:i,dropped:a,unreached:o}=e.state.plugins;for(let t of[...Xz(e.projectDir,e.cwd,e.configFile),...r,...i,...[...a,...o].map(e=>e.path)]){let{dir:e,name:r}=_b(t),i=n.has(e)?n.get(e):new Set;i?.add(r),n.set(e,i)}for(let e of r){let{dir:t,name:r,leaf:i}=_b(s.join(e,`_`));i&&r===`_`&&n.set(t,null)}return{files:t,dirs:[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>t===null?{path:e}:{path:e,filenames:[...t].sort()})}}function QK(e){return e.filter(Boolean).join(`
205
- `)||null}function $K(e,t,n,r,i=()=>{}){let{layers:a,config:o,installed:s}=dB(t.layers,PB,{entered:i,warned:e=>n.push(...e)},{projectDir:t.projectDir,cwd:e});i(a.length===1?a[0].path:null);let c=a.at(-1)?.config??PB,l=a.find(e=>e.path===t.home)?.raw??{},u=new GK,d=new VO(u,o.globals.default_empty_value??``,r.gitService,r.sessionState),f;try{f=xK(o,d,e,r.compile??bK),n.push(...f.loadWarnings),wV(o),IF(o)}catch(e){throw d.dispose(),e}return{config:o,compileKey:f.compileKey,store:u,registry:d,compiled:f.compiled,neededInputPaths:rW(o),lastRenderCellsBySegment:new Map,authoredRoots:XK(c,l),fileHeldSettings:uV(l),unused:[...new Map(a.flatMap(e=>LK(e.raw,c)).map(e=>[`${e.kind}:${e.name}`,e])).values()],plugins:{checkout:s.checkout,roots:s.roots,loaded:[...s.rendering.values()],dropped:[...s.dropped,...a.flatMap(e=>e.plugins.dropped)],unreached:s.unreached,reached:s.reached,rendering:s.rendering}}}function eq(e,t,n,r){let i=Qz(e,t,n),a={layers:i.kind===`chain`?i.layers:[],home:i.home,projectDir:e},o=[rB(e,t),tB(i)],s,c=null;try{s=$K(t,a,o,r,e=>{c=e})}catch(e){return e instanceof Hg&&o.push(...e.warnings),{layers:a.layers,home:a.home,failedFile:c,warning:QK(o),state:null,error:e instanceof Hg||e instanceof Error?e.message:String(e)}}return{layers:a.layers,home:a.home,warning:QK(o),state:s,error:null}}function tq(e,t,n){return $K(e,{layers:[],home:``,projectDir:t},[],n)}var nq=class{entries=new Map;holds=new Map;compiles=new Map;deps;log;budgetBytes;maxEntries;observers;constructor(e,t){this.deps={...e,compile:(e,t)=>this.compileOf(e,t)},this.log=e.log??Oe,this.budgetBytes=t.budgetBytes,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{}}compileOf(e,t){return this.compiles.get(e)??TK(t)}accountedBytes(){let e=new Set([...this.entries.values()].map(e=>e.state.compileKey));return this.entries.size*3145728+e.size*10485760}getOrCreate(e,t,n){let r=YK(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=eq(e,t,n,this.deps);a.state!==null&&this.log(`info`,qK(a.layers,a.state));let o={projectDir:e,cwd:t,configFile:n,configLayers:[],configHome:``,failedFile:null,lastError:a.error,lastWarning:a.warning,state:a.state??tq(t,e,this.deps),watcher:null,watcherKey:null};return this.serve(o.state),this.entries.set(r,o),this.fit(o),this.log(`info`,`render-cache entry projectDir=${e} cwd=${t} compile=${o.state.compileKey.slice(0,12)} entries=${this.entries.size} compiles=${this.compiles.size} accounted=${Nn(this.accountedBytes())}/${Nn(this.budgetBytes())}MB`),this.refreshWatcher(o,a),this.observers.onReload?.(o),o}hold(e,t,n){let r=this.getOrCreate(e,t,n),{state:i}=r,a=this.holdOf(i);a.holders++;let o=!1;return{entry:r,state:i,[Symbol.dispose]:()=>{if(o)throw Error(`render-cache hold released twice`);o=!0,a.holders--,this.reclaim(i,a)}}}get stats(){let e=0,t=0;for(let n of this.holds.values())n.holders>0&&e++,n.retired!==null&&t++;return{size:this.entries.size,held:e,retired:t,compiles:this.compiles.size,accountedBytes:this.accountedBytes(),budgetBytes:this.budgetBytes()}}fit(e){let t=()=>this.entries.size<=this.maxEntries&&this.accountedBytes()<=this.budgetBytes();for(let[n,r]of this.entries){if(t())return;r!==e&&(r.watcher?.release(),this.entries.delete(n),this.retire(r.state,`evict`))}}serve(e){let t=this.compiles.get(e.compileKey);if(t!==void 0&&t!==e.compiled)throw Error(`render cache: a second compile for key ${e.compileKey.slice(0,12)}`);this.holds.set(e,{holders:0,retired:null}),this.compiles.set(e.compileKey,e.compiled),t===void 0&&this.log(`info`,`render-cache compile built key=${e.compileKey.slice(0,12)} compiles=${this.compiles.size}`)}holdOf(e){let t=this.holds.get(e);if(t===void 0)throw Error(`render-cache state never served`);return t}retire(e,t){let n=this.holdOf(e);n.retired={reason:t,held:n.holders},this.reclaim(e,n)}reclaim(e,t){t.retired===null||t.holders>0||(this.holds.delete(e),this.log(`info`,JK(t.retired,e.registry.dispose())),[...this.holds.keys()].some(t=>t.compileKey===e.compileKey)||this.compiles.delete(e.compileKey))}reload(e,t,n){this.reloadInto(this.getOrCreate(e,t,n))}reloadInto(e){let t=eq(e.projectDir,e.cwd,e.configFile,this.deps);if(e.lastWarning=t.warning,e.lastError=t.error,t.state!==null){this.log(`info`,qK(t.layers,t.state));let n=e.state;e.state=t.state,this.serve(t.state),this.retire(n,`reload`)}this.fit(e),this.refreshWatcher(e,t),this.observers.onReload?.(e)}refreshWatcher(e,t){e.configLayers=t.layers,e.configHome=t.home,e.failedFile=t.error===null?null:t.failedFile;let n=ZK(e,t.layers),r=`config:${e.projectDir}:${e.cwd}:${e.configFile??``}:${JSON.stringify(n)}`;e.watcher!==null&&e.watcherKey===r||(e.watcher?.release(),e.watcherKey=r,e.watcher=this.deps.watchers.acquire(r,n,()=>this.onConfigChanged(e)))}onConfigChanged(e){this.log(`info`,`config change detected for entry projectDir=${e.projectDir} cwd=${e.cwd}`),this.reloadInto(e)}get size(){return this.entries.size}firstState(){return this.entries.values().next().value?.state??null}};const rq=16384;var iq=class e{startedAt=new Date;requestsTotal=0;requestsErrored=0;requestsTimedOut=0;inFlight=0;watchersOpened=0;watchersClosed=0;subprocessTotal=0;subprocessInFlight=0;subprocessCount=new Map;subprocessHistogram=new Map;subprocessHistogramRotator=new Map;rollingTimestamps=[];rollingHead=0;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)}};recordRollingNow(){let e=Date.now();if(this.rollingTimestamps.length<rq){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%rq}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=Date.now()-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,p50DurationMs:r,p99DurationMs:i}}static referenceSnapshot(){return new e().snapshot({gitCache:{size:0,expired:0,hits:0,misses:0,invalidations:0,watchers:0},usageCache:{size:0,hits:0,misses:0,sweeps:0},transcriptReads:{reads:0,bytes:0,longLines:0,largestLine:0},renderCache:{size:0,held:0,retired:0,compiles:0,accountedBytes:0,budgetBytes:0},effectCache:{sessions:0,effects: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},watchersActive:0,handlerProbes:[],clients:[],bundle:`/`,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:qe,sourceDigest:Xe(),protocolVersion:3,startedAt:this.startedAt.toISOString(),uptimeSec:Math.floor((Date.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},gitCache:e.gitCache,usageCache:e.usageCache,transcriptReads:e.transcriptReads,renderCache:e.renderCache,effectCache:e.effectCache,sessionState:e.sessionState,frameFeeds:e.frameFeeds,tmuxStatus:e.tmuxStatus,watchers:{active:e.watchersActive,opened:this.watchersOpened,closed:this.watchersClosed},subprocesses:this.snapshotSubprocesses(),nextRestartReason:e.nextRestartReason??null,handlerProbes:e.handlerProbes,clients:e.clients,bundle:e.bundle,daemon:e.daemon,doctorStores:e.doctorStores}}};function aq(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),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 oq={load:()=>({}),save:()=>{},flush:()=>{}};var sq=class{sessions;storage;head=0;atom=(0,xb.createAtom)(`SessionState`);constructor(e=oq,t=256){this.maxSessions=t,this.storage=e,this.sessions=new Map,this.hydrateFromStorage()}useStorage(e){this.storage=e,this.hydrateFromStorage()}hydrateFromStorage(){this.sessions=new Map(Object.entries(this.storage.load()).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}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){t.length!==0&&(0,xb.runInAction)(()=>{let n=this.sessions.get(e)??{values:new Map,revision:0};t.some(({key:e,value:t})=>n.values.get(e)!==t)&&(n.revision=++this.head);for(let{key:e,value:r}of t)n.values.set(e,r);this.touch(e,n),this.evictOldest(),this.persist(),this.atom.reportChanged()})}clear(e,t){(0,xb.runInAction)(()=>{let n=this.sessions.get(e);n&&(n.values.delete(t)&&(n.revision=++this.head),n.values.size===0?this.sessions.delete(e):this.touch(e,n)),this.persist(),this.atom.reportChanged()})}prune(e){(0,xb.runInAction)(()=>{for(let t of this.sessions.keys())e.has(t)||this.sessions.delete(t);this.persist(),this.atom.reportChanged()})}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()}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 cq(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;for(let t of Object.values(e)){if(typeof t!=`object`||!t||Array.isArray(t))return!1;for(let e of Object.values(t))if(typeof e!=`string`)return!1}return!0}var lq=class{timer=null;pending=null;constructor(e,t=500,n=Oe){this.filePath=e,this.debounceMs=t,this.logger=n}load(){let e;try{e=p.readFileSync(this.filePath,`utf8`)}catch(e){let t=e.code;return t!==`ENOENT`&&this.logger(`warn`,`session-state read failed (${t}); starting empty`),{}}try{let t=JSON.parse(e);return cq(t)?t:(this.logger(`warn`,`session-state load: unexpected shape, starting empty`),{})}catch{return this.logger(`warn`,`session-state load: corrupt JSON, starting empty`),{}}}save(e){this.pending=e,!this.timer&&(this.timer=setTimeout(()=>this.flush(),this.debounceMs),this.timer.unref())}flush(){if(this.timer&&=(clearTimeout(this.timer),null),this.pending===null)return;let e=this.pending;try{p.mkdirSync(s.dirname(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp`;p.writeFileSync(t,JSON.stringify(e),{mode:384}),p.chmodSync(t,384),p.renameSync(t,this.filePath),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}};const uq=new Set([`1`,`true`]),dq=new Set([`0`,`false`,``]);function fq(e,t){let n=Lq(e),r=n.scope===`segment-palette`?`string`:iv(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(uq.has(t))return`true`;if(dq.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function pq(e){try{return p.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function mq(e,t,n){try{if(t===null){p.rmSync(pt(e),{force:!0});return}O(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function hq(e){return/^\s*$/.test(e)?null:_i(e)}function gq(e,t){return e!==null&&yi(e,t)!==void 0}function _q(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(_q),...i}}return e}function vq(e){if(!Ey(e))return _q(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,_q(t)])),...n}}const yq=MB,bq=yq.segments,xq=yq.presets,Sq=yq.root;function Cq(e,t,n,r){if(!gq(e,t)&&n===void 0)throw new J(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function wq(e,t){let n=eA(t);return t.scope===`segment-palette`&&Cq(e,[`segments`,t.segment],bq[t.segment],n.join(`.`)),n}function Tq(e){return _i(Di(e))}function Eq(){return Object.entries(Sq.rows).map(([e,t])=>{let n=_q(t);return{path:[`root`],fragment:Tq({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function Dq(e,t){let n=e===null?void 0:yi(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function Oq(e,t){if(t===void 0)return null;let n=vq(t);return{path:e,fragment:Tq(n),unit:{path:e,value:n}}}function kq(e,t){let n=[`presets`,t],r=[...n,`root`],i=xq[t];Cq(e,n,i,r.join(`.`));let a=Dq(e,r)??Oq(r,i?.root);return a!==null&&Ji(a.fragment)?a:null}function Aq(e,t){let n=qi(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 jq(e,t){return[...Eq(),Dq(e,[`root`]),kq(e,t)].filter(e=>e!==null).reduce(Aq,new Map)}function Mq(e,t,n){for(let{node:r,...i}of jq(e,t).values())if(Xi(r,n))return i;throw new J(`${Nq(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 Nq(e,t){return kq(e,t)?.path??[`root`]}function Pq(e,t){return t.scope===`preset-root`?Nq(e,t.preset):eA(t)}function Fq(e,{unit:t}){return t===null?e:Vi(e,t.path,Di(t.value),Ti)}function Iq(e){let t=$k(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function Lq(e){let t=Iq(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function Rq(e,t,n,r,i){i(t,n,Yq(t,r)),mq(t.path,r,e.logger),e.record(t.path,n,r)}function zq(e,t,n){let r=Hq(e,t,n);if(r.length>0)throw new J(`refused: ${e.above.join(`, `)} sets ${r.join(`, `)} over ${e.path}, so this click would change nothing on the bar — edit it there`)}const Bq=()=>{};function Vq(e,t){try{return t()}catch(t){throw!(t instanceof J)||e.above.length===0?t:new J(`${t.message} — or it is declared by ${e.above.join(`, `)}, which the bar does not edit`)}}function Hq(e,t,n){let r=Uq(e,t);if(r===null)return[];let i=new Set(qq(Kq(r),Kq(n)));return qq(Gq(e,r),Gq(e,n)).filter(e=>!i.has(e))}function Uq(e,t){try{return Wq(e,t)}catch(e){if(e instanceof Hg)return null;throw e}}function Wq(e,t){return dB(t===null?e.above:[e.path,...e.above],PB,{entered:()=>{},warned:()=>{}},{projectDir:e.projectDir,cwd:e.cwd},n=>n===e.path&&t!==null?t:p.readFileSync(n,`utf8`))}function Gq(e,t){let[n]=t.layers;return n?.path===e.path?n.config:t.base}function Kq(e){return e.layers.at(-1)?.config??e.base}function qq(e,t,n=``){return!Jq(e)||!Jq(t)?JSON.stringify(e)===JSON.stringify(t)?[]:[n]:[...new Set([...Object.keys(e),...Object.keys(t)])].flatMap(r=>qq(e[r],t[r],n===``?r:`${n}.${r}`))}function Jq(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yq(e,t){try{return Wq(e,t)}catch(e){throw e instanceof Hg?new J(`refused: the config file would not load after this click — ${e.message}`):e}}function Xq(e,t){let n=Lq(t),r=hq(pq(e)??``),i=r===null?void 0:yi(r,eA(n));return i!==void 0&&`value`in i?i.value:void 0}function Zq(e,t,n){Qq(e,t,n,[])}function Qq(e,t,n,r){let i=pq(t.path),a=n.reduce((e,[t,n])=>Vi(e,wq(hq(e),Lq(t)),fq(t,n),Ti),i??``);Rq(e,t,i,Vq(t,()=>$q(a,t.path,r,e=>e)),zq)}function $q(e,t,n,r){return n.reduce((e,{preset:n,id:i,setting:a,value:o})=>{let s=r(e,n,i),c=Mq(hq(s),n,i),l=ea(Fq(s,c),c.path,i,a,Di(o));if(l===null)throw new J(`${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 eJ(e,t,n){let r=hq(e),i=[`presets`,t,`root`];for(let[a,{path:o,unit:s,node:c}]of jq(r,t)){if(!Xi(c,n))continue;if(i.every((e,t)=>o[t]===e))return e;let l=s===null?xi(e,c):Di(s.value);if(a!==`#`)return Vi(e,[...i,`rows`,a],l,Ti);if(kq(r,t)!==null)throw new J(`cannot give preset "${t}" its own copy of ${o.join(`.`)}: it already stages rows of its own over that tree`);return Vi(e,i,l,Ti)}return e}function tJ(e,t){return Ui(e,t,t[0]===`presets`&&t.length>2&&!IB(t[1])?2:0)}function nJ(e,t,n){let r=n.map(Iq),i=pq(t.path);if(i===null)return;let a=r.reduce((e,t)=>tJ(e,Pq(hq(e),t)),i);a!==i&&Rq(e,t,i,a,Bq)}function rJ(e){let t=e===null?void 0:yi(e,[`presets`]);return t?.kind===`object`?t.entries.map(e=>e.key):[]}function iJ(e,t){let n=new Set([...FB,...rJ(e),...t.above.flatMap(e=>Object.keys(ui.default.parse(p.readFileSync(e,`utf8`)).presets??{}))].map(XO));return Array.from({length:n.size+1},(e,t)=>`custom-${t+1}`).find(e=>!n.has(XO(e)))}function aJ(e,t,n,r,i,a){let o=pq(t.path),s=hq(o??``),c=iJ(s,t),l=[`presets`,c],u=Vq(t,()=>kq(s,n)),d=[...u===null?[]:[[[...l,`root`],u.unit===null?xi(o??``,u.fragment):Di(u.unit.value)]],...Object.keys(r).length===0?[]:[[[...l,`globals`],Di(r)]]],f=i.map(([e,t])=>{let n=Qk(c,e);return[wq(s,Lq(n)),fq(n,t)]}),p=[...d,...f].reduce((e,[t,n])=>Vi(e,t,n,Ti),Vi(o??``,l,`{}`,Ti));return Rq(e,t,o,Vq(t,()=>$q(p,t.path,a.map(e=>({...e,preset:c})),eJ)),zq),c}function oJ(e,t,n,r){let i=pq(t.path);Rq(e,t,i,Vi(i??``,[`themeDefaults`,n],Di(r),Ti),zq)}function sJ(e,t,n){if(IB(n))throw new J(`cannot delete preset "${n}": it is bundled — reset its settings instead`);let r=[`presets`,n],i=pq(t.path),a=hq(i??``);if(i===null||a===null||yi(a,r)===void 0)throw new J(`cannot delete preset "${n}": ${t.path} declares no ${r.join(`.`)} — the bar you clicked is stale; it reloads on the next render`);let o=yi(a,[`globals`,`preset`]);Rq(e,t,i,[r,...o?.kind===`string`&&o.value===n?[[`globals`,`preset`]]:[]].reduce((e,t)=>tJ(e,t),i),Bq)}function cJ(e,t,n,r){let i=Iq(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=pq(t.path),o=r.op===`remove`?r.target:r.anchor,s=Vq(t,()=>Mq(hq(a??``),i.preset,o)),c=Fq(a??``,s),{after:l,placed:u}=lJ(c,s.path,r,()=>{let e=Yq(t,c).config;return Iy(e.presets).map(t=>zy(e,t).node)});if(l===null)throw new J(`${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 Rq(e,t,a,l,zq),u}function lJ(e,t,n,r){switch(n.op){case`remove`:return{after:Qi(e,t,n.target),placed:null};case`insert`:{let i=CF(n.segment,n.anchor,r());return{after:$i(e,t,i,n.anchor,n.relation),placed:i}}}}const uJ={load:()=>({}),save:()=>{}},dJ=new Set(lv.map(e=>e.sessionKey)),fJ=e=>dJ.has(e)||e.startsWith(dA),pJ=8*1024*1024,mJ={past:[],future:[]},hJ=e=>e.kind===`session`?`session:${e.key}`:`file:${e.file}`;var gJ=class{state=new Map;moves=new Map;head=0;constructor(e,t,n=uJ){this.sessionState=e,this.logger=t,this.storage=n,this.state=new Map(Object.entries(n.load()))}useStorage(e){this.storage=e,this.state=new Map(Object.entries(e.load()))}depth(e){let{past:t,future:n,savepoint:r}=this.state.get(e)??mJ;return{undo:t.length,redo:n.length,sinceEdit:r?.net.length??0}}revision(e){return this.moves.get(e)??0}history(e){return this.state.get(e)??mJ}begin(){let e=new Map,t=(t,n)=>{let r=e.get(t)??new Map,i=r.get(hJ(n));r.set(hJ(n),i===void 0?n:{...n,before:i.before}),e.set(t,r)},n=new Map;return{sessionState:aq(this.sessionState,e=>fJ(e)||e===`edit.mode`,(e,r,i,a)=>{if(r===`edit.mode`){let t=n.get(e);n.set(e,{before:t===void 0?i:t.before,after:a});return}t(e,{kind:`session`,key:r,before:i,after:a})}),file:(e,n,r,i)=>t(e,{kind:`file`,file:n,before:r,after:i}),commit:()=>{let t=new Map(e),r=new Map(n);e.clear(),n.clear();for(let e of new Set([...t.keys(),...r.keys()])){let n=[...t.get(e)?.values()??[]].filter(e=>e.before!==e.after),i=this.history(e),a=n.length===0?i:wJ(i,n),o=r.get(e),s=o===void 0?a:OJ(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 J(`undo: nothing to undo`);return this.apply(e,n,`before`,`undo`,EJ(t,n)),n}rewind(e){let t=this.history(e),{savepoint:n}=t;if(n===void 0)throw new J(`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(hJ)),a=n.net.filter(e=>!i.has(hJ(e))),o=yJ(kJ(DJ(t,n),i));if(this.apply(e,a,`before`,`rewind`,{past:o,future:[],savepoint:{at:o.length,net:[],below:[]}}),r.length>0)throw new J(`rewind: ${r.map(jJ).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 J(`redo: nothing to redo`);let a=[...n,i],o=yJ(a);return this.apply(e,i,`after`,`redo`,{past:o,future:r.slice(0,-1),...xJ(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(hJ)),{past:n,future:i,savepoint:a}=this.history(e);throw this.put(e,{past:kJ(n,t),future:kJ(i,t),...a!==void 0&&{savepoint:{at:kJ([...n,...[...i].reverse()].slice(0,a.at),t).length,net:a.net.filter(e=>!t.has(hJ(e))),below:kJ(a.below,t)}}}),new J(`${r}: ${o.map(jJ).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):pq(t.file)}write(e,t,n){t.kind===`file`?mq(t.file,n,this.logger):n===null?this.sessionState.clear(e,t.key):this.sessionState.set(e,t.key,n)}put(e,t){this.moves.delete(e),this.moves.set(e,++this.head);for(let[e]of this.moves){if(this.moves.size<=1024)break;this.moves.delete(e)}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||_J(n)>pJ;){let[e,t]=n.entries().next().value;n.size>1?n.delete(e):t.past.length+t.future.length>0?n.set(e,vJ(t)):(this.logger(`warn`,`settings-history: edit mode's changes for session ${e} exceed ${pJ} bytes; cancel is no longer available`),n.delete(e))}this.storage.save(Object.fromEntries(n)),this.state=n}};function _J(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 vJ({past:e,future:t,savepoint:n}){return e.length>0?{past:e.slice(1),future:t,...xJ(n,1,[])}:{past:e,future:t.slice(1),...xJ(n,0,[])}}function yJ(e){return e.slice(-50)}const bJ=e=>e===pA.member;function xJ(e,t,n){return e===void 0?{}:{savepoint:{at:Math.max(0,e.at-t),net:SJ(e.net,n),below:e.below}}}function SJ(e,t){let n=new Map(e.map(e=>[hJ(e),e]));for(let e of t){let t=n.get(hJ(e));n.set(hJ(e),t===void 0?e:{...t,after:e.after})}return[...n.values()].filter(e=>e.before!==e.after)}const CJ=e=>e.map(e=>({...e,before:e.after,after:e.before}));function wJ(e,t){let n=[...e.past,t],r=yJ(n),{savepoint:i}=e,a=i===void 0?0:Math.max(0,i.at-e.past.length);return{past:r,future:[],...xJ(i&&{at:Math.min(i.at,e.past.length),net:i.net,below:[...TJ(e.future,a),...i.below]},n.length-r.length,t)}}function TJ(e,t){let n=Math.min(t,e.length);return e.slice(e.length-n).reverse()}function EJ(e,t){return{past:e.past.slice(0,-1),future:yJ([...e.future,t]),...xJ(e.savepoint,0,CJ(t))}}function DJ(e,t){let{past:n,future:r}=e,i=n.slice(0,t.at);return[...i,...TJ(r,t.at-i.length),...t.below]}function OJ(e,t){if(bJ(t.after)&&!bJ(t.before))return{...e,savepoint:{at:e.past.length,net:[],below:[]}};if(!bJ(t.after)&&bJ(t.before)){let{past:t,future:n}=e;return{past:t,future:n}}return e}function kJ(e,t){return e.map(e=>e.filter(e=>!t.has(hJ(e)))).filter(e=>e.length>0)}function AJ(e){return e.map(jJ).join(`, `)}function jJ(e){return e.kind===`session`?`session setting "${e.key}"`:e.file}function MJ(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`&&typeof t.file==`string`)&&n(t.before)&&n(t.after)}function NJ(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(MJ))}function PJ(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(MJ)&&NJ(t.below)}function FJ(e){if(typeof e!=`object`||!e)return!1;let t=e;return NJ(t.past)&&NJ(t.future)&&(t.savepoint===void 0||PJ(t.savepoint))}function IJ(e,t){let n=e=>e.kind===`file`||fJ(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 LJ(e,t){return{load:()=>{let n;try{n=p.readFileSync(e,`utf8`)}catch(e){let n=e.code;return n!==`ENOENT`&&t(`warn`,`settings-history read failed (${n}); starting empty`),{}}try{let e=JSON.parse(n);if(typeof e==`object`&&e&&!Array.isArray(e)&&Object.values(e).every(FJ)){let n=new Set,r=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,IJ(t,n)]));return n.size>0&&t(`warn`,`settings-history load: dropped the changes to ${[...n].map(e=>`"${e}"`).join(`, `)}, no longer a setting`),r}}catch{}return t(`warn`,`settings-history load: unexpected shape, starting empty`),{}},save:n=>{try{p.mkdirSync(s.dirname(e),{recursive:!0}),O(e,JSON.stringify(n),384)}catch(e){let n=`settings-history write failed — the change landed but is not undoable: ${e.message}`;throw t(`error`,n),Error(n)}}}}const RJ=e=>!fJ(e)&&!WM(e)&&e!==`update.dismissed`;var zJ=class{past=new Map;depth(e,t,n){return this.restorable(e,t,n).length}restorable(e,t,n){let r=new Map,i=n=>r.has(n)?r.get(n):t.get(e,n),a=[];for(let t of[...this.past.get(e)??[]].reverse())if(t.every(e=>i(e.key)===e.after&&(e.before===null||n.validate(e.key,e.before).ok))){a.unshift(t);for(let e of t)r.set(e.key,e.before)}return a}begin(e){let t=new Map;return{sessionState:aq(e,RJ,(e,n,r,i)=>{let a=t.get(e)??new Map,o=a.get(n);a.set(n,{key:n,before:o?o.before:r,after:i}),t.set(e,a)}),commit:()=>{for(let[e,n]of t){let t=[...n.values()].filter(e=>e.before!==e.after);t.length>0&&this.push(e,t)}t.clear()}}}back(e,t,n){let r=this.past.get(e)??[],i=this.restorable(e,t,n),a=i.at(-1),o=r.length-i.length;if(a===void 0)throw this.put(e,i),new J(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,xb.runInAction)(()=>{let n=a.flatMap(({key:e,before:t})=>t===null?[]:[{key:e,value:t}]);n.length>0&&t.setBatch(e,n);for(let{key:n,before:r}of a)r===null&&t.clear(e,n)}),this.put(e,i.slice(0,-1)),{step:a,discarded:o}}push(e,t){let n=this.past.get(e)??[];this.put(e,[...n,t].slice(-20))}put(e,t){for(this.past.delete(e),t.length>0&&this.past.set(e,t);this.past.size>32;)this.past.delete(this.past.keys().next().value)}};const BJ=`click.error`;function VJ(e,t,n,r){let i={text:n,at:r,answered:!1};e.set(t,BJ,JSON.stringify(i))}function HJ(e,t,n){let r=UJ(e,t);!(r?.at===n.at&&r.text===n.text)||r.answered||e.set(t,BJ,JSON.stringify({...r,answered:!0}))}function UJ(e,t){let n=e.get(t,BJ);return n===null?null:GJ(n)}function WJ(e,t,n,r){let i=UJ(e,t);return i===null?{kind:`none`}:n<i.at+5?{kind:`held`,error:i}:r===`request`&&!i.answered?{kind:`owed`,error:i}:{kind:`over`}}function GJ(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{text:n,at:r,answered:i}=t;return typeof n==`string`&&typeof r==`number`&&(i===void 0||typeof i==`boolean`)?{text:n,at:r,answered:i===!0}:null}function KJ(e,t,n,r){let i=s.join(e,t),a=()=>{let e;try{e=p.readFileSync(i,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`ok`,value:n}:{kind:`failed`,reason:`${i}: ${e.message}`}}let t;try{t=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${i} is not JSON: ${e.message}`}}let a=r(t);return a.kind===`ok`?a:{kind:`failed`,reason:`${i} ${a.reason}`}};return{read:a,update:e=>{let t=a();if(t.kind===`failed`)return t;let n=e(t.value);return n!==t.value&&O(i,`${JSON.stringify(n,null,2)}\n`),{kind:`ok`,value:n}}}}const qJ=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function JJ(e){let t=e=>({kind:`failed`,reason:e});if(!qJ(e))return t(`is not an object`);for(let[n,r]of Object.entries(e)){if(!qJ(r))return t(`holds ${JSON.stringify(n)} as something other than its sightings`);for(let[e,n]of Object.entries(r))if(!Aj.includes(n))return t(`marks ${JSON.stringify(e)} ${JSON.stringify(n)}, not ${Aj.join(` or `)}`)}return{kind:`ok`,value:e}}function YJ(e,t,n,r){return{...e,[t]:{...e[t],[n]:r}}}const XJ=e=>KJ(e,`doctor-marks.json`,{},JJ),ZJ=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of terminals`},QJ=(e,t)=>e.includes(t)?e:[...e,t],$J=e=>KJ(e,`doctor-clicked-terminals.json`,[],ZJ);var eY=class extends Error{constructor(e){super(`the doctor looked at ${e} less than a second ago — click again`),this.name=`DoctorBusy`}};const tY=e=>e===void 0||e===``?{kind:`recent`}:{kind:`shell`,sessionId:e},nY=(e,t)=>t.filter(t=>e.kind===`recent`?t.ago<=300:t.sessionId===e.sessionId),rY=(e,t,n)=>{if(e.kind===`recent`)return n;let[r]=nY(e,t);return r===void 0?n:r.projectDir},iY=(e,t)=>nY(e,t).map(({role:t,frame:n,since:r,redrawn:i,projectDir:a,claudeConfigDir:o})=>({role:t,frame:n,projectDir:a,claudeConfigDir:o,redraws:JA(i,r,e.kind===`recent`?Math.min(...i):0)}));function aY(e){let t=new Map;for(let n of e.split(`
210
+ `)||null}function $K(e,t,n,r,i=()=>{}){let{layers:a,config:o,installed:s}=dB(t.layers,PB,{entered:i,warned:e=>n.push(...e)},{projectDir:t.projectDir,cwd:e});i(a.length===1?a[0].path:null);let c=a.at(-1)?.config??PB,l=a.find(e=>e.path===t.home)?.raw??{},u=new GK,d=new VO(u,o.globals.default_empty_value??``,r.gitService,r.sessionState),f;try{f=xK(o,d,e,r.compile??bK),n.push(...f.loadWarnings),wV(o),IF(o)}catch(e){throw d.dispose(),e}return{config:o,compileKey:f.compileKey,store:u,registry:d,compiled:f.compiled,neededInputPaths:rW(o),lastRenderCellsBySegment:new Map,authoredRoots:XK(c,l),fileHeldSettings:uV(l),unused:[...new Map(a.flatMap(e=>LK(e.raw,c)).map(e=>[`${e.kind}:${e.name}`,e])).values()],plugins:{checkout:s.checkout,roots:s.roots,loaded:[...s.rendering.values()],dropped:[...s.dropped,...a.flatMap(e=>e.plugins.dropped)],unreached:s.unreached,reached:s.reached,rendering:s.rendering}}}function eq(e,t,n,r){let i=Qz(e,t,n),a={layers:i.kind===`chain`?i.layers:[],home:i.home,projectDir:e},o=[rB(e,t),tB(i)],s,c=null;try{s=$K(t,a,o,r,e=>{c=e})}catch(e){return e instanceof Hg&&o.push(...e.warnings),{layers:a.layers,home:a.home,failedFile:c,warning:QK(o),state:null,error:e instanceof Hg||e instanceof Error?e.message:String(e)}}return{layers:a.layers,home:a.home,warning:QK(o),state:s,error:null}}function tq(e,t,n){return $K(e,{layers:[],home:``,projectDir:t},[],n)}var nq=class{entries=new Map;holds=new Map;compiles=new Map;deps;log;budgetBytes;maxEntries;observers;constructor(e,t){this.deps={...e,compile:(e,t)=>this.compileOf(e,t)},this.log=e.log??Oe,this.budgetBytes=t.budgetBytes,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{}}compileOf(e,t){return this.compiles.get(e)??TK(t)}accountedBytes(){let e=new Set([...this.entries.values()].map(e=>e.state.compileKey));return this.entries.size*3145728+e.size*10485760}getOrCreate(e,t,n){let r=YK(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=eq(e,t,n,this.deps);a.state!==null&&this.log(`info`,qK(a.layers,a.state));let o={projectDir:e,cwd:t,configFile:n,configLayers:[],configHome:``,failedFile:null,lastError:a.error,lastWarning:a.warning,state:a.state??tq(t,e,this.deps),watcher:null,watcherKey:null};return this.serve(o.state),this.entries.set(r,o),this.fit(o),this.log(`info`,`render-cache entry projectDir=${e} cwd=${t} compile=${o.state.compileKey.slice(0,12)} entries=${this.entries.size} compiles=${this.compiles.size} accounted=${Nn(this.accountedBytes())}/${Nn(this.budgetBytes())}MB`),this.refreshWatcher(o,a),this.observers.onReload?.(o),o}hold(e,t,n){let r=this.getOrCreate(e,t,n),{state:i}=r,a=this.holdOf(i);a.holders++;let o=!1;return{entry:r,state:i,[Symbol.dispose]:()=>{if(o)throw Error(`render-cache hold released twice`);o=!0,a.holders--,this.reclaim(i,a)}}}get stats(){let e=0,t=0;for(let n of this.holds.values())n.holders>0&&e++,n.retired!==null&&t++;return{size:this.entries.size,held:e,retired:t,compiles:this.compiles.size,accountedBytes:this.accountedBytes(),budgetBytes:this.budgetBytes()}}fit(e){let t=()=>this.entries.size<=this.maxEntries&&this.accountedBytes()<=this.budgetBytes();for(let[n,r]of this.entries){if(t())return;r!==e&&(r.watcher?.release(),this.entries.delete(n),this.retire(r.state,`evict`))}}serve(e){let t=this.compiles.get(e.compileKey);if(t!==void 0&&t!==e.compiled)throw Error(`render cache: a second compile for key ${e.compileKey.slice(0,12)}`);this.holds.set(e,{holders:0,retired:null}),this.compiles.set(e.compileKey,e.compiled),t===void 0&&this.log(`info`,`render-cache compile built key=${e.compileKey.slice(0,12)} compiles=${this.compiles.size}`)}holdOf(e){let t=this.holds.get(e);if(t===void 0)throw Error(`render-cache state never served`);return t}retire(e,t){let n=this.holdOf(e);n.retired={reason:t,held:n.holders},this.reclaim(e,n)}reclaim(e,t){t.retired===null||t.holders>0||(this.holds.delete(e),this.log(`info`,JK(t.retired,e.registry.dispose())),[...this.holds.keys()].some(t=>t.compileKey===e.compileKey)||this.compiles.delete(e.compileKey))}reload(e,t,n){this.reloadInto(this.getOrCreate(e,t,n))}reloadInto(e){let t=eq(e.projectDir,e.cwd,e.configFile,this.deps);if(e.lastWarning=t.warning,e.lastError=t.error,t.state!==null){this.log(`info`,qK(t.layers,t.state));let n=e.state;e.state=t.state,this.serve(t.state),this.retire(n,`reload`)}this.fit(e),this.refreshWatcher(e,t),this.observers.onReload?.(e)}refreshWatcher(e,t){e.configLayers=t.layers,e.configHome=t.home,e.failedFile=t.error===null?null:t.failedFile;let n=ZK(e,t.layers),r=`config:${e.projectDir}:${e.cwd}:${e.configFile??``}:${JSON.stringify(n)}`;e.watcher!==null&&e.watcherKey===r||(e.watcher?.release(),e.watcherKey=r,e.watcher=this.deps.watchers.acquire(r,n,()=>this.onConfigChanged(e)))}onConfigChanged(e){this.log(`info`,`config change detected for entry projectDir=${e.projectDir} cwd=${e.cwd}`),this.reloadInto(e)}get size(){return this.entries.size}firstState(){return this.entries.values().next().value?.state??null}};const rq=16384;var iq=class e{startedAt=new Date;requestsTotal=0;requestsErrored=0;requestsTimedOut=0;inFlight=0;watchersOpened=0;watchersClosed=0;subprocessTotal=0;subprocessInFlight=0;subprocessCount=new Map;subprocessHistogram=new Map;subprocessHistogramRotator=new Map;rollingTimestamps=[];rollingHead=0;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)}};recordRollingNow(){let e=Date.now();if(this.rollingTimestamps.length<rq){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%rq}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=Date.now()-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,p50DurationMs:r,p99DurationMs:i}}static referenceSnapshot(){return new e().snapshot({gitCache:{size:0,expired:0,hits:0,misses:0,invalidations:0,watchers:0},usageCache:{size:0,hits:0,misses:0,sweeps:0},transcriptReads:{reads:0,bytes:0,longLines:0,largestLine:0},renderCache:{size:0,held:0,retired:0,compiles:0,accountedBytes:0,budgetBytes:0},effectCache:{sessions:0,effects: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},watchersActive:0,handlerProbes:[],clients:[],bundle:`/`,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:qe,sourceDigest:Xe(),protocolVersion:3,startedAt:this.startedAt.toISOString(),uptimeSec:Math.floor((Date.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},gitCache:e.gitCache,usageCache:e.usageCache,transcriptReads:e.transcriptReads,renderCache:e.renderCache,effectCache:e.effectCache,sessionState:e.sessionState,frameFeeds:e.frameFeeds,tmuxStatus:e.tmuxStatus,watchers:{active:e.watchersActive,opened:this.watchersOpened,closed:this.watchersClosed},subprocesses:this.snapshotSubprocesses(),nextRestartReason:e.nextRestartReason??null,handlerProbes:e.handlerProbes,clients:e.clients,bundle:e.bundle,daemon:e.daemon,doctorStores:e.doctorStores}}};function aq(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),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 oq={load:()=>({}),save:()=>{},flush:()=>{}};var sq=class{sessions;storage;head=0;atom=(0,xb.createAtom)(`SessionState`);constructor(e=oq,t=256){this.maxSessions=t,this.storage=e,this.sessions=new Map,this.hydrateFromStorage()}useStorage(e){this.storage=e,this.hydrateFromStorage()}hydrateFromStorage(){this.sessions=new Map(Object.entries(this.storage.load()).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}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){t.length!==0&&(0,xb.runInAction)(()=>{let n=this.sessions.get(e)??{values:new Map,revision:0};t.some(({key:e,value:t})=>n.values.get(e)!==t)&&(n.revision=++this.head);for(let{key:e,value:r}of t)n.values.set(e,r);this.touch(e,n),this.evictOldest(),this.persist(),this.atom.reportChanged()})}clear(e,t){(0,xb.runInAction)(()=>{let n=this.sessions.get(e);n&&(n.values.delete(t)&&(n.revision=++this.head),n.values.size===0?this.sessions.delete(e):this.touch(e,n)),this.persist(),this.atom.reportChanged()})}prune(e){(0,xb.runInAction)(()=>{for(let t of this.sessions.keys())e.has(t)||this.sessions.delete(t);this.persist(),this.atom.reportChanged()})}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()}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 cq(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;for(let t of Object.values(e)){if(typeof t!=`object`||!t||Array.isArray(t))return!1;for(let e of Object.values(t))if(typeof e!=`string`)return!1}return!0}var lq=class{timer=null;pending=null;constructor(e,t=500,n=Oe){this.filePath=e,this.debounceMs=t,this.logger=n}load(){let e;try{e=p.readFileSync(this.filePath,`utf8`)}catch(e){let t=e.code;return t!==`ENOENT`&&this.logger(`warn`,`session-state read failed (${t}); starting empty`),{}}try{let t=JSON.parse(e);return cq(t)?t:(this.logger(`warn`,`session-state load: unexpected shape, starting empty`),{})}catch{return this.logger(`warn`,`session-state load: corrupt JSON, starting empty`),{}}}save(e){this.pending=e,!this.timer&&(this.timer=setTimeout(()=>this.flush(),this.debounceMs),this.timer.unref())}flush(){if(this.timer&&=(clearTimeout(this.timer),null),this.pending===null)return;let e=this.pending;try{p.mkdirSync(s.dirname(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp`;p.writeFileSync(t,JSON.stringify(e),{mode:384}),p.chmodSync(t,384),p.renameSync(t,this.filePath),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}};const uq=new Set([`1`,`true`]),dq=new Set([`0`,`false`,``]);function fq(e,t){let n=Lq(e),r=n.scope===`segment-palette`?`string`:iv(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(uq.has(t))return`true`;if(dq.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function pq(e){try{return p.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function mq(e,t,n){try{if(t===null){p.rmSync(pt(e),{force:!0});return}O(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function hq(e){return/^\s*$/.test(e)?null:_i(e)}function gq(e,t){return e!==null&&yi(e,t)!==void 0}function _q(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(_q),...i}}return e}function vq(e){if(!Ey(e))return _q(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,_q(t)])),...n}}const yq=MB,bq=yq.segments,xq=yq.presets,Sq=yq.root;function Cq(e,t,n,r){if(!gq(e,t)&&n===void 0)throw new J(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function wq(e,t){let n=eA(t);return t.scope===`segment-palette`&&Cq(e,[`segments`,t.segment],bq[t.segment],n.join(`.`)),n}function Tq(e){return _i(Di(e))}function Eq(){return Object.entries(Sq.rows).map(([e,t])=>{let n=_q(t);return{path:[`root`],fragment:Tq({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function Dq(e,t){let n=e===null?void 0:yi(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function Oq(e,t){if(t===void 0)return null;let n=vq(t);return{path:e,fragment:Tq(n),unit:{path:e,value:n}}}function kq(e,t){let n=[`presets`,t],r=[...n,`root`],i=xq[t];Cq(e,n,i,r.join(`.`));let a=Dq(e,r)??Oq(r,i?.root);return a!==null&&Ji(a.fragment)?a:null}function Aq(e,t){let n=qi(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 jq(e,t){return[...Eq(),Dq(e,[`root`]),kq(e,t)].filter(e=>e!==null).reduce(Aq,new Map)}function Mq(e,t,n){for(let{node:r,...i}of jq(e,t).values())if(Xi(r,n))return i;throw new J(`${Nq(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 Nq(e,t){return kq(e,t)?.path??[`root`]}function Pq(e,t){return t.scope===`preset-root`?Nq(e,t.preset):eA(t)}function Fq(e,{unit:t}){return t===null?e:Vi(e,t.path,Di(t.value),Ti)}function Iq(e){let t=$k(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function Lq(e){let t=Iq(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function Rq(e,t,n,r,i){i(t,n,Yq(t,r)),mq(t.path,r,e.logger),e.record(t.path,n,r)}function zq(e,t,n){let r=Hq(e,t,n);if(r.length>0)throw new J(`refused: ${e.above.join(`, `)} sets ${r.join(`, `)} over ${e.path}, so this click would change nothing on the bar — edit it there`)}const Bq=()=>{};function Vq(e,t){try{return t()}catch(t){throw!(t instanceof J)||e.above.length===0?t:new J(`${t.message} — or it is declared by ${e.above.join(`, `)}, which the bar does not edit`)}}function Hq(e,t,n){let r=Uq(e,t);if(r===null)return[];let i=new Set(qq(Kq(r),Kq(n)));return qq(Gq(e,r),Gq(e,n)).filter(e=>!i.has(e))}function Uq(e,t){try{return Wq(e,t)}catch(e){if(e instanceof Hg)return null;throw e}}function Wq(e,t){return dB(t===null?e.above:[e.path,...e.above],PB,{entered:()=>{},warned:()=>{}},{projectDir:e.projectDir,cwd:e.cwd},n=>n===e.path&&t!==null?t:p.readFileSync(n,`utf8`))}function Gq(e,t){let[n]=t.layers;return n?.path===e.path?n.config:t.base}function Kq(e){return e.layers.at(-1)?.config??e.base}function qq(e,t,n=``){return!Jq(e)||!Jq(t)?JSON.stringify(e)===JSON.stringify(t)?[]:[n]:[...new Set([...Object.keys(e),...Object.keys(t)])].flatMap(r=>qq(e[r],t[r],n===``?r:`${n}.${r}`))}function Jq(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yq(e,t){try{return Wq(e,t)}catch(e){throw e instanceof Hg?new J(`refused: the config file would not load after this click — ${e.message}`):e}}function Xq(e,t){let n=Lq(t),r=hq(pq(e)??``),i=r===null?void 0:yi(r,eA(n));return i!==void 0&&`value`in i?i.value:void 0}function Zq(e,t,n){Qq(e,t,n,[])}function Qq(e,t,n,r){let i=pq(t.path),a=n.reduce((e,[t,n])=>Vi(e,wq(hq(e),Lq(t)),fq(t,n),Ti),i??``);Rq(e,t,i,Vq(t,()=>$q(a,t.path,r,e=>e)),zq)}function $q(e,t,n,r){return n.reduce((e,{preset:n,id:i,setting:a,value:o})=>{let s=r(e,n,i),c=Mq(hq(s),n,i),l=ea(Fq(s,c),c.path,i,a,Di(o));if(l===null)throw new J(`${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 eJ(e,t,n){let r=hq(e),i=[`presets`,t,`root`];for(let[a,{path:o,unit:s,node:c}]of jq(r,t)){if(!Xi(c,n))continue;if(i.every((e,t)=>o[t]===e))return e;let l=s===null?xi(e,c):Di(s.value);if(a!==`#`)return Vi(e,[...i,`rows`,a],l,Ti);if(kq(r,t)!==null)throw new J(`cannot give preset "${t}" its own copy of ${o.join(`.`)}: it already stages rows of its own over that tree`);return Vi(e,i,l,Ti)}return e}function tJ(e,t){return Ui(e,t,t[0]===`presets`&&t.length>2&&!IB(t[1])?2:0)}function nJ(e,t,n){let r=n.map(Iq),i=pq(t.path);if(i===null)return;let a=r.reduce((e,t)=>tJ(e,Pq(hq(e),t)),i);a!==i&&Rq(e,t,i,a,Bq)}function rJ(e){let t=e===null?void 0:yi(e,[`presets`]);return t?.kind===`object`?t.entries.map(e=>e.key):[]}function iJ(e,t){let n=new Set([...FB,...rJ(e),...t.above.flatMap(e=>Object.keys(ui.default.parse(p.readFileSync(e,`utf8`)).presets??{}))].map(XO));return Array.from({length:n.size+1},(e,t)=>`custom-${t+1}`).find(e=>!n.has(XO(e)))}function aJ(e,t,n,r,i,a){let o=pq(t.path),s=hq(o??``),c=iJ(s,t),l=[`presets`,c],u=Vq(t,()=>kq(s,n)),d=[...u===null?[]:[[[...l,`root`],u.unit===null?xi(o??``,u.fragment):Di(u.unit.value)]],...Object.keys(r).length===0?[]:[[[...l,`globals`],Di(r)]]],f=i.map(([e,t])=>{let n=Qk(c,e);return[wq(s,Lq(n)),fq(n,t)]}),p=[...d,...f].reduce((e,[t,n])=>Vi(e,t,n,Ti),Vi(o??``,l,`{}`,Ti));return Rq(e,t,o,Vq(t,()=>$q(p,t.path,a.map(e=>({...e,preset:c})),eJ)),zq),c}function oJ(e,t,n,r){let i=pq(t.path);Rq(e,t,i,Vi(i??``,[`themeDefaults`,n],Di(r),Ti),zq)}function sJ(e,t,n){if(IB(n))throw new J(`cannot delete preset "${n}": it is bundled — reset its settings instead`);let r=[`presets`,n],i=pq(t.path),a=hq(i??``);if(i===null||a===null||yi(a,r)===void 0)throw new J(`cannot delete preset "${n}": ${t.path} declares no ${r.join(`.`)} — the bar you clicked is stale; it reloads on the next render`);let o=yi(a,[`globals`,`preset`]);Rq(e,t,i,[r,...o?.kind===`string`&&o.value===n?[[`globals`,`preset`]]:[]].reduce((e,t)=>tJ(e,t),i),Bq)}function cJ(e,t,n,r){let i=Iq(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=pq(t.path),o=r.op===`remove`?r.target:r.anchor,s=Vq(t,()=>Mq(hq(a??``),i.preset,o)),c=Fq(a??``,s),{after:l,placed:u}=lJ(c,s.path,r,()=>{let e=Yq(t,c).config;return Iy(e.presets).map(t=>zy(e,t).node)});if(l===null)throw new J(`${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 Rq(e,t,a,l,zq),u}function lJ(e,t,n,r){switch(n.op){case`remove`:return{after:Qi(e,t,n.target),placed:null};case`insert`:{let i=CF(n.segment,n.anchor,r());return{after:$i(e,t,i,n.anchor,n.relation),placed:i}}}}const uJ={load:()=>({}),save:()=>{}},dJ=new Set(lv.map(e=>e.sessionKey)),fJ=e=>dJ.has(e)||e.startsWith(dA),pJ=8*1024*1024,mJ={past:[],future:[]},hJ=e=>e.kind===`session`?`session:${e.key}`:`file:${e.file}`;var gJ=class{state=new Map;moves=new Map;head=0;constructor(e,t,n=uJ){this.sessionState=e,this.logger=t,this.storage=n,this.state=new Map(Object.entries(n.load()))}useStorage(e){this.storage=e,this.state=new Map(Object.entries(e.load()))}depth(e){let{past:t,future:n,savepoint:r}=this.state.get(e)??mJ;return{undo:t.length,redo:n.length,sinceEdit:r?.net.length??0}}revision(e){return this.moves.get(e)??0}history(e){return this.state.get(e)??mJ}begin(){let e=new Map,t=(t,n)=>{let r=e.get(t)??new Map,i=r.get(hJ(n));r.set(hJ(n),i===void 0?n:{...n,before:i.before}),e.set(t,r)},n=new Map;return{sessionState:aq(this.sessionState,e=>fJ(e)||e===`edit.mode`,(e,r,i,a)=>{if(r===`edit.mode`){let t=n.get(e);n.set(e,{before:t===void 0?i:t.before,after:a});return}t(e,{kind:`session`,key:r,before:i,after:a})}),file:(e,n,r,i)=>t(e,{kind:`file`,file:n,before:r,after:i}),commit:()=>{let t=new Map(e),r=new Map(n);e.clear(),n.clear();for(let e of new Set([...t.keys(),...r.keys()])){let n=[...t.get(e)?.values()??[]].filter(e=>e.before!==e.after),i=this.history(e),a=n.length===0?i:wJ(i,n),o=r.get(e),s=o===void 0?a:OJ(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 J(`undo: nothing to undo`);return this.apply(e,n,`before`,`undo`,EJ(t,n)),n}rewind(e){let t=this.history(e),{savepoint:n}=t;if(n===void 0)throw new J(`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(hJ)),a=n.net.filter(e=>!i.has(hJ(e))),o=yJ(kJ(DJ(t,n),i));if(this.apply(e,a,`before`,`rewind`,{past:o,future:[],savepoint:{at:o.length,net:[],below:[]}}),r.length>0)throw new J(`rewind: ${r.map(jJ).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 J(`redo: nothing to redo`);let a=[...n,i],o=yJ(a);return this.apply(e,i,`after`,`redo`,{past:o,future:r.slice(0,-1),...xJ(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(hJ)),{past:n,future:i,savepoint:a}=this.history(e);throw this.put(e,{past:kJ(n,t),future:kJ(i,t),...a!==void 0&&{savepoint:{at:kJ([...n,...[...i].reverse()].slice(0,a.at),t).length,net:a.net.filter(e=>!t.has(hJ(e))),below:kJ(a.below,t)}}}),new J(`${r}: ${o.map(jJ).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):pq(t.file)}write(e,t,n){t.kind===`file`?mq(t.file,n,this.logger):n===null?this.sessionState.clear(e,t.key):this.sessionState.set(e,t.key,n)}put(e,t){this.moves.delete(e),this.moves.set(e,++this.head);for(let[e]of this.moves){if(this.moves.size<=1024)break;this.moves.delete(e)}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||_J(n)>pJ;){let[e,t]=n.entries().next().value;n.size>1?n.delete(e):t.past.length+t.future.length>0?n.set(e,vJ(t)):(this.logger(`warn`,`settings-history: edit mode's changes for session ${e} exceed ${pJ} bytes; cancel is no longer available`),n.delete(e))}this.storage.save(Object.fromEntries(n)),this.state=n}};function _J(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 vJ({past:e,future:t,savepoint:n}){return e.length>0?{past:e.slice(1),future:t,...xJ(n,1,[])}:{past:e,future:t.slice(1),...xJ(n,0,[])}}function yJ(e){return e.slice(-50)}const bJ=e=>e===pA.member;function xJ(e,t,n){return e===void 0?{}:{savepoint:{at:Math.max(0,e.at-t),net:SJ(e.net,n),below:e.below}}}function SJ(e,t){let n=new Map(e.map(e=>[hJ(e),e]));for(let e of t){let t=n.get(hJ(e));n.set(hJ(e),t===void 0?e:{...t,after:e.after})}return[...n.values()].filter(e=>e.before!==e.after)}const CJ=e=>e.map(e=>({...e,before:e.after,after:e.before}));function wJ(e,t){let n=[...e.past,t],r=yJ(n),{savepoint:i}=e,a=i===void 0?0:Math.max(0,i.at-e.past.length);return{past:r,future:[],...xJ(i&&{at:Math.min(i.at,e.past.length),net:i.net,below:[...TJ(e.future,a),...i.below]},n.length-r.length,t)}}function TJ(e,t){let n=Math.min(t,e.length);return e.slice(e.length-n).reverse()}function EJ(e,t){return{past:e.past.slice(0,-1),future:yJ([...e.future,t]),...xJ(e.savepoint,0,CJ(t))}}function DJ(e,t){let{past:n,future:r}=e,i=n.slice(0,t.at);return[...i,...TJ(r,t.at-i.length),...t.below]}function OJ(e,t){if(bJ(t.after)&&!bJ(t.before))return{...e,savepoint:{at:e.past.length,net:[],below:[]}};if(!bJ(t.after)&&bJ(t.before)){let{past:t,future:n}=e;return{past:t,future:n}}return e}function kJ(e,t){return e.map(e=>e.filter(e=>!t.has(hJ(e)))).filter(e=>e.length>0)}function AJ(e){return e.map(jJ).join(`, `)}function jJ(e){return e.kind===`session`?`session setting "${e.key}"`:e.file}function MJ(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`&&typeof t.file==`string`)&&n(t.before)&&n(t.after)}function NJ(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(MJ))}function PJ(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(MJ)&&NJ(t.below)}function FJ(e){if(typeof e!=`object`||!e)return!1;let t=e;return NJ(t.past)&&NJ(t.future)&&(t.savepoint===void 0||PJ(t.savepoint))}function IJ(e,t){let n=e=>e.kind===`file`||fJ(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 LJ(e,t){return{load:()=>{let n;try{n=p.readFileSync(e,`utf8`)}catch(e){let n=e.code;return n!==`ENOENT`&&t(`warn`,`settings-history read failed (${n}); starting empty`),{}}try{let e=JSON.parse(n);if(typeof e==`object`&&e&&!Array.isArray(e)&&Object.values(e).every(FJ)){let n=new Set,r=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,IJ(t,n)]));return n.size>0&&t(`warn`,`settings-history load: dropped the changes to ${[...n].map(e=>`"${e}"`).join(`, `)}, no longer a setting`),r}}catch{}return t(`warn`,`settings-history load: unexpected shape, starting empty`),{}},save:n=>{try{p.mkdirSync(s.dirname(e),{recursive:!0}),O(e,JSON.stringify(n),384)}catch(e){let n=`settings-history write failed — the change landed but is not undoable: ${e.message}`;throw t(`error`,n),Error(n)}}}}const RJ=e=>!fJ(e)&&!UM(e)&&e!==`update.dismissed`;var zJ=class{past=new Map;depth(e,t,n){return this.restorable(e,t,n).length}restorable(e,t,n){let r=new Map,i=n=>r.has(n)?r.get(n):t.get(e,n),a=[];for(let t of[...this.past.get(e)??[]].reverse())if(t.every(e=>i(e.key)===e.after&&(e.before===null||n.validate(e.key,e.before).ok))){a.unshift(t);for(let e of t)r.set(e.key,e.before)}return a}begin(e){let t=new Map;return{sessionState:aq(e,RJ,(e,n,r,i)=>{let a=t.get(e)??new Map,o=a.get(n);a.set(n,{key:n,before:o?o.before:r,after:i}),t.set(e,a)}),commit:()=>{for(let[e,n]of t){let t=[...n.values()].filter(e=>e.before!==e.after);t.length>0&&this.push(e,t)}t.clear()}}}back(e,t,n){let r=this.past.get(e)??[],i=this.restorable(e,t,n),a=i.at(-1),o=r.length-i.length;if(a===void 0)throw this.put(e,i),new J(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,xb.runInAction)(()=>{let n=a.flatMap(({key:e,before:t})=>t===null?[]:[{key:e,value:t}]);n.length>0&&t.setBatch(e,n);for(let{key:n,before:r}of a)r===null&&t.clear(e,n)}),this.put(e,i.slice(0,-1)),{step:a,discarded:o}}push(e,t){let n=this.past.get(e)??[];this.put(e,[...n,t].slice(-20))}put(e,t){for(this.past.delete(e),t.length>0&&this.past.set(e,t);this.past.size>32;)this.past.delete(this.past.keys().next().value)}};const BJ=`click.error`;function VJ(e,t,n,r){let i={text:n,at:r,answered:!1};e.set(t,BJ,JSON.stringify(i))}function HJ(e,t,n){let r=UJ(e,t);!(r?.at===n.at&&r.text===n.text)||r.answered||e.set(t,BJ,JSON.stringify({...r,answered:!0}))}function UJ(e,t){let n=e.get(t,BJ);return n===null?null:GJ(n)}function WJ(e,t,n,r){let i=UJ(e,t);return i===null?{kind:`none`}:n<i.at+5?{kind:`held`,error:i}:r===`request`&&!i.answered?{kind:`owed`,error:i}:{kind:`over`}}function GJ(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{text:n,at:r,answered:i}=t;return typeof n==`string`&&typeof r==`number`&&(i===void 0||typeof i==`boolean`)?{text:n,at:r,answered:i===!0}:null}function KJ(e,t,n,r){let i=s.join(e,t),a=()=>{let e;try{e=p.readFileSync(i,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`ok`,value:n}:{kind:`failed`,reason:`${i}: ${e.message}`}}let t;try{t=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${i} is not JSON: ${e.message}`}}let a=r(t);return a.kind===`ok`?a:{kind:`failed`,reason:`${i} ${a.reason}`}};return{read:a,update:e=>{let t=a();if(t.kind===`failed`)return t;let n=e(t.value);return n!==t.value&&O(i,`${JSON.stringify(n,null,2)}\n`),{kind:`ok`,value:n}}}}const qJ=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function JJ(e){let t=e=>({kind:`failed`,reason:e});if(!qJ(e))return t(`is not an object`);for(let[n,r]of Object.entries(e)){if(!qJ(r))return t(`holds ${JSON.stringify(n)} as something other than its sightings`);for(let[e,n]of Object.entries(r))if(!Dj.includes(n))return t(`marks ${JSON.stringify(e)} ${JSON.stringify(n)}, not ${Dj.join(` or `)}`)}return{kind:`ok`,value:e}}function YJ(e,t,n,r){return{...e,[t]:{...e[t],[n]:r}}}const XJ=e=>KJ(e,`doctor-marks.json`,{},JJ),ZJ=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of terminals`},QJ=(e,t)=>e.includes(t)?e:[...e,t],$J=e=>KJ(e,`doctor-clicked-terminals.json`,[],ZJ);var eY=class extends Error{constructor(e){super(`the doctor looked at ${e} less than a second ago — click again`),this.name=`DoctorBusy`}};const tY=e=>e===void 0||e===``?{kind:`recent`}:{kind:`shell`,sessionId:e},nY=(e,t)=>t.filter(t=>e.kind===`recent`?t.ago<=300:t.sessionId===e.sessionId),rY=(e,t,n)=>{if(e.kind===`recent`)return n;let[r]=nY(e,t);return r===void 0?n:r.projectDir},iY=(e,t)=>nY(e,t).map(({role:e,frame:t,projectDir:n,claudeConfigDir:r})=>({role:e,frame:t,projectDir:n,claudeConfigDir:r}));function aY(e){let t=new Map;for(let n of e.split(`
206
211
  `)){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*oY(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 sY={pullRequests:e=>oW(e).showPullRequest===!0,rateLimits:e=>aW(e,`block`)||aW(e,`weekly`),memento:e=>aW(e,`memento`)};function cY(e,t){let n=new Map;for(let r of _g(zy(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=>Dg(e.segments[t])===`fail`),i=new Map(r.map(t=>[t,tW(e,t,n.get(t))])),a=e=>r.filter(t=>sY[e](i.get(t)));return{pullRequests:a(`pullRequests`),rateLimits:a(`rateLimits`),memento:a(`memento`)}}
207
212
  /*!
208
213
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -477,31 +482,31 @@ function run(argv) {
477
482
  : iterm(argv[1], points),
478
483
  );
479
484
  }
480
- `;function NY(e){let t=ut({bin:`osascript`,args:[`-l`,`JavaScript`,`-e`,MY,...e],timeoutMs:3e3,category:`doctor.font`});if(!t.ok){if(t.reason===`rate-limited`)throw new eY(`the font`);return{kind:`failed`,reason:`osascript failed (${t.error??`${t.reason}: ${t.stderr.trim()}`})`}}let n;try{n=JSON.parse(t.stdout)}catch{return{kind:`failed`,reason:`osascript answered ${JSON.stringify(t.stdout.trim())}, not JSON`}}return typeof n==`object`&&n&&`error`in n?{kind:`failed`,reason:n.error}:{kind:`ok`,value:n}}const PY=e=>e.map(e=>String.fromCodePoint(parseInt(e,16))),FY=e=>[...e].map(jY).join(`,`);function IY(e,t){let n=NY([`font`,e.kind,e.name,FY(t)]);if(n.kind===`failed`)return n;let{lacks:r}=n.value;return{kind:`ok`,value:{font:e.name,lacks:r===null?null:PY(r)}}}function LY(e,t){if(e.font===null)return{kind:`failed`,reason:`iTerm2 profile ${JSON.stringify(e.name)} names no font`};let n=`iTerm2 profile ${JSON.stringify(e.name)}`+(e.nonAscii?`, its non-ASCII font`:``)+(e.powerline?`, built-in Powerline glyphs on`:``),r=e.lacks===null||!e.powerline?e.lacks:e.lacks.filter(e=>!pj(t,e));return{kind:`ok`,value:{font:e.font,from:n,lacks:r}}}const RY=e=>e.kind===`ok`&&e.value.lacks!==null&&e.value.lacks.length===0;function zY(e,t,n){if(e.length===0)return{kind:`failed`,reason:t===null?`iTerm2 has no profiles in its preferences`:`iTerm2 has no profile named ${JSON.stringify(t)}`};let r=e.map(e=>LY(e,n));if(t!==null)return r[0];let i=r.find(e=>!RY(e));return i===void 0?{kind:`ok`,value:{font:[...new Set(r.flatMap(e=>e.kind===`ok`?[e.value.font]:[]))].join(`, `),from:`every iTerm2 profile, since the session does not say which draws the bar`,lacks:[]}}:i.kind===`failed`?i:{kind:`ok`,value:{...i.value,from:`${i.value.from}, one of its profiles, and the session does not say which draws the bar`}}}function BY(e,t,n){if(process.platform!==`darwin`)return{kind:`failed`,reason:`iTerm2 runs only on macOS`};let r=t.ITERM_PROFILE??null,i=NY([`iterm`,r??``,FY(n)]);return i.kind===`failed`?i:zY(i.value.profiles.map(e=>({...e,lacks:e.lacks===null?null:PY(e.lacks)})),r,e)}function VY(e,t){let n=e.split(`
485
+ `;function NY(e){let t=ut({bin:`osascript`,args:[`-l`,`JavaScript`,`-e`,MY,...e],timeoutMs:3e3,category:`doctor.font`});if(!t.ok){if(t.reason===`rate-limited`)throw new eY(`the font`);return{kind:`failed`,reason:`osascript failed (${t.error??`${t.reason}: ${t.stderr.trim()}`})`}}let n;try{n=JSON.parse(t.stdout)}catch{return{kind:`failed`,reason:`osascript answered ${JSON.stringify(t.stdout.trim())}, not JSON`}}return typeof n==`object`&&n&&`error`in n?{kind:`failed`,reason:n.error}:{kind:`ok`,value:n}}const PY=e=>e.map(e=>String.fromCodePoint(parseInt(e,16))),FY=e=>[...e].map(jY).join(`,`);function IY(e,t){let n=NY([`font`,e.kind,e.name,FY(t)]);if(n.kind===`failed`)return n;let{lacks:r}=n.value;return{kind:`ok`,value:{font:e.name,lacks:r===null?null:PY(r)}}}function LY(e,t){if(e.font===null)return{kind:`failed`,reason:`iTerm2 profile ${JSON.stringify(e.name)} names no font`};let n=`iTerm2 profile ${JSON.stringify(e.name)}`+(e.nonAscii?`, its non-ASCII font`:``)+(e.powerline?`, built-in Powerline glyphs on`:``),r=e.lacks===null||!e.powerline?e.lacks:e.lacks.filter(e=>!uj(t,e));return{kind:`ok`,value:{font:e.font,from:n,lacks:r}}}const RY=e=>e.kind===`ok`&&e.value.lacks!==null&&e.value.lacks.length===0;function zY(e,t,n){if(e.length===0)return{kind:`failed`,reason:t===null?`iTerm2 has no profiles in its preferences`:`iTerm2 has no profile named ${JSON.stringify(t)}`};let r=e.map(e=>LY(e,n));if(t!==null)return r[0];let i=r.find(e=>!RY(e));return i===void 0?{kind:`ok`,value:{font:[...new Set(r.flatMap(e=>e.kind===`ok`?[e.value.font]:[]))].join(`, `),from:`every iTerm2 profile, since the session does not say which draws the bar`,lacks:[]}}:i.kind===`failed`?i:{kind:`ok`,value:{...i.value,from:`${i.value.from}, one of its profiles, and the session does not say which draws the bar`}}}function BY(e,t,n){if(process.platform!==`darwin`)return{kind:`failed`,reason:`iTerm2 runs only on macOS`};let r=t.ITERM_PROFILE??null,i=NY([`iterm`,r??``,FY(n)]);return i.kind===`failed`?i:zY(i.value.profiles.map(e=>({...e,lacks:e.lacks===null?null:PY(e.lacks)})),r,e)}function VY(e,t){let n=e.split(`
481
486
  `).filter(e=>e!==``).map(e=>{let t=e.indexOf(` `);return t<=0?null:{family:e.slice(0,t),ranges:e.slice(t+1).split(/\s+/).filter(e=>e!==``).map(e=>{let[t,n=t]=e.split(`-`).map(e=>parseInt(e,16));return[t,n]})}});if(n.length===0||n.some(e=>e===null))return{kind:`failed`,reason:`fc-match answered ${JSON.stringify(e.slice(0,200))}, not families and their charsets`};let r=n.flatMap(e=>e.ranges),i=[...t].filter(e=>{let t=e.codePointAt(0);return!r.some(([e,n])=>e<=t&&t<=n)});return{kind:`ok`,value:{font:n[0].family,lacks:i}}}const HY=e=>e.replace(/[\\:,=-]/g,`\\$&`);function UY(e,t){let n=ut({bin:`fc-match`,args:[`--sort`,`--format`,`%{family[0]} %{charset}
482
487
  `,`:family=${HY(e)}`],timeoutMs:3e3,category:`doctor.font`});if(!n.ok){if(n.reason===`rate-limited`)throw new eY(`the font`);return{kind:`failed`,reason:`fc-match failed (${n.error??`${n.reason}: ${n.stderr.trim()}`})`}}return VY(n.stdout,t)}function WY(e,t){return process.platform===`darwin`?IY(e,t):UY(e.name,t)}function GY(e,t){let n=t||s.join(e,`.config`);return[s.join(n,`alacritty`,`alacritty.toml`),s.join(n,`alacritty.toml`),s.join(e,`.config`,`alacritty`,`alacritty.toml`),s.join(e,`.alacritty.toml`)]}function KY(e){return e===`darwin`?`Menlo`:`monospace`}const qY=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function JY(e){let t=qY(e.font)?e.font:{},n=qY(t.normal)?t.normal:{},r=(qY(e.general)?e.general:{}).import??e.import??[];return{family:typeof n.family==`string`?n.family:null,imports:Array.isArray(r)?r.filter(e=>typeof e==`string`):[]}}function YY(e,t,n){let r;try{r=p.readFileSync(e,`utf8`)}catch(t){return{kind:`failed`,reason:`cannot read ${e}: ${t.message}`}}let i;try{i=AY(r)}catch(t){return{kind:`failed`,reason:`cannot parse ${e}: ${t.message}`}}let a=JY(i);if(a.family!==null)return{kind:`ok`,value:{family:a.family,from:e}};if(n===5)return{kind:`ok`,value:null};let o=null;for(let r of a.imports){let i=r.startsWith(`~/`)?s.join(t,r.slice(2)):s.resolve(s.dirname(e),r);if(!p.existsSync(i))continue;let a=YY(i,t,n+1);if(a.kind===`failed`)return a;o=a.value??o}return{kind:`ok`,value:o}}function XY(e,t){let n=C.homedir(),r=GY(n,e.XDG_CONFIG_HOME).find(e=>p.existsSync(e)),i=r===void 0?{kind:`ok`,value:null}:YY(r,n,0);if(i.kind===`failed`)return i;let a=i.value?.family??KY(process.platform),o=i.value?.from??(r===void 0?`Alacritty's default, no config file`:`Alacritty's default, ${r} sets none`),s=WY({kind:`family`,name:a},t);if(s.kind===`failed`)return s;let{font:c,lacks:l}=s.value;return{kind:`ok`,value:{font:c,from:c===a?o:`${o}; ${a} as fontconfig matches it`,lacks:l}}}const ZY={iterm2:BY,alacritty:(e,t,n)=>XY(t,n)};function QY(e,t,n){return ZY[e.name](e.version,t,n)}function $Y(e){let t=e?.through;return typeof t==`string`||t===null?{kind:`ok`,value:{through:t}}:{kind:`failed`,reason:`names no post-mortem read`}}const eX=e=>KJ(e,`doctor-post-mortems-read.json`,{through:null},$Y);function tX(e){try{return{kind:`ok`,value:e()}}catch(e){return{kind:`failed`,reason:e instanceof Error?e.message:String(e)}}}const nX={realpath:e=>tX(()=>p.realpathSync(e)),checkoutOf:Je,digest:e=>tX(()=>Ge(e)),nativeShipped:Wa(process.platform,process.arch)};function rX(e,t,n){let r=e.realpath(t);if(r.kind===`failed`)return{kind:`failed`,reason:`the daemon's bundle ${t} cannot be resolved: ${r.reason}`};let i=e.checkoutOf(r.value);return{kind:`ok`,value:{daemon:{bundle:r.value,checkout:i===null?null:{root:i,rustSource:e.digest(s.join(i,`rust-client`))}},nativeShipped:e.nativeShipped,clients:n.map(t=>t===null?{kind:`unreported`}:{kind:`reported`,client:t.kind,bundle:e.realpath(t.bundle),source:t.source})}}}const iX=e=>({marks:XJ(e),clicked:$J(e),postMortemsRead:eX(e)}),aX=e=>({marks:e.marks.read(),clicked:e.clicked.read(),postMortemsRead:e.postMortemsRead.read()});function oX(e){let t=e.replace(/\n$/,``);if(t===` `)return{kind:`ok`,value:null};let n=t.split(` `),[r,i,a,o,s]=n;return n.length!==5||!/^[1-9]\d*$/.test(o)||!/^[01]$/.test(s)?{kind:`failed`,reason:`tmux answered ${JSON.stringify(e)}, not the five fields asked for`}:{kind:`ok`,value:{features:r.split(`,`).filter(e=>e!==``),termtype:i,termname:a,pid:Number(o),utf8:s===`1`}}}const sX=/^(sshd|mosh-server)\b/;function cX(e,t){let n=aY(e);if(!n.has(t))return{kind:`failed`,reason:`process ${t} is not running`};for(let e of oY(n,t))if(sX.test(e.command.slice(e.command.lastIndexOf(`/`)+1)))return{kind:`ok`,value:!0};return{kind:`ok`,value:!1}}function lX(e){let t=ut({bin:`ps`,args:[`-A`,`-o`,`pid=,ppid=,comm=`],timeoutMs:2e3,category:`doctor.process`});if(!t.ok){if(t.reason===`rate-limited`)throw new eY(`the processes`);return{kind:`failed`,reason:`ps failed (${t.error??`${t.reason}: ${t.stderr.trim()}`})`}}return cX(t.stdout,e)}const uX=/^(.*)\/(?:dist\/index\.mjs|src\/index\.ts|bin\/cc-candybar)$/;function dX(e,t){let n=[];for(let r of e.split(`
483
488
  `)){let e=/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\w{3} \w{3}\s+\d+ [\d:]{8} \d{4})\s+.* (\/.*) daemon$/.exec(r);e===null||!t(e[5])||n.push({pid:Number(e[1]),ppid:Number(e[2]),rss:Number(e[3])*1024,started:`${e[4].replace(/\s+/g,` `)} UTC`})}return n.filter(e=>!n.some(t=>t.ppid===e.pid))}function fX(e){let t;try{t=p.realpathSync(e)}catch{return!1}let n=uX.exec(t)?.[1];return n!==void 0&&p.existsSync(s.join(n,`bin`,`cc-candybar`))}function pX(){let e=ut({bin:`ps`,args:[`-U`,String(C.userInfo().uid),`-ww`,`-o`,`pid=,ppid=,rss=,lstart=,args=`],timeoutMs:2e3,category:`doctor.daemons`,env:{...process.env,LC_ALL:`C`,TZ:`UTC`}});return e.ok?{kind:`ok`,value:dX(e.stdout,fX)}:{kind:`failed`,reason:`ps failed (${e.error??`${e.reason}: ${e.stderr.trim()}`})`}}function mX(e){let t=hU(e,`doctor.tmux`,[`display`,`-p`,`-t`,e.pane,`#{client_termfeatures} #{client_termtype} #{client_termname} #{client_pid} #{client_utf8}`]);if(t.kind===`rate-limited`)throw new eY(`tmux`);return t.kind===`failed`?{kind:`failed`,reason:t.reason}:oX(t.stdout)}function hX(e){return{probeTmux:mX,remoteLogin:lX,fontInUse:QY,loadConfig:e,managedSettingsDir:process.env.CC_CANDYBAR_CLAUDE_MANAGED_DIR??ka(process.platform),install:nX,daemons:pX,forge:bX,memento:MU,transcript:_X}}function gX(e,t){let n=e.toString(`utf-8`),r=t?0:n.indexOf(`
484
489
  `)+1,i=n.lastIndexOf(`
485
490
  `)+1,a=0,o=0;for(let e of n.slice(r,i).split(`
486
- `)){let t=PH(e);t.kind!==`blank`&&(a++,t.kind===`unparsed`&&o++)}return{lines:a,unparsed:o,whole:t}}function _X(e){let t=va(e,jj+1);return t.kind===`ok`?F(gX(t.value.buf,t.value.fromStart)):t}function vX(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 yX={github:{loginHost:()=>`github.com`,args:e=>[`auth`,`token`,`--hostname`,e],nonZero:`logged-out`},gitlab:{loginHost:e=>e,args:()=>[`--version`],nonZero:`failed`}};function bX(e){if(CD(e)===void 0)return{kind:`ok`,value:null};let t=HD(ut({bin:`git`,args:[...VD],cwd:e,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:2e3,category:`doctor.forge`}));if(t.kind===`failed`)return t;let n=qD(t.value);if(n===null)return{kind:`ok`,value:null};let r=BD(n);if(r===null)return{kind:`ok`,value:null};let i=FD[r],a=yX[r],o=a.loginHost(zD(n)),s=ut({bin:i,args:[...a.args(o)],cwd:e,timeoutMs:2e3,category:`doctor.forge`});return xX(i,o,a.nonZero,s)}function xX(e,t,n,r){let i=n=>({kind:`ok`,value:{cli:e,host:t,status:n}});return r.ok?i(`ready`):ID(r)?i(`missing`):r.reason===`non-zero`&&n===`logged-out`?i({loggedOut:MD(r.stderr)}):{kind:`failed`,reason:jD(e,r)}}function SX(e){let t={layers:e.layers,warnings:e.warning===null?[]:e.warning.split(`
487
- `)};return e.error===null?{...t,kind:`loaded`,unused:e.unused}:{...t,kind:`failed`,error:e.error}}const CX=e=>tX(()=>ja(e));function wX(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:Sa(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:CX(e),bars:t.map(({role:e,frame:t,redraws:n})=>({role:e,frame:t,redraws:n}))});return{origin:o(e,i),elsewhere:[...a.values()].map(({at:e,bars:t})=>o(e,t))}}function TX(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,client:e.probeTmux(t)}}function EX(e,t){switch(e.kind){case`unreported`:return{kind:`unreported`};case`outside`:return t===void 0?{kind:`unreported`}:{kind:`seen`,identified:bj(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:yj(t),tmuxClient:t}}}}function DX(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(lj(s))return{kind:`bundling`,name:s,version:c};if(!uj(s))return{kind:`unread`,name:s,version:c};let{ITERM_PROFILE:l,...u}=o??{},d=a===null?{kind:`ok`,value:n.ssh===!0}: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`}:e.fontInUse({name:s,version:c},a===null?o??{}:u,r)}}function OX(e){switch(e.via){case`link`:return{kind:`arrived`,handler:e.handler,bar:qe};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"}}}function kX(e,t){let[n,...r]=e;return n===void 0?{kind:`unneeded`}:{kind:`needed`,segments:[n,...r],fact:t()}}function AX(e,t,n,r,i){return{pullRequests:kX(t.pullRequests,()=>e.forge(n.cwd)),rateLimits:kX(t.rateLimits,()=>i),memento:kX(t.memento,()=>({located:e.memento(r,n.projectDir),claudeConfigDir:r}))}}function jX(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}}}}function MX(e,t,n,r,i,a,o,s,c,l,u){let d=e.loadConfig(n),f=HB(d.config,r,()=>!1),p=TX(e,t.tmux),m=EX(p,t.terminalEnv),h=[...new Set([...Yv(f),...Jv(JSON.stringify(d.config))])].join(``);return{tmux:p,width:l,terminal:m,nerdFont:h===``?{kind:`none`}:{kind:`glyphs`,glyphs:h,terminal:DX(e,m,t,h)},marks:u.marks,clicked:u.clicked,daemon:{serving:i,processes:e.daemons(),read:u.postMortemsRead},config:SX(d),sighted:s,frames:c.kind===`failed`?c:{kind:`read`},data:AX(e,cY(d.config,f.preset),n,xa(t.claudeConfigDir),a),transcripts:vX(e,o),claudeSettings:wX({managedDir:e.managedSettingsDir,projectDir:n.projectDir,userFile:Sa(xa(t.claudeConfigDir))},c.kind===`ok`?c.value:[])}}function NX(e,t,n){switch(t.kind){case`claude-settings`:{let e=t.file.path;O(e,Vi(Ea(e),t.path,JSON.stringify(t.value),Ei));let r=e=>({...e,sources:CX(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||In(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 PX={connectMs:200,budgetMs:500};async function FX(e){let n=e.includes(`--json`),r=await IX();r.kind!==`ok`&&(t.stderr.write(`daemon-stats: ${ln(r)}\n`),t.exit(1)),n&&t.stdout.write(JSON.stringify(r.value,null,2)+`
491
+ `)){let t=PH(e);t.kind!==`blank`&&(a++,t.kind===`unparsed`&&o++)}return{lines:a,unparsed:o,whole:t}}function _X(e){let t=va(e,Oj+1);return t.kind===`ok`?F(gX(t.value.buf,t.value.fromStart)):t}function vX(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 yX={github:{loginHost:()=>`github.com`,args:e=>[`auth`,`token`,`--hostname`,e],nonZero:`logged-out`},gitlab:{loginHost:e=>e,args:()=>[`--version`],nonZero:`failed`}};function bX(e){if(CD(e)===void 0)return{kind:`ok`,value:null};let t=HD(ut({bin:`git`,args:[...VD],cwd:e,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:2e3,category:`doctor.forge`}));if(t.kind===`failed`)return t;let n=qD(t.value);if(n===null)return{kind:`ok`,value:null};let r=BD(n);if(r===null)return{kind:`ok`,value:null};let i=FD[r],a=yX[r],o=a.loginHost(zD(n)),s=ut({bin:i,args:[...a.args(o)],cwd:e,timeoutMs:2e3,category:`doctor.forge`});return xX(i,o,a.nonZero,s)}function xX(e,t,n,r){let i=n=>({kind:`ok`,value:{cli:e,host:t,status:n}});return r.ok?i(`ready`):ID(r)?i(`missing`):r.reason===`non-zero`&&n===`logged-out`?i({loggedOut:MD(r.stderr)}):{kind:`failed`,reason:jD(e,r)}}function SX(e){let t={layers:e.layers,warnings:e.warning===null?[]:e.warning.split(`
492
+ `)};return e.error===null?{...t,kind:`loaded`,unused:e.unused}:{...t,kind:`failed`,error:e.error}}const CX=e=>tX(()=>ja(e));function wX(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:Sa(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:CX(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))}}function TX(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,client:e.probeTmux(t)}}function EX(e,t){switch(e.kind){case`unreported`:return{kind:`unreported`};case`outside`:return t===void 0?{kind:`unreported`}:{kind:`seen`,identified:_j(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:gj(t),tmuxClient:t}}}}function DX(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(oj(s))return{kind:`bundling`,name:s,version:c};if(!sj(s))return{kind:`unread`,name:s,version:c};let{ITERM_PROFILE:l,...u}=o??{},d=a===null?{kind:`ok`,value:n.ssh===!0}: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`}:e.fontInUse({name:s,version:c},a===null?o??{}:u,r)}}function OX(e){switch(e.via){case`link`:return{kind:`arrived`,handler:e.handler,bar:qe};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"}}}function kX(e,t){let[n,...r]=e;return n===void 0?{kind:`unneeded`}:{kind:`needed`,segments:[n,...r],fact:t()}}function AX(e,t,n,r,i){return{pullRequests:kX(t.pullRequests,()=>e.forge(n.cwd)),rateLimits:kX(t.rateLimits,()=>i),memento:kX(t.memento,()=>({located:e.memento(r,n.projectDir),claudeConfigDir:r}))}}function jX(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}}}}function MX(e,t,n,r,i,a,o,s,c,l,u){let d=e.loadConfig(n),f=HB(d.config,r,()=>!1),p=TX(e,t.tmux),m=EX(p,t.terminalEnv),h=[...new Set([...Yv(f),...Jv(JSON.stringify(d.config))])].join(``);return{tmux:p,width:l,terminal:m,nerdFont:h===``?{kind:`none`}:{kind:`glyphs`,glyphs:h,terminal:DX(e,m,t,h)},marks:u.marks,clicked:u.clicked,daemon:{serving:i,processes:e.daemons(),read:u.postMortemsRead},config:SX(d),sighted:s,frames:c.kind===`failed`?c:{kind:`read`},data:AX(e,cY(d.config,f.preset),n,xa(t.claudeConfigDir),a),transcripts:vX(e,o),claudeSettings:wX({managedDir:e.managedSettingsDir,projectDir:n.projectDir,userFile:Sa(xa(t.claudeConfigDir))},c.kind===`ok`?c.value:[])}}function NX(e,t,n){switch(t.kind){case`claude-settings`:{let e=t.file.path;O(e,Vi(Ea(e),t.path,JSON.stringify(t.value),Ei));let r=e=>({...e,sources:CX(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||In(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 PX={connectMs:200,budgetMs:500};async function FX(e){let n=e.includes(`--json`),r=await IX();r.kind!==`ok`&&(t.stderr.write(`daemon-stats: ${ln(r)}\n`),t.exit(1)),n&&t.stdout.write(JSON.stringify(r.value,null,2)+`
488
493
  `);let i=LX(r.value);if(i!==null){t.stderr.write(`daemon-stats: ${i}\n`),t.exitCode=1;return}n||t.stdout.write(GX(r.value))}function IX(){return nn({kind:`stats`},PX,e=>`stats`in e?e.stats:void 0)}function LX(e,t=RX){let n=iq.referenceSnapshot(),r=zX(Object.fromEntries(t.map(e=>[e,n[e]])),e);if(r.length===0)return null;let i=VX(e.version,e.sourceDigest??null),a=VX(qe,Xe());return`the daemon (${i}) reports no ${r.join(`, `)}; it is another build than this client (${a}), and restarts only when its own bundle changes`}const RX=Object.keys(iq.referenceSnapshot());function zX(e,t,n=``){if(Array.isArray(e))return Array.isArray(t)?[]:[n||`<snapshot>`];if(!BX(e))return[];if(!BX(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(...zX(e[i],t[i],a)):r.push(a)}return r}function BX(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function VX(e,t){return`${e} [${t===null?`no digest`:Ke(t)}]`}function HX(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function UX(e,t){let n=e+t;return n===0?`n/a`:`${(e/n*100).toFixed(1)}%`}function WX(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 GX(e){let t=[];t.push(`cc-candybar daemon stats`),t.push(``),t.push(`process`),t.push(` pid ${e.pid}`),t.push(` build ${VX(e.version,e.sourceDigest)}`),t.push(` protocol ${e.protocolVersion}`),t.push(` startedAt ${e.startedAt}`),t.push(` uptime ${WX(e.uptimeSec)}`),t.push(` rss ${HX(e.rssBytes)}`),t.push(` heapUsed ${HX(e.heapUsedBytes)}`),t.push(` heapTotal ${HX(e.heapTotalBytes)}`),t.push(` external ${HX(e.externalBytes)}`),t.push(` arrayBuffers ${HX(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(``),t.push(`gitCache`),t.push(` size ${e.gitCache.size}`),t.push(` expired ${e.gitCache.expired}`),t.push(` hit rate ${UX(e.gitCache.hits,e.gitCache.misses)} (${e.gitCache.hits} / ${e.gitCache.hits+e.gitCache.misses})`),t.push(` invalidations ${e.gitCache.invalidations}`),t.push(``),t.push(`usageCache`),t.push(` size ${e.usageCache.size}`),t.push(` hit rate ${UX(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(`transcriptReads`),t.push(` reads ${e.transcriptReads.reads}`),t.push(` bytes ${HX(e.transcriptReads.bytes)}`),t.push(` long lines ${e.transcriptReads.longLines}`),t.push(` largest line ${HX(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(` accounted ${HX(e.renderCache.accountedBytes)} / ${HX(e.renderCache.budgetBytes)}`),t.push(``),t.push(`effectCache`),t.push(` sessions ${e.effectCache.sessions}`),t.push(` effects ${e.effectCache.effects}`),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(``),t.push(`subprocesses`),t.push(` total ${e.subprocesses.total}`),t.push(` inFlight ${e.subprocesses.inFlight}`),t.push(` lastMinute ${e.subprocesses.lastMinute}`);let n=Object.entries(e.subprocesses.byCategory),r=n.reduce((e,[t])=>Math.max(e,t.length),13);for(let[i,a]of n){let n=e.subprocesses.p50DurationMs[i],o=e.subprocesses.p99DurationMs[i],s=n!==void 0&&o!==void 0?` (p50 ${n}ms · p99 ${o}ms)`:``;t.push(` ${i.padEnd(r)} ${a}${s}`)}return e.nextRestartReason&&(t.push(``),t.push(`nextRestart ${e.nextRestartReason}`)),t.join(`
489
494
  `)+`
490
495
  `}const KX=e=>({kind:`ok`,value:e}),qX=e=>({kind:`failed`,reason:e});var JX=class{arrivals=[];arrive(e){this.arrivals=[...this.arrivals,e].slice(-16)}list(){return this.arrivals}};const YX=/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;function XX(e){return YX.test(e)?e:null}function ZX(e){let t=e.opener();if(t.kind===`failed`)return t;if(t.value===null)return KX(null);let n=t.value,r=e.script(n);if(r.kind===`failed`)return KX({app:n,missing:qX(`its script could not be read (${r.reason})`)});let i=to(r.value);return KX({app:n,missing:i===null?qX("its script is not one `cc-candybar install` wrote"):KX([i.node,i.script].filter(t=>!e.exists(t)))})}async function QX(e,t){let n=e.now()+5e3;for(;e.now()<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`,handler:r.handler,bar:n.value.version}}return null}async function $X(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} (CC_CANDYBAR_SOCKET); the URL handler delivers links 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=e.open(`${fr}://${Lr}/${n}`);return(r===null?await QX(e,n):null)??{kind:`lost`,unopened:r,opener:ZX(e)}}function eZ(e,t,n){let r=ut({bin:t,args:[...n],category:e,timeoutMs:5e3});return r.ok?KX(r.stdout):qX(r.stderr.trim()||r.error||r.reason)}const tZ=`ObjC.import("AppKit");var u = $.NSWorkspace.sharedWorkspace.URLForApplicationToOpenURL($.NSURL.URLWithString("${fr}://probe"));u.isNil() ? "" : u.path.js`;async function nZ(){let e=await IX();if(e.kind!==`ok`)return qX(ln(e).split(`
491
496
  `).join(` — `));let t=LX(e.value,[`handlerProbes`]);if(t!==null)return qX(t);let{version:n,handlerProbes:r}=e.value;return KX({version:n,arrivals:r})}function rZ(){return{platform:process.platform,sockets:{own:vt(),handler:yt()},now:Date.now,nonce:ne,daemon:nZ,open:e=>{let t=eZ(`doctor.open`,`/usr/bin/open`,[`-g`,e]);return t.kind===`ok`?null:t.reason},pause:()=>new Promise(e=>setTimeout(e,100)),opener:()=>{let e=eZ(`doctor.launch-services`,`/usr/bin/osascript`,[`-l`,`JavaScript`,`-e`,tZ]);if(e.kind===`failed`)return e;let t=e.value.trim();return KX(t===``?null:t)},script:e=>eZ(`doctor.osadecompile`,`/usr/bin/osadecompile`,[no(e)]),exists:p.existsSync}}const iZ=/^─{20,}/,aZ=/^❯(\s|$)/,oZ=/›\s*stashed$/;function sZ(e){let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>iZ.test(e)?[t]:[]).at(-2);return n===void 0||!aZ.test(t[n+1]??``)?null:{hint:t[n-1]??``,prompt:t[n+1]}}function cZ(e){if(e.inMode)return{kind:`in-mode`};let t=sZ(e);return t===null?{kind:`no-prompt`}:oZ.test(t.hint)?{kind:`stashed`}:{kind:`ready`}}function lZ(e){return/^❯\s*\S/u.test(sZ(e)?.prompt??``)}const uZ=/^\S+\s+\S[^…]*…\s+\((\d+[hms]\s*)+/u;function dZ(e){return e.screen.some(e=>uZ.test(e))}const fZ={"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 pZ(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}}function mZ(e,t,n){let r=pZ(t);if(r.kind===`refused`)return r;let i=r.hint,a=cZ(e.read(i));if(a.kind!==`ready`)return{kind:`refused`,reason:fZ[a.kind]};let o=e.type(i,n);return o.kind===`typed`?{kind:`typed`,pane:i.pane}:o}function hZ(e,t,n,r){let i=hU(e,t,n,r);if(i.kind===`failed`)throw Error(i.reason);return i}function gZ(e){let t=hZ(e,`claude-input.read`,[`display`,`-p`,`-t`,e.pane,`#{pane_in_mode}`,`;`,`capture-pane`,`-p`,`-t`,e.pane]);if(t.kind===`rate-limited`)throw Error(t.reason);let[n=``,...r]=t.stdout.split(`
492
- `);return{inMode:n!==`0`,screen:r}}function _Z(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`]}function vZ(e,t){let n=hZ(e,`claude-input.type`,_Z(e.pane,`cc-candybar-slash`,[`C-s`]),t);return n.kind===`ok`?{kind:`typed`}:{kind:`refused`,reason:`cc-candybar typed a command moments ago — click again in a second (${n.reason})`}}function yZ(){return{read:gZ,type:vZ}}function bZ(e){if(!e)throw new J(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new J(`invalid session id "${e}"`);return e}function xZ(e){return SZ(()=>decodeURIComponent(e))}function SZ(e){try{return e()}catch(e){throw e instanceof URIError?new J(`malformed wire encoding: ${e.message}`):e}}function CZ(e,t){let n=ut({bin:`/usr/bin/pbcopy`,stdinInput:e,category:`click.pbcopy`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.pbcopy rate-limited: ${n.error??``}`);return}throw Error(`pbcopy failed (${n.reason}, exit ${n.exitCode??`null`})`)}}const wZ=(e,t)=>CZ(xZ(e),t),TZ=(e,t)=>{let n=ut({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,xZ(e)],category:`click.open`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.open rate-limited: ${n.error??``}`);return}throw Error(`open -a "Visual Studio Code" failed (${n.reason}, exit ${n.exitCode??`null`})`)}},EZ=(e,t)=>CZ(xZ(e),t),DZ=(e,t)=>CZ(xZ(e),t),OZ=(e,t)=>{let n=bZ(xZ(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},kZ=(e,t)=>{let[n=``,...r]=SZ(()=>Vr(e)),i=bZ(n),a=wV(UZ(t,i));if(r.length===0)throw new J(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new J(`set-state: expected even-count <key>/<value> pairs, got ${r.length} segment(s) after session id (have keys: ${a.listKeys().join(`, `)})`);let o=[];for(let e=0;e<r.length;e+=2){let t=r[e],n=r[e+1];if(!t)throw new J(`set-state: empty key at pair ${e/2+1} (expected <sessionId>/<key>/<value>[/<key>/<value>...] segments)`);let i=a.validate(t,n);if(!i.ok)throw new J(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}NZ(t,i,`set-state`,o),t.navigating.setBatch(i,o);let s=o.map(e=>`${e.key}=${e.value}`).join(` `);t.dlog(`info`,`set-state: ${s} (session=${i})`)},AZ=/^-?\d+$/;function jZ(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const MZ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n);if(!r)throw new J(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!AZ.test(i))throw new J(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=UZ(t,a),c=wV(s),l=c.rangeParamsFor(r);if(!l)throw new J(`step-state: key "${r}" is not a bounded (range) state key (have keys: ${c.listKeys().join(`, `)})`);let u=t.sessionState.get(a,r),d=u&&AZ.test(u)?PZ(l,parseInt(u,10)):FZ(`step-state`,r,l,DV(s,e=>t.sessionState.get(a,e),r)),f=jZ(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new J(`step-state: ${p.reason}`);NZ(t,a,`step-state`,[{key:r,value:p.value}]),t.navigating.set(a,r,p.value),t.dlog(`info`,`step-state: ${r} ${d}→${p.value} (by ${o}, session=${a})`)};function NZ(e,t,n,r){let i=r.filter(e=>e.key.startsWith(dA));if(i.length===0)return;let a=rV(UZ(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new J(`${n}: refused — ${a.join(`; `)}`)}function PZ(e,t){return Math.max(e.min,Math.min(e.max,t))}function FZ(e,t,n,r){if(r===null)return n.min;if(!AZ.test(r))throw new J(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return PZ(n,parseInt(r,10))}const IZ=`render-origin`;function LZ(e,t,n){return{...e,configFile:t.get(n,`config-override`)??e.configFile}}function RZ(e){return JSON.stringify(e)}function zZ(e){let t;try{t=JSON.parse(e)}catch{throw new J(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new J(`render origin is not an object: ${e}`);let{projectDir:n,cwd:r,configFile:i}=t;if(typeof n!=`string`||typeof r!=`string`||i!==null&&typeof i!=`string`)throw new J(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,configFile:i}}function BZ(e,t){let n=VZ(e,t);if(n===null)throw new J(`session ${t} has not rendered yet — no config to act on`);return n}function VZ(e,t){let n=e.sessionState.get(t,IZ);return n===null?null:LZ(zZ(n),e.sessionState,t)}function HZ(e,t,n){let r=VZ(e,t);if(r===null)return;let{path:i}=WZ(r);n.some(e=>e.kind===`file`&&e.file===i)&&e.reloadConfig(r)}function UZ(e,t){return e.configFor(BZ(e,t))}function WZ(e){return eB(e.projectDir,e.cwd,e.configFile??void 0)}function GZ(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.dlog}}const KZ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n),o=BZ(t,a),s=t.configFor(o),c=IF(s);if(!r)throw new J(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new J(`set-config: ${l.reason}`);let u=WZ(o),d=tV(s,e=>t.sessionState.get(a,e),r);Zq(GZ(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.dlog(`info`,`set-config: ${d.key}=${l.value} → ${u.path} (session=${a})`)},qZ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n);if(!r)throw new J(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!AZ.test(i))throw new J(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=BZ(t,a),c=t.configFor(s),l=IF(c),u=l.rangeParamsFor(r);if(!u)throw new J(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=WZ(s),f=tV(c,e=>t.sessionState.get(a,e),r),p=Xq(d.path,f.key),m=typeof p==`number`?PZ(u,p):FZ(`step-config`,r,u,RF(f.globals,r)),h=jZ(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new J(`step-config: ${g.reason}`);Zq(GZ(t,a),d,[[f.key,g.value]]),t.reloadConfig(s),t.dlog(`info`,`step-config: ${f.key} ${m}→${g.value} (by ${o}) → ${d.path} (session=${a})`)},JZ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n),i=BZ(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=$B(a,o),c=nV(a,o);if(s.length+c.length===0){t.dlog(`info`,`save: nothing unsaved (session=${r})`);return}let l=wV(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new J(`save: ${t.reason}`);return[e.target,t.value]});XZ(`save`,l,c);let d=WZ(i);Qq(GZ(t,r),d,u,c),t.reloadConfig(i);for(let e of[...s.map(e=>e.sessionKey),...c.map(e=>e.key)])t.sessionState.clear(r,e);t.dlog(`info`,`save: ${[...u.map(([e,t])=>`${e}=${t}`),...c.map(YZ)].join(` `)} → ${d.path} (session=${r})`)},YZ=e=>`${e.preset}/${e.id}.settings.${e.setting}=${Ig(e.value)}`;function XZ(e,t,n){for(let r of n){let n=t.validate(r.key,Ig(r.value));if(!n.ok)throw new J(`${e}: ${n.reason}`)}}const ZZ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n),i=BZ(t,r),a=t.configFor(i),o=oV(a,e=>t.sessionState.get(r,e)),s=wV(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new J(`save-preset: ${t.reason}`);return[e.configKey,t.value]});XZ(`save-preset`,s,o.placements);let l=WZ(i),u=aJ(GZ(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...lv.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,sv.preset.sessionKey,u),t.dlog(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(YZ)].join(` `)} → ${l.path} (session=${r})`)},QZ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n),i=BZ(t,r),a=cV(t.configFor(i),e=>t.sessionState.get(r,e));if(a.kind===`rule`)throw new J(`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 o=WZ(i);oJ(GZ(t,r),o,a.theme,a.look),t.reloadConfig(i);let s=new Set($B(t.configFor(i),e=>t.sessionState.get(r,e)).map(e=>e.sessionKey)),c=ev.map(e=>sv[e].sessionKey).filter(e=>!s.has(e));for(let e of c)t.sessionState.clear(r,e);t.dlog(`info`,`save-theme-default: ${a.theme} ${ev.map(e=>`${e}=${a.look[e]}`).join(` `)} → ${o.path} (session=${r})`)},$Z=(e,t)=>{let[n=``,r=``]=SZ(()=>Vr(e)),i=bZ(n);if(!r)throw new J(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=BZ(t,i),o=WZ(a);sJ(GZ(t,i),o,r),t.reloadConfig(a);let s=sv.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.dlog(`info`,`delete-preset: ${r} ← ${o.path} (session=${i})`)},eQ=(e,t)=>{let[n=``,...r]=SZ(()=>Vr(e)),i=bZ(n),a=BZ(t,i),o=IF(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new J(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=WZ(a),l=r.map(lV),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);nJ(GZ(t,i),c,u),t.reloadConfig(a);for(let e of d)t.sessionState.clear(i,e);t.dlog(`info`,`reset-config: ${[...u,...d.map(e=>`session:${e}`)].join(` `)} ← ${c.path} (session=${i})`)};function tQ(e,t){let n=(e,t)=>[..._g(zy(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(Iy(t.presets).flatMap(e=>n(t,e).map(t=>fA(XO(e),pg(t)))));return Iy(e.presets).flatMap(t=>n(e,t).map(e=>({member:fA(XO(t),pg(e)),node:e})).filter(({member:e})=>!r.has(e)))}function nQ(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[oA]:[]])}const rQ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n),o=BZ(t,a),s=t.configFor(o),c=IF(s);if(!r)throw new J(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new J(`apply-layout-op: ${l.reason}`);let u=SF(l.value);if(u===null)throw new J(`apply-layout-op: "${l.value}" is not a layout op token`);let d=WZ(o),f=cJ(GZ(t,a),d,r,u);t.reloadConfig(o);let p=nQ(tQ(s,t.configFor(o)),t.sessionState.get(a,oA)).filter(e=>t.sessionState.get(a,e)!==null);for(let e of p)t.sessionState.clear(a,e);t.dlog(`info`,`apply-layout-op: ${r} ${l.value} → ${d.path} placed=${JSON.stringify(f)} released=${JSON.stringify(p)} (session=${a})`)},iQ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n);t.journal.commit();let i=t.history.undo(r);HZ(t,r,i),t.dlog(`info`,`undo: restored ${AJ(i)} (session=${r})`)},aQ=(e,t)=>{let n=bZ(xZ(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,wV(UZ(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.dlog(`info`,`back: ${a} discarded=${i} (session=${n})`)},oQ=(e,t)=>{let n=bZ(xZ(e));t.journal.commit();let r=t.history.rewind(n);HZ(t,n,r),t.dlog(`info`,`rewind: put back ${AJ(r)||`nothing`} as edit mode found it (session=${n})`)},sQ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n);t.journal.commit();let i=t.history.redo(r);HZ(t,r,i),t.dlog(`info`,`redo: re-applied ${AJ(i)} (session=${r})`)},cQ=(e,t)=>{bZ(xZ(e)),t.applyUpdate()},lQ=`client-hints`;function uQ(e,t){let n=e.sessionState.get(t,lQ);if(n===null)throw new J(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new J(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new J(`client hints record is not an object: ${n}`);return zt(r)}function dQ(e,t,n){let r=bM(n);e.sessionState.setBatch(t,RM(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} ${IM(n.nerdFont,n.marks)} ${EM(n.terminal,n.clicked)} ${DM(n.terminal,n.width)} ${OM(n.install)} ${AM(n.daemon)} ${jM(n.data)} ${FM(n.transcripts)} ${MM(n.frames,n.claudeSettings)} ${PM(n.claudeSettings.origin.sources)} (session=${t})`)}function fQ(e,t){let n={kind:`clicked`,sessionId:t,via:e.arrival.via},r=e.clients.ofSession(t,_O(new Date)),i;try{i=MX(e.doctor,uQ(e,t),BZ(e,t),n=>e.sessionState.get(t,n),{kind:`ok`,value:e.serving()},{kind:`ok`,value:r.map(e=>e.rateLimits)},{kind:`ok`,value:r.map(e=>e.transcript)},n,{kind:`ok`,value:iY(n,r)},jX(t,r),aX(e.doctorStores))}catch(e){throw e instanceof eY?new J(e.message):e}return{...i,urlHandler:OX(e.arrival),install:rX(e.doctor.install,e.bundle,r.map(e=>e.client)),clicked:pQ(e,i)}}function pQ(e,{terminal:t,clicked:n}){let r=t.kind===`seen`?xj(t.identified):null;if(r===null||e.arrival.via!==`link`)return n;try{return e.doctorStores.clicked.update(e=>QJ(e,r))}catch(t){return e.dlog(`warn`,`doctor: clicked terminal not filed for ${JSON.stringify(r)}: ${t instanceof Error?t.message:String(t)}`),n}}const mQ=(e,t)=>{let n=bZ(xZ(e));dQ(t,n,fQ(t,n))},hQ=(e,t)=>{let n=XX(xZ(e));if(n===null)throw new J(`doctor-probe: the value is not a probe nonce`);if(t.arrival.via!==`link`)throw new J(`doctor-probe: a probe arrives only as a link`);let{handler:r}=t.arrival;t.probes.arrive({nonce:n,handler:r}),t.dlog(`info`,`doctor-probe: arrived nonce=${n} handler=${r??`unreported`}`)},gQ=(e,t)=>{let[n=``,r=``]=SZ(()=>Vr(e)),i=bZ(n),a=xM(r);if(a===void 0)throw new J(`doctor-fix: unknown check "${r}"`);let o=fQ(t,i),s=a.probe(o);if(s.ok||s.fix===void 0)throw new J(`doctor-fix: ${a.label} — ${s.ok?`nothing to fix`:s.reason}`);let c=NX(t.doctorStores,s.fix,o);if(c.kind===`failed`)throw new J(`doctor-fix: ${a.label} — ${c.reason}`);t.dlog(`info`,`doctor-fix: ${a.name} → ${Nj(s.fix)} (session=${i})`),dQ(t,i,c.value)},_Q=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n),o=xM(r);if(o===void 0)throw new J(`doctor-mark: unknown check "${r}"`);if(!Aj.includes(i))throw new J(`doctor-mark: the mark is ${JSON.stringify(i)}, not ${Aj.join(` or `)}`);let s=fQ(t,a),c=o.probe(s);if(c.ok||c.sighting===void 0)throw new J(`doctor-mark: ${o.label} — ${c.ok?`nothing to mark`:`shows nothing to look at`}`);let l=[o.name,c.sighting.id,i],u=t.doctorStores.marks.update(e=>YJ(e,...l));if(u.kind===`failed`)throw new J(`doctor-mark: ${u.reason}`);t.dlog(`info`,`doctor-mark: ${o.name} ${i} on ${c.sighting.id} (session=${a})`),dQ(t,a,{...s,marks:u})},vQ=(e,t)=>{let[n=``,...r]=SZ(()=>Vr(e)),i=bZ(n),a=BZ(t,i),o=Object.values(t.configFor(a).actions).filter(e=>`ceiling`in e).find(e=>{let t=RL(e);return t.length===r.length&&t.every((e,t)=>e===r[t])});if(o===void 0)throw new J(`ceiling: "${r.join(` `)}" is not a move this config declares`);let s=o.ceiling===`set`?{kind:`set`,to:o.to}:{kind:`clear`},c=xU({sessionId:i,projectDir:a.projectDir,cwd:a.cwd},uQ(t,i));t.memento.move(c,s),t.dlog(`info`,`ceiling: ${r.join(` `)} (session=${i} claudeConfigDir=${c.claudeConfigDir})`)},yQ=(e,t)=>{let[n=``,r=``]=SZ(()=>Vr(e)),i=bZ(n),a=Object.values(t.configFor(BZ(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new J(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=mZ(t.claudeInput,uQ(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.dlog(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new J(`${r} was not typed: ${s.reason}`);t.dlog(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)},bQ=`config-override`,xQ=new Map([[gr,wZ],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new J(`load-config: expected <sessionId>/<path> (missing separator)`);let r=bZ(SZ(()=>decodeURIComponent(e.slice(0,n)))),i=SZ(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new J(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new J(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,bQ),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,bQ,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[_r,TZ],[mr,kZ],[hr,MZ],[xr,KZ],[Sr,qZ],[Dr,eQ],[Cr,JZ],[wr,ZZ],[Tr,QZ],[Er,$Z],[Or,rQ],[kr,iQ],[Ar,sQ],[jr,aQ],[Mr,oQ],[yr,EZ],[br,DZ],[vr,OZ],[Nr,cQ],[Pr,mQ],[Fr,gQ],[Ir,_Q],[Lr,hQ],[Rr,vQ],[zr,yQ]]),SQ=new Set([mr,hr,xr,Sr,Dr,Cr,wr,Tr,Er,Or,kr,Ar,jr,Mr,vr,Nr,Pr,Fr,Ir,Rr,zr]),CQ=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of Gr(Ur(e))){if(!i&&SQ.has(a)){let e=Vr(o);e.length>0&&e[0]&&(i=e[0])}let e=xQ.get(a);if(!e){n.push(`unknown effect verb "${a}"`);continue}try{e(o,t)}catch(e){e instanceof J||(r=!0),n.push(`${a}: ${e instanceof Error?e.message:String(e)}`)}}if(n.length>0){i&&VJ(t.sessionState,i,n.join(`
493
- `),_O(new Date));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new J(e)}};function wQ(e){return(t,n)=>{let r=n.history.begin(),i=n.navigation.begin(r.sessionState),a=[];try{e(t,{...n,sessionState:r.sessionState,journal:r,navigating:i.sessionState})}catch(e){a.push(e)}i.commit();try{r.commit()}catch(e){a.push(e)}if(a.length===1)throw a[0];if(a.length>1)throw Error(a.map(e=>String(e.message??e)).join(`; `))}}const TQ=new Map([...xQ,[pr,CQ]].map(([e,t])=>[e,wQ(t)]));Object.freeze([...TQ.keys()]);const EQ=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`]),DQ=[[`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`]],OQ=[[`workspace.added_dirs`,`string-list`]];function kQ(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of DQ){let i=MQ(n,e);if(i==null)t.missingRequired.push(e);else{let n=AQ(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of OQ){let i=MQ(n,e),a=i===void 0?r:jQ(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))EQ.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function AQ(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function jQ(e){return Array.isArray(e)&&e.every(e=>AQ(e)===`string`)?`string-list`:AQ(e)}function MQ(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 NQ(e,t){switch(e){case`vars`:return{what:e,vars:PQ(t)};case`segments`:return{what:e,segments:zQ(t)};case`config`:return{what:e,config:UQ(t)}}}function PQ(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=LQ(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=FQ(r),s=n.getLastError(e);o.push({name:e,source:i.get(e)??null,...a,lastError:s===void 0?null:{timestampMs:s.timestamp,message:s.message},ageMs:IQ(r.lastUpdatedMs())})}return o}function FQ(e){if(e.kind!==`document`)try{return{type:e.type,value:e.read()}}catch(t){return{type:e.type,value:t instanceof Error?t.message:String(t)}}let t=e.read();switch(t.kind){case`ok`:return{type:`document`,value:JSON.stringify(t.value)};case`absent`:return{type:`document`,value:`(not yet scanned)`};case`failed`:return{type:`document`,value:t.reason}}}function IQ(e){return e===null?null:Math.max(0,Date.now()-e)}function LQ(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,RQ(r));for(let[n,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))t.set(`${n}.${e}`,RQ(i));return t}function RQ(e){return e.kind}function zQ(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=VQ(n),o=BQ(n),s=[];for(let e of a){let t=n.segments[e];t&&s.push({name:e,description:t.description??null,template:t.template,referencedVars:HQ(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function BQ(e){let t=new Map;for(let n of Iy(e.presets))for(let r of _g(zy(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=pg(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function VQ(e){let t=[],n=new Set;for(let r of _g(ky(e.root)))r.kind===`segment`&&e.segments[r.name]&&!n.has(r.name)&&(t.push(r.name),n.add(r.name));for(let r of Object.keys(e.segments))n.has(r)||(t.push(r),n.add(r));return t}function HQ(e,t,n){let r=new Set;for(let i of sb(e,t).keys()){if(n.has(i)){r.add(i);continue}let e=i.split(`.`);for(;e.length>1;){e.pop();let t=e.join(`.`);if(n.has(t)){r.add(t);break}}}return Array.from(r).sort()}function UQ(e){return e===null?null:e.config}const WQ=[`vars`,`segments`,`config`];function GQ(e){return typeof e==`string`&&WQ.includes(e)}function KQ(e){return Math.max(1,e-2)}const qQ={moving:1e3/30,still:1e3},JQ=1e3;function YQ(e){return E_.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 XQ(e,t){e.push(t);let n=e.findIndex(e=>e>t-JQ);e.splice(0,n)}const ZQ=e=>({resp:e,bytes:JSON.stringify(e)}),QQ=(e,t)=>T_[t].elsewhere===null?e.statusline:e.bar,$Q=e=>Math.round(1e3/e);var e$=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++,this.wake(e))}subscribe(e,t){let n=this.requests.get(e);if(n!==void 0&&!this.deps.lanes(n.req)[t.lane])return this.refuse(e,t),()=>{};let r=this.feeds.get(e)??this.open(e);return r.followers.set(t,null),r.rates.has(t.lane)||r.rates.set(t.lane,[]),this.send(r,t),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${r.followers.size} data=${this.requests.has(e)?`Y`:`N`}`),()=>this.unsubscribe(r,t)}following(e){return new Set([...this.feeds.get(e)?.followers.keys()??[]].filter(e=>e.drawing()).map(e=>e.lane))}wake(e){let t=this.feeds.get(e);if(t!==void 0)switch(t.phase.kind){case`drawing`:t.phase.again=!0;return;case`due`:clearTimeout(t.phase.timer),this.draw(t);return;case`waiting`:this.draw(t);return}}wakeWhere(e){for(let{sessionId:t,req:n}of this.watched())e(n)&&this.wake(t)}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}watched(){return[...this.feeds.keys()].flatMap(e=>{let t=this.requests.get(e);return t===void 0?[]:[{sessionId:e,req:t.req}]})}feedsOf(e){let t=this.feeds.get(e);if(t===void 0)return M_;let n=this.deps.now()-JQ,r=this.shown(t);return j_(e=>{let i=t.rates.get(e);if(i===void 0)return k_;let a=0;for(let n of t.followers.keys())n.lane===e&&a++;let o=0;for(let e of i)e>n&&o++;return{subscribers:a,fps:o,shown:r}})}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.now(),n={sessionId:e,followers:new Map,rates:new Map,unwatch:this.deps.watch(e,()=>this.wake(e)),phase:{kind:`waiting`},last:null,since:t,drawn:0,noted:0,moving:0,unseen:0,failed:0,pushed:0,pace:$Q(this.deps.periods.still),drawMs:0,summarizedAt:t};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),this.draw(n),n}unsubscribe(e,t){e.followers.delete(t)&&([...e.followers.keys()].some(e=>e.lane===t.lane)||e.rates.delete(t.lane),!(e.followers.size>0)&&(e.phase.kind===`due`&&clearTimeout(e.phase.timer),e.unwatch(),this.feeds.delete(e.sessionId),this.feeds.size===0&&(this.stopWatching?.(),this.stopWatching=null),this.summarize(e,`closed`)))}draw(e){return this.step(e).catch(t=>{if(this.deps.log(`error`,`feed sid=${JSON.stringify(e.sessionId)} threw: ${w(t)}`),this.feeds.get(e.sessionId)!==e)return;let n=this.deps.now();this.schedule(e,null,n,n)})}async step(e){let t=this.requests.get(e.sessionId);if(t===void 0){e.phase={kind:`waiting`};return}let{req:n}=t,r={kind:`drawing`,again:!1};e.phase=r;let i=this.deps.now(),a=await this.deps.render(n,e.pace),o=this.deps.now();if(this.drawn++,e.drawn++,e.drawMs+=o-i,this.feeds.get(e.sessionId)===e&&(this.countFailure(e,a),this.push(e,a),this.feeds.get(e.sessionId)===e)){if(o-e.summarizedAt>=6e4&&this.summarize(e,`running`),r.again){this.draw(e);return}this.schedule(e,a,i,o)}}schedule(e,t,n,r){let i=t?.moves===!0,a=i&&this.shown(e);a&&e.moving++,i&&!a&&e.unseen++;let o=a?this.deps.periods.moving:this.deps.periods.still;e.pace=$Q(o),e.phase={kind:`due`,timer:setTimeout(()=>void this.draw(e),Math.max(0,n+o-r))}}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){let n=this.requests.get(e.sessionId);if(n!==void 0){let t=this.deps.lanes(n.req);for(let n of[...e.followers.keys()])t[n.lane]||(this.unsubscribe(e,n),this.refuse(e.sessionId,n))}if(e.followers.size===0)return;let r={bar:ZQ(t.resp),statusline:ZQ(t.statusline)};if(e.last?.answers.bar.bytes===r.bar.bytes&&e.last.answers.statusline.bytes===r.statusline.bytes)return;let i=e.last?.answers??null;e.last={answers:r},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);let a=this.deps.now();for(let[t,n]of e.rates)(i===null||QQ(i,t).bytes!==QQ(r,t).bytes)&&XQ(n,a);for(let t of e.followers.keys())this.send(e,t)}send(e,t){if(e.last===null)return;let{resp:n,bytes:r}=QQ(e.last.answers,t.lane);e.followers.get(t)!==r&&(t.frame(n,r),e.followers.set(t,r))}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:zA(t.lane),code:`SWITCHED_OFF`,daemonV:3})}summarize(e,t){let n=this.deps.now();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((n-e.since)/1e3)}s drawn=${e.drawn} noted=${e.noted} moving=${e.moving} unseen=${e.unseen} failed=${e.failed} pushed=${e.pushed} pace=${e.pace}fps meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};function t$(e){let t=null;return e.on(`drain`,()=>{let n=t;t=null,n!==null&&e.write(n)}),n=>{if(e.writable){if(e.writableNeedDrain){t=n;return}e.write(n)}}}const n$=`#{pane_id} #{session_id} #{session_attached} #{window_active} #{window_zoomed_flag} #{pane_active}`,r$=`#{session_id} #{client_control_mode} #{pane_id}`;function i$(e){let t=new Set;for(let n of e.split(`
497
+ `);return{inMode:n!==`0`,screen:r}}function _Z(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`]}function vZ(e,t){let n=hZ(e,`claude-input.type`,_Z(e.pane,`cc-candybar-slash`,[`C-s`]),t);return n.kind===`ok`?{kind:`typed`}:{kind:`refused`,reason:`cc-candybar typed a command moments ago — click again in a second (${n.reason})`}}function yZ(){return{read:gZ,type:vZ}}function bZ(e){if(!e)throw new J(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new J(`invalid session id "${e}"`);return e}function xZ(e){return SZ(()=>decodeURIComponent(e))}function SZ(e){try{return e()}catch(e){throw e instanceof URIError?new J(`malformed wire encoding: ${e.message}`):e}}function CZ(e,t){let n=ut({bin:`/usr/bin/pbcopy`,stdinInput:e,category:`click.pbcopy`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.pbcopy rate-limited: ${n.error??``}`);return}throw Error(`pbcopy failed (${n.reason}, exit ${n.exitCode??`null`})`)}}const wZ=(e,t)=>CZ(xZ(e),t),TZ=(e,t)=>{let n=ut({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,xZ(e)],category:`click.open`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.open rate-limited: ${n.error??``}`);return}throw Error(`open -a "Visual Studio Code" failed (${n.reason}, exit ${n.exitCode??`null`})`)}},EZ=(e,t)=>CZ(xZ(e),t),DZ=(e,t)=>CZ(xZ(e),t),OZ=(e,t)=>{let n=bZ(xZ(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},kZ=(e,t)=>{let[n=``,...r]=SZ(()=>Vr(e)),i=bZ(n),a=wV(UZ(t,i));if(r.length===0)throw new J(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new J(`set-state: expected even-count <key>/<value> pairs, got ${r.length} segment(s) after session id (have keys: ${a.listKeys().join(`, `)})`);let o=[];for(let e=0;e<r.length;e+=2){let t=r[e],n=r[e+1];if(!t)throw new J(`set-state: empty key at pair ${e/2+1} (expected <sessionId>/<key>/<value>[/<key>/<value>...] segments)`);let i=a.validate(t,n);if(!i.ok)throw new J(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}NZ(t,i,`set-state`,o),t.navigating.setBatch(i,o);let s=o.map(e=>`${e.key}=${e.value}`).join(` `);t.dlog(`info`,`set-state: ${s} (session=${i})`)},AZ=/^-?\d+$/;function jZ(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const MZ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n);if(!r)throw new J(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!AZ.test(i))throw new J(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=UZ(t,a),c=wV(s),l=c.rangeParamsFor(r);if(!l)throw new J(`step-state: key "${r}" is not a bounded (range) state key (have keys: ${c.listKeys().join(`, `)})`);let u=t.sessionState.get(a,r),d=u&&AZ.test(u)?PZ(l,parseInt(u,10)):FZ(`step-state`,r,l,DV(s,e=>t.sessionState.get(a,e),r)),f=jZ(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new J(`step-state: ${p.reason}`);NZ(t,a,`step-state`,[{key:r,value:p.value}]),t.navigating.set(a,r,p.value),t.dlog(`info`,`step-state: ${r} ${d}→${p.value} (by ${o}, session=${a})`)};function NZ(e,t,n,r){let i=r.filter(e=>e.key.startsWith(dA));if(i.length===0)return;let a=rV(UZ(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new J(`${n}: refused — ${a.join(`; `)}`)}function PZ(e,t){return Math.max(e.min,Math.min(e.max,t))}function FZ(e,t,n,r){if(r===null)return n.min;if(!AZ.test(r))throw new J(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return PZ(n,parseInt(r,10))}const IZ=`render-origin`;function LZ(e,t,n){return{...e,configFile:t.get(n,`config-override`)??e.configFile}}function RZ(e){return JSON.stringify(e)}function zZ(e){let t;try{t=JSON.parse(e)}catch{throw new J(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new J(`render origin is not an object: ${e}`);let{projectDir:n,cwd:r,configFile:i}=t;if(typeof n!=`string`||typeof r!=`string`||i!==null&&typeof i!=`string`)throw new J(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,configFile:i}}function BZ(e,t){let n=VZ(e,t);if(n===null)throw new J(`session ${t} has not rendered yet — no config to act on`);return n}function VZ(e,t){let n=e.sessionState.get(t,IZ);return n===null?null:LZ(zZ(n),e.sessionState,t)}function HZ(e,t,n){let r=VZ(e,t);if(r===null)return;let{path:i}=WZ(r);n.some(e=>e.kind===`file`&&e.file===i)&&e.reloadConfig(r)}function UZ(e,t){return e.configFor(BZ(e,t))}function WZ(e){return eB(e.projectDir,e.cwd,e.configFile??void 0)}function GZ(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.dlog}}const KZ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n),o=BZ(t,a),s=t.configFor(o),c=IF(s);if(!r)throw new J(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new J(`set-config: ${l.reason}`);let u=WZ(o),d=tV(s,e=>t.sessionState.get(a,e),r);Zq(GZ(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.dlog(`info`,`set-config: ${d.key}=${l.value} → ${u.path} (session=${a})`)},qZ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n);if(!r)throw new J(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!AZ.test(i))throw new J(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=BZ(t,a),c=t.configFor(s),l=IF(c),u=l.rangeParamsFor(r);if(!u)throw new J(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=WZ(s),f=tV(c,e=>t.sessionState.get(a,e),r),p=Xq(d.path,f.key),m=typeof p==`number`?PZ(u,p):FZ(`step-config`,r,u,RF(f.globals,r)),h=jZ(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new J(`step-config: ${g.reason}`);Zq(GZ(t,a),d,[[f.key,g.value]]),t.reloadConfig(s),t.dlog(`info`,`step-config: ${f.key} ${m}→${g.value} (by ${o}) → ${d.path} (session=${a})`)},JZ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n),i=BZ(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=$B(a,o),c=nV(a,o);if(s.length+c.length===0){t.dlog(`info`,`save: nothing unsaved (session=${r})`);return}let l=wV(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new J(`save: ${t.reason}`);return[e.target,t.value]});XZ(`save`,l,c);let d=WZ(i);Qq(GZ(t,r),d,u,c),t.reloadConfig(i);for(let e of[...s.map(e=>e.sessionKey),...c.map(e=>e.key)])t.sessionState.clear(r,e);t.dlog(`info`,`save: ${[...u.map(([e,t])=>`${e}=${t}`),...c.map(YZ)].join(` `)} → ${d.path} (session=${r})`)},YZ=e=>`${e.preset}/${e.id}.settings.${e.setting}=${Ig(e.value)}`;function XZ(e,t,n){for(let r of n){let n=t.validate(r.key,Ig(r.value));if(!n.ok)throw new J(`${e}: ${n.reason}`)}}const ZZ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n),i=BZ(t,r),a=t.configFor(i),o=oV(a,e=>t.sessionState.get(r,e)),s=wV(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new J(`save-preset: ${t.reason}`);return[e.configKey,t.value]});XZ(`save-preset`,s,o.placements);let l=WZ(i),u=aJ(GZ(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...lv.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,sv.preset.sessionKey,u),t.dlog(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(YZ)].join(` `)} → ${l.path} (session=${r})`)},QZ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n),i=BZ(t,r),a=cV(t.configFor(i),e=>t.sessionState.get(r,e));if(a.kind===`rule`)throw new J(`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 o=WZ(i);oJ(GZ(t,r),o,a.theme,a.look),t.reloadConfig(i);let s=new Set($B(t.configFor(i),e=>t.sessionState.get(r,e)).map(e=>e.sessionKey)),c=ev.map(e=>sv[e].sessionKey).filter(e=>!s.has(e));for(let e of c)t.sessionState.clear(r,e);t.dlog(`info`,`save-theme-default: ${a.theme} ${ev.map(e=>`${e}=${a.look[e]}`).join(` `)} → ${o.path} (session=${r})`)},$Z=(e,t)=>{let[n=``,r=``]=SZ(()=>Vr(e)),i=bZ(n);if(!r)throw new J(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=BZ(t,i),o=WZ(a);sJ(GZ(t,i),o,r),t.reloadConfig(a);let s=sv.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.dlog(`info`,`delete-preset: ${r} ← ${o.path} (session=${i})`)},eQ=(e,t)=>{let[n=``,...r]=SZ(()=>Vr(e)),i=bZ(n),a=BZ(t,i),o=IF(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new J(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=WZ(a),l=r.map(lV),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);nJ(GZ(t,i),c,u),t.reloadConfig(a);for(let e of d)t.sessionState.clear(i,e);t.dlog(`info`,`reset-config: ${[...u,...d.map(e=>`session:${e}`)].join(` `)} ← ${c.path} (session=${i})`)};function tQ(e,t){let n=(e,t)=>[..._g(zy(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(Iy(t.presets).flatMap(e=>n(t,e).map(t=>fA(XO(e),pg(t)))));return Iy(e.presets).flatMap(t=>n(e,t).map(e=>({member:fA(XO(t),pg(e)),node:e})).filter(({member:e})=>!r.has(e)))}function nQ(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[oA]:[]])}const rQ=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n),o=BZ(t,a),s=t.configFor(o),c=IF(s);if(!r)throw new J(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new J(`apply-layout-op: ${l.reason}`);let u=SF(l.value);if(u===null)throw new J(`apply-layout-op: "${l.value}" is not a layout op token`);let d=WZ(o),f=cJ(GZ(t,a),d,r,u);t.reloadConfig(o);let p=nQ(tQ(s,t.configFor(o)),t.sessionState.get(a,oA)).filter(e=>t.sessionState.get(a,e)!==null);for(let e of p)t.sessionState.clear(a,e);t.dlog(`info`,`apply-layout-op: ${r} ${l.value} → ${d.path} placed=${JSON.stringify(f)} released=${JSON.stringify(p)} (session=${a})`)},iQ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n);t.journal.commit();let i=t.history.undo(r);HZ(t,r,i),t.dlog(`info`,`undo: restored ${AJ(i)} (session=${r})`)},aQ=(e,t)=>{let n=bZ(xZ(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,wV(UZ(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.dlog(`info`,`back: ${a} discarded=${i} (session=${n})`)},oQ=(e,t)=>{let n=bZ(xZ(e));t.journal.commit();let r=t.history.rewind(n);HZ(t,n,r),t.dlog(`info`,`rewind: put back ${AJ(r)||`nothing`} as edit mode found it (session=${n})`)},sQ=(e,t)=>{let[n=``]=SZ(()=>Vr(e)),r=bZ(n);t.journal.commit();let i=t.history.redo(r);HZ(t,r,i),t.dlog(`info`,`redo: re-applied ${AJ(i)} (session=${r})`)},cQ=(e,t)=>{bZ(xZ(e)),t.applyUpdate()},lQ=`client-hints`;function uQ(e,t){let n=e.sessionState.get(t,lQ);if(n===null)throw new J(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new J(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new J(`client hints record is not an object: ${n}`);return zt(r)}function dQ(e,t,n){let r=yM(n);e.sessionState.setBatch(t,LM(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} ${FM(n.nerdFont,n.marks)} ${TM(n.terminal,n.clicked)} ${EM(n.terminal,n.width)} ${DM(n.install)} ${kM(n.daemon)} ${AM(n.data)} ${PM(n.transcripts)} ${jM(n.frames,n.claudeSettings)} ${NM(n.claudeSettings.origin.sources)} (session=${t})`)}function fQ(e,t){let n={kind:`clicked`,sessionId:t,via:e.arrival.via},r=e.clients.ofSession(t,_O(new Date)),i;try{i=MX(e.doctor,uQ(e,t),BZ(e,t),n=>e.sessionState.get(t,n),{kind:`ok`,value:e.serving()},{kind:`ok`,value:r.map(e=>e.rateLimits)},{kind:`ok`,value:r.map(e=>e.transcript)},n,{kind:`ok`,value:iY(n,r)},jX(t,r),aX(e.doctorStores))}catch(e){throw e instanceof eY?new J(e.message):e}return{...i,urlHandler:OX(e.arrival),install:rX(e.doctor.install,e.bundle,r.map(e=>e.client)),clicked:pQ(e,i)}}function pQ(e,{terminal:t,clicked:n}){let r=t.kind===`seen`?vj(t.identified):null;if(r===null||e.arrival.via!==`link`)return n;try{return e.doctorStores.clicked.update(e=>QJ(e,r))}catch(t){return e.dlog(`warn`,`doctor: clicked terminal not filed for ${JSON.stringify(r)}: ${t instanceof Error?t.message:String(t)}`),n}}const mQ=(e,t)=>{let n=bZ(xZ(e));dQ(t,n,fQ(t,n))},hQ=(e,t)=>{let n=XX(xZ(e));if(n===null)throw new J(`doctor-probe: the value is not a probe nonce`);if(t.arrival.via!==`link`)throw new J(`doctor-probe: a probe arrives only as a link`);let{handler:r}=t.arrival;t.probes.arrive({nonce:n,handler:r}),t.dlog(`info`,`doctor-probe: arrived nonce=${n} handler=${r??`unreported`}`)},gQ=(e,t)=>{let[n=``,r=``]=SZ(()=>Vr(e)),i=bZ(n),a=bM(r);if(a===void 0)throw new J(`doctor-fix: unknown check "${r}"`);let o=fQ(t,i),s=a.probe(o);if(s.ok||s.fix===void 0)throw new J(`doctor-fix: ${a.label} — ${s.ok?`nothing to fix`:s.reason}`);let c=NX(t.doctorStores,s.fix,o);if(c.kind===`failed`)throw new J(`doctor-fix: ${a.label} — ${c.reason}`);t.dlog(`info`,`doctor-fix: ${a.name} → ${Aj(s.fix)} (session=${i})`),dQ(t,i,c.value)},_Q=(e,t)=>{let[n=``,r=``,i=``]=SZ(()=>Vr(e)),a=bZ(n),o=bM(r);if(o===void 0)throw new J(`doctor-mark: unknown check "${r}"`);if(!Dj.includes(i))throw new J(`doctor-mark: the mark is ${JSON.stringify(i)}, not ${Dj.join(` or `)}`);let s=fQ(t,a),c=o.probe(s);if(c.ok||c.sighting===void 0)throw new J(`doctor-mark: ${o.label} — ${c.ok?`nothing to mark`:`shows nothing to look at`}`);let l=[o.name,c.sighting.id,i],u=t.doctorStores.marks.update(e=>YJ(e,...l));if(u.kind===`failed`)throw new J(`doctor-mark: ${u.reason}`);t.dlog(`info`,`doctor-mark: ${o.name} ${i} on ${c.sighting.id} (session=${a})`),dQ(t,a,{...s,marks:u})},vQ=(e,t)=>{let[n=``,...r]=SZ(()=>Vr(e)),i=bZ(n),a=BZ(t,i),o=Object.values(t.configFor(a).actions).filter(e=>`ceiling`in e).find(e=>{let t=RL(e);return t.length===r.length&&t.every((e,t)=>e===r[t])});if(o===void 0)throw new J(`ceiling: "${r.join(` `)}" is not a move this config declares`);let s=o.ceiling===`set`?{kind:`set`,to:o.to}:{kind:`clear`},c=xU({sessionId:i,projectDir:a.projectDir,cwd:a.cwd},uQ(t,i));t.memento.move(c,s),t.dlog(`info`,`ceiling: ${r.join(` `)} (session=${i} claudeConfigDir=${c.claudeConfigDir})`)},yQ=(e,t)=>{let[n=``,r=``]=SZ(()=>Vr(e)),i=bZ(n),a=Object.values(t.configFor(BZ(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new J(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=mZ(t.claudeInput,uQ(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.dlog(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new J(`${r} was not typed: ${s.reason}`);t.dlog(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)},bQ=`config-override`,xQ=new Map([[gr,wZ],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new J(`load-config: expected <sessionId>/<path> (missing separator)`);let r=bZ(SZ(()=>decodeURIComponent(e.slice(0,n)))),i=SZ(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new J(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new J(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,bQ),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,bQ,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[_r,TZ],[mr,kZ],[hr,MZ],[xr,KZ],[Sr,qZ],[Dr,eQ],[Cr,JZ],[wr,ZZ],[Tr,QZ],[Er,$Z],[Or,rQ],[kr,iQ],[Ar,sQ],[jr,aQ],[Mr,oQ],[yr,EZ],[br,DZ],[vr,OZ],[Nr,cQ],[Pr,mQ],[Fr,gQ],[Ir,_Q],[Lr,hQ],[Rr,vQ],[zr,yQ]]),SQ=new Set([mr,hr,xr,Sr,Dr,Cr,wr,Tr,Er,Or,kr,Ar,jr,Mr,vr,Nr,Pr,Fr,Ir,Rr,zr]),CQ=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of Gr(Ur(e))){if(!i&&SQ.has(a)){let e=Vr(o);e.length>0&&e[0]&&(i=e[0])}let e=xQ.get(a);if(!e){n.push(`unknown effect verb "${a}"`);continue}try{e(o,t)}catch(e){e instanceof J||(r=!0),n.push(`${a}: ${e instanceof Error?e.message:String(e)}`)}}if(n.length>0){i&&VJ(t.sessionState,i,n.join(`
498
+ `),_O(new Date));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new J(e)}};function wQ(e){return(t,n)=>{let r=n.history.begin(),i=n.navigation.begin(r.sessionState),a=[];try{e(t,{...n,sessionState:r.sessionState,journal:r,navigating:i.sessionState})}catch(e){a.push(e)}i.commit();try{r.commit()}catch(e){a.push(e)}if(a.length===1)throw a[0];if(a.length>1)throw Error(a.map(e=>String(e.message??e)).join(`; `))}}const TQ=new Map([...xQ,[pr,CQ]].map(([e,t])=>[e,wQ(t)]));Object.freeze([...TQ.keys()]);const EQ=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`]),DQ=[[`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`]],OQ=[[`workspace.added_dirs`,`string-list`]];function kQ(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of DQ){let i=MQ(n,e);if(i==null)t.missingRequired.push(e);else{let n=AQ(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of OQ){let i=MQ(n,e),a=i===void 0?r:jQ(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))EQ.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function AQ(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function jQ(e){return Array.isArray(e)&&e.every(e=>AQ(e)===`string`)?`string-list`:AQ(e)}function MQ(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 NQ(e,t){switch(e){case`vars`:return{what:e,vars:PQ(t)};case`segments`:return{what:e,segments:zQ(t)};case`config`:return{what:e,config:UQ(t)}}}function PQ(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=LQ(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=FQ(r),s=n.getLastError(e);o.push({name:e,source:i.get(e)??null,...a,lastError:s===void 0?null:{timestampMs:s.timestamp,message:s.message},ageMs:IQ(r.lastUpdatedMs())})}return o}function FQ(e){if(e.kind!==`document`)try{return{type:e.type,value:e.read()}}catch(t){return{type:e.type,value:t instanceof Error?t.message:String(t)}}let t=e.read();switch(t.kind){case`ok`:return{type:`document`,value:JSON.stringify(t.value)};case`absent`:return{type:`document`,value:`(not yet scanned)`};case`failed`:return{type:`document`,value:t.reason}}}function IQ(e){return e===null?null:Math.max(0,Date.now()-e)}function LQ(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,RQ(r));for(let[n,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))t.set(`${n}.${e}`,RQ(i));return t}function RQ(e){return e.kind}function zQ(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=VQ(n),o=BQ(n),s=[];for(let e of a){let t=n.segments[e];t&&s.push({name:e,description:t.description??null,template:t.template,referencedVars:HQ(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function BQ(e){let t=new Map;for(let n of Iy(e.presets))for(let r of _g(zy(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=pg(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function VQ(e){let t=[],n=new Set;for(let r of _g(ky(e.root)))r.kind===`segment`&&e.segments[r.name]&&!n.has(r.name)&&(t.push(r.name),n.add(r.name));for(let r of Object.keys(e.segments))n.has(r)||(t.push(r),n.add(r));return t}function HQ(e,t,n){let r=new Set;for(let i of sb(e,t).keys()){if(n.has(i)){r.add(i);continue}let e=i.split(`.`);for(;e.length>1;){e.pop();let t=e.join(`.`);if(n.has(t)){r.add(t);break}}}return Array.from(r).sort()}function UQ(e){return e===null?null:e.config}const WQ=[`vars`,`segments`,`config`];function GQ(e){return typeof e==`string`&&WQ.includes(e)}function KQ(e){return Math.max(1,e-2)}const qQ={moving:1e3/30,still:1e3},JQ=1e3;function YQ(e){return E_.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 XQ(e,t){e.push(t);let n=e.findIndex(e=>e>t-JQ);e.splice(0,n)}const ZQ=e=>({resp:e,bytes:JSON.stringify(e)}),QQ=(e,t)=>T_[t].elsewhere===null?e.statusline:e.bar,$Q=e=>Math.round(1e3/e);var e$=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++,this.wake(e))}subscribe(e,t){let n=this.requests.get(e);if(n!==void 0&&!this.deps.lanes(n.req)[t.lane])return this.refuse(e,t),()=>{};let r=this.feeds.get(e)??this.open(e);return r.followers.set(t,null),r.rates.has(t.lane)||r.rates.set(t.lane,[]),this.send(r,t),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${r.followers.size} data=${this.requests.has(e)?`Y`:`N`}`),()=>this.unsubscribe(r,t)}following(e){return new Set([...this.feeds.get(e)?.followers.keys()??[]].filter(e=>e.drawing()).map(e=>e.lane))}wake(e){let t=this.feeds.get(e);if(t!==void 0)switch(t.phase.kind){case`drawing`:t.phase.again=!0;return;case`due`:clearTimeout(t.phase.timer),this.draw(t);return;case`waiting`:this.draw(t);return}}wakeWhere(e){for(let{sessionId:t,req:n}of this.watched())e(n)&&this.wake(t)}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}watched(){return[...this.feeds.keys()].flatMap(e=>{let t=this.requests.get(e);return t===void 0?[]:[{sessionId:e,req:t.req}]})}feedsOf(e){let t=this.feeds.get(e);if(t===void 0)return M_;let n=this.deps.now()-JQ,r=this.shown(t);return j_(e=>{let i=t.rates.get(e);if(i===void 0)return k_;let a=0;for(let n of t.followers.keys())n.lane===e&&a++;let o=0;for(let e of i)e>n&&o++;return{subscribers:a,fps:o,shown:r}})}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.now(),n={sessionId:e,followers:new Map,rates:new Map,unwatch:this.deps.watch(e,()=>this.wake(e)),phase:{kind:`waiting`},last:null,since:t,drawn:0,noted:0,moving:0,unseen:0,failed:0,pushed:0,pace:$Q(this.deps.periods.still),drawMs:0,summarizedAt:t};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),this.draw(n),n}unsubscribe(e,t){e.followers.delete(t)&&([...e.followers.keys()].some(e=>e.lane===t.lane)||e.rates.delete(t.lane),!(e.followers.size>0)&&(e.phase.kind===`due`&&clearTimeout(e.phase.timer),e.unwatch(),this.feeds.delete(e.sessionId),this.feeds.size===0&&(this.stopWatching?.(),this.stopWatching=null),this.summarize(e,`closed`)))}draw(e){return this.step(e).catch(t=>{if(this.deps.log(`error`,`feed sid=${JSON.stringify(e.sessionId)} threw: ${w(t)}`),this.feeds.get(e.sessionId)!==e)return;let n=this.deps.now();this.schedule(e,null,n,n)})}async step(e){let t=this.requests.get(e.sessionId);if(t===void 0){e.phase={kind:`waiting`};return}let{req:n}=t,r={kind:`drawing`,again:!1};e.phase=r;let i=this.deps.now(),a=await this.deps.render(n,e.pace),o=this.deps.now();if(this.drawn++,e.drawn++,e.drawMs+=o-i,this.feeds.get(e.sessionId)===e&&(this.countFailure(e,a),this.push(e,a),this.feeds.get(e.sessionId)===e)){if(o-e.summarizedAt>=6e4&&this.summarize(e,`running`),r.again){this.draw(e);return}this.schedule(e,a,i,o)}}schedule(e,t,n,r){let i=t?.moves===!0,a=i&&this.shown(e);a&&e.moving++,i&&!a&&e.unseen++;let o=a?this.deps.periods.moving:this.deps.periods.still;e.pace=$Q(o),e.phase={kind:`due`,timer:setTimeout(()=>void this.draw(e),Math.max(0,n+o-r))}}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){let n=this.requests.get(e.sessionId);if(n!==void 0){let t=this.deps.lanes(n.req);for(let n of[...e.followers.keys()])t[n.lane]||(this.unsubscribe(e,n),this.refuse(e.sessionId,n))}if(e.followers.size===0)return;let r={bar:ZQ(t.resp),statusline:ZQ(t.statusline)};if(e.last?.answers.bar.bytes===r.bar.bytes&&e.last.answers.statusline.bytes===r.statusline.bytes)return;let i=e.last?.answers??null;e.last={answers:r},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);let a=this.deps.now();for(let[t,n]of e.rates)(i===null||QQ(i,t).bytes!==QQ(r,t).bytes)&&XQ(n,a);for(let t of e.followers.keys())this.send(e,t)}send(e,t){if(e.last===null)return;let{resp:n,bytes:r}=QQ(e.last.answers,t.lane);e.followers.get(t)!==r&&(t.frame(n,r),e.followers.set(t,r))}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:BA(t.lane),code:`SWITCHED_OFF`,daemonV:3})}summarize(e,t){let n=this.deps.now();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((n-e.since)/1e3)}s drawn=${e.drawn} noted=${e.noted} moving=${e.moving} unseen=${e.unseen} failed=${e.failed} pushed=${e.pushed} pace=${e.pace}fps meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};function t$(e){let t=null;return e.on(`drain`,()=>{let n=t;t=null,n!==null&&e.write(n)}),n=>{if(e.writable){if(e.writableNeedDrain){t=n;return}e.write(n)}}}const n$=`#{pane_id} #{session_id} #{session_attached} #{window_active} #{window_zoomed_flag} #{pane_active}`,r$=`#{session_id} #{client_control_mode} #{pane_id}`;function i$(e){let t=new Set;for(let n of e.split(`
494
499
  `)){let[e,r]=n.trim().split(` `);e!==void 0&&r===`1`&&t.add(e)}return t}function a$(e,t){let n=new Set;for(let r of e.split(`
495
500
  `)){let[e,i,a,o,s,c]=r.trim().split(` `);e===void 0||e===``||i===void 0||Number(a)>0&&(o===`1`||t.has(i))&&(s!==`1`||c===`1`)&&n.add(e)}return n}function o$(e,t){let n=new Map;for(let t of e.split(`
496
501
  `)){let[e,r]=t.trim().split(` `);e!==void 0&&e!==``&&r!==void 0&&n.set(e,r)}let r=new Map;for(let e of t.split(`
497
502
  `)){let[t,n,i]=e.trim().split(` `);t!==void 0&&n===`0`&&i!==void 0&&r.set(t,i)}return{sessionOf:n,shownBy:r}}var s$=class{servers=new Map;loop={kind:`idle`};constructor(e){this.deps=e}follow(){switch(this.loop.kind){case`idle`:this.deps.log(`info`,`visibility following`),this.ask();break;case`asking`:this.loop.following=!0;break;case`due`:break}return()=>this.stop()}stop(){switch(this.loop.kind){case`due`:clearTimeout(this.loop.timer),this.end();return;case`asking`:this.loop.following=!1;return;case`idle`:return}}ask(){let e={kind:`asking`,following:!0};this.loop=e,Promise.resolve().then(()=>this.refresh(this.deps.sockets())).catch(e=>this.deps.log(`error`,`visibility refresh threw: ${w(e)}`)).then(()=>{if(e.following){this.loop={kind:`due`,timer:setTimeout(()=>this.ask(),this.deps.intervalMs).unref()};return}this.end()})}end(){this.deps.log(`info`,`visibility stopped forgot=${this.servers.size}`),this.loop={kind:`idle`},this.servers.clear()}shown(e){if(e==null)return!0;let t=this.servers.get(e.socket);return t?.kind!==`asked`||t.shown.has(e.pane)}async refresh(e){for(let t of this.servers.keys())e.has(t)||this.servers.delete(t);let t=await Promise.all([...e].map(async e=>{let[t,n]=await Promise.all([this.deps.listPanes(e),this.deps.listClients(e)]);return[e,t.kind===`ok`?n.kind===`ok`?{kind:`asked`,shown:a$(t.stdout,i$(n.stdout)),status:o$(t.stdout,n.stdout)}:{kind:`unasked`,reason:n.reason}:{kind:`unasked`,reason:t.reason}]})),n=new Set;for(let[e,r]of t){let t=this.servers.get(e);this.servers.set(e,r),!c$(t,r)&&(n.add(e),this.deps.log(r.kind===`asked`?`info`:`warn`,r.kind===`asked`?`visibility socket=${JSON.stringify(e)} shown=${[...r.shown].join(`,`)||`-`}`:`visibility socket=${JSON.stringify(e)} unasked: ${r.reason} — its panes count as shown`))}for(let[e,n]of t)n.kind===`asked`&&this.deps.onAnswer(e,n.status);n.size>0&&this.deps.onChange(n)}};function c$(e,t){return e===void 0||e.kind!==t.kind?!1:e.kind===`unasked`||t.kind===`unasked`?!0:e.shown.size===t.shown.size&&[...e.shown].every(e=>t.shown.has(e))}const l$=`@cc-candybar-status-prior`,u$=`@cc-candybar-status-wrote`,d$=`@cc-candybar-binding-prior`,f$=[`-T`,`root`,`MouseDown1Status`],p$=Array.from({length:5},(e,t)=>t),m$=e=>`@cc-candybar-row-${e}`,h$=e=>`#[fill=terminal]#{${m$(e)}}`,g$=e=>`status-format[${e}]`;function _$(e){return e===0?`off`:e===1?`on`:String(e)}function v$(e){let t=e===`off`?0:e===`on`?1:/^[2-5]$/.test(e)?+e:NaN;if(Number.isNaN(t))throw Error(`tmux status is ${JSON.stringify(e)}`);return t}function y$(e,t){if(e===null)return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[Number(n)]===t[Number(n)])}function b$(e){return e.endsWith(`;`)?`${e.slice(0,-1)}\\;`:e}function x$(e){return e.flatMap((e,t)=>[...t===0?[]:[`;`],...e])}function S$(e){return`"${e.replace(/[\\"$]/g,e=>`\\${e}`)}"`}function C$(e){return e.map(e=>e.map(S$).join(` `)).join(` ; `)}const w$=`ccb:separator`;function T$(e){return x$(e.flatMap((e,t)=>t===0?[e]:[[`display-message`,`-p`,w$],e]))}function E$(e,t){let n=e.split(`${w$}\n`);return n.length===t?n.map(e=>e.replace(/\n$/,``)):null}const D$=(e,t)=>[`show-options`,`-q`,`-v`,`-t`,e,t],O$=e=>[`show-options`,`-g`,`-q`,`-v`,e],k$=e=>[[`show-options`,`-t`,e],D$(e,`status`),...p$.map(t=>D$(e,g$(t)))];function A$(e){let[t=``,n=``,...r]=e,i=t.split(`
498
503
  `).map(e=>e.split(` `)[0]??``),a={};for(let e of p$)i.includes(g$(e))&&(a[e]=r[e]??``);let o=i.includes(`status-format`)||Object.keys(a).length>0;return{status:i.includes(`status`)?n:null,formats:o?a:null}}function j$(e,t){return[[`set-option`,`-u`,`-t`,e,`status-format`],...Object.entries(t??{}).map(([t,n])=>[`set-option`,`-t`,e,g$(Number(t)),b$(n)])]}const M$=e=>[[`display-message`,`-p`,`-t`,e,`#{status}`],...k$(e),...p$.map(e=>O$(g$(e))),D$(e,l$),D$(e,u$)];function N$(e,t,n){let r,i;try{r=JSON.parse(e),i=t===``?r.base:v$(t)}catch(e){return{kind:`theirs`,why:`${l$} does not read (${String(e)})`}}return r.owner===n?{kind:`ours`,prior:r,status:i}:{kind:`theirs`,why:`the daemon at ${JSON.stringify(r.owner)} draws it`}}function P$(e,t,n){let[r=``,...i]=t,a=A$(i.slice(0,7)),o=i.slice(7,12),[s=``,c=``]=i.slice(12);if(s!==``)return N$(s,c,n);let l=v$(r),u={};for(let e=0;e<l;e++){let t=a.formats===null?o[e]:a.formats[e];t!==void 0&&t!==``&&(u[e]=t)}let d={...u,...Object.fromEntries(Array.from({length:5-l},(e,t)=>[l+t,h$(t)]))},f={owner:n,base:l,status:a.status,formats:a.formats,wrote:d};return{kind:`lay-out`,prior:f,commands:[[`set-option`,`-t`,e,l$,JSON.stringify(f)],...j$(e,d)]}}const F$=e=>[...k$(e),D$(e,u$)];function I$(e,t,n){let r=A$(n.slice(0,7)),i=n[7]??``,a=[],o=[];if(y$(r.formats,t.wrote))a.push(...j$(e,t.formats));else{o.push(`status-format`);for(let[n,i]of Object.entries(r.formats??{}))Number(n)>=t.base&&i===t.wrote[Number(n)]&&a.push([`set-option`,`-u`,`-t`,e,g$(+n)])}return i!==``&&(r.status===i?a.push(t.status===null?[`set-option`,`-u`,`-t`,e,`status`]:[`set-option`,`-t`,e,`status`,b$(t.status)]):o.push(`status`)),a.push(...p$.map(t=>[`set-option`,`-q`,`-u`,`-t`,e,m$(t)]),[`set-option`,`-q`,`-u`,`-t`,e,l$],[`set-option`,`-q`,`-u`,`-t`,e,u$]),{commands:a,kept:o}}const L$=/^bind-key\s+(?:-r\s+)?(?:-N\s+(?:"(?:[^"\\]|\\.)*"|\S+)\s+)?-T\s+root\s+MouseDown1Status\s+(.+)$/m,R$=[[`list-keys`,`-T`,`root`]];function z$(e){let t=L$.exec(e);return t===null?null:{line:t[0],command:t[1]}}const B$=`cc-candybar://tmux-status-click/`,V$=e=>`${B$}${Br([e])}/#{s/%//:pane_id}/#{q:mouse_status_range}`,H$=e=>e?.command.includes(B$)??!1;function U$(e,t){let n={command:[`set-option`,`-g`,`-q`,`-u`,d$]};return H$(z$(t))?{steps:[e===null?{command:[`unbind-key`,...f$]}:{command:[`source-file`,`-`],stdin:`${e.line}\n`},n],said:`restored MouseDown1Status to ${e===null?`unbound`:JSON.stringify(e.line)}`}:{steps:[n],said:`left MouseDown1Status as it is: bound again since`}}var W$=class{held=new Map;servers=new Map;closed=!1;writes=0;failedWrites=0;constructor(e){this.deps=e}observe(e,t,n){if(this.closed)return;let r=this.held.get(e),i=n&&t!=null?t:null;if(r!==void 0&&(i===null||r.socket!==i.socket||r.pane!==i.pane)&&this.release(r,`switched off or moved`),i===null||this.held.has(e))return;let a={sessionId:e,socket:i.socket,pane:i.pane,unsubscribe:null,frame:null};this.held.set(e,a),this.serverOf(i.socket),this.deps.log(`info`,`tmux-status: holding sid=${JSON.stringify(e)} pane=${i.pane} socket=${JSON.stringify(i.socket)}`),this.deps.defer(()=>{this.held.get(e)===a&&(a.unsubscribe=this.deps.subscribe(e,{lane:`tmuxStatus`,frame:e=>{a.frame=_H(e),this.reconcile(a.socket)},refused:t=>{this.held.get(e)===a&&this.release(a,`refused: ${t.error}`)},drawing:()=>this.draws(a)}))})}answered(e,t){if(this.closed)return;let n=this.serverOf(e);n.view=t;for(let n of[...this.held.values()])if(n.socket===e)if(!t.sessionOf.has(n.pane))this.release(n,`pane gone`);else{let t=this.deps.sessionInPane(e,n.pane);t!==null&&t!==n.sessionId&&this.release(n,`pane taken by sid=${JSON.stringify(t)}`)}this.reconcile(e)}draws(e){let t=this.servers.get(e.socket),n=t?.view?.sessionOf.get(e.pane);return n!==void 0&&t.layouts.has(n)&&t.view.shownBy.get(n)===e.pane}restoreAll(){this.closed=!0;for(let e of this.held.values())e.unsubscribe?.();this.held.clear();for(let[e,t]of this.servers){for(let[n,r]of[...t.layouts]){t.layouts.delete(n);let i=this.askSync(e,F$(n));if(i===null)continue;let a=I$(n,r.prior,i);this.writeSync(e,a.commands),this.saidRestored(e,n,a.kept)}let n=t.binding;if(t.binding={kind:`none`},n.kind===`ours`||n.kind===`adopted`){let t=this.askSync(e,R$);if(t===null)continue;this.writeBindingRestoreSync(e,n.prior,t[0]??``)}}}linkAt(e){let[t,n,r,...i]=Vr(e);if(t===void 0||n===void 0||r===void 0||i.length>0)return{kind:`refused`,reason:`tmux-status-click needs <socket>/<pane>/<range>, got ${JSON.stringify(e)}`};let a=[...this.held.values()].find(e=>e.socket===t&&e.pane===`%${n}`)?.frame?.links[r];return a===void 0?{kind:`refused`,reason:`pane %${n}'s status line draws no link ${r} now`}:{kind:`link`,url:a}}stats(){return{sessions:this.held.size,layouts:[...this.servers.values()].reduce((e,t)=>e+t.layouts.size,0),writes:this.writes,failedWrites:this.failedWrites}}async settled(){for(let e of this.servers.values())await e.running}serverOf(e){let t=this.servers.get(e);if(t!==void 0)return t;let n={view:null,adopted:!1,layouts:new Map,left:new Map,binding:{kind:`none`},running:null,again:!1,lastFailure:null};return this.servers.set(e,n),n}release(e,t){e.unsubscribe?.(),this.held.delete(e.sessionId),this.deps.log(`info`,`tmux-status: released sid=${JSON.stringify(e.sessionId)} pane=${e.pane} — ${t}`),this.reconcile(e.socket)}reconcile(e){let t=this.servers.get(e);if(!(t===void 0||this.closed)){if(t.running!==null){t.again=!0;return}t.running=(async()=>{try{do t.again=!1,await this.step(e,t);while(t.again&&!this.closed)}catch(t){this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} reconcile threw: ${String(t)}`)}finally{t.running=null}})()}}async step(e,t){let n=t.view;if(n===null)return;t.adopted||(t.adopted=!0,await this.adopt(e,t));let r=new Map;for(let t of this.held.values()){if(t.socket!==e)continue;let i=n.sessionOf.get(t.pane);i!==void 0&&r.set(i,[...r.get(i)??[],t])}for(let i of new Set([...t.layouts.keys(),...t.left.keys(),...r.keys()])){if(this.closed)return;let a=r.get(i)??[],o=t.layouts.get(i);if(a.length===0){t.left.delete(i),o!==void 0&&await this.restore(e,t,i);continue}if(t.left.has(i))continue;let s=o??await this.install(e,t,i);if(s===null)continue;let c=a.find(e=>e.pane===n.shownBy.get(i))?.frame?.rows.slice(0,5-s.prior.base)??[];await this.draw(e,i,s,c)}this.closed||(t.layouts.size>0?await this.installBinding(e,t):await this.restoreBinding(e,t))}async adopt(e,t){let n=await this.run(e,[`list-sessions`,`-F`,`#{session_id}\t#{${l$}}\t#{${u$}}`]);if(n.kind===`ok`)for(let r of n.stdout.split(`
499
- `)){let[n,i,a=``]=r.split(` `);if(n===void 0||i===void 0||i===``)continue;let o=N$(i,a,this.deps.owner);o.kind===`ours`?t.layouts.set(n,{prior:o.prior,rows:[],status:o.status}):this.leave(e,t,n,o.why)}let r=(await this.ask(e,[O$(`@cc-candybar-binding-prior`)]))?.[0]??``;if(r!==``)try{let e=JSON.parse(r);e.owner===this.deps.owner&&(t.binding={kind:`adopted`,prior:e.prior})}catch(t){this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${d$} does not read (${String(t)}), left as it is`)}(t.layouts.size>0||t.binding.kind===`adopted`)&&this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} took over layouts=${[...t.layouts.keys()].join(`,`)||`-`} binding=${t.binding.kind}`)}leave(e,t,n,r){t.left.set(n,r),this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} session ${n} left as it is: ${r}`)}async install(e,t,n){let r=await this.ask(e,M$(n));if(r===null||this.closed)return null;let i=P$(n,r,this.deps.owner);if(i.kind===`theirs`)return this.leave(e,t,n,i.why),null;let a={prior:i.prior,rows:[],status:i.kind===`ours`?i.status:i.prior.base};return t.layouts.set(n,a),i.kind===`lay-out`&&await this.write(e,i.commands),this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.kind===`ours`?`took over`:`laid out`} session ${n} base=${i.prior.base} own=${[i.prior.status===null?[]:[`status`],i.prior.formats===null?[]:[`status-format`]].flat().join(`,`)||`-`}`),a}async draw(e,t,n,r){let i=n.prior.base+r.length,a=[];if(r.forEach((e,r)=>{n.rows[r]!==e&&a.push([`set-option`,`-t`,t,m$(r),e])}),i!==n.status){let e=_$(i);a.push([`set-option`,`-t`,t,`status`,e],[`set-option`,`-t`,t,u$,e])}(a.length===0||await this.write(e,[[`if-shell`,`-F`,`-t`,t,`#{@cc-candybar-status-prior}`,C$(a)]]))&&(n.rows=r,n.status=i)}async restore(e,t,n){let r=t.layouts.get(n);if(r===void 0)return;t.layouts.delete(n);let i=await this.ask(e,F$(n));if(i===null)return;let a=I$(n,r.prior,i);await this.write(e,a.commands),this.saidRestored(e,n,a.kept)}saidRestored(e,t,n){this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} restored session ${t} kept=${n.join(`,`)||`-`}`)}async installBinding(e,t){let n=t.binding;if(n.kind===`ours`||n.kind===`left`)return;let r=await this.ask(e,R$);if(r===null||this.closed)return;let i=z$(r[0]??``);if(n.kind===`none`&&H$(i)){t.binding={kind:`left`,why:`another cc-candybar daemon's status-line clicks are bound to MouseDown1Status; left as it is, so this daemon's are off`},this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.binding.why}`);return}let a=n.kind===`adopted`&&H$(i)?n.prior:i,o={owner:this.deps.owner,prior:a};if(t.binding={kind:`ours`,prior:a},!await this.write(e,[[`bind-key`,...f$,`if-shell`,`-F`,`#{m:ccb*,#{mouse_status_range}}`,`run-shell -b ${S$(`${this.deps.handler} ${V$(e)}`)}`,...a===null?[]:[a.command]],[`set-option`,`-g`,`@cc-candybar-binding-prior`,JSON.stringify(o)]])){t.binding=n;return}this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} bound MouseDown1Status (was ${a===null?`unbound`:JSON.stringify(a.line)})`)}async restoreBinding(e,t){let n=t.binding;if(t.binding={kind:`none`},n.kind!==`ours`&&n.kind!==`adopted`)return;let r=await this.ask(e,R$);if(r===null)return;let i=U$(n.prior,r[0]??``);for(let t of i.steps)await this.write(e,[t.command],t.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.said}`)}writeBindingRestoreSync(e,t,n){let r=U$(t,n);for(let t of r.steps)this.writeSync(e,[t.command],t.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${r.said}`)}counted(e,t){let n=this.serverOf(e);return t.kind===`ok`?(n.lastFailure=null,t):(this.failedWrites++,n.lastFailure!==t.reason&&this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.reason}`),n.lastFailure=t.reason,t)}async run(e,t,n){return this.counted(e,await this.deps.edge.run(e,t,n))}async ask(e,t){let n=await this.run(e,T$(t));return n.kind===`ok`?E$(n.stdout,t.length):null}askSync(e,t){let n=this.counted(e,this.deps.edge.runSync(e,T$(t)));return n.kind===`ok`?E$(n.stdout,t.length):null}async write(e,t,n){return t.length===0?!0:(this.writes++,(await this.run(e,x$(t),n)).kind===`ok`)}writeSync(e,t,n){t.length!==0&&(this.writes++,this.counted(e,this.deps.edge.runSync(e,x$(t),n)))}};const G$=`CC_CANDYBAR_CONFIG`;function K$(e,t){return mz(t,e[G$])}const $=e=>({arity:e,keep:!0}),q$=e=>({arity:e,keep:!1}),J$={"--add-dir":$(`variadic`),"--agent":$(`one`),"--agents":$(`one`),"--allow-dangerously-skip-permissions":$(`none`),"--allowedTools":$(`variadic`),"--allowed-tools":$(`variadic`),"--append-system-prompt":$(`one`),"--autocompact":$(`one`),"--ax-screen-reader":$(`none`),"--bg":q$(`none`),"--background":q$(`none`),"--bare":$(`none`),"--betas":$(`variadic`),"--brief":$(`none`),"--chrome":$(`none`),"--cloud":q$(`optional`),"-c":q$(`none`),"--continue":q$(`none`),"--dangerously-skip-permissions":$(`none`),"-d":$(`optional`),"--debug":$(`optional`),"--debug-file":$(`one`),"--desktop":q$(`none`),"--disable-slash-commands":$(`none`),"--disallowedTools":$(`variadic`),"--disallowed-tools":$(`variadic`),"--effort":$(`one`),"--environment":q$(`one`),"--exclude-dynamic-system-prompt-sections":$(`none`),"--fallback-model":$(`one`),"--file":$(`variadic`),"--fork-session":q$(`none`),"--forward-subagent-text":$(`none`),"--from-pr":q$(`optional`),"-h":q$(`none`),"--help":q$(`none`),"--ide":$(`none`),"--include-hook-events":$(`none`),"--include-partial-messages":$(`none`),"--input-format":$(`one`),"--json-schema":$(`one`),"--max-budget-usd":$(`one`),"--mcp-config":$(`variadic`),"--model":$(`one`),"-n":$(`one`),"--name":$(`one`),"--no-chrome":$(`none`),"--no-session-persistence":$(`none`),"--output-format":$(`one`),"--permission-mode":$(`one`),"--permission-prompts":$(`one`),"--plugin-dir":$(`one`),"--plugin-url":$(`one`),"-p":q$(`none`),"--print":q$(`none`),"--prompt-suggestions":$(`optional`),"--remote-control":$(`optional`),"--remote-control-session-name-prefix":$(`one`),"--replay-user-messages":$(`none`),"--restricted":$(`none`),"-r":q$(`optional`),"--resume":q$(`optional`),"--safe-mode":$(`none`),"--session-id":q$(`one`),"--setting-sources":$(`one`),"--settings":$(`one`),"--strict-mcp-config":$(`none`),"--system-prompt":$(`one`),"--system-prompt-snapshot":$(`one`),"--teleport":q$(`optional`),"--tmux":q$(`none`),"--tools":$(`variadic`),"--verbose":$(`none`),"-v":q$(`none`),"--version":q$(`none`),"-w":q$(`optional`),"--worktree":q$(`optional`)},Y$={resume:`--resume`,fresh:`--session-id`};function X$(e){return[Y$[e.kind],e.sessionId]}const Z$=e=>e.startsWith(`-`)&&e!==`-`;function Q$(e,t){let n=t1(t);return n===null?{dir:e??t,args:[]}:e!==null&&$$(e,n.top)?{dir:e,args:[]}:{dir:e===null||t1(e)!==null?n.repo:e,args:[`--worktree`,n.name]}}const $$=(e,t)=>e===t||e.startsWith(t+s.sep);function e1(e){let t=[],n=e.slice(1),r=0;for(;r<n.length;){let e=n[r];if(r+=1,e===`--`)break;if(!Z$(e))continue;let i=e.indexOf(`=`),a=i===-1?e:e.slice(0,i),o=J$[a];if(o===void 0)return{kind:`refused`,reason:`Claude Code was started with ${a}, which cc-candybar does not know how to carry to a restart`};let s=i===-1?o.arity===`one`?n.slice(r,r+1):o.arity===`optional`?n.slice(r,r+1).filter(e=>!Z$(e)):o.arity===`variadic`?n1(n.slice(r),e=>!Z$(e)):[]:[];if(o.arity===`one`&&i===-1&&s.length===0)return{kind:`refused`,reason:`Claude Code was started with ${a} and no value after it`};r+=s.length,o.keep&&t.push(e,...s)}return{kind:`args`,args:t}}function t1(e){let t=e.split(s.sep),n=t.findLastIndex((e,n)=>e===`worktrees`&&t[n-1]===`.claude`&&n+1<t.length);return n===-1?null:{name:t[n+1].replaceAll(`+`,`/`),top:t.slice(0,n+2).join(s.sep),repo:t.slice(0,n-1).join(s.sep)||s.sep}}function n1(e,t){let n=e.findIndex(e=>!t(e));return n===-1?[...e]:e.slice(0,n)}const r1=`candybar-band@cc-candybar`,i1=s.join(`bin`,`cc-candybar-native`),a1=`@cc-candybar-bar-pane`,o1=JM(`/reload-plugins`),s1=e=>({kind:`done`,said:e});function c1(e){let t=pZ(e.hints.tmux);if(t.kind===`refused`)throw new J(t.reason);return t.hint}const l1={band:{on:(e,t,n)=>{let r=Je(t.bundle);if(r===null)throw new J(`${T_.band.label} runs the band mod from a cc-candybar source checkout, and this daemon runs ${t.bundle} — run the daemon from a checkout (mod/README.md)`);let i=s.join(r,i1);if(!n.fileExists(i))throw new J(`the band mod starts ${i}, which is not built — run \`just install-rust\` in ${r}`);return{kind:`underway`,said:`installing ${r1} from ${r}`,finished:u1(e,r,n)}},off:()=>s1(`nothing to stop: the band mod draws nothing while the lane is off`)},statusline:{on:(e,t,n)=>{let r=c1(e),i=Pe(t.preload),a=[t.preload,i].find(e=>!n.fileExists(e));if(a!==void 0)throw new J(`${T_.statusline.label} restarts Claude Code under the attach launcher, and ${a} is not there — run \`cc-candybar install\` (in a checkout, \`pnpm build\`)`);return{kind:`underway`,said:`restarting Claude Code in ${r.pane} under the attach launcher`,finished:p1(e,r,{node:t.node[0],launcher:i,preload:t.preload},n)}},off:()=>s1(`nothing to stop: the attached statusline draws its command's output while the lane is off`)},pane:{on:(e,t,n)=>{let r=c1(e),i=n.barPanes(r);return i.length>0?s1(`bar pane ${i.join(`, `)} already draws ${r.pane}'s bar`):s1(`opened bar pane ${n.openBarPane(r,[...t.node,t.bundle,`bar-pane`,r.pane],{CC_CANDYBAR_SOCKET:t.socket})} under ${r.pane}`)},off:(e,t,n)=>{let r=pZ(e.hints.tmux);if(r.kind===`refused`)return s1(`no bar pane to close: ${r.reason}`);let i=r.hint,a=n.barPanes(i);for(let e of a)n.closePane(i,e);return s1(a.length===0?`no bar pane draws ${i.pane}'s bar`:`closed bar pane ${a.join(`, `)}`)}},tmuxStatus:{on:e=>s1(`the daemon draws ${c1(e).pane}'s bar in its status line`),off:()=>s1(`nothing to stop: the daemon puts the status line back once the lane is off`)}};async function u1(e,t,n){let r=e.hints.claudeConfigDir;await n.claude([`plugin`,`marketplace`,`add`,t],r),await n.claude([`plugin`,`install`,r1],r);let i=mZ(n.claudeInput,e.hints.tmux,o1);if(i.kind===`refused`)throw Error(`the band mod is installed, but /reload-plugins was not typed: ${i.reason} — or type /reload-plugins yourself`);return`installed ${r1} from ${t} and typed /reload-plugins into ${i.pane}`}const d1=new Set([ya,G$,...Mt]);function f1(e){return new Map(e.flatMap(e=>{let t=e.indexOf(`=`);return t>0?[[e.slice(0,t),e.slice(t+1)]]:[]}))}async function p1(e,t,n,r){let i=await r.paneClaude(t);if(i.attached)return`left Claude Code in ${t.pane} running: it already runs under the attach launcher`;if(!i.fromShell)throw Error(`Claude Code is the first process of pane ${t.pane}, so nothing would be left in the pane to start it again under the attach launcher — start Claude Code from a shell in the pane`);let a=await r.moduleGraph(n.node,Fe(n.launcher),i.executable);if(!a.ok)throw Error(`Claude Code in ${t.pane} runs ${i.executable}, which the attach launcher cannot start (${a.reason}) — ${T_.statusline.label} needs the native Claude Code install (\`claude install\`), so it was left running`);if((await r.paneClaude(t)).pid!==i.pid)throw Error(`Claude Code in ${t.pane} is no longer the process the restart read (pid ${i.pid}), so it was not restarted under the attach launcher`);let o=v1(r.claudeInput.read(t));if(o!==null)throw Error(`Claude Code in ${t.pane} was left running: ${o} — then turn ${T_.statusline.label} off and on again`);let s=m1(e,r.presence(e.transcript));if(s!==null)throw Error(`Claude Code in ${t.pane} was left running: ${s}`);let c=e1(i.argv);if(c.kind===`refused`)throw Error(`${c.reason} — restart it with that flag removed`);let l=f1(i.env),u=l.get(`PATH`),d=r.launcherNode(u);if(d.kind===`refused`)throw Error(`Claude Code in ${t.pane} was left running, under the PATH it was started with: ${d.why}`);let f=r.onPath(`claude`,u)===i.executable?`claude`:i.executable,p=[...l].filter(([e])=>d1.has(e)),m=(e,t)=>Re(n.preload,{dir:e.dir,env:p,program:f,args:[...e.args,...c.args,...X$(t)]});if(r.terminate(i.pid),!await r.exited(i.pid,15e3))throw Error(`Claude Code in ${t.pane} did not exit within ${15e3/1e3} s of SIGTERM, so it was not restarted under the attach launcher`);let h=(e,n)=>Error(`Claude Code in ${t.pane} exited, but ${e}, so it was not started again — start it with \`${n}\``),g=h1(e,r.presence(e.transcript)),_=g.kind===`unchecked`?{kind:`resume`,sessionId:e.sessionId}:g,v;try{v=await r.paneDir(t,i.parent)}catch(e){throw h(`the directory it was started in could not be read (${e.message})`,m(Q$(null,i.cwd),_))}let y=m(Q$(v,i.cwd),_);if(g.kind===`unchecked`)throw h(`whether session ${e.sessionId} has a conversation could not be seen (${g.error})`,y);try{r.typeShellLine(t,y)}catch(e){throw h(`the line could not be typed into its pane (${e.message})`,y)}if(!await r.followed(e.sessionId,`statusline`,3e4))throw Error(`Claude Code in ${t.pane} did not come back attached within ${3e4/1e3} s of \`${y}\` — the pane says why`);return`restarted Claude Code in ${t.pane} under the attach launcher with \`${y}\`, ${g1[g.kind](e.sessionId)}, and its statusline follows lane B`}function m1(e,t){return typeof t==`object`?`whether session ${e.sessionId} has a conversation could not be seen (${t.error})`:t===`present`||e.answered===`no`?null:e.answered===`yes`?`session ${e.sessionId} has a conversation but no transcript to resume it from (is session persistence off?), so a restart would lose it`:`this Claude Code does not say whether session ${e.sessionId} has a conversation, and it has no transcript to resume one from`}function h1(e,t){return typeof t==`object`?{kind:`unchecked`,error:t.error}:{kind:t===`present`?`resume`:`fresh`,sessionId:e.sessionId}}const g1={resume:e=>`resuming ${e}`,fresh:e=>`starting ${e} afresh, since it had no conversation yet`},_1={"in-mode":`its pane is in tmux copy mode — leave it (q)`,stashed:`it holds a stashed prompt (ctrl+s), which ending it would lose — restore or send it`,"no-prompt":`it is not at its prompt (a dialog or picker is open) — close it`};function v1(e){let t=cZ(e);return t.kind===`ready`?dZ(e)?`it is in the middle of a turn, which ending it would end — wait until it is idle`:lZ(e)?`its prompt holds a draft, which ending it would lose — send or clear it`:null:_1[t.kind]}const y1={switches:Object.fromEntries(E_.map(e=>[e,!1])),revision:0};var b1=class{seen=new Map;queued=new Map;constructor(e){this.deps=e}observe(e,t,n){let r=this.seen.get(e.sessionId)??y1;this.seen.delete(e.sessionId),this.seen.set(e.sessionId,{switches:t,revision:n});for(let[e]of this.seen){if(this.seen.size<=1024)break;this.seen.delete(e)}if(r.revision!==n)for(let n of E_){if(r.switches[n]===t[n])continue;let i=t[n];this.deps.defer(()=>this.enqueue(e.sessionId,()=>this.sync(e,n,i)))}}enqueue(e,t){let n=this.queued.get(e);if(n!==void 0){n.push(t);return}let r=[];this.queued.set(e,r);let i=t=>void t().then(()=>{let t=r.shift();t===void 0?this.queued.delete(e):i(t)});i(t)}sync(e,t,n){let r=`(session=${e.sessionId})`,i=i=>{let a=`lane: ${t} ${n?`on`:`off`}: ${i instanceof Error?i.message:String(i)}`;this.deps.log(`warn`,`${a} ${r}`),VJ(this.deps.state,e.sessionId,a,this.deps.now())},a;try{a=l1[t][n?`on`:`off`](e,this.deps.host,this.deps.edge)}catch(e){return i(e),Promise.resolve()}return this.deps.log(`info`,`lane: ${t} ${n?`on`:`off`} — ${a.said} ${r}`),a.kind===`underway`?a.finished.then(e=>this.deps.log(`info`,`lane: ${t} ${e} ${r}`),i):Promise.resolve()}};function x1(e,t,n){for(let r of(t??``).split(s.delimiter)){if(!s.isAbsolute(r))continue;let t=s.join(r,e);if(n(t))return t}return null}function S1(e,t){try{return p.accessSync(e,t),p.statSync(e).isFile()}catch{return!1}}function C1(e){try{return p.realpathSync(e)}catch{return s.resolve(e)}}function w1(e,t,n){let r=x1(`node`,e,t);return r===null?{kind:`refused`,why:"no `node` on PATH to run the attach launcher"}:s.basename(n(r))===`bun`?{kind:`refused`,why:`the \`node\` on PATH (${r}) is Bun; the attach launcher runs under Node`}:{kind:`node`,file:r}}const T1=2e3;function E1(e,t,n){let r=hU(e,`lane.tmux`,t,n);if(r.kind!==`ok`)throw Error(r.reason);return r.stdout}function D1(e,t){if(t.ok)return t.stdout;let n=t.error??[t.reason,t.stderr.trim(),t.stdout.trim()].filter(e=>e!==``).join(`: `);throw Error(`${e} failed (${n})`)}function O1(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`ok`in t&&t.ok===!1&&`reason`in t&&typeof t.reason==`string`)return`detail`in t&&typeof t.detail==`string`?`${t.reason}: ${t.detail}`:t.reason}catch{}return null}const k1=`#{pane_id} #{${a1}}`;function A1(e,t){return e.split(`
504
+ `)){let[n,i,a=``]=r.split(` `);if(n===void 0||i===void 0||i===``)continue;let o=N$(i,a,this.deps.owner);o.kind===`ours`?t.layouts.set(n,{prior:o.prior,rows:[],status:o.status}):this.leave(e,t,n,o.why)}let r=(await this.ask(e,[O$(`@cc-candybar-binding-prior`)]))?.[0]??``;if(r!==``)try{let e=JSON.parse(r);e.owner===this.deps.owner&&(t.binding={kind:`adopted`,prior:e.prior})}catch(t){this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${d$} does not read (${String(t)}), left as it is`)}(t.layouts.size>0||t.binding.kind===`adopted`)&&this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} took over layouts=${[...t.layouts.keys()].join(`,`)||`-`} binding=${t.binding.kind}`)}leave(e,t,n,r){t.left.set(n,r),this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} session ${n} left as it is: ${r}`)}async install(e,t,n){let r=await this.ask(e,M$(n));if(r===null||this.closed)return null;let i=P$(n,r,this.deps.owner);if(i.kind===`theirs`)return this.leave(e,t,n,i.why),null;let a={prior:i.prior,rows:[],status:i.kind===`ours`?i.status:i.prior.base};return t.layouts.set(n,a),i.kind===`lay-out`&&await this.write(e,i.commands),this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.kind===`ours`?`took over`:`laid out`} session ${n} base=${i.prior.base} own=${[i.prior.status===null?[]:[`status`],i.prior.formats===null?[]:[`status-format`]].flat().join(`,`)||`-`}`),a}async draw(e,t,n,r){let i=n.prior.base+r.length,a=[];if(r.forEach((e,r)=>{n.rows[r]!==e&&a.push([`set-option`,`-t`,t,m$(r),e])}),i!==n.status){let e=_$(i);a.push([`set-option`,`-t`,t,`status`,e],[`set-option`,`-t`,t,u$,e])}(a.length===0||await this.write(e,[[`if-shell`,`-F`,`-t`,t,`#{@cc-candybar-status-prior}`,C$(a)]]))&&(n.rows=r,n.status=i)}async restore(e,t,n){let r=t.layouts.get(n);if(r===void 0)return;t.layouts.delete(n);let i=await this.ask(e,F$(n));if(i===null)return;let a=I$(n,r.prior,i);await this.write(e,a.commands),this.saidRestored(e,n,a.kept)}saidRestored(e,t,n){this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} restored session ${t} kept=${n.join(`,`)||`-`}`)}async installBinding(e,t){let n=t.binding;if(n.kind===`ours`||n.kind===`left`)return;let r=await this.ask(e,R$);if(r===null||this.closed)return;let i=z$(r[0]??``);if(n.kind===`none`&&H$(i)){t.binding={kind:`left`,why:`another cc-candybar daemon's status-line clicks are bound to MouseDown1Status; left as it is, so this daemon's are off`},this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.binding.why}`);return}let a=n.kind===`adopted`&&H$(i)?n.prior:i,o={owner:this.deps.owner,prior:a};if(t.binding={kind:`ours`,prior:a},!await this.write(e,[[`bind-key`,...f$,`if-shell`,`-F`,`#{m:ccb*,#{mouse_status_range}}`,`run-shell -b ${S$(`${this.deps.handler} ${V$(e)}`)}`,...a===null?[]:[a.command]],[`set-option`,`-g`,`@cc-candybar-binding-prior`,JSON.stringify(o)]])){t.binding=n;return}this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} bound MouseDown1Status (was ${a===null?`unbound`:JSON.stringify(a.line)})`)}async restoreBinding(e,t){let n=t.binding;if(t.binding={kind:`none`},n.kind!==`ours`&&n.kind!==`adopted`)return;let r=await this.ask(e,R$);if(r===null)return;let i=U$(n.prior,r[0]??``);for(let t of i.steps)await this.write(e,[t.command],t.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.said}`)}writeBindingRestoreSync(e,t,n){let r=U$(t,n);for(let t of r.steps)this.writeSync(e,[t.command],t.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${r.said}`)}counted(e,t){let n=this.serverOf(e);return t.kind===`ok`?(n.lastFailure=null,t):(this.failedWrites++,n.lastFailure!==t.reason&&this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.reason}`),n.lastFailure=t.reason,t)}async run(e,t,n){return this.counted(e,await this.deps.edge.run(e,t,n))}async ask(e,t){let n=await this.run(e,T$(t));return n.kind===`ok`?E$(n.stdout,t.length):null}askSync(e,t){let n=this.counted(e,this.deps.edge.runSync(e,T$(t)));return n.kind===`ok`?E$(n.stdout,t.length):null}async write(e,t,n){return t.length===0?!0:(this.writes++,(await this.run(e,x$(t),n)).kind===`ok`)}writeSync(e,t,n){t.length!==0&&(this.writes++,this.counted(e,this.deps.edge.runSync(e,x$(t),n)))}};const G$=`CC_CANDYBAR_CONFIG`;function K$(e,t){return mz(t,e[G$])}const $=e=>({arity:e,keep:!0}),q$=e=>({arity:e,keep:!1}),J$={"--add-dir":$(`variadic`),"--agent":$(`one`),"--agents":$(`one`),"--allow-dangerously-skip-permissions":$(`none`),"--allowedTools":$(`variadic`),"--allowed-tools":$(`variadic`),"--append-system-prompt":$(`one`),"--autocompact":$(`one`),"--ax-screen-reader":$(`none`),"--bg":q$(`none`),"--background":q$(`none`),"--bare":$(`none`),"--betas":$(`variadic`),"--brief":$(`none`),"--chrome":$(`none`),"--cloud":q$(`optional`),"-c":q$(`none`),"--continue":q$(`none`),"--dangerously-skip-permissions":$(`none`),"-d":$(`optional`),"--debug":$(`optional`),"--debug-file":$(`one`),"--desktop":q$(`none`),"--disable-slash-commands":$(`none`),"--disallowedTools":$(`variadic`),"--disallowed-tools":$(`variadic`),"--effort":$(`one`),"--environment":q$(`one`),"--exclude-dynamic-system-prompt-sections":$(`none`),"--fallback-model":$(`one`),"--file":$(`variadic`),"--fork-session":q$(`none`),"--forward-subagent-text":$(`none`),"--from-pr":q$(`optional`),"-h":q$(`none`),"--help":q$(`none`),"--ide":$(`none`),"--include-hook-events":$(`none`),"--include-partial-messages":$(`none`),"--input-format":$(`one`),"--json-schema":$(`one`),"--max-budget-usd":$(`one`),"--mcp-config":$(`variadic`),"--model":$(`one`),"-n":$(`one`),"--name":$(`one`),"--no-chrome":$(`none`),"--no-session-persistence":$(`none`),"--output-format":$(`one`),"--permission-mode":$(`one`),"--permission-prompts":$(`one`),"--plugin-dir":$(`one`),"--plugin-url":$(`one`),"-p":q$(`none`),"--print":q$(`none`),"--prompt-suggestions":$(`optional`),"--remote-control":$(`optional`),"--remote-control-session-name-prefix":$(`one`),"--replay-user-messages":$(`none`),"--restricted":$(`none`),"-r":q$(`optional`),"--resume":q$(`optional`),"--safe-mode":$(`none`),"--session-id":q$(`one`),"--setting-sources":$(`one`),"--settings":$(`one`),"--strict-mcp-config":$(`none`),"--system-prompt":$(`one`),"--system-prompt-snapshot":$(`one`),"--teleport":q$(`optional`),"--tmux":q$(`none`),"--tools":$(`variadic`),"--verbose":$(`none`),"-v":q$(`none`),"--version":q$(`none`),"-w":q$(`optional`),"--worktree":q$(`optional`)},Y$={resume:`--resume`,fresh:`--session-id`};function X$(e){return[Y$[e.kind],e.sessionId]}const Z$=e=>e.startsWith(`-`)&&e!==`-`;function Q$(e,t){let n=t1(t);return n===null?{dir:e??t,args:[]}:e!==null&&$$(e,n.top)?{dir:e,args:[]}:{dir:e===null||t1(e)!==null?n.repo:e,args:[`--worktree`,n.name]}}const $$=(e,t)=>e===t||e.startsWith(t+s.sep);function e1(e){let t=[],n=e.slice(1),r=0;for(;r<n.length;){let e=n[r];if(r+=1,e===`--`)break;if(!Z$(e))continue;let i=e.indexOf(`=`),a=i===-1?e:e.slice(0,i),o=J$[a];if(o===void 0)return{kind:`refused`,reason:`Claude Code was started with ${a}, which cc-candybar does not know how to carry to a restart`};let s=i===-1?o.arity===`one`?n.slice(r,r+1):o.arity===`optional`?n.slice(r,r+1).filter(e=>!Z$(e)):o.arity===`variadic`?n1(n.slice(r),e=>!Z$(e)):[]:[];if(o.arity===`one`&&i===-1&&s.length===0)return{kind:`refused`,reason:`Claude Code was started with ${a} and no value after it`};r+=s.length,o.keep&&t.push(e,...s)}return{kind:`args`,args:t}}function t1(e){let t=e.split(s.sep),n=t.findLastIndex((e,n)=>e===`worktrees`&&t[n-1]===`.claude`&&n+1<t.length);return n===-1?null:{name:t[n+1].replaceAll(`+`,`/`),top:t.slice(0,n+2).join(s.sep),repo:t.slice(0,n-1).join(s.sep)||s.sep}}function n1(e,t){let n=e.findIndex(e=>!t(e));return n===-1?[...e]:e.slice(0,n)}const r1=`candybar-band@cc-candybar`,i1=s.join(`bin`,`cc-candybar-native`),a1=`@cc-candybar-bar-pane`,o1=qM(`/reload-plugins`),s1=e=>({kind:`done`,said:e});function c1(e){let t=pZ(e.hints.tmux);if(t.kind===`refused`)throw new J(t.reason);return t.hint}const l1={band:{on:(e,t,n)=>{let r=Je(t.bundle);if(r===null)throw new J(`${T_.band.label} runs the band mod from a cc-candybar source checkout, and this daemon runs ${t.bundle} — run the daemon from a checkout (mod/README.md)`);let i=s.join(r,i1);if(!n.fileExists(i))throw new J(`the band mod starts ${i}, which is not built — run \`just install-rust\` in ${r}`);return{kind:`underway`,said:`installing ${r1} from ${r}`,finished:u1(e,r,n)}},off:()=>s1(`nothing to stop: the band mod draws nothing while the lane is off`)},statusline:{on:(e,t,n)=>{let r=c1(e),i=Pe(t.preload),a=[t.preload,i].find(e=>!n.fileExists(e));if(a!==void 0)throw new J(`${T_.statusline.label} restarts Claude Code under the attach launcher, and ${a} is not there — run \`cc-candybar install\` (in a checkout, \`pnpm build\`)`);return{kind:`underway`,said:`restarting Claude Code in ${r.pane} under the attach launcher`,finished:p1(e,r,{node:t.node[0],launcher:i,preload:t.preload},n)}},off:()=>s1(`nothing to stop: the attached statusline draws its command's output while the lane is off`)},pane:{on:(e,t,n)=>{let r=c1(e),i=n.barPanes(r);return i.length>0?s1(`bar pane ${i.join(`, `)} already draws ${r.pane}'s bar`):s1(`opened bar pane ${n.openBarPane(r,[...t.node,t.bundle,`bar-pane`,r.pane],{CC_CANDYBAR_SOCKET:t.socket})} under ${r.pane}`)},off:(e,t,n)=>{let r=pZ(e.hints.tmux);if(r.kind===`refused`)return s1(`no bar pane to close: ${r.reason}`);let i=r.hint,a=n.barPanes(i);for(let e of a)n.closePane(i,e);return s1(a.length===0?`no bar pane draws ${i.pane}'s bar`:`closed bar pane ${a.join(`, `)}`)}},tmuxStatus:{on:e=>s1(`the daemon draws ${c1(e).pane}'s bar in its status line`),off:()=>s1(`nothing to stop: the daemon puts the status line back once the lane is off`)}};async function u1(e,t,n){let r=e.hints.claudeConfigDir;await n.claude([`plugin`,`marketplace`,`add`,t],r),await n.claude([`plugin`,`install`,r1],r);let i=mZ(n.claudeInput,e.hints.tmux,o1);if(i.kind===`refused`)throw Error(`the band mod is installed, but /reload-plugins was not typed: ${i.reason} — or type /reload-plugins yourself`);return`installed ${r1} from ${t} and typed /reload-plugins into ${i.pane}`}const d1=new Set([ya,G$,...Mt]);function f1(e){return new Map(e.flatMap(e=>{let t=e.indexOf(`=`);return t>0?[[e.slice(0,t),e.slice(t+1)]]:[]}))}async function p1(e,t,n,r){let i=await r.paneClaude(t);if(i.attached)return`left Claude Code in ${t.pane} running: it already runs under the attach launcher`;if(!i.fromShell)throw Error(`Claude Code is the first process of pane ${t.pane}, so nothing would be left in the pane to start it again under the attach launcher — start Claude Code from a shell in the pane`);let a=await r.moduleGraph(n.node,Fe(n.launcher),i.executable);if(!a.ok)throw Error(`Claude Code in ${t.pane} runs ${i.executable}, which the attach launcher cannot start (${a.reason}) — ${T_.statusline.label} needs the native Claude Code install (\`claude install\`), so it was left running`);if((await r.paneClaude(t)).pid!==i.pid)throw Error(`Claude Code in ${t.pane} is no longer the process the restart read (pid ${i.pid}), so it was not restarted under the attach launcher`);let o=v1(r.claudeInput.read(t));if(o!==null)throw Error(`Claude Code in ${t.pane} was left running: ${o} — then turn ${T_.statusline.label} off and on again`);let s=m1(e,r.presence(e.transcript));if(s!==null)throw Error(`Claude Code in ${t.pane} was left running: ${s}`);let c=e1(i.argv);if(c.kind===`refused`)throw Error(`${c.reason} — restart it with that flag removed`);let l=f1(i.env),u=l.get(`PATH`),d=r.launcherNode(u);if(d.kind===`refused`)throw Error(`Claude Code in ${t.pane} was left running, under the PATH it was started with: ${d.why}`);let f=r.onPath(`claude`,u)===i.executable?`claude`:i.executable,p=[...l].filter(([e])=>d1.has(e)),m=(e,t)=>Re(n.preload,{dir:e.dir,env:p,program:f,args:[...e.args,...c.args,...X$(t)]});if(r.terminate(i.pid),!await r.exited(i.pid,15e3))throw Error(`Claude Code in ${t.pane} did not exit within ${15e3/1e3} s of SIGTERM, so it was not restarted under the attach launcher`);let h=(e,n)=>Error(`Claude Code in ${t.pane} exited, but ${e}, so it was not started again — start it with \`${n}\``),g=h1(e,r.presence(e.transcript)),_=g.kind===`unchecked`?{kind:`resume`,sessionId:e.sessionId}:g,v;try{v=await r.paneDir(t,i.parent)}catch(e){throw h(`the directory it was started in could not be read (${e.message})`,m(Q$(null,i.cwd),_))}let y=m(Q$(v,i.cwd),_);if(g.kind===`unchecked`)throw h(`whether session ${e.sessionId} has a conversation could not be seen (${g.error})`,y);try{r.typeShellLine(t,y)}catch(e){throw h(`the line could not be typed into its pane (${e.message})`,y)}if(!await r.followed(e.sessionId,`statusline`,3e4))throw Error(`Claude Code in ${t.pane} did not come back attached within ${3e4/1e3} s of \`${y}\` — the pane says why`);return`restarted Claude Code in ${t.pane} under the attach launcher with \`${y}\`, ${g1[g.kind](e.sessionId)}, and its statusline follows lane B`}function m1(e,t){return typeof t==`object`?`whether session ${e.sessionId} has a conversation could not be seen (${t.error})`:t===`present`||e.answered===`no`?null:e.answered===`yes`?`session ${e.sessionId} has a conversation but no transcript to resume it from (is session persistence off?), so a restart would lose it`:`this Claude Code does not say whether session ${e.sessionId} has a conversation, and it has no transcript to resume one from`}function h1(e,t){return typeof t==`object`?{kind:`unchecked`,error:t.error}:{kind:t===`present`?`resume`:`fresh`,sessionId:e.sessionId}}const g1={resume:e=>`resuming ${e}`,fresh:e=>`starting ${e} afresh, since it had no conversation yet`},_1={"in-mode":`its pane is in tmux copy mode — leave it (q)`,stashed:`it holds a stashed prompt (ctrl+s), which ending it would lose — restore or send it`,"no-prompt":`it is not at its prompt (a dialog or picker is open) — close it`};function v1(e){let t=cZ(e);return t.kind===`ready`?dZ(e)?`it is in the middle of a turn, which ending it would end — wait until it is idle`:lZ(e)?`its prompt holds a draft, which ending it would lose — send or clear it`:null:_1[t.kind]}const y1={switches:Object.fromEntries(E_.map(e=>[e,!1])),revision:0};var b1=class{seen=new Map;queued=new Map;constructor(e){this.deps=e}observe(e,t,n){let r=this.seen.get(e.sessionId)??y1;this.seen.delete(e.sessionId),this.seen.set(e.sessionId,{switches:t,revision:n});for(let[e]of this.seen){if(this.seen.size<=1024)break;this.seen.delete(e)}if(r.revision!==n)for(let n of E_){if(r.switches[n]===t[n])continue;let i=t[n];this.deps.defer(()=>this.enqueue(e.sessionId,()=>this.sync(e,n,i)))}}enqueue(e,t){let n=this.queued.get(e);if(n!==void 0){n.push(t);return}let r=[];this.queued.set(e,r);let i=t=>void t().then(()=>{let t=r.shift();t===void 0?this.queued.delete(e):i(t)});i(t)}sync(e,t,n){let r=`(session=${e.sessionId})`,i=i=>{let a=`lane: ${t} ${n?`on`:`off`}: ${i instanceof Error?i.message:String(i)}`;this.deps.log(`warn`,`${a} ${r}`),VJ(this.deps.state,e.sessionId,a,this.deps.now())},a;try{a=l1[t][n?`on`:`off`](e,this.deps.host,this.deps.edge)}catch(e){return i(e),Promise.resolve()}return this.deps.log(`info`,`lane: ${t} ${n?`on`:`off`} — ${a.said} ${r}`),a.kind===`underway`?a.finished.then(e=>this.deps.log(`info`,`lane: ${t} ${e} ${r}`),i):Promise.resolve()}};function x1(e,t,n){for(let r of(t??``).split(s.delimiter)){if(!s.isAbsolute(r))continue;let t=s.join(r,e);if(n(t))return t}return null}function S1(e,t){try{return p.accessSync(e,t),p.statSync(e).isFile()}catch{return!1}}function C1(e){try{return p.realpathSync(e)}catch{return s.resolve(e)}}function w1(e,t,n){let r=x1(`node`,e,t);return r===null?{kind:`refused`,why:"no `node` on PATH to run the attach launcher"}:s.basename(n(r))===`bun`?{kind:`refused`,why:`the \`node\` on PATH (${r}) is Bun; the attach launcher runs under Node`}:{kind:`node`,file:r}}const T1=2e3;function E1(e,t,n){let r=hU(e,`lane.tmux`,t,n);if(r.kind!==`ok`)throw Error(r.reason);return r.stdout}function D1(e,t){if(t.ok)return t.stdout;let n=t.error??[t.reason,t.stderr.trim(),t.stdout.trim()].filter(e=>e!==``).join(`: `);throw Error(`${e} failed (${n})`)}function O1(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`ok`in t&&t.ok===!1&&`reason`in t&&typeof t.reason==`string`)return`detail`in t&&typeof t.detail==`string`?`${t.reason}: ${t.detail}`:t.reason}catch{}return null}const k1=`#{pane_id} #{${a1}}`;function A1(e,t){return e.split(`
500
505
  `).map(e=>e.trim().split(` `)).filter(([,e])=>e===t).map(([e])=>e)}const j1=/(^|\/)(cc-attach|bun-attach\.js)(\s|$)/;function M1(e,t,n){for(let r of oY(aY(e),t)){if(r.command.split(` `).some(e=>j1.test(e)))return!0;if(r.pid===n)return!1}return!1}const N1=[`import ctypes, json, struct, sys`,`libc = ctypes.CDLL(None)`,`mib = (ctypes.c_int * 3)(1, 49, int(sys.argv[1]))`,`size = ctypes.c_size_t(0)`,`if libc.sysctl(mib, 3, None, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`buf = ctypes.create_string_buffer(size.value)`,`if libc.sysctl(mib, 3, buf, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`raw = buf.raw[:size.value]`,`argc = struct.unpack_from('i', raw)[0]`,`rest = raw[4:]`,`end = rest.index(b'\\0')`,`exe = rest[:end].decode('utf-8', 'surrogateescape')`,`rest = rest[end:].lstrip(b'\\0')`,`words = [w.decode('utf-8', 'surrogateescape') for w in rest.split(b'\\0')]`,`end = words.index('', argc) if '' in words[argc:] else len(words)`,`print(json.dumps({'executable': exe, 'argv': words[:argc], 'env': words[argc:end]}))`].join(`
501
- `);async function P1(e){if(process.platform===`linux`)return{executable:await p.promises.readlink(`/proc/${e}/exe`),argv:(await p.promises.readFile(`/proc/${e}/cmdline`,`utf8`)).split(`\0`).slice(0,-1),env:(await p.promises.readFile(`/proc/${e}/environ`,`utf8`)).split(`\0`).slice(0,-1)};let t=D1(`reading process ${e}'s arguments`,await lt({bin:`python3`,args:[`-c`,N1,String(e)],timeoutMs:5e3,category:`lane.process`}));return JSON.parse(t)}async function F1(e,t){return D1(e,await lt({bin:`ps`,args:t,timeoutMs:2e3,category:`lane.process`}))}async function I1(e){let t=await gU(e,`lane.tmux`,[`display`,`-p`,`-t`,e.pane,`#{pane_pid} #{pane_current_path}`]);if(t.kind!==`ok`)throw Error(t.reason);let[n=``,r=``]=t.stdout.trimEnd().split(` `),i=(await F1(`asking pane ${e.pane}'s foreground job`,[`-o`,`tpgid=`,`-p`,n])).trim();return{panePid:Number(n),cwd:r,foreground:Number(i)}}async function L1(e){let{panePid:t,cwd:n,foreground:r}=await I1(e),i=await F1(`listing processes`,[`-A`,`-o`,`pid=,ppid=,args=`]),a=await P1(r),o=aY(i).get(r)?.ppid;if(o===void 0)throw Error(`pane ${e.pane}'s foreground job ${r} is gone`);return{pid:r,executable:await p.promises.realpath(a.executable),argv:a.argv,env:a.env,cwd:n,parent:o,fromShell:r!==t,attached:M1(i,r,t)}}function R1(e){let{CLAUDE_CONFIG_DIR:t,...n}=process.env;return e===void 0?n:{...n,CLAUDE_CONFIG_DIR:e}}function z1(e){return{claudeInput:yZ(),barPanes:e=>A1(E1(e,[`list-panes`,`-a`,`-F`,k1]),e.pane),openBarPane:(e,t,n)=>{let r=E1(e,[`split-window`,`-d`,`-v`,`-l`,`1`,`-t`,e.pane,`-P`,`-F`,`#{pane_id}`,...Object.entries(n).flatMap(([e,t])=>[`-e`,`${e}=${t}`]),...t]).trim();return E1(e,[`set-option`,`-p`,`-t`,r,a1,e.pane]),r},closePane:(e,t)=>void E1(e,[`kill-pane`,`-t`,t]),claude:async(e,t)=>void D1(`claude ${e.join(` `)}`,await lt({bin:`claude`,args:[...e],env:R1(t),timeoutMs:3e4,category:`lane.claude`})),fileExists:e=>p.existsSync(e),presence:Jz,paneClaude:L1,paneDir:async(e,t)=>{let n=Date.now()+T1;for(;;){let r=await I1(e);if(r.foreground===t){if(r.cwd===``)throw Error(`tmux read no directory for pane ${e.pane}`);return r.cwd}if(Date.now()>n)throw Error(`the shell in pane ${e.pane} (pid ${t}) did not take its terminal back within ${T1/1e3} s`);await ge(100)}},launcherNode:e=>w1(e,e=>S1(e,p.constants.X_OK),C1),onPath:(e,t)=>{let n=x1(e,t,e=>S1(e,p.constants.X_OK));return n===null?null:p.realpathSync(n)},followed:async(t,n,r)=>{let i=Date.now()+r;for(;!e(t).has(n);){if(Date.now()>i)return!1;await ge(200)}return!0},moduleGraph:async(e,t,n)=>{let r=await lt({bin:e,args:[t,n],timeoutMs:2e4,category:`lane.process`}),i=!r.ok&&r.reason===`non-zero`?O1(r.stdout):null;return i===null?(D1(`reading ${n}'s module graph`,r),{ok:!0}):{ok:!1,reason:i}},terminate:e=>{try{process.kill(e,`SIGTERM`)}catch(t){throw Error(`Claude Code (pid ${e}) could not be sent SIGTERM: ${t instanceof Error?t.message:String(t)}`)}},exited:async(e,t)=>{let n=Date.now()+t;for(;Mo(e);){if(Date.now()>n)return!1;await ge(100)}return!0},typeShellLine:(e,t)=>void E1(e,_Z(e.pane,`cc-candybar-lane`,[]),t)}}function B1(e,t){return E_.filter(n=>e[n]&&T_[n].elsewhere!==null&&t.has(n))}function V1(e,t){let n=`the bar is drawn in ${t.map(e=>T_[e].elsewhere).join(` and `)}`,r=Hr([{verb:Dr,args:[e,...t.map(e=>T_[e].setting)]}]);return{channels:[{severity:ny,message:n,lines:[[ry(n,Hr([{verb:gr,args:[n]}])),ry(`[⟲ draw it here]`,r)]]}]}}const H1={order:-1/0,text:null,failure:null};var U1=class{synced=new Map;constructor(e){this.dir=e}pathFor(e){return s.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t,n){let r=this.synced.get(e)??H1;if(t<r.order)return{link:this.linkFor(e,n),failure:null};let i=n===r.text&&r.failure===null?null:this.write(e,n);return this.synced.delete(e),this.synced.set(e,{order:t,text:n,failure:i}),this.forgetOldestClean(),{link:this.linkFor(e,n),failure:i}}linkFor(e,t){let n=this.synced.get(e)??H1;return n.text===t?n.failure===null?{kind:`file`,path:this.pathFor(e)}:{kind:`unavailable`,reason:n.failure}:{kind:`unavailable`,reason:`the file holds another render's text until the session's next statusline request`}}forgetOldestClean(){let e=0;for(let t of this.synced.values())t.text===null&&t.failure===null&&e++;for(let[t,n]of this.synced){if(e<=256)return;n.text!==null||n.failure!==null||(this.synced.delete(t),e--)}}write(e,t){let n=this.pathFor(e);try{return t===null?p.rmSync(n,{force:!0}):(p.mkdirSync(this.dir,{recursive:!0,mode:448}),p.writeFileSync(n,t,{mode:384})),null}catch(e){return`${n}: ${e.message}`}}reset(){this.synced.clear();try{return p.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};function W1(e,t){for(let n of Object.entries(t))e.push(n)}const G1={ok:`info`,"bad-request":`warn`,threw:`error`};function K1(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,w(e.error)]]}}function q1(e,t,n){let r=[...e,[`took`,`${n}ms`],[`outcome`,t.kind],...K1(t)];return{level:G1[t.kind],line:`render${r.map(([e,t])=>` ${e}=${CM(t)}`).join(``)}`}}const J1=new iq,Y1=new JX,X1=new oj,Z1=i(import.meta.url),Q1=iX(gt());st(J1.launchStats);const $1=new aO({counters:J1,logger:M}),e0=PU({watchers:$1,logger:M}),{gitProvider:t0,usageStore:n0,mementoProvider:r0}=e0,i0=new sq,a0=new gJ(i0,M),o0=new zJ,s0=new Rv,c0=[t.execPath,...t.execArgv],l0=new b1({edge:z1(e=>d0.following(e)),host:{bundle:Z1,node:c0,socket:vt(),preload:$a(Z1)},state:i0,log:M,now:()=>_O(new Date),defer:e=>void pe(e)}),u0=new W$({edge:{run:(e,t,n)=>gU({socket:e},`tmux-status`,t,n),runSync:(e,t,n)=>hU({socket:e},`tmux-status`,t,n)},subscribe:(e,t)=>d0.subscribe(e,t),sessionInPane:(e,t)=>d0.newestWhere(({hints:{tmux:n}})=>n!=null&&n.socket===e&&n.pane===t),handler:[`CC_CANDYBAR_SOCKET=${je(vt())}`,...[...c0,Z1].map(je),`url-handle`].join(` `),owner:vt(),defer:e=>void pe(e),log:M}),d0=new e$({render:(e,t)=>Q0(e,t),watch:(e,t)=>(0,xb.reaction)(()=>i0.revision(e),t,{scheduler:e=>pe(e)}),lanes:e=>e2(e),shown:e=>f0.shown(e.hints.tmux),watching:()=>f0.follow(),periods:qQ,now:()=>performance.now(),log:M}),f0=new s$({listPanes:e=>gU({socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,n$]),listClients:e=>gU({socket:e},`frames.visibility`,[`list-clients`,`-F`,r$]),sockets:()=>new Set(d0.watched().flatMap(({req:e})=>p0(e))),onAnswer:(e,t)=>u0.answered(e,t),onChange:e=>d0.wakeWhere(t=>p0(t).some(t=>e.has(t))),intervalMs:1e3,log:M});function p0({hints:{tmux:e}}){return e==null?[]:[e.socket]}const m0=new U1(At()),h0=new nq({gitService:t0,sessionState:i0,watchers:$1,log:M},{budgetBytes:()=>(O0(),KK(x0)),observers:{onReload:e=>M(`info`,`config loaded projectDir=${e.projectDir} cwd=${e.cwd} files=${e.configLayers.join(` < `)||`<bundled default>`} error=${e.lastError===null?`none`:JSON.stringify(e.lastError)} warning=${e.lastWarning===null?`none`:JSON.stringify(e.lastWarning)}`)}}),g0=60*1e3,_0=YV({targets:[...new Set([...import.meta.url.startsWith(`file://`)?[i(import.meta.url)]:[],...t.argv[1]?[t.argv[1]]:[]])],intervalMs:g0,stat:p.statSync,exit:()=>N0(0),log:M}),v0=KV({entryUrl:import.meta.url,intervalMs:g0,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>_0.checkNow(),log:M});let y0=null,b0=null,x0=0;function S0(){t.on(`uncaughtException`,e=>{M(`error`,`uncaughtException: ${e.stack||e.message}`),N0(1)}),t.on(`unhandledRejection`,e=>{M(`error`,`unhandledRejection: ${String(e)}`),N0(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{M(`info`,`received ${e}, shutting down`),N0(0)});try{k0(t.env)}catch(e){M(`error`,`refusing to boot: ${e.message}`),N0(1);return}y0=Oo(t.pid);let e=Ro(Bo(y0));if(!e.decision.allow){M(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),N0(1);return}b0=e.registryPath,p.mkdirSync(_t(),{recursive:!0}),xt(vt()),i0.useStorage(new lq(wt(),500,M)),a0.useStorage(LJ(Tt(),M)),jo({anchor:Ao(t.env),isAlive:Mo,onOrphaned:e=>{M(`info`,`parent watchdog: ${e}; shutting down`),N0(0)}}),C0(E.createServer({allowHalfOpen:!1},e=>{P0(e)}),vt(),!1)}function C0(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){M(`error`,`server error: ${i.message}`),N0(1);return}if(r){M(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}w0(e,n)}),e.listen(n,()=>T0(n))}function w0(e,n){let r=vo(yo(St(n)),(e,t)=>Do(e,t,{readStartTime:Eo,pidAlive:Mo}));if(r.kind===`attach-and-exit`){M(`info`,`EADDRINUSE: ${r.reason} — exiting`),t.exit(0);return}M(`warn`,`EADDRINUSE: ${r.reason} — unlinking stale socket and rebinding`);try{p.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){M(`error`,`cannot unlink stale socket ${n}: ${e.message}`),N0(1);return}}C0(e,n,!0)}function T0(e){let n=So(e);if(n.kind!==`present`){M(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),N0(0);return}A0(e);try{p.chmodSync(e,384)}catch(e){M(`warn`,`chmod socket failed: ${e.message}`)}M(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${Nn(se.getHeapStatistics().heap_size_limit)}MB memoryLimit=${Nn(x0)}MB`),nr();let r=m0.reset();r!==null&&M(`warn`,`diagnostic dump wipe failed: ${r}`),_0.arm(),v0.arm(),O0().arm(),E0(e,n.identity)}function E0(e,n){To({bound:n,myPid:t.pid,readIdentity:()=>So(e),readLease:()=>yo(St(e)),shutdown:e=>N0(e),log:M}).arm()}let D0=null;function O0(){if(D0===null)throw Error(`daemon: limits not yet established`);return D0}function k0(e){x0=Pn(e),D0=Vn(qn(J1.startedAt.getTime(),e=>N0(e),{limitBytes:x0}))}function A0(e){let n=bo(St(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:y0});n!==null&&M(`warn`,`lease write failed: ${n}`)}let j0=0,M0=!1;function N0(e){if(!M0){M0=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{u0.restoreAll(),t0.close()}catch(e){M(`warn`,`gitService close failed: ${e.message}`)}try{n0.close()}catch(e){M(`warn`,`usageStore close failed: ${e.message}`)}try{$1.closeAll()}catch(e){M(`warn`,`watcherRegistry close failed: ${e.message}`)}try{i0.flush()}catch(e){M(`warn`,`sessionState flush failed: ${e.message}`)}xo(Ct(),t.pid),b0!==null&&zo(b0,t.pid,Io,e=>p.unlinkSync(e)),t.exit(e)}}function P0(e){j0++,J1.inFlight=j0;let t=!1,n=!0,r=()=>{n&&(n=!1,j0=Math.max(0,j0-1),J1.inFlight=j0)},i=(n,r,i)=>{if(t){r!==null&&M(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let a=r===null?void 0:()=>N0(r);try{e.end(Zt(n),e=>{e??i(),a?.()})}catch(e){M(`warn`,`response write failed: ${e.message}`),a?.()}},a=!1,o=setTimeout(()=>{a=!0,J1.requestsTimedOut++,i({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,F0)},200),s=$t(e=>{H0(e,()=>a).then(e=>e.kind===`reply`?i(e.resp,e.exitAfterFlush,e.delivered):c(e.sessionId,e.lane)).catch(e=>{M(`error`,`handler threw: ${w(e)}`),i(z0(e),null,F0)})},e=>{M(`warn`,`frame parse failed: ${e.message}`),i({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null,F0)}),c=(n,i)=>{if(t||e.destroyed)return;clearTimeout(o),r(),e.off(`data`,s);let a=t$(e),c=d0.subscribe(n,{lane:i,frame:(e,t)=>a(Qt(vH[i](e,t))),refused:t=>e.end(Zt(t)),drawing:()=>!0});t=!0,e.on(`close`,c)};e.on(`data`,s),e.on(`error`,e=>{M(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(o),r()})}const F0=()=>{},I0=e=>({resp:e,exitAfterFlush:null,delivered:F0}),L0=e=>({kind:`reply`,...e}),R0={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},z0=e=>({ok:!1,error:e instanceof Error?e.message:w(e),code:`RENDER_FAILED`,daemonV:3}),B0=(e,t)=>L0(I0({ok:!1,error:t,code:e,daemonV:3}));function V0(e){if(typeof e.sessionId!=`string`||e.sessionId===``)return B0(`BAD_REQUEST`,`subscribe needs a non-empty string sessionId`);if(e.lane===void 0)return B0(`VERSION_MISMATCH`,`this client's subscribe names no lane (${E_.join(`, `)}): it predates the lane toggles — update it`);let t=N_(e.lane);return t===null?B0(`BAD_REQUEST`,`subscribe needs a lane, one of ${E_.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:e.sessionId,lane:t}}async function H0(e,t){return!e||typeof e!=`object`||typeof e.v!=`number`?B0(`BAD_REQUEST`,`malformed request`):e.v===3?e.kind===`subscribe`?V0(e):typeof e.kind!=`string`||!Object.hasOwn(R0,e.kind)?B0(`BAD_REQUEST`,`unknown kind`):L0(await U0(e,t)):(e.v>3?M(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):M(`info`,`version mismatch: client=${e.v} < daemon=3; client is stale — staying up`),{kind:`reply`,resp:{ok:!1,error:`protocol v${e.v} not supported (daemon at v3)`,code:`VERSION_MISMATCH`,daemonV:3},exitAfterFlush:e.v>3?0:null,delivered:F0})}async function U0(e,t){if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,delivered:F0};if(e.kind===`pane-session`){let{socket:t,pane:n}=e;return I0(typeof t!=`string`||typeof n!=`string`?{ok:!1,error:`pane-session needs a string socket and pane`,code:`BAD_REQUEST`,daemonV:3}:{ok:!0,paneSession:d0.newestWhere(({hints:{tmux:e}})=>e!=null&&e.socket===t&&e.pane===n)})}if(e.kind===`stats`)return I0({ok:!0,stats:J1.snapshot({gitCache:t0.getStats(),usageCache:n0.getStats(),transcriptReads:ua(),renderCache:h0.stats,effectCache:s0.getStats(),sessionState:{sessions:i0.size(),observers:i0.observers(),revision:i0.latestRevision()},frameFeeds:d0.getStats(),tmuxStatus:u0.stats(),watchersActive:$1.size(),nextRestartReason:O0().describeNextRestart(),handlerProbes:Y1.list(),clients:X1.list(_O(new Date)),bundle:Z1,daemon:O0().serving(),doctorStores:aX(Q1)})});if(e.kind===`render`){let n=new Date,r=_O(n),i=n.getTime(),a=[],o=++J1.requestsTotal,s=t2(e),c=(e,t)=>X1.see(e.hookData.session_id,{client:e.hints.client??null,termCols:e.hints.termCols??null,rateLimits:e.rateLimits,claudeConfigDir:xa(e.hints.claudeConfigDir),projectDir:e.requested.projectDir,transcript:nj(e.hookData),frame:t},r,o);s.ok&&(c(s.req,`drawing`),d0.note(s.req.hookData.session_id,s.req,o));let l=s.ok?await s2(s.req,o,r,a).then(({answer:e,motion:t,clickShown:n})=>(c(s.req,t),{outcome:{kind:`ok`},resp:{ok:!0,output:e},delivered:n===null?F0:()=>HJ(i0,s.req.hookData.session_id,n)}),e=>(c(s.req,`failed`),{outcome:{kind:`threw`,error:e},resp:z0(e),delivered:F0})):n2(s.problems);l.outcome.kind!==`ok`&&J1.requestsErrored++,W1(a,{timedOut:t()?`Y`:`N`});let{level:u,line:d}=q1(a,l.outcome,Date.now()-i);return M(u,d),{resp:l.resp,exitAfterFlush:null,delivered:l.delivered}}if(e.kind===`click`)return I0(X0(e.verb,e.value,{via:`link`,handler:Xt(e.clientVersion)}));if(e.kind===`debug`){if(!GQ(e.what))return I0({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${WQ.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=h0.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?J0(t.lastRenderCellsBySegment,t.config.globals.colorCompatibility??rv(`colorCompatibility`)):q0};return I0({ok:!0,debug:NQ(e.what,n)})}throw Error(`no reply for request ${w(e)}`)}function W0(e,t){let{tokens:n}=T({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),r=(n??[]).filter(e=>e.kind===`option`&&e.name===`config`).at(-1),i=(n??[]).flatMap(e=>{switch(e.kind){case`option`:return e.name===`config`?e===r&&e.value===void 0?[{arg:e.rawName,why:`no-value`}]:[]:[{arg:e.rawName,why:`unknown`}];case`positional`:return[{arg:e.value,why:`positional`}];case`option-terminator`:return[]}});return{configFile:mz(t,r?.value),refusedArgs:i.filter((e,t)=>i.findIndex(t=>t.arg===e.arg&&t.why===e.why)===t)}}const G0={sessionState:i0,dlog:M,applyUpdate:()=>v0.act(),doctor:hX(e=>{let t=[e.projectDir,e.cwd,e.configFile??void 0];h0.reload(...t);let n=h0.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}}),doctorStores:Q1,probes:Y1,clients:X1,bundle:Z1,serving:()=>O0().serving(),memento:r0,claudeInput:yZ(),history:a0,navigation:o0,configFor:e=>h0.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>h0.reload(e.projectDir,e.cwd,e.configFile??void 0)};G0.reloadConfig;const K0={endcaps:rv(`endcaps`),colorCompatibility:rv(`colorCompatibility`),wrap:rv(`autoWrap`),padding:rv(`padding`),width:1/0},q0=new Map;function J0(e,t){let n=new Map;for(let[r,i]of e)n.set(r,Zv(i,{...K0,colorCompatibility:t}));return n}const Y0={...e0,history:e=>a0.depth(e),feeds:e=>d0.feedsOf(e)};function X0(e,t,n){if(e===`tmux-status-click`)return Z0(t);let r=TQ.get(e);if(!r)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return r(t,{...G0,arrival:n}),{ok:!0,output:``}}catch(e){let t=e instanceof J?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}function Z0(e){let n=e=>({ok:!1,error:e,code:`BAD_REQUEST`,daemonV:3}),r=u0.linkAt(e);if(r.kind===`refused`)return n(r.reason);if(M(`info`,`tmux-status: click ${JSON.stringify(r.url)}`),r.url.startsWith(`cc-candybar://`)){let e=fo(r.url);return e.verb===`tmux-status-click`?n(`a status-line link names another status-line click`):X0(e.verb,e.value,{via:`tmux-status`})}let i=ut({bin:t.platform===`darwin`?`/usr/bin/open`:`xdg-open`,args:[r.url],category:`click.open`});return i.ok?{ok:!0,output:``}:{ok:!1,error:`opening ${r.url} failed (${i.error??i.reason})`,code:`RENDER_FAILED`,daemonV:3}}async function Q0(e,t){let n=new Date,r=[];try{let{drawn:i,motion:a,lanes:o}=await r2(e,_O(n),r,{by:`feed`,fps:t}),s=m0.linkFor(e.hookData.session_id,a2(i)),c=e.hookData.session_id,l=i2(i,s);return{resp:{ok:!0,output:l},statusline:{ok:!0,output:c2(c,i,s,l,B1(o,d0.following(c)))},moves:a===`moves`,failure:null}}catch(e){let{level:t,line:i}=q1(r,{kind:`threw`,error:e},Date.now()-n.getTime()),a=z0(e);return{resp:a,statusline:a,moves:!1,failure:{level:t,line:`frame ${i}`}}}}function $0(e,t){return HB(t.config,t=>i0.get(e,t),e=>t.authoredRoots.has(e))}function e2(e){try{var t=na();let n=e.hookData.session_id,r=LZ(e.requested,i0,n);return BB($0(n,t.u(h0.hold(r.projectDir,r.cwd,r.configFile??void 0)).state))}catch(e){t.e=e}finally{t.d()}}function t2(e){let{report:t}=kQ(e.hookData);for(let e of t.unknownTopLevelFields)M(`info`,`schema: unknown field '${e}' — Anthropic may have added it`);let n=[];for(let e of t.missingRequired)n.push(`missing required field '${e}'`);for(let{path:e,expected:r,got:i}of t.typeMismatches)n.push(`field '${e}' expected ${r}, got ${i}`);if((typeof e.cwd!=`string`||!u(e.cwd))&&n.push(`request 'cwd' is not an absolute path: ${JSON.stringify(e.cwd)}`),(!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))&&n.push(`request 'args' is not a list of strings: ${JSON.stringify(e.args)}`),n.length>0)return{ok:!1,problems:n};let r=zt(e),{configFile:i,refusedArgs:a}=W0(e.args,e.cwd);return{ok:!0,req:{...e,hints:r,rateLimits:tj(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,configFile:i??r.configEnv??null},refusedArgs:a}}}const n2=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},delivered:F0});async function r2(e,t,n,r){try{var i=na();W1(n,{sid:e.hookData.session_id,at:t.toFixed(3)});let a=e.hookData.session_id,o=e.hints,s=Bt(e,o),c=Vt(s);W1(n,{termCols:String(o.termCols??`?`),termRows:String(o.termRows??`?`),refused:s.map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:o.client?.kind??`unreported`,rateLimits:e.rateLimits});let l=LZ(e.requested,i0,a),{entry:u,state:d}=i.u(h0.hold(l.projectDir,l.cwd,l.configFile??void 0)),f=o.termCols,p=KQ(f??120),m=Qv(o.termRows);W1(n,{width:String(p)});let h=t=>i0.get(e.hookData.session_id,t),g=$0(a,d),_=BB(g);W1(n,{lanes:E_.filter(e=>_[e]).join(`,`)||`-`}),l0.observe({sessionId:a,hints:o,origin:l,transcript:e.hookData.transcript_path,answered:$A(e.hookData)},_,a0.revision(a)),u0.observe(a,o.tmux,_.tmuxStatus);let v=await sW(e.hookData,t,{...Y0,navigation:e=>o0.depth(e,i0,wV(d.config))},e.cwd,d.neededInputPaths(g.preset),g,o,{...dV(d.config,d.fileHeldSettings,h),configPath:u.configLayers.includes(u.configHome)?u.configHome:null});W1(n,{prompts:String(v.metrics?.messageCount??`-`),nonPrompts:String(v.metrics?.nonPrompts??`-`),pr:WU(v.git),feeds:YQ(v.feeds)});let y=[],b=VU(g,p),ee=s0.of(a),x=NK(d.config,d.compiled,d.store,d.registry,{...v,drawing:r},t,b,{perSegmentSink:d.lastRenderCellsBySegment,onRenderWarning:e=>y.push(e)},{...g,effects:ee}),S=WJ(i0,a,t,r.by),te=S.kind===`held`||S.kind===`owed`?S.error:null,ne=te?.text??null,C=[Ut(e.refusedArgs),c,u.lastError,ne].filter(Boolean).join(`
506
+ `);async function P1(e){if(process.platform===`linux`)return{executable:await p.promises.readlink(`/proc/${e}/exe`),argv:(await p.promises.readFile(`/proc/${e}/cmdline`,`utf8`)).split(`\0`).slice(0,-1),env:(await p.promises.readFile(`/proc/${e}/environ`,`utf8`)).split(`\0`).slice(0,-1)};let t=D1(`reading process ${e}'s arguments`,await lt({bin:`python3`,args:[`-c`,N1,String(e)],timeoutMs:5e3,category:`lane.process`}));return JSON.parse(t)}async function F1(e,t){return D1(e,await lt({bin:`ps`,args:t,timeoutMs:2e3,category:`lane.process`}))}async function I1(e){let t=await gU(e,`lane.tmux`,[`display`,`-p`,`-t`,e.pane,`#{pane_pid} #{pane_current_path}`]);if(t.kind!==`ok`)throw Error(t.reason);let[n=``,r=``]=t.stdout.trimEnd().split(` `),i=(await F1(`asking pane ${e.pane}'s foreground job`,[`-o`,`tpgid=`,`-p`,n])).trim();return{panePid:Number(n),cwd:r,foreground:Number(i)}}async function L1(e){let{panePid:t,cwd:n,foreground:r}=await I1(e),i=await F1(`listing processes`,[`-A`,`-o`,`pid=,ppid=,args=`]),a=await P1(r),o=aY(i).get(r)?.ppid;if(o===void 0)throw Error(`pane ${e.pane}'s foreground job ${r} is gone`);return{pid:r,executable:await p.promises.realpath(a.executable),argv:a.argv,env:a.env,cwd:n,parent:o,fromShell:r!==t,attached:M1(i,r,t)}}function R1(e){let{CLAUDE_CONFIG_DIR:t,...n}=process.env;return e===void 0?n:{...n,CLAUDE_CONFIG_DIR:e}}function z1(e){return{claudeInput:yZ(),barPanes:e=>A1(E1(e,[`list-panes`,`-a`,`-F`,k1]),e.pane),openBarPane:(e,t,n)=>{let r=E1(e,[`split-window`,`-d`,`-v`,`-l`,`1`,`-t`,e.pane,`-P`,`-F`,`#{pane_id}`,...Object.entries(n).flatMap(([e,t])=>[`-e`,`${e}=${t}`]),...t]).trim();return E1(e,[`set-option`,`-p`,`-t`,r,a1,e.pane]),r},closePane:(e,t)=>void E1(e,[`kill-pane`,`-t`,t]),claude:async(e,t)=>void D1(`claude ${e.join(` `)}`,await lt({bin:`claude`,args:[...e],env:R1(t),timeoutMs:3e4,category:`lane.claude`})),fileExists:e=>p.existsSync(e),presence:Jz,paneClaude:L1,paneDir:async(e,t)=>{let n=Date.now()+T1;for(;;){let r=await I1(e);if(r.foreground===t){if(r.cwd===``)throw Error(`tmux read no directory for pane ${e.pane}`);return r.cwd}if(Date.now()>n)throw Error(`the shell in pane ${e.pane} (pid ${t}) did not take its terminal back within ${T1/1e3} s`);await ge(100)}},launcherNode:e=>w1(e,e=>S1(e,p.constants.X_OK),C1),onPath:(e,t)=>{let n=x1(e,t,e=>S1(e,p.constants.X_OK));return n===null?null:p.realpathSync(n)},followed:async(t,n,r)=>{let i=Date.now()+r;for(;!e(t).has(n);){if(Date.now()>i)return!1;await ge(200)}return!0},moduleGraph:async(e,t,n)=>{let r=await lt({bin:e,args:[t,n],timeoutMs:2e4,category:`lane.process`}),i=!r.ok&&r.reason===`non-zero`?O1(r.stdout):null;return i===null?(D1(`reading ${n}'s module graph`,r),{ok:!0}):{ok:!1,reason:i}},terminate:e=>{try{process.kill(e,`SIGTERM`)}catch(t){throw Error(`Claude Code (pid ${e}) could not be sent SIGTERM: ${t instanceof Error?t.message:String(t)}`)}},exited:async(e,t)=>{let n=Date.now()+t;for(;Mo(e);){if(Date.now()>n)return!1;await ge(100)}return!0},typeShellLine:(e,t)=>void E1(e,_Z(e.pane,`cc-candybar-lane`,[]),t)}}function B1(e,t){return E_.filter(n=>e[n]&&T_[n].elsewhere!==null&&t.has(n))}function V1(e,t){let n=`the bar is drawn in ${t.map(e=>T_[e].elsewhere).join(` and `)}`,r=Hr([{verb:Dr,args:[e,...t.map(e=>T_[e].setting)]}]);return{channels:[{severity:ny,message:n,lines:[[ry(n,Hr([{verb:gr,args:[n]}])),ry(`[⟲ draw it here]`,r)]]}]}}const H1={order:-1/0,text:null,failure:null};var U1=class{synced=new Map;constructor(e){this.dir=e}pathFor(e){return s.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t,n){let r=this.synced.get(e)??H1;if(t<r.order)return{link:this.linkFor(e,n),failure:null};let i=n===r.text&&r.failure===null?null:this.write(e,n);return this.synced.delete(e),this.synced.set(e,{order:t,text:n,failure:i}),this.forgetOldestClean(),{link:this.linkFor(e,n),failure:i}}linkFor(e,t){let n=this.synced.get(e)??H1;return n.text===t?n.failure===null?{kind:`file`,path:this.pathFor(e)}:{kind:`unavailable`,reason:n.failure}:{kind:`unavailable`,reason:`the file holds another render's text until the session's next statusline request`}}forgetOldestClean(){let e=0;for(let t of this.synced.values())t.text===null&&t.failure===null&&e++;for(let[t,n]of this.synced){if(e<=256)return;n.text!==null||n.failure!==null||(this.synced.delete(t),e--)}}write(e,t){let n=this.pathFor(e);try{return t===null?p.rmSync(n,{force:!0}):(p.mkdirSync(this.dir,{recursive:!0,mode:448}),p.writeFileSync(n,t,{mode:384})),null}catch(e){return`${n}: ${e.message}`}}reset(){this.synced.clear();try{return p.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};function W1(e,t){for(let n of Object.entries(t))e.push(n)}const G1={ok:`info`,"bad-request":`warn`,threw:`error`};function K1(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,w(e.error)]]}}function q1(e,t,n){let r=[...e,[`took`,`${n}ms`],[`outcome`,t.kind],...K1(t)];return{level:G1[t.kind],line:`render${r.map(([e,t])=>` ${e}=${SM(t)}`).join(``)}`}}const J1=new iq,Y1=new JX,X1=new rj,Z1=i(import.meta.url),Q1=iX(gt());st(J1.launchStats);const $1=new aO({counters:J1,logger:M}),e0=PU({watchers:$1,logger:M}),{gitProvider:t0,usageStore:n0,mementoProvider:r0}=e0,i0=new sq,a0=new gJ(i0,M),o0=new zJ,s0=new Rv,c0=[t.execPath,...t.execArgv],l0=new b1({edge:z1(e=>d0.following(e)),host:{bundle:Z1,node:c0,socket:vt(),preload:$a(Z1)},state:i0,log:M,now:()=>_O(new Date),defer:e=>void pe(e)}),u0=new W$({edge:{run:(e,t,n)=>gU({socket:e},`tmux-status`,t,n),runSync:(e,t,n)=>hU({socket:e},`tmux-status`,t,n)},subscribe:(e,t)=>d0.subscribe(e,t),sessionInPane:(e,t)=>d0.newestWhere(({hints:{tmux:n}})=>n!=null&&n.socket===e&&n.pane===t),handler:[`CC_CANDYBAR_SOCKET=${je(vt())}`,...[...c0,Z1].map(je),`url-handle`].join(` `),owner:vt(),defer:e=>void pe(e),log:M}),d0=new e$({render:(e,t)=>Q0(e,t),watch:(e,t)=>(0,xb.reaction)(()=>i0.revision(e),t,{scheduler:e=>pe(e)}),lanes:e=>e2(e),shown:e=>f0.shown(e.hints.tmux),watching:()=>f0.follow(),periods:qQ,now:()=>performance.now(),log:M}),f0=new s$({listPanes:e=>gU({socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,n$]),listClients:e=>gU({socket:e},`frames.visibility`,[`list-clients`,`-F`,r$]),sockets:()=>new Set(d0.watched().flatMap(({req:e})=>p0(e))),onAnswer:(e,t)=>u0.answered(e,t),onChange:e=>d0.wakeWhere(t=>p0(t).some(t=>e.has(t))),intervalMs:1e3,log:M});function p0({hints:{tmux:e}}){return e==null?[]:[e.socket]}const m0=new U1(At()),h0=new nq({gitService:t0,sessionState:i0,watchers:$1,log:M},{budgetBytes:()=>(O0(),KK(x0)),observers:{onReload:e=>M(`info`,`config loaded projectDir=${e.projectDir} cwd=${e.cwd} files=${e.configLayers.join(` < `)||`<bundled default>`} error=${e.lastError===null?`none`:JSON.stringify(e.lastError)} warning=${e.lastWarning===null?`none`:JSON.stringify(e.lastWarning)}`)}}),g0=60*1e3,_0=YV({targets:[...new Set([...import.meta.url.startsWith(`file://`)?[i(import.meta.url)]:[],...t.argv[1]?[t.argv[1]]:[]])],intervalMs:g0,stat:p.statSync,exit:()=>N0(0),log:M}),v0=KV({entryUrl:import.meta.url,intervalMs:g0,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>_0.checkNow(),log:M});let y0=null,b0=null,x0=0;function S0(){t.on(`uncaughtException`,e=>{M(`error`,`uncaughtException: ${e.stack||e.message}`),N0(1)}),t.on(`unhandledRejection`,e=>{M(`error`,`unhandledRejection: ${String(e)}`),N0(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{M(`info`,`received ${e}, shutting down`),N0(0)});try{k0(t.env)}catch(e){M(`error`,`refusing to boot: ${e.message}`),N0(1);return}y0=Oo(t.pid);let e=Ro(Bo(y0));if(!e.decision.allow){M(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),N0(1);return}b0=e.registryPath,p.mkdirSync(_t(),{recursive:!0}),xt(vt()),i0.useStorage(new lq(wt(),500,M)),a0.useStorage(LJ(Tt(),M)),jo({anchor:Ao(t.env),isAlive:Mo,onOrphaned:e=>{M(`info`,`parent watchdog: ${e}; shutting down`),N0(0)}}),C0(E.createServer({allowHalfOpen:!1},e=>{P0(e)}),vt(),!1)}function C0(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){M(`error`,`server error: ${i.message}`),N0(1);return}if(r){M(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}w0(e,n)}),e.listen(n,()=>T0(n))}function w0(e,n){let r=vo(yo(St(n)),(e,t)=>Do(e,t,{readStartTime:Eo,pidAlive:Mo}));if(r.kind===`attach-and-exit`){M(`info`,`EADDRINUSE: ${r.reason} — exiting`),t.exit(0);return}M(`warn`,`EADDRINUSE: ${r.reason} — unlinking stale socket and rebinding`);try{p.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){M(`error`,`cannot unlink stale socket ${n}: ${e.message}`),N0(1);return}}C0(e,n,!0)}function T0(e){let n=So(e);if(n.kind!==`present`){M(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),N0(0);return}A0(e);try{p.chmodSync(e,384)}catch(e){M(`warn`,`chmod socket failed: ${e.message}`)}M(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${Nn(se.getHeapStatistics().heap_size_limit)}MB memoryLimit=${Nn(x0)}MB`),nr();let r=m0.reset();r!==null&&M(`warn`,`diagnostic dump wipe failed: ${r}`),_0.arm(),v0.arm(),O0().arm(),E0(e,n.identity)}function E0(e,n){To({bound:n,myPid:t.pid,readIdentity:()=>So(e),readLease:()=>yo(St(e)),shutdown:e=>N0(e),log:M}).arm()}let D0=null;function O0(){if(D0===null)throw Error(`daemon: limits not yet established`);return D0}function k0(e){x0=Pn(e),D0=Vn(qn(J1.startedAt.getTime(),e=>N0(e),{limitBytes:x0}))}function A0(e){let n=bo(St(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:y0});n!==null&&M(`warn`,`lease write failed: ${n}`)}let j0=0,M0=!1;function N0(e){if(!M0){M0=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{u0.restoreAll(),t0.close()}catch(e){M(`warn`,`gitService close failed: ${e.message}`)}try{n0.close()}catch(e){M(`warn`,`usageStore close failed: ${e.message}`)}try{$1.closeAll()}catch(e){M(`warn`,`watcherRegistry close failed: ${e.message}`)}try{i0.flush()}catch(e){M(`warn`,`sessionState flush failed: ${e.message}`)}xo(Ct(),t.pid),b0!==null&&zo(b0,t.pid,Io,e=>p.unlinkSync(e)),t.exit(e)}}function P0(e){j0++,J1.inFlight=j0;let t=!1,n=!0,r=()=>{n&&(n=!1,j0=Math.max(0,j0-1),J1.inFlight=j0)},i=(n,r,i)=>{if(t){r!==null&&M(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let a=r===null?void 0:()=>N0(r);try{e.end(Zt(n),e=>{e??i(),a?.()})}catch(e){M(`warn`,`response write failed: ${e.message}`),a?.()}},a=!1,o=setTimeout(()=>{a=!0,J1.requestsTimedOut++,i({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,F0)},200),s=$t(e=>{H0(e,()=>a).then(e=>e.kind===`reply`?i(e.resp,e.exitAfterFlush,e.delivered):c(e.sessionId,e.lane)).catch(e=>{M(`error`,`handler threw: ${w(e)}`),i(z0(e),null,F0)})},e=>{M(`warn`,`frame parse failed: ${e.message}`),i({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null,F0)}),c=(n,i)=>{if(t||e.destroyed)return;clearTimeout(o),r(),e.off(`data`,s);let a=t$(e),c=d0.subscribe(n,{lane:i,frame:(e,t)=>a(Qt(vH[i](e,t))),refused:t=>e.end(Zt(t)),drawing:()=>!0});t=!0,e.on(`close`,c)};e.on(`data`,s),e.on(`error`,e=>{M(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(o),r()})}const F0=()=>{},I0=e=>({resp:e,exitAfterFlush:null,delivered:F0}),L0=e=>({kind:`reply`,...e}),R0={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},z0=e=>({ok:!1,error:e instanceof Error?e.message:w(e),code:`RENDER_FAILED`,daemonV:3}),B0=(e,t)=>L0(I0({ok:!1,error:t,code:e,daemonV:3}));function V0(e){if(typeof e.sessionId!=`string`||e.sessionId===``)return B0(`BAD_REQUEST`,`subscribe needs a non-empty string sessionId`);if(e.lane===void 0)return B0(`VERSION_MISMATCH`,`this client's subscribe names no lane (${E_.join(`, `)}): it predates the lane toggles — update it`);let t=N_(e.lane);return t===null?B0(`BAD_REQUEST`,`subscribe needs a lane, one of ${E_.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:e.sessionId,lane:t}}async function H0(e,t){return!e||typeof e!=`object`||typeof e.v!=`number`?B0(`BAD_REQUEST`,`malformed request`):e.v===3?e.kind===`subscribe`?V0(e):typeof e.kind!=`string`||!Object.hasOwn(R0,e.kind)?B0(`BAD_REQUEST`,`unknown kind`):L0(await U0(e,t)):(e.v>3?M(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):M(`info`,`version mismatch: client=${e.v} < daemon=3; client is stale — staying up`),{kind:`reply`,resp:{ok:!1,error:`protocol v${e.v} not supported (daemon at v3)`,code:`VERSION_MISMATCH`,daemonV:3},exitAfterFlush:e.v>3?0:null,delivered:F0})}async function U0(e,t){if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,delivered:F0};if(e.kind===`pane-session`){let{socket:t,pane:n}=e;return I0(typeof t!=`string`||typeof n!=`string`?{ok:!1,error:`pane-session needs a string socket and pane`,code:`BAD_REQUEST`,daemonV:3}:{ok:!0,paneSession:d0.newestWhere(({hints:{tmux:e}})=>e!=null&&e.socket===t&&e.pane===n)})}if(e.kind===`stats`)return I0({ok:!0,stats:J1.snapshot({gitCache:t0.getStats(),usageCache:n0.getStats(),transcriptReads:ua(),renderCache:h0.stats,effectCache:s0.getStats(),sessionState:{sessions:i0.size(),observers:i0.observers(),revision:i0.latestRevision()},frameFeeds:d0.getStats(),tmuxStatus:u0.stats(),watchersActive:$1.size(),nextRestartReason:O0().describeNextRestart(),handlerProbes:Y1.list(),clients:X1.list(_O(new Date)),bundle:Z1,daemon:O0().serving(),doctorStores:aX(Q1)})});if(e.kind===`render`){let n=new Date,r=_O(n),i=n.getTime(),a=[],o=++J1.requestsTotal,s=t2(e),c=(e,t)=>X1.see(e.hookData.session_id,{client:e.hints.client??null,termCols:e.hints.termCols??null,rateLimits:e.rateLimits,claudeConfigDir:xa(e.hints.claudeConfigDir),projectDir:e.requested.projectDir,transcript:$A(e.hookData),frame:t},r,o);s.ok&&(c(s.req,`drawing`),d0.note(s.req.hookData.session_id,s.req,o));let l=s.ok?await s2(s.req,o,r,a).then(({answer:e,motion:t,clickShown:n})=>(c(s.req,t),{outcome:{kind:`ok`},resp:{ok:!0,output:e},delivered:n===null?F0:()=>HJ(i0,s.req.hookData.session_id,n)}),e=>(c(s.req,`failed`),{outcome:{kind:`threw`,error:e},resp:z0(e),delivered:F0})):n2(s.problems);l.outcome.kind!==`ok`&&J1.requestsErrored++,W1(a,{timedOut:t()?`Y`:`N`});let{level:u,line:d}=q1(a,l.outcome,Date.now()-i);return M(u,d),{resp:l.resp,exitAfterFlush:null,delivered:l.delivered}}if(e.kind===`click`)return I0(X0(e.verb,e.value,{via:`link`,handler:Xt(e.clientVersion)}));if(e.kind===`debug`){if(!GQ(e.what))return I0({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${WQ.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=h0.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?J0(t.lastRenderCellsBySegment,t.config.globals.colorCompatibility??rv(`colorCompatibility`)):q0};return I0({ok:!0,debug:NQ(e.what,n)})}throw Error(`no reply for request ${w(e)}`)}function W0(e,t){let{tokens:n}=T({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),r=(n??[]).filter(e=>e.kind===`option`&&e.name===`config`).at(-1),i=(n??[]).flatMap(e=>{switch(e.kind){case`option`:return e.name===`config`?e===r&&e.value===void 0?[{arg:e.rawName,why:`no-value`}]:[]:[{arg:e.rawName,why:`unknown`}];case`positional`:return[{arg:e.value,why:`positional`}];case`option-terminator`:return[]}});return{configFile:mz(t,r?.value),refusedArgs:i.filter((e,t)=>i.findIndex(t=>t.arg===e.arg&&t.why===e.why)===t)}}const G0={sessionState:i0,dlog:M,applyUpdate:()=>v0.act(),doctor:hX(e=>{let t=[e.projectDir,e.cwd,e.configFile??void 0];h0.reload(...t);let n=h0.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}}),doctorStores:Q1,probes:Y1,clients:X1,bundle:Z1,serving:()=>O0().serving(),memento:r0,claudeInput:yZ(),history:a0,navigation:o0,configFor:e=>h0.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>h0.reload(e.projectDir,e.cwd,e.configFile??void 0)};G0.reloadConfig;const K0={endcaps:rv(`endcaps`),colorCompatibility:rv(`colorCompatibility`),wrap:rv(`autoWrap`),padding:rv(`padding`),width:1/0},q0=new Map;function J0(e,t){let n=new Map;for(let[r,i]of e)n.set(r,Zv(i,{...K0,colorCompatibility:t}));return n}const Y0={...e0,history:e=>a0.depth(e),feeds:e=>d0.feedsOf(e)};function X0(e,t,n){if(e===`tmux-status-click`)return Z0(t);let r=TQ.get(e);if(!r)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return r(t,{...G0,arrival:n}),{ok:!0,output:``}}catch(e){let t=e instanceof J?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}function Z0(e){let n=e=>({ok:!1,error:e,code:`BAD_REQUEST`,daemonV:3}),r=u0.linkAt(e);if(r.kind===`refused`)return n(r.reason);if(M(`info`,`tmux-status: click ${JSON.stringify(r.url)}`),r.url.startsWith(`cc-candybar://`)){let e=fo(r.url);return e.verb===`tmux-status-click`?n(`a status-line link names another status-line click`):X0(e.verb,e.value,{via:`tmux-status`})}let i=ut({bin:t.platform===`darwin`?`/usr/bin/open`:`xdg-open`,args:[r.url],category:`click.open`});return i.ok?{ok:!0,output:``}:{ok:!1,error:`opening ${r.url} failed (${i.error??i.reason})`,code:`RENDER_FAILED`,daemonV:3}}async function Q0(e,t){let n=new Date,r=[];try{let{drawn:i,motion:a,lanes:o}=await r2(e,_O(n),r,{by:`feed`,fps:t}),s=m0.linkFor(e.hookData.session_id,a2(i)),c=e.hookData.session_id,l=i2(i,s);return{resp:{ok:!0,output:l},statusline:{ok:!0,output:c2(c,i,s,l,B1(o,d0.following(c)))},moves:a===`moves`,failure:null}}catch(e){let{level:t,line:i}=q1(r,{kind:`threw`,error:e},Date.now()-n.getTime()),a=z0(e);return{resp:a,statusline:a,moves:!1,failure:{level:t,line:`frame ${i}`}}}}function $0(e,t){return HB(t.config,t=>i0.get(e,t),e=>t.authoredRoots.has(e))}function e2(e){try{var t=na();let n=e.hookData.session_id,r=LZ(e.requested,i0,n);return BB($0(n,t.u(h0.hold(r.projectDir,r.cwd,r.configFile??void 0)).state))}catch(e){t.e=e}finally{t.d()}}function t2(e){let{report:t}=kQ(e.hookData);for(let e of t.unknownTopLevelFields)M(`info`,`schema: unknown field '${e}' — Anthropic may have added it`);let n=[];for(let e of t.missingRequired)n.push(`missing required field '${e}'`);for(let{path:e,expected:r,got:i}of t.typeMismatches)n.push(`field '${e}' expected ${r}, got ${i}`);if((typeof e.cwd!=`string`||!u(e.cwd))&&n.push(`request 'cwd' is not an absolute path: ${JSON.stringify(e.cwd)}`),(!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))&&n.push(`request 'args' is not a list of strings: ${JSON.stringify(e.args)}`),n.length>0)return{ok:!1,problems:n};let r=zt(e),{configFile:i,refusedArgs:a}=W0(e.args,e.cwd);return{ok:!0,req:{...e,hints:r,rateLimits:QA(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,configFile:i??r.configEnv??null},refusedArgs:a}}}const n2=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},delivered:F0});async function r2(e,t,n,r){try{var i=na();W1(n,{sid:e.hookData.session_id,at:t.toFixed(3)});let a=e.hookData.session_id,o=e.hints,s=Bt(e,o),c=Vt(s);W1(n,{termCols:String(o.termCols??`?`),termRows:String(o.termRows??`?`),refused:s.map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:o.client?.kind??`unreported`,rateLimits:e.rateLimits});let l=LZ(e.requested,i0,a),{entry:u,state:d}=i.u(h0.hold(l.projectDir,l.cwd,l.configFile??void 0)),f=o.termCols,p=KQ(f??120),m=Qv(o.termRows);W1(n,{width:String(p)});let h=t=>i0.get(e.hookData.session_id,t),g=$0(a,d),_=BB(g);W1(n,{lanes:E_.filter(e=>_[e]).join(`,`)||`-`}),l0.observe({sessionId:a,hints:o,origin:l,transcript:e.hookData.transcript_path,answered:XA(e.hookData)},_,a0.revision(a)),u0.observe(a,o.tmux,_.tmuxStatus);let v=await sW(e.hookData,t,{...Y0,navigation:e=>o0.depth(e,i0,wV(d.config))},e.cwd,d.neededInputPaths(g.preset),g,o,{...dV(d.config,d.fileHeldSettings,h),configPath:u.configLayers.includes(u.configHome)?u.configHome:null});W1(n,{prompts:String(v.metrics?.messageCount??`-`),nonPrompts:String(v.metrics?.nonPrompts??`-`),pr:WU(v.git),feeds:YQ(v.feeds)});let y=[],b=VU(g,p),ee=s0.of(a),x=NK(d.config,d.compiled,d.store,d.registry,{...v,drawing:r},t,b,{perSegmentSink:d.lastRenderCellsBySegment,onRenderWarning:e=>y.push(e)},{...g,effects:ee}),S=WJ(i0,a,t,r.by),te=S.kind===`held`||S.kind===`owed`?S.error:null,ne=te?.text??null,C=[Ut(e.refusedArgs),c,u.lastError,ne].filter(Boolean).join(`
502
507
  `),re=v0.notice({sessionId:a,dismissed:i0.get(a,AV),enabled:g.updateNotice}),ie=u.lastError===null?null:u.failedFile,ae=[...u.lastWarning===null?[]:[{kind:`load`,message:u.lastWarning}],...y],w=iy(C,re,ae.map(e=>e.message).join(`
503
508
  `)),T=t0.getStats(),oe=n0.getStats(),E=ee.lastFrame(),se=E.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,ce=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,le=ae.map(e=>{switch(e.kind){case`rule`:return`rule:${e.slot}`;case`refresh`:return`refresh:${e.variable}`;case`load`:case`band-floor`:case`when`:return e.kind}}).join(`,`)||`-`;return W1(n,{git:`${T.size}/${T.hits}h/${T.misses}m`,usage:`${oe.size}/${oe.hits}h/${oe.misses}m`,effect:E.effect,effectT:E.t.toFixed(3),effectRows:`${E.made}made/${E.reused}reused`,effectOwn:se,fadeBasis:E.basis,stateRev:String(E.revision),fades:ce(E.fades),leaves:ce(E.leaves),motion:x.motion,err:C?`Y`:`N`,clickError:S.kind===`none`?`-`:S.kind,upd:String(re.length),warn:le}),{drawn:{body:x.text,diagnostics:w,failedConfigFile:ie,geometry:{width:p,rowCap:m,colorCompatibility:g.colorCompatibility}},motion:x.motion,clickShown:te,lanes:_}}catch(e){i.e=e}finally{i.d()}}function i2(e,t){return sy(e.body,e.diagnostics,{fullText:t,failedConfigFile:e.failedConfigFile},e.geometry)+`
504
- `}function a2(e){return e.diagnostics===null?null:oy(e.diagnostics)}function o2(e){let t=e.hookData.session_id,{client:n,...r}=e.hints,i=JSON.stringify(r);i0.get(t,`client-hints`)!==i&&i0.set(t,lQ,i);let a=RZ(e.requested);i0.get(t,`render-origin`)!==a&&i0.set(t,IZ,a)}async function s2(e,t,n,r){o2(e);let{drawn:i,motion:a,clickShown:o,lanes:s}=await r2(e,n,r,D_),{link:c,failure:l}=m0.sync(e.hookData.session_id,t,a2(i));W1(r,{dumpFailed:l===null?`-`:JSON.stringify(l)});let u=i2(i,c),d=e.hookData.session_id,f=B1(s,d0.following(d)),p=c2(d,i,c,u,f),m=aj(e.hints.client??null)===`statusline`;return W1(r,{handoff:(m?f:[]).join(`,`)||`-`}),{answer:m?p:u,motion:a,clickShown:o}}function c2(e,t,n,r,i){let[a,...o]=i;return a===void 0?r:i2({...t,body:cy(V1(e,[a,...o]),t.geometry)},n)}const l2={connectMs:200,budgetMs:500};async function u2(e,n){let r=n.includes(`--json`),i=await d2(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${ln(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
509
+ `}function a2(e){return e.diagnostics===null?null:oy(e.diagnostics)}function o2(e){let t=e.hookData.session_id,{client:n,...r}=e.hints,i=JSON.stringify(r);i0.get(t,`client-hints`)!==i&&i0.set(t,lQ,i);let a=RZ(e.requested);i0.get(t,`render-origin`)!==a&&i0.set(t,IZ,a)}async function s2(e,t,n,r){o2(e);let{drawn:i,motion:a,clickShown:o,lanes:s}=await r2(e,n,r,D_),{link:c,failure:l}=m0.sync(e.hookData.session_id,t,a2(i));W1(r,{dumpFailed:l===null?`-`:JSON.stringify(l)});let u=i2(i,c),d=e.hookData.session_id,f=B1(s,d0.following(d)),p=c2(d,i,c,u,f),m=nj(e.hints.client??null)===`statusline`;return W1(r,{handoff:(m?f:[]).join(`,`)||`-`}),{answer:m?p:u,motion:a,clickShown:o}}function c2(e,t,n,r,i){let[a,...o]=i;return a===void 0?r:i2({...t,body:cy(V1(e,[a,...o]),t.geometry)},n)}const l2={connectMs:200,budgetMs:500};async function u2(e,n){let r=n.includes(`--json`),i=await d2(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${ln(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
505
510
  `);return}t.stdout.write(f2(i.value))}function d2(e){return nn({kind:`debug`,what:e},l2,e=>`debug`in e?e.debug:void 0)}function f2(e){switch(e.what){case`vars`:return p2(e.vars);case`segments`:return m2(e.segments);case`config`:return h2(e.config);default:return e}}function p2(e){if(e.length===0)return`no variables (DSL not active)
506
511
  `;let t=[`variables (${e.length})`,``],n=e.reduce((e,t)=>Math.max(e,t.name.length),4),r=e.reduce((e,t)=>Math.max(e,(t.source??`—`).length),6),i=e.reduce((e,t)=>Math.max(e,t.type.length),4);for(let a of e){let e=a.ageMs===null?``:` ${_2(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${g2(a.value)}${e}${o}`)}return t.join(`
507
512
  `)+`
@@ -510,16 +515,16 @@ function run(argv) {
510
515
  `)+`
511
516
  `}function h2(e){return e===null?`config: DSL not active
512
517
  `:JSON.stringify(e,null,2)+`
513
- `}function g2(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function _2(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function v2(){let e=b2();return e===null?null:p.readFileSync(e,`utf-8`)}function y2(){let e;try{e=v2()}catch(e){t.stderr.write(`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`),t.exit(2)}e===null&&(t.stderr.write("schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n"),t.exit(2)),t.stdout.write(e),t.exit(0)}function b2(){let e=s.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=s.dirname(s.resolve(n));for(;;){let t=s.join(r,e);if(p.existsSync(t))return t;let n=s.dirname(r);if(n===r)return null;r=n}}const x2=5e3;function S2(e,t,n){let r=`/home/tester`,i=Math.floor(n),a=`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`,o={current_dir:`${r}/code/cc-candybar/src`,project_dir:`${r}/code/cc-candybar`,added_dirs:[]};return{hook_event_name:`Status`,session_id:a,version:`1.15.0`,home:r,cwd:`${r}/code/cc-candybar/src`,transcript_path:`${r}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},effort:{level:`xhigh`},workspace:o,git:{repoName:`cc-candybar`,repoUrl:`https://github.com/promptctl/cc-candybar`,branch:`main`,sha:`abc1234`,ahead:2,behind:1,staged:3,unstaged:2,untracked:1,conflicts:0,upstream:`origin/main`,tracking:`tracked`,stash:1,status:`dirty`,operation:`rebase`,timeSinceCommit:780},session:{cost:.39,tokens:241400},today:{cost:12.5,tokens:34e5},context:{totalTokens:48487,contextLeft:24},metrics:{lastResponseTime:8.2,responseTime:4.2,sessionDuration:930,messageCount:8,linesAdded:512,linesRemoved:88},block:{nativeUtilization:63,resetsAt:i+2*3600},weekly:{percentage:21,resetsAt:i+5*86400},cache:{expiresAt:i+900},tmux:{pane:`%0`,session:`work`},host:{name:`tester-box`,user:`tester`,ssh:!0},autocompact:nN(4e5,1e6),...HU(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:mv(()=>!0),themeDefault:{differs:!0,theme:`<theme>`},resumeCommand:BU(o,a,void 0),configPath:t??`${r}/.config/cc-candybar/config.json5`}}function C2(e,t){let n=Qz(e,e),r=tB(n);return r!==null&&t.push(r),n.kind===`chain`?n.layers:[]}async function w2(e,n=t.cwd()){let r=[],i=mz(n,e)??null,a=i===null?C2(n,r):[i];if(i!==null){let e;try{e=p.statSync(i,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:i,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:i,message:`not a file`}}let o=rB(n,n);o!==null&&r.push(o);try{return{kind:`clean`,layers:a,warnings:r,rendered:await D2(a,n,r)}}catch(e){let t=e;return typeof t==`object`&&t&&typeof t.code==`string`&&typeof t.path==`string`&&a.includes(t.path)&&typeof t.message==`string`?{kind:`unreadable`,path:t.path,message:t.message}:(e instanceof Hg&&r.push(...e.warnings),{kind:`fatal`,layers:a,message:e instanceof Hg||e instanceof Error?e.message:String(e),warnings:r})}}async function T2(e,t,n){let r=dB(e,PB,{entered:()=>{},warned:e=>n.push(...e)},{projectDir:t,cwd:t}),{config:i}=r,a=new GK,o=new VO(a,i.globals.default_empty_value??``,void 0,new sq);try{let s=yK(i,o,{cwd:t});n.push(...s.loadWarnings);let c=await o.settled(x2);return c.length>0&&n.push(`source${c.length===1?``:`s`} still running after ${x2} ms, rendered with fallback values: ${c.join(`, `)}`),{layers:e,droppedPlugins:[...r.installed.dropped,...r.layers.flatMap(e=>e.plugins.dropped)],config:i,compiled:s,store:a,registry:o}}catch(e){throw o.dispose(),e}}function E2({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=new Map,l=new Set;return{rendered:MK(t,n,r,i,S2(a,e.at(-1)??null,s),s,VU(a,o),{onSegmentError:(e,t)=>c.set(`segment "${e}"`,t),onRenderWarning:e=>{switch(e.kind){case`rule`:c.set(`${e.slot} rule`,e.message);return;case`when`:c.set(e.where,e.error);return;case`refresh`:c.set(`variable "${e.variable}"`,`cannot refresh: ${e.error}`);return;case`band-floor`:l.add(e.message);return;default:}}},a),failures:c,advisories:l}}async function D2(e,t,n){let r=await T2(e,t,n),{config:i}=r,a=_O(new Date);try{let e=GV();try{wV(i),IF(i)}finally{e()}let t=Ly(null,i.globals.preset,i.presets),o=(e,t)=>{let n=HB(i,t=>t===`preset`?e:null,()=>t),o;try{o=E2(r,n,200,a)}catch(e){o={failures:new Map([[`render`,e instanceof Error?e.message:String(e)]]),advisories:new Set}}return{preset:e,customized:t,...o}},s=o(t,!1),c=[s,o(t,!0),...Iy(i.presets).filter(e=>e!==t).flatMap(e=>[o(e,!1),o(e,!0)])],l=e=>{let n=new Map;for(let t of c)for(let r of e(t)){let e=n.get(r)??new Map;e.set(t.preset,(e.get(t.preset)??new Set).add(t.customized)),n.set(r,e)}return[...n].map(([e,n])=>n.get(t)?.has(!1)?e:`${e} (under ${[...n].map(([e,n])=>[...e===t?[]:[`preset "${e}"`],...n.has(!1)?[]:[`.preset.customized = true`]].join(`, `)).join(`; `)})`)};n.push(...l(e=>e.advisories));let u=l(e=>[...e.failures].map(([e,t])=>`${e}: ${t}`)),d=s.rendered,f=r.droppedPlugins.length,p=[...f>0?[`${f} plugin${f===1?``:`s`} did not load (named in the warnings)`]:[],...u.length>0||d===void 0?[`config renders with ${u.length} render error${u.length===1?``:`s`} (the daemon would show them on the bar):\n`+u.map(e=>` ${e}`).join(`
518
+ `}function g2(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function _2(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function v2(){let e=b2();return e===null?null:p.readFileSync(e,`utf-8`)}function y2(){let e;try{e=v2()}catch(e){t.stderr.write(`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`),t.exit(2)}e===null&&(t.stderr.write("schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n"),t.exit(2)),t.stdout.write(e),t.exit(0)}function b2(){let e=s.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=s.dirname(s.resolve(n));for(;;){let t=s.join(r,e);if(p.existsSync(t))return t;let n=s.dirname(r);if(n===r)return null;r=n}}const x2=5e3;function S2(e,t,n){let r=`/home/tester`,i=Math.floor(n),a=`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`,o={current_dir:`${r}/code/cc-candybar/src`,project_dir:`${r}/code/cc-candybar`,added_dirs:[]};return{hook_event_name:`Status`,session_id:a,version:`1.15.0`,home:r,cwd:`${r}/code/cc-candybar/src`,transcript_path:`${r}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},effort:{level:`xhigh`},workspace:o,git:{repoName:`cc-candybar`,repoUrl:`https://github.com/promptctl/cc-candybar`,branch:`main`,sha:`abc1234`,ahead:2,behind:1,staged:3,unstaged:2,untracked:1,conflicts:0,upstream:`origin/main`,tracking:`tracked`,stash:1,status:`dirty`,operation:`rebase`,timeSinceCommit:780},session:{cost:.39,tokens:241400},today:{cost:12.5,tokens:34e5},context:{totalTokens:48487,contextLeft:24},metrics:{lastResponseTime:8.2,responseTime:4.2,sessionDuration:930,messageCount:8,linesAdded:512,linesRemoved:88},block:{nativeUtilization:63,resetsAt:i+2*3600},weekly:{percentage:21,resetsAt:i+5*86400},cache:{expiresAt:i+900},tmux:{pane:`%0`,session:`work`},host:{name:`tester-box`,user:`tester`,ssh:!0},autocompact:tN(4e5,1e6),...HU(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:mv(()=>!0),themeDefault:{differs:!0,theme:`<theme>`},resumeCommand:BU(o,a,void 0),configPath:t??`${r}/.config/cc-candybar/config.json5`}}function C2(e,t){let n=Qz(e,e),r=tB(n);return r!==null&&t.push(r),n.kind===`chain`?n.layers:[]}async function w2(e,n=t.cwd()){let r=[],i=mz(n,e)??null,a=i===null?C2(n,r):[i];if(i!==null){let e;try{e=p.statSync(i,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:i,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:i,message:`not a file`}}let o=rB(n,n);o!==null&&r.push(o);try{return{kind:`clean`,layers:a,warnings:r,rendered:await D2(a,n,r)}}catch(e){let t=e;return typeof t==`object`&&t&&typeof t.code==`string`&&typeof t.path==`string`&&a.includes(t.path)&&typeof t.message==`string`?{kind:`unreadable`,path:t.path,message:t.message}:(e instanceof Hg&&r.push(...e.warnings),{kind:`fatal`,layers:a,message:e instanceof Hg||e instanceof Error?e.message:String(e),warnings:r})}}async function T2(e,t,n){let r=dB(e,PB,{entered:()=>{},warned:e=>n.push(...e)},{projectDir:t,cwd:t}),{config:i}=r,a=new GK,o=new VO(a,i.globals.default_empty_value??``,void 0,new sq);try{let s=yK(i,o,{cwd:t});n.push(...s.loadWarnings);let c=await o.settled(x2);return c.length>0&&n.push(`source${c.length===1?``:`s`} still running after ${x2} ms, rendered with fallback values: ${c.join(`, `)}`),{layers:e,droppedPlugins:[...r.installed.dropped,...r.layers.flatMap(e=>e.plugins.dropped)],config:i,compiled:s,store:a,registry:o}}catch(e){throw o.dispose(),e}}function E2({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=new Map,l=new Set;return{rendered:MK(t,n,r,i,S2(a,e.at(-1)??null,s),s,VU(a,o),{onSegmentError:(e,t)=>c.set(`segment "${e}"`,t),onRenderWarning:e=>{switch(e.kind){case`rule`:c.set(`${e.slot} rule`,e.message);return;case`when`:c.set(e.where,e.error);return;case`refresh`:c.set(`variable "${e.variable}"`,`cannot refresh: ${e.error}`);return;case`band-floor`:l.add(e.message);return;default:}}},a),failures:c,advisories:l}}async function D2(e,t,n){let r=await T2(e,t,n),{config:i}=r,a=_O(new Date);try{let e=GV();try{wV(i),IF(i)}finally{e()}let t=Ly(null,i.globals.preset,i.presets),o=(e,t)=>{let n=HB(i,t=>t===`preset`?e:null,()=>t),o;try{o=E2(r,n,200,a)}catch(e){o={failures:new Map([[`render`,e instanceof Error?e.message:String(e)]]),advisories:new Set}}return{preset:e,customized:t,...o}},s=o(t,!1),c=[s,o(t,!0),...Iy(i.presets).filter(e=>e!==t).flatMap(e=>[o(e,!1),o(e,!0)])],l=e=>{let n=new Map;for(let t of c)for(let r of e(t)){let e=n.get(r)??new Map;e.set(t.preset,(e.get(t.preset)??new Set).add(t.customized)),n.set(r,e)}return[...n].map(([e,n])=>n.get(t)?.has(!1)?e:`${e} (under ${[...n].map(([e,n])=>[...e===t?[]:[`preset "${e}"`],...n.has(!1)?[]:[`.preset.customized = true`]].join(`, `)).join(`; `)})`)};n.push(...l(e=>e.advisories));let u=l(e=>[...e.failures].map(([e,t])=>`${e}: ${t}`)),d=s.rendered,f=r.droppedPlugins.length,p=[...f>0?[`${f} plugin${f===1?``:`s`} did not load (named in the warnings)`]:[],...u.length>0||d===void 0?[`config renders with ${u.length} render error${u.length===1?``:`s`} (the daemon would show them on the bar):\n`+u.map(e=>` ${e}`).join(`
514
519
  `)]:[]];if(p.length>0||d===void 0)throw Error(p.join(`
515
520
  `));return d}finally{r.registry.dispose()}}function O2(e){return e.map(e=>`warning: ${e}\n`).join(``)}function k2(e,t=!1){switch(e.kind){case`clean`:return{stdout:`✓ ${e.layers.join(` < `)||`bundled default (no config file found)`}: config OK${e.warnings.length>0?` (${e.warnings.length} warning${e.warnings.length===1?``:`s`})`:``}\n`+(t?`${e.rendered}\n`:``),stderr:O2(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:O2(e.warnings)+`✗ ${e.layers.join(` < `)||`<default>`}\n${e.message}\n`,code:1};case`unreadable`:return{stdout:``,stderr:`check: cannot read ${e.path}: ${e.message}\n`,code:2}}}const A2=`--render`,j2=`Usage: cc-candybar check [${A2}] [config-file]\n`;function M2(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==A2);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${j2}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${j2}`}:{kind:`run`,target:n[0],render:t.includes(A2)}}async function N2(e){let n=M2(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:k2(await w2(n.target??K$(t.env,t.cwd())),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const P2=/^[a-z][a-z0-9+.-]*:\/\//i,F2=/^[^@\s/]+@[^:\s/]+:/,I2=/^([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;function L2(e){if(!URL.canParse(e))return e;let t=new URL(e);return t.password===``?e:(t.password=`***`,t.href)}function R2(e,t,n){let r=pz(t,e);if(n(r))return{kind:`path`,dir:r};if(P2.test(e)||F2.test(e))return{kind:`git`,url:e,shown:L2(e)};let i=I2.exec(e);if(i){let e=`https://github.com/${i[1]}.git`;return{kind:`git`,url:e,shown:e}}return{error:`"${e}" is not a directory, a GitHub repo slug (owner/repo) or a git URL`}}function z2(e,t){let n=s.join(e,Uz),r=Kz(n);if(`error`in r)throw Error(`${t}: could not list ${Uz}: ${r.error}`);if(r.folders.length===0)throw Error(`${t} has no plugins: none at ${Uz}/<name>/${_z}`);return r.folders.map(e=>s.join(n,e,_z))}function B2(e,t,n){let r=(n,...r)=>{let i=ut({bin:`git`,args:r,env:n,category:`plugin.git`});if(!i.ok)throw Error(`git ${r.map(n=>n===e?t:n).join(` `)} failed (${i.reason}): ${i.stderr.trim()||i.error||``}`);return i.stdout},i={...process.env,GIT_TERMINAL_PROMPT:`0`};for(let e of r(i,`rev-parse`,`--local-env-vars`).split(`
516
521
  `))delete i[e];r(i,`clone`,`--quiet`,`--depth`,`1`,`--filter=blob:none`,`--sparse`,`--`,e,n),r(i,`-C`,n,`sparse-checkout`,`set`,`--no-cone`,`/${Uz}/`)}function V2(e,t){switch(e.kind){case`path`:return t(e.dir);case`git`:{let n=p.mkdtempSync(s.join(C.tmpdir(),`cc-candybar-plugin-`));try{return B2(e.url,e.shown,s.join(n,`repo`)),t(s.join(n,`repo`))}finally{p.rmSync(n,{recursive:!0,force:!0})}}}}function H2(e){let t;try{t=p.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return`installed`;throw e}if(t.isDirectory())return`updated`;if(t.isSymbolicLink())return`replaced`;throw Error(`${e} is a file, not a plugin folder: move it, then install again`)}function U2(e,t,n,r){switch(r){case`updated`:p.renameSync(s.join(e,_z),s.join(t,_z));return;case`replaced`:p.renameSync(t,n),p.renameSync(e,t);return;case`installed`:p.renameSync(e,t);return}}function W2(e,t,n){let r=z2(e,n);p.mkdirSync(t,{recursive:!0});let i=p.mkdtempSync(s.join(t,`.install-`));try{let a=r.map(e=>{let t=s.join(i,s.basename(s.dirname(e)));p.mkdirSync(t);try{p.copyFileSync(e,s.join(t,_z))}catch(e){if(e.code!==`ENOENT`)throw e}return t}),o=lB(a.map(e=>s.join(e,_z)),PB,{root:e,git:!1});if(o.length>0)throw Error(o.map(e=>`${n}: ${s.join(Uz,s.relative(i,e.path))} would not load: ${e.reason.split(i).join(s.join(n,Uz))}`).join(`
517
- `));let c=a.map(e=>{let n=s.basename(e),r=s.join(t,n);return{folder:e,name:n,target:r,placed:H2(r)}}),l=[];try{for(let{folder:e,name:t,target:n,placed:r}of c)U2(e,n,s.join(i,`.replaced-${t}`),r),l.push(t)}catch(e){throw Error(`${e.message} (placed before it: ${l.join(`, `)||`none`})`)}return c.map(({target:e,placed:t})=>({path:s.join(e,_z),placed:t}))}finally{p.rmSync(i,{recursive:!0,force:!0})}}function G2(e){let[t,n,...r]=e;if(t!==`install`||n===void 0||r.length>0)return console.error(`Usage: cc-candybar plugin install <path | owner/repo | git URL>`),2;let i=R2(n,process.cwd(),NO);if(`error`in i)return console.error(`plugin install: ${i.error}`),2;try{let e=i.kind===`path`?i.dir:i.shown,t=V2(i,t=>W2(t,Hz(),e));for(let{path:n,placed:r}of t)console.log(`${r} plugin ${s.basename(s.dirname(n))} → ${n} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}function K2(e,t){if(e!==void 0&&/^\+?\d+$/.test(e)){let t=Number(e);if(t>0&&t<=4294967295)return t}if(t&&t>0)return t}const q2=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function J2(e,t,n){return{termCols:K2(e.COLUMNS,n.columns),termRows:K2(e.LINES,n.rows),ssh:q2.some(t=>(e[t]??``)!==``),tmux:KA(e),configEnv:K$(e,t),claudeConfigDir:ba(e,t),mementoEnv:Nt(e,t),terminalEnv:Ft(e)}}function Y2(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function X2(e){let t=LX(e,[`bundle`,`clients`]);if(t!==null)return{kind:`failed`,reason:t};if(typeof e.bundle!=`string`)return{kind:`failed`,reason:`the running daemon (${e.version}) reported its bundle as ${JSON.stringify(e.bundle)}`};let n=Y2(e);return n.every(e=>typeof e.ago==`number`&&typeof e.sessionId==`string`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:tn(e.client)??null,sessionId:e.sessionId,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age or session: ${JSON.stringify(e.clients)}`}}const Z2=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)},Q2=e=>{let t=e??{};if(t.kind===`unmeasured`)return!0;let n=t.charge;return t.kind===`measured`&&typeof t.rss==`number`&&typeof t.heapTotal==`number`&&typeof n?.bytes==`number`&&(n.kind===`charged`&&(n.measure===`phys_footprint`||n.measure===`rss`)||n.kind===`stand-in`&&typeof n.unread==`string`&&Number.isFinite(n.gap))};function $2(e,t){let n=e;if(n?.kind===`failed`&&typeof n.reason==`string`)return{kind:`failed`,reason:n.reason};if(n?.kind!==`ok`)return{kind:`misshapen`,reason:`is not an answer`};let r=t(n.value);return r.kind===`ok`?r:{kind:`misshapen`,reason:r.reason}}function e4(e){let t=LX(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=$2(n?.postMortems,e=>Array.isArray(e)&&e.every(Z2)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of post-mortems`});return typeof n?.pid==`number`&&Q2(n.memory)&&typeof n.limit==`number`&&r.kind!==`misshapen`?{kind:`ok`,value:{...n,postMortems:r}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function t4(e,t,n){let r=LX(e,[`clients`]);if(r!==null)return{kind:`failed`,reason:r};let i=Y2(e);return i.every(t)?{kind:`ok`,value:i}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without ${n} — restart it on this build: ${JSON.stringify(e.clients)}`}}const n4=e=>ij.includes(e.role),r4=e=>t4(e,e=>typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof e.claudeConfigDir==`string`&&ej.includes(e.rateLimits),`the rate-limit windows they carried`),i4=e=>t4(e,e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof t?.path==`string`&&typeof t.answered==`boolean`},`their transcripts`),a4=e=>t4(e,e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&typeof e.projectDir==`string`&&typeof e.sessionId==`string`&&typeof e.since==`number`&&Array.isArray(e.redrawn)&&e.redrawn.length>0&&e.redrawn.every(Number.isInteger)&&n4(e)&&rj.includes(e.frame),`what they drew, when, and from which project`),o4=e=>t4(e,e=>typeof e.sessionId==`string`&&typeof e.ago==`number`&&n4(e)&&(e.termCols===null||typeof e.termCols==`number`),`whose they were or the width they measured`);function s4(e,t,n){let r=e.doctorStores?.[t],i=$2(r,n);return i.kind===`misshapen`?{kind:`failed`,reason:`the running daemon (${e.version}) reported its ${t} as ${JSON.stringify(r)}, which ${i.reason}`}:i}function c4(e){let t=LX(e,[`doctorStores`]);if(t!==null){let e={kind:`failed`,reason:t};return{marks:e,clicked:e,postMortemsRead:e}}return{marks:s4(e,`marks`,JJ),clicked:s4(e,`clicked`,ZJ),postMortemsRead:s4(e,`postMortemsRead`,$Y)}}async function l4(){let e=await IX();if(e.kind!==`ok`){let t={kind:`failed`,reason:ln(e).split(`
518
- `).join(` — `)};return{clients:t,rateLimits:t,transcripts:t,frames:t,widths:t,serving:t,stores:{marks:t,clicked:t,postMortemsRead:t}}}return{clients:X2(e.value),rateLimits:r4(e.value),transcripts:i4(e.value),frames:a4(e.value),widths:o4(e.value),serving:e4(e.value),stores:c4(e.value)}}const u4=` (fix: click the settings menu (${Jr} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,d4=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${Jr} by default) › 🧰 tools › 🩺 doctor`;function f4({check:e,verdict:t}){return t.ok?`✓ ${e.label}${t.note===void 0?``:` — ${t.note}`}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:u4}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${d4}\n`)}function p4(e){let t={sessionState:new sq},n=eq(e.projectDir,e.cwd,e.configFile??void 0,t),r=n.state??tq(e.cwd,e.projectDir,t);return r.registry.dispose(),{layers:n.layers,error:n.error,warning:n.warning,unused:r.unused,config:r.config}}function m4(e,t,n){return n.kind===`failed`?n:rX(e,n.value.bundle,nY(t,n.value.clients).map(({client:e})=>e))}function h4(e,t,n){return t.kind===`failed`?t:{kind:`ok`,value:nY(e,t.value).filter(e=>e.claudeConfigDir===n).map(e=>e.rateLimits)}}function g4(e,t){return t.kind===`failed`?t:{kind:`ok`,value:nY(e,t.value).map(e=>e.transcript)}}function _4(e,t){return t.kind===`failed`?t:{kind:`ok`,value:iY(e,t.value)}}function v4(e,t,n){return e.kind===`recent`?{kind:`ok`,value:{columns:n,of:{kind:`command`}}}:t.kind===`failed`?t:jX(e.sessionId,nY(e,t.value))}async function y4(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=J2(r,i,a()),u=tY(r.CLAUDE_CODE_SESSION_ID);s={...MX(e,l,{projectDir:rY(u,c.frames.kind===`ok`?c.frames.value:[],i),cwd:i,configFile:mz(i,o)??K$(r,i)??null},()=>null,c.serving,h4(u,c.rateLimits,xa(l.claudeConfigDir)),g4(u,c.transcripts),u,_4(u,c.frames),v4(u,c.widths,l.termCols??null),c.stores),urlHandler:await $X(t),install:m4(e.install,u,c.clients)}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=bM(s);return{stdout:c.map(f4).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function b4(){if(t.stderr.isTTY)return t.stderr;let e;try{e=v(`/dev/tty`,`r+`)}catch{return{}}let n=new _e(e),{columns:r}=n;return n.destroy(),{columns:r}}async function x4(e){(e.length>1||e[0]===``||e[0]?.startsWith(`--`))&&(t.stderr.write(`doctor: expected at most one config file
522
+ `));let c=a.map(e=>{let n=s.basename(e),r=s.join(t,n);return{folder:e,name:n,target:r,placed:H2(r)}}),l=[];try{for(let{folder:e,name:t,target:n,placed:r}of c)U2(e,n,s.join(i,`.replaced-${t}`),r),l.push(t)}catch(e){throw Error(`${e.message} (placed before it: ${l.join(`, `)||`none`})`)}return c.map(({target:e,placed:t})=>({path:s.join(e,_z),placed:t}))}finally{p.rmSync(i,{recursive:!0,force:!0})}}function G2(e){let[t,n,...r]=e;if(t!==`install`||n===void 0||r.length>0)return console.error(`Usage: cc-candybar plugin install <path | owner/repo | git URL>`),2;let i=R2(n,process.cwd(),NO);if(`error`in i)return console.error(`plugin install: ${i.error}`),2;try{let e=i.kind===`path`?i.dir:i.shown,t=V2(i,t=>W2(t,Hz(),e));for(let{path:n,placed:r}of t)console.log(`${r} plugin ${s.basename(s.dirname(n))} → ${n} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}function K2(e,t){if(e!==void 0&&/^\+?\d+$/.test(e)){let t=Number(e);if(t>0&&t<=4294967295)return t}if(t&&t>0)return t}const q2=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function J2(e,t,n){return{termCols:K2(e.COLUMNS,n.columns),termRows:K2(e.LINES,n.rows),ssh:q2.some(t=>(e[t]??``)!==``),tmux:JA(e),configEnv:K$(e,t),claudeConfigDir:ba(e,t),mementoEnv:Nt(e,t),terminalEnv:Ft(e)}}function Y2(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function X2(e){let t=LX(e,[`bundle`,`clients`]);if(t!==null)return{kind:`failed`,reason:t};if(typeof e.bundle!=`string`)return{kind:`failed`,reason:`the running daemon (${e.version}) reported its bundle as ${JSON.stringify(e.bundle)}`};let n=Y2(e);return n.every(e=>typeof e.ago==`number`&&typeof e.sessionId==`string`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:tn(e.client)??null,sessionId:e.sessionId,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age or session: ${JSON.stringify(e.clients)}`}}const Z2=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)},Q2=e=>{let t=e??{};if(t.kind===`unmeasured`)return!0;let n=t.charge;return t.kind===`measured`&&typeof t.rss==`number`&&typeof t.heapTotal==`number`&&typeof n?.bytes==`number`&&(n.kind===`charged`&&(n.measure===`phys_footprint`||n.measure===`rss`)||n.kind===`stand-in`&&typeof n.unread==`string`&&Number.isFinite(n.gap))};function $2(e,t){let n=e;if(n?.kind===`failed`&&typeof n.reason==`string`)return{kind:`failed`,reason:n.reason};if(n?.kind!==`ok`)return{kind:`misshapen`,reason:`is not an answer`};let r=t(n.value);return r.kind===`ok`?r:{kind:`misshapen`,reason:r.reason}}function e4(e){let t=LX(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=$2(n?.postMortems,e=>Array.isArray(e)&&e.every(Z2)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of post-mortems`});return typeof n?.pid==`number`&&Q2(n.memory)&&typeof n.limit==`number`&&r.kind!==`misshapen`?{kind:`ok`,value:{...n,postMortems:r}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function t4(e,t,n){let r=LX(e,[`clients`]);if(r!==null)return{kind:`failed`,reason:r};let i=Y2(e);return i.every(t)?{kind:`ok`,value:i}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without ${n} — restart it on this build: ${JSON.stringify(e.clients)}`}}const n4=e=>tj.includes(e.role),r4=e=>t4(e,e=>typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof e.claudeConfigDir==`string`&&ZA.includes(e.rateLimits),`the rate-limit windows they carried`),i4=e=>t4(e,e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof t?.path==`string`&&typeof t.answered==`boolean`},`their transcripts`),a4=e=>t4(e,e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&typeof e.projectDir==`string`&&typeof e.sessionId==`string`&&n4(e)&&ej.includes(e.frame),`what they drew and from which project`),o4=e=>t4(e,e=>typeof e.sessionId==`string`&&typeof e.ago==`number`&&n4(e)&&(e.termCols===null||typeof e.termCols==`number`),`whose they were or the width they measured`);function s4(e,t,n){let r=e.doctorStores?.[t],i=$2(r,n);return i.kind===`misshapen`?{kind:`failed`,reason:`the running daemon (${e.version}) reported its ${t} as ${JSON.stringify(r)}, which ${i.reason}`}:i}function c4(e){let t=LX(e,[`doctorStores`]);if(t!==null){let e={kind:`failed`,reason:t};return{marks:e,clicked:e,postMortemsRead:e}}return{marks:s4(e,`marks`,JJ),clicked:s4(e,`clicked`,ZJ),postMortemsRead:s4(e,`postMortemsRead`,$Y)}}async function l4(){let e=await IX();if(e.kind!==`ok`){let t={kind:`failed`,reason:ln(e).split(`
523
+ `).join(` — `)};return{clients:t,rateLimits:t,transcripts:t,frames:t,widths:t,serving:t,stores:{marks:t,clicked:t,postMortemsRead:t}}}return{clients:X2(e.value),rateLimits:r4(e.value),transcripts:i4(e.value),frames:a4(e.value),widths:o4(e.value),serving:e4(e.value),stores:c4(e.value)}}const u4=` (fix: click the settings menu (${Jr} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,d4=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${Jr} by default) › 🧰 tools › 🩺 doctor`;function f4({check:e,verdict:t}){return t.ok?`✓ ${e.label}${t.note===void 0?``:` — ${t.note}`}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:u4}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${d4}\n`)}function p4(e){let t={sessionState:new sq},n=eq(e.projectDir,e.cwd,e.configFile??void 0,t),r=n.state??tq(e.cwd,e.projectDir,t);return r.registry.dispose(),{layers:n.layers,error:n.error,warning:n.warning,unused:r.unused,config:r.config}}function m4(e,t,n){return n.kind===`failed`?n:rX(e,n.value.bundle,nY(t,n.value.clients).map(({client:e})=>e))}function h4(e,t,n){return t.kind===`failed`?t:{kind:`ok`,value:nY(e,t.value).filter(e=>e.claudeConfigDir===n).map(e=>e.rateLimits)}}function g4(e,t){return t.kind===`failed`?t:{kind:`ok`,value:nY(e,t.value).map(e=>e.transcript)}}function _4(e,t){return t.kind===`failed`?t:{kind:`ok`,value:iY(e,t.value)}}function v4(e,t,n){return e.kind===`recent`?{kind:`ok`,value:{columns:n,of:{kind:`command`}}}:t.kind===`failed`?t:jX(e.sessionId,nY(e,t.value))}async function y4(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=J2(r,i,a()),u=tY(r.CLAUDE_CODE_SESSION_ID);s={...MX(e,l,{projectDir:rY(u,c.frames.kind===`ok`?c.frames.value:[],i),cwd:i,configFile:mz(i,o)??K$(r,i)??null},()=>null,c.serving,h4(u,c.rateLimits,xa(l.claudeConfigDir)),g4(u,c.transcripts),u,_4(u,c.frames),v4(u,c.widths,l.termCols??null),c.stores),urlHandler:await $X(t),install:m4(e.install,u,c.clients)}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=yM(s);return{stdout:c.map(f4).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function b4(){if(t.stderr.isTTY)return t.stderr;let e;try{e=v(`/dev/tty`,`r+`)}catch{return{}}let n=new _e(e),{columns:r}=n;return n.destroy(),{columns:r}}async function x4(e){(e.length>1||e[0]===``||e[0]?.startsWith(`--`))&&(t.stderr.write(`doctor: expected at most one config file
519
524
  Usage: cc-candybar doctor [config-file]
520
525
  `),t.exit(2));let n=t.cwd(),r=await y4(hX(p4),rZ(),l4,t.env,n,b4,e[0]);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}function S4(e){return!e.ok&&e.code!==`RENDER_FAILED`}function C4(e,t,n,r,i){let a=null,o=e=>{a===null&&(a=e,s.destroy(),i(e))},s=E.createConnection({path:e}),c={v:3,kind:`subscribe`,sessionId:t,lane:n};return s.once(`connect`,()=>s.write(Zt(c))),s.on(`data`,$t(e=>{let t=e;S4(t)?o({kind:`refused`,resp:t}):r(t)},e=>o({kind:`failed`,error:e}))),s.on(`error`,e=>o({kind:`failed`,error:e})),s.on(`close`,()=>o({kind:`closed-there`})),{close:()=>o({kind:`closed-here`})}}function w4(e,t){switch(t){case`frame-ok`:return 250;case`frame-failed`:return e;case`fault`:return Math.min(2e3,e*2)}}function T4(e){switch(e.kind){case`failed`:return{kind:`reconnect`,reason:`stream failed (${e.error.message})`,kick:!0};case`closed-there`:return{kind:`reconnect`,reason:`daemon closed the stream`,kick:!1};case`refused`:return e.resp.code===`SWITCHED_OFF`?{kind:`off`,resp:e.resp}:e.resp.code===`TIMEOUT`?{kind:`reconnect`,reason:`the daemon was too busy to open the stream (${e.resp.error})`,kick:!1}:e.resp.code===`BAD_REQUEST`?{kind:`reconnect`,reason:`the daemon does not take subscribe (${e.resp.error}); it restarts on the new build`,kick:!1}:e.resp.code===`VERSION_MISMATCH`&&e.resp.daemonV!==void 0&&e.resp.daemonV<3?{kind:`reconnect`,reason:`the daemon is older than this client (${e.resp.error})`,kick:!0}:{kind:`exit`,reason:`the daemon refused the stream: ${e.resp.code}: ${e.resp.error}`}}}function E4(e,t,n,r){let i=null,a=null,o=!1,s=250,c=(e,t)=>{a=setTimeout(()=>{a=null,((t?r.beforeReconnect?.():void 0)??Promise.resolve()).then(()=>{o||l()})},e)},l=()=>{i=C4(e,t,n,e=>{s=w4(s,e.ok?`frame-ok`:`frame-failed`),r.frame(e)},e=>{if(e.kind===`closed-here`||o)return;let t=T4(e);switch(t.kind){case`exit`:r.exit(t.reason);return;case`off`:r.off(t.resp),c(5e3,!1);return;case`reconnect`:{r.fault(t.reason,s),t.kick&&Jn();let e=s;s=w4(s,`fault`),c(e,!0);return}}})};return l(),{close:()=>{o=!0,a!==null&&clearTimeout(a),i?.close()}}}function D4(e,t){return t.kind===`frame`||t.kind!==e.kind?!0:t.kind===`fault`&&e.kind===`fault`&&t.reason!==e.reason}async function O4(e,n){let{values:r,tokens:i}=T({args:e.slice(3),options:{config:{type:`string`},lane:{type:`string`}},strict:!0,tokens:!0}),a=[e[1],...i.flatMap(e=>e.kind===`option`&&e.name===`config`?[e.rawName,e.value]:[])],o=t.cwd(),s=e=>{t.stderr.write(`cc-candybar frames: ${e}\n`)},c=N_(r.lane);c===null&&(s(`--lane needs one of ${E_.join(`, `)}`),t.exit(2)),t.stdout.on(`error`,()=>t.exit(0));let l=t$(t.stdout),u=null,d=null,f=null,p={kind:`none`},m=(e,t)=>{D4(p,e)&&t(),p=e},h=async e=>{let r=await mn(e,a,o,{...J2(t.env,o,t.stderr),client:Lt(`frames`,n)});r.kind!==`ok`&&(s(ln(r)),r.kind===`transient`&&Jn())},g=e=>{f?.close(),f=E4(vt(),e,c,{frame:e=>m({kind:`frame`},()=>l(`${JSON.stringify(e)}\n`)),off:e=>m({kind:`off`},()=>l(`${JSON.stringify(e)}\n`)),fault:(e,t)=>m({kind:`fault`,reason:e},()=>s(`${e}; reconnecting in ${t}ms`)),exit:e=>{s(e),t.exit(1)},beforeReconnect:()=>d===null?Promise.resolve():h(d)})};for await(let e of ve({input:t.stdin})){if(e.trim()===``)continue;let t;try{t=JSON.parse(e)}catch(e){s(`stdin line is not JSON: ${e.message}`);continue}if(typeof t.session_id!=`string`||t.session_id===``){s(`stdin line carries no session_id`);continue}d=t,await h(t),t.session_id!==u&&(u=t.session_id,g(u))}t.exit(0)}function k4(e){let t=e.replace(/\n+$/,``).split(`
521
526
  `);return{bytes:t.map((e,t)=>`\x1b[${t+1}H${e}`).join(``)+`\x1B[J`,rows:t.length}}const A4=5e3,j4=`usage: cc-candybar bar-pane <claude-code-pane-id, e.g. %3>`;function M4(e,t,n,r){let i=e.split(`
522
- `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?a$(e,i$(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function N4(e,t){let[n,r]=await Promise.all([gU(e,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${t}},#{==:#{pane_id},${e.pane}}}`,`-F`,n$]),gU(e,`bar-pane.tmux`,[`list-clients`,`-F`,r$])]);return n.kind===`ok`?r.kind===`ok`?{kind:`ok`,placement:M4(n.stdout,r.stdout,t,e.pane)}:r:n}function P4(){let e=Date.now();return t=>{if(t.kind===`ok`)e=Date.now();else if(Date.now()-e>A4)throw Error(`tmux has not answered for ${A4/1e3} s: ${t.reason}`)}}function F4(e){let{positionals:t}=(()=>{try{return T({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${j4}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(j4);return{pane:n}}async function I4(e){try{return await L4(e),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function L4(e){let{pane:n}=F4(e),r=KA(t.env);if(r===null)throw Error(`cc-candybar bar-pane runs in a tmux pane`);if(!t.stdout.isTTY)throw Error(`cc-candybar bar-pane draws on its pane's terminal`);let i=await N4(r,n);if(i.kind!==`ok`)throw Error(i.reason);let a=i.placement;if(a.kind===`gone`)throw Error(`no pane ${n} on this tmux server (${r.socket})`);t.stdout.write(`\x1B[?25l\x1B[?7l`),t.on(`exit`,()=>t.stdout.write(`\x1B[?25h\x1B[?7h`));for(let[e,n]of[[`SIGINT`,130],[`SIGTERM`,143],[`SIGHUP`,129]])t.once(e,()=>t.exit(n));let o=e=>{t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),t.exit(1)},s=null,c=`waiting for pane ${n}'s bar`,l=()=>s?.said.latest??c,u=``,d=P4(),f=async()=>{if(a.kind!==`shown`)return;let e=k4(l());e.rows!==t.stdout.rows&&!a.zoomed&&d(await gU(r,`bar-pane.tmux`,[`resize-pane`,`-t`,r.pane,`-y`,String(e.rows)])),e.bytes!==u&&t.stdout.write(e.bytes),u=e.bytes},p=null,m=!1,h=()=>{m=!0,p??=(async()=>{try{for(;m;)m=!1,await f()}finally{p=null}})(),p.catch(o)};t.stdout.on(`resize`,()=>{u=``,h()});let g=e=>{if(s?.sessionId===e)return;if(s?.follower.close(),e===null){s=null;return}let t={latest:null},n=e=>{t.latest=e,h()};s={sessionId:e,said:t,follower:E4(vt(),e,`pane`,{frame:e=>n($V(pn(e)).output),off:e=>n(e.error),fault:n,exit:e=>o(Error(e))})}},_=P4();for(;a.kind!==`gone`;){if(a.kind===`hidden`)g(null);else{let e=await hn(r.socket,n);e.kind===`ok`?(g(e.value),c=e.value===null?`waiting for pane ${n}'s statusline to render on ${vt()}`:`waiting for pane ${n}'s bar`):(e.kind===`transient`&&(Jn(),u=``),c=ln(e))}h(),await ge(500);let e=await N4(r,n);_(e),e.kind===`ok`&&(a=e.placement)}g(null),t.stderr.write(`cc-candybar bar-pane: pane ${n} closed\n`)}const R4=i(import.meta.url),z4=e=>e.some(e=>t.argv.includes(e));function B4(){console.log(UA);let e=$a(R4),t=p.existsSync(e)?``:" (nothing is there yet: run `cc-candybar install` first — in a checkout, `pnpm build`)\n";console.log(`Starting Claude Code on ${T_.statusline.label} yourself (a Bun-compiled Claude Code):\n ${Re(e,{dir:void 0,env:[],program:`claude`,args:[]})}\n${t}`)}const V4={install:async e=>{await go(e,R4),t.exit(0)},"install-url-handler":async()=>{uo(R4),t.exit(0)},"url-handle":async e=>{await po(e[0])},daemon:async()=>{S0()},"daemon-stats":async e=>{await FX(e),t.exit(0)},frames:async()=>{await O4(t.argv,R4)},check:async e=>{await N2(e)},lint:async e=>{await N2(e)},plugin:async e=>{t.exit(G2(e))},schema:async()=>{y2()},doctor:async e=>{await x4(e)},"bar-pane":async e=>{t.exit(await I4(e))},...Object.fromEntries(WQ.map(e=>[e,async n=>{await u2(e,n),t.exit(0)}]))};async function H4(){try{let e=t.argv[2],n=e!==void 0&&!e.startsWith(`-`)?e:null;if(n!==null&&!Object.hasOwn(V4,n)&&(console.error(`cc-candybar: unknown subcommand ${JSON.stringify(n)} — see --help`),t.exit(2)),z4(kA.help)&&(B4(),t.exit(0)),z4(kA.version)&&(console.log(`cc-candybar ${qe}`),t.exit(0)),n!==null){await V4[n](t.argv.slice(3));return}t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
527
+ `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?a$(e,i$(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function N4(e,t){let[n,r]=await Promise.all([gU(e,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${t}},#{==:#{pane_id},${e.pane}}}`,`-F`,n$]),gU(e,`bar-pane.tmux`,[`list-clients`,`-F`,r$])]);return n.kind===`ok`?r.kind===`ok`?{kind:`ok`,placement:M4(n.stdout,r.stdout,t,e.pane)}:r:n}function P4(){let e=Date.now();return t=>{if(t.kind===`ok`)e=Date.now();else if(Date.now()-e>A4)throw Error(`tmux has not answered for ${A4/1e3} s: ${t.reason}`)}}function F4(e){let{positionals:t}=(()=>{try{return T({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${j4}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(j4);return{pane:n}}async function I4(e){try{return await L4(e),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function L4(e){let{pane:n}=F4(e),r=JA(t.env);if(r===null)throw Error(`cc-candybar bar-pane runs in a tmux pane`);if(!t.stdout.isTTY)throw Error(`cc-candybar bar-pane draws on its pane's terminal`);let i=await N4(r,n);if(i.kind!==`ok`)throw Error(i.reason);let a=i.placement;if(a.kind===`gone`)throw Error(`no pane ${n} on this tmux server (${r.socket})`);t.stdout.write(`\x1B[?25l\x1B[?7l`),t.on(`exit`,()=>t.stdout.write(`\x1B[?25h\x1B[?7h`));for(let[e,n]of[[`SIGINT`,130],[`SIGTERM`,143],[`SIGHUP`,129]])t.once(e,()=>t.exit(n));let o=e=>{t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),t.exit(1)},s=null,c=`waiting for pane ${n}'s bar`,l=()=>s?.said.latest??c,u=``,d=P4(),f=async()=>{if(a.kind!==`shown`)return;let e=k4(l());e.rows!==t.stdout.rows&&!a.zoomed&&d(await gU(r,`bar-pane.tmux`,[`resize-pane`,`-t`,r.pane,`-y`,String(e.rows)])),e.bytes!==u&&t.stdout.write(e.bytes),u=e.bytes},p=null,m=!1,h=()=>{m=!0,p??=(async()=>{try{for(;m;)m=!1,await f()}finally{p=null}})(),p.catch(o)};t.stdout.on(`resize`,()=>{u=``,h()});let g=e=>{if(s?.sessionId===e)return;if(s?.follower.close(),e===null){s=null;return}let t={latest:null},n=e=>{t.latest=e,h()};s={sessionId:e,said:t,follower:E4(vt(),e,`pane`,{frame:e=>n($V(pn(e)).output),off:e=>n(e.error),fault:n,exit:e=>o(Error(e))})}},_=P4();for(;a.kind!==`gone`;){if(a.kind===`hidden`)g(null);else{let e=await hn(r.socket,n);e.kind===`ok`?(g(e.value),c=e.value===null?`waiting for pane ${n}'s statusline to render on ${vt()}`:`waiting for pane ${n}'s bar`):(e.kind===`transient`&&(Jn(),u=``),c=ln(e))}h(),await ge(500);let e=await N4(r,n);_(e),e.kind===`ok`&&(a=e.placement)}g(null),t.stderr.write(`cc-candybar bar-pane: pane ${n} closed\n`)}const R4=i(import.meta.url),z4=e=>e.some(e=>t.argv.includes(e));function B4(){console.log(GA);let e=$a(R4),t=p.existsSync(e)?``:" (nothing is there yet: run `cc-candybar install` first — in a checkout, `pnpm build`)\n";console.log(`Starting Claude Code on ${T_.statusline.label} yourself (a Bun-compiled Claude Code):\n ${Re(e,{dir:void 0,env:[],program:`claude`,args:[]})}\n${t}`)}const V4={install:async e=>{await go(e,R4),t.exit(0)},"install-url-handler":async()=>{uo(R4),t.exit(0)},"url-handle":async e=>{await po(e[0])},daemon:async()=>{S0()},"daemon-stats":async e=>{await FX(e),t.exit(0)},frames:async()=>{await O4(t.argv,R4)},check:async e=>{await N2(e)},lint:async e=>{await N2(e)},plugin:async e=>{t.exit(G2(e))},schema:async()=>{y2()},doctor:async e=>{await x4(e)},"bar-pane":async e=>{t.exit(await I4(e))},...Object.fromEntries(WQ.map(e=>[e,async n=>{await u2(e,n),t.exit(0)}]))};async function H4(){try{let e=t.argv[2],n=e!==void 0&&!e.startsWith(`-`)?e:null;if(n!==null&&!Object.hasOwn(V4,n)&&(console.error(`cc-candybar: unknown subcommand ${JSON.stringify(n)} — see --help`),t.exit(2)),z4(kA.help)&&(B4(),t.exit(0)),z4(kA.version)&&(console.log(`cc-candybar ${qe}`),t.exit(0)),n!==null){await V4[n](t.argv.slice(3));return}t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
523
528
 
524
529
  cc-candybar is designed to be used as a Claude Code statusLine command.
525
530
  It reads hook data from stdin and outputs formatted statusline.