@promptctl/cc-candybar 1.147.2 → 1.148.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +62 -64
  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,{closeSync as c,constants as l,createReadStream as u,existsSync as d,fstatSync as f,openSync as p,readSync as m,realpathSync as h,statSync as g,watch as _}from"node:fs";import v,{basename as y,dirname as b,isAbsolute as x,join as S,sep as C}from"node:path";import w,{homedir as ee}from"node:os";import{spawn as te,spawnSync as ne}from"node:child_process";import{inspect as T,parseArgs as re,types as E}from"node:util";import D from"node:net";import ie from"node:v8";import O,{createHash as ae,randomUUID as oe}from"node:crypto";import{open as se,readFile as ce,readdir as le,stat as ue}from"node:fs/promises";import{clearInterval as de,setImmediate as fe,setInterval as pe}from"node:timers";import{get as me}from"node:https";import{setTimeout as he}from"node:timers/promises";import{createInterface as ge}from"node:readline";import{WriteStream as _e}from"node:tty";var ve=Object.create,ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,xe=Object.getOwnPropertyNames,Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty,we=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ce.call(e,s)&&s!==n&&ye(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=be(t,s))||r.enumerable});return e},Ee=(e,t,n)=>(n=e==null?{}:ve(Se(e)),Te(t||!e||!e.__esModule?ye(n,`default`,{value:e,enumerable:!0}):n,e));function k(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}function De(e,t){return E.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!d(t)?`working directory does not exist: ${t}`:e.message:String(e)}const Oe={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3},ke=new Map;function Ae(e){let t=Oe[e];if(t===void 0)return{allowed:!0};let n=ke.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 je(e){ke.set(e,Date.now())}function Me(e){return e.env??process.env}function Ne(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 Pe=null;function Fe(e){Pe=e}function Ie(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Le(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();return Pe?.onStart(e.category),new Promise(t=>{let r;try{r=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){Pe?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(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),Pe?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{Ie(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:De(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 Re(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=ne(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});Pe?.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:De(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 Pe?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(t,e.cwd)}}}function ze(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=Be(e);return Pe?.onEnd(e.category,Date.now()-n),r}function Be(e){let t;try{t=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(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 Ve(e,t,n){let r=`${e}.tmp`,i=n??s.statSync(e,{throwIfNoEntry:!1})?.mode;try{s.writeFileSync(r,t,i===void 0?{}:{mode:i}),s.renameSync(r,e)}catch(e){throw s.rmSync(r,{force:!0}),e}}function He(e,t){let n=e[t];return n&&n.length>0?n:void 0}function Ue(e=process.env){let t=He(e,`XDG_STATE_HOME`)??v.join(w.homedir(),`.local`,`state`);return v.join(t,`cc-candybar`)}function We(){let e=He(process.env,`XDG_CACHE_HOME`)??v.join(w.homedir(),`.cache`);return v.join(e,`cc-candybar`)}function Ge(){return Ue()}function Ke(){return process.env.CC_CANDYBAR_SOCKET||qe()}function qe(){let e=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function Je(e){s.mkdirSync(e,{recursive:!0,mode:448});let t=s.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=w.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 Ye(e){Je(v.dirname(e));for(let t of[e,Xe(e)])try{if(s.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function Xe(e){return`${e}.lease`}function Ze(){return Xe(Ke())}function Qe(){return v.join(Ue(),`session-state.json`)}function $e(){return v.join(Ue(),`settings-history.json`)}function et(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function tt(){return v.join(Ue(),`spawn.lock`)}function nt(){return v.join(Ue(),`spawn.cooldown`)}function rt(){return v.join(Ue(),`spawn.backoff`)}function it(){return v.join(Ue(),`diagnostics`)}function at(e=process.env){return v.join(Ue(e),`daemon.log`)}const ot=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function st(e,t){return Object.fromEntries(ot.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,v.resolve(t,r)]]}))}const ct=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function lt(e){return Object.fromEntries(ct.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const ut=[`native`,`node`,`frames`];function A(e,t){return{kind:e,bundle:t,source:null}}const dt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,mementoEnv:!0,terminalEnv:!0,client:!0});function ft(e){let t=yt(e.termCols),n=yt(e.termRows),r=bt(e.ssh),i=_t(e.tmux),a=gt(e.configEnv),o=gt(e.claudeConfigDir),s=j(e.mementoEnv),c=ht(e.terminalEnv),l=Dt(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 pt(e,t){return dt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function mt(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).`}function j(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ot.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 ht(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ct.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`&&v.isAbsolute(e)?e:void 0}function _t(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 vt=1e4;function yt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>vt?vt:t}function bt(e){return typeof e==`boolean`?e:void 0}function xt(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var St=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Ct(e){return wt(JSON.stringify(e))}function wt(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Tt(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 St(`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 St(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Et(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=Tt(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(Ct(t))})}function Dt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=gt(n);return ut.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function Ot(e,t,n){let r=null;try{r=await Nt(Ke(),t.connectMs);let i=await Et(r,{v:3,...e},t.budgetMs);return jt(e.kind,i,n)}catch(e){return Mt(e)}finally{r&&r.destroy()}}function kt(e,t){return typeof e==`string`?e:t}function At(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function jt(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=kt(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:At(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 Mt(e){if(e instanceof St||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 Nt(e,t){return new Promise((n,r)=>{let i=D.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 Pt(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 Ft=`1.147.2`,It={connectMs:50,budgetMs:150},Lt={connectMs:50,budgetMs:200};function Rt(e){let t=e.output;return typeof t==`string`?t:void 0}function zt(e){return jt(`render`,e,Rt)}function Bt(e,t,n,r){return Ot({kind:`render`,hookData:e,args:t,cwd:n,...r},It,Rt)}function Vt(e,t){return Ot({kind:`pane-session`,socket:e,pane:t},Lt,e=>`paneSession`in e?e.paneSession:void 0)}function Ht(e,t){return Ot({kind:`click`,verb:e,value:t,clientVersion:Ft},Lt,Rt)}let M=null;function Ut(e){if(M!==null)return M;s.mkdirSync(v.dirname(e),{recursive:!0});try{M=s.statSync(e).size}catch{M=0}return M}function Wt(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,r=`${e}.${t+1}`;try{s.renameSync(n,r)}catch{}}try{s.renameSync(e,`${e}.1`)}catch{}M=0}const Gt=(e,t)=>k(t);function N(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=at(),t=Ut(e);s.appendFileSync(e,n),M=t+Buffer.byteLength(n,`utf8`),M>=5242880&&Wt(e)}catch(e){M=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}function Kt(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(`
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,{closeSync as c,constants as l,createReadStream as u,existsSync as d,fstatSync as f,openSync as p,readSync as m,realpathSync as h,statSync as g,watch as _}from"node:fs";import v,{basename as y,dirname as b,isAbsolute as x,join as S,sep as C}from"node:path";import w,{homedir as ee}from"node:os";import{spawn as te,spawnSync as ne}from"node:child_process";import{inspect as T,parseArgs as re,types as E}from"node:util";import D from"node:net";import ie from"node:v8";import O,{createHash as ae,randomUUID as oe}from"node:crypto";import{open as se,readFile as ce,readdir as le,stat as ue}from"node:fs/promises";import{clearInterval as de,setImmediate as fe,setInterval as pe}from"node:timers";import{get as me}from"node:https";import{setTimeout as he}from"node:timers/promises";import{createInterface as ge}from"node:readline";import{WriteStream as _e}from"node:tty";var ve=Object.create,ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,xe=Object.getOwnPropertyNames,Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty,we=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ce.call(e,s)&&s!==n&&ye(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=be(t,s))||r.enumerable});return e},Ee=(e,t,n)=>(n=e==null?{}:ve(Se(e)),Te(t||!e||!e.__esModule?ye(n,`default`,{value:e,enumerable:!0}):n,e));function k(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}function De(e,t){return E.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!d(t)?`working directory does not exist: ${t}`:e.message:String(e)}const Oe={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3},ke=new Map;function Ae(e){let t=Oe[e];if(t===void 0)return{allowed:!0};let n=ke.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 je(e){ke.set(e,Date.now())}function Me(e){return e.env??process.env}function Ne(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 Pe=null;function Fe(e){Pe=e}function Ie(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Le(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();return Pe?.onStart(e.category),new Promise(t=>{let r;try{r=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){Pe?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(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),Pe?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{Ie(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:De(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 Re(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=ne(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});Pe?.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:De(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 Pe?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(t,e.cwd)}}}function ze(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=Be(e);return Pe?.onEnd(e.category,Date.now()-n),r}function Be(e){let t;try{t=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(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 Ve(e,t,n){let r=`${e}.tmp`,i=n??s.statSync(e,{throwIfNoEntry:!1})?.mode;try{s.writeFileSync(r,t,i===void 0?{}:{mode:i}),s.renameSync(r,e)}catch(e){throw s.rmSync(r,{force:!0}),e}}function He(e,t){let n=e[t];return n&&n.length>0?n:void 0}function Ue(e=process.env){let t=He(e,`XDG_STATE_HOME`)??v.join(w.homedir(),`.local`,`state`);return v.join(t,`cc-candybar`)}function We(){let e=He(process.env,`XDG_CACHE_HOME`)??v.join(w.homedir(),`.cache`);return v.join(e,`cc-candybar`)}function Ge(){return Ue()}function Ke(){return process.env.CC_CANDYBAR_SOCKET||qe()}function qe(){let e=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function Je(e){s.mkdirSync(e,{recursive:!0,mode:448});let t=s.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=w.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 Ye(e){Je(v.dirname(e));for(let t of[e,Xe(e)])try{if(s.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function Xe(e){return`${e}.lease`}function Ze(){return Xe(Ke())}function Qe(){return v.join(Ue(),`session-state.json`)}function $e(){return v.join(Ue(),`settings-history.json`)}function et(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function tt(){return v.join(Ue(),`spawn.lock`)}function nt(){return v.join(Ue(),`spawn.cooldown`)}function rt(){return v.join(Ue(),`spawn.backoff`)}function it(){return v.join(Ue(),`diagnostics`)}function at(e=process.env){return v.join(Ue(e),`daemon.log`)}const ot=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function st(e,t){return Object.fromEntries(ot.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,v.resolve(t,r)]]}))}const ct=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function lt(e){return Object.fromEntries(ct.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const ut=[`native`,`node`,`frames`];function A(e,t){return{kind:e,bundle:t,source:null}}const dt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,mementoEnv:!0,terminalEnv:!0,client:!0});function ft(e){let t=yt(e.termCols),n=yt(e.termRows),r=bt(e.ssh),i=_t(e.tmux),a=gt(e.configEnv),o=gt(e.claudeConfigDir),s=j(e.mementoEnv),c=ht(e.terminalEnv),l=Dt(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 pt(e,t){return dt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function mt(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).`}function j(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ot.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 ht(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ct.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`&&v.isAbsolute(e)?e:void 0}function _t(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 vt=1e4;function yt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>vt?vt:t}function bt(e){return typeof e==`boolean`?e:void 0}function xt(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var St=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Ct(e){return wt(JSON.stringify(e))}function wt(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Tt(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 St(`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 St(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Et(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=Tt(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(Ct(t))})}function Dt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=gt(n);return ut.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function Ot(e,t,n){let r=null;try{r=await Nt(Ke(),t.connectMs);let i=await Et(r,{v:3,...e},t.budgetMs);return jt(e.kind,i,n)}catch(e){return Mt(e)}finally{r&&r.destroy()}}function kt(e,t){return typeof e==`string`?e:t}function At(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function jt(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=kt(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:At(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 Mt(e){if(e instanceof St||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 Nt(e,t){return new Promise((n,r)=>{let i=D.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 Pt(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 Ft=`1.148.0`,It={connectMs:50,budgetMs:150},Lt={connectMs:50,budgetMs:200};function Rt(e){let t=e.output;return typeof t==`string`?t:void 0}function zt(e){return jt(`render`,e,Rt)}function Bt(e,t,n,r){return Ot({kind:`render`,hookData:e,args:t,cwd:n,...r},It,Rt)}function Vt(e,t){return Ot({kind:`pane-session`,socket:e,pane:t},Lt,e=>`paneSession`in e?e.paneSession:void 0)}function Ht(e,t){return Ot({kind:`click`,verb:e,value:t,clientVersion:Ft},Lt,Rt)}let M=null;function Ut(e){if(M!==null)return M;s.mkdirSync(v.dirname(e),{recursive:!0});try{M=s.statSync(e).size}catch{M=0}return M}function Wt(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,r=`${e}.${t+1}`;try{s.renameSync(n,r)}catch{}}try{s.renameSync(e,`${e}.1`)}catch{}M=0}const Gt=(e,t)=>k(t);function N(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=at(),t=Ut(e);s.appendFileSync(e,n),M=t+Buffer.byteLength(n,`utf8`),M>=5242880&&Wt(e)}catch(e){M=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}function Kt(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(`
3
3
  `)}function qt(e,t){return e===`darwin`?[P(`footprint`,[`-p`,String(t)]),P(`vmmap`,[`--summary`,String(t)])]:e===`linux`?[Jt(`/proc/self/smaps_rollup`),Jt(`/proc/self/status`)]:[]}function P(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=Re({bin:e,args:[...t],timeoutMs:5e3,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}`}${Yt(n.stderr)}`}}}}function Jt(e){return{name:e,read:()=>{try{let t=s.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 Yt(e){let t=e.split(`
4
4
  `).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const Xt=`CC_CANDYBAR_RSS_LIMIT_MB`;function Zt(e){let t=e[Xt];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${Xt} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function Qt(e){return Zt(e)*2}const $t=1024*1024,en=e=>Math.round(e/$t);function tn(e){return Zt(e)*$t}const nn={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function rn(e,t){return e>t}function an(e,t){return e>t*.75}function on(e,t,n){let{prefix:r,suffix:i}=nn[t];return v.join(e,`${r}${n}${i}`)}function sn(e){for(let t of Object.keys(nn)){let{prefix:n,suffix:r}=nn[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function cn(e){let t=e.rssLimitBytes??512*$t,n=e.snapshotsKeep??3,r=!1;function i(){if(r)return!0;let{rss:i,heapTotal:a}=e.memoryBytes();if(i<=t)return!1;r=!0,e.log(`warn`,`RSS ${i} > limit ${t} (v8 heap ${a}); recording memory then shutting down`);let o=`${new Date(e.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return ln(e.log,`memory report`,()=>{let t=on(e.snapshotDir,`memoryReport`,o);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),ln(e.log,`heap snapshot`,()=>{let t=on(e.snapshotDir,`heapSnapshot`,o);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),ln(e.log,`artifact rotation`,()=>{for(let{artifacts:t}of un(e.listArtifacts()).slice(n))for(let n of Object.values(t))ln(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0}function a(){let{rss:n,heapTotal:r}=e.memoryBytes();return an(n,t)?`rss ${n} approaching limit ${t} (v8 heap ${r})`:null}function o(){let{rss:n}=e.memoryBytes(),r;try{r={kind:`ok`,value:un(e.listArtifacts())}}catch(e){r={kind:`failed`,reason:e.message}}return{pid:e.pid,rss:n,rssLimit:t,postMortems:r}}function s(e=6e4){let t=setInterval(()=>{i()},e);return t.unref(),{disarm:()=>clearInterval(t)}}return{checkRss:i,describeNextRestart:a,serving:o,arm:s}}function ln(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function un(e){let t=new Map;for(let n of e){let e=v.basename(n),r=sn(e);if(r===null)continue;let{prefix:i,suffix:a}=nn[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(nn);return[...t].sort(([e],[t])=>rn(e,t)?-1:1).map(([e,t])=>({identity:e,artifacts:Object.fromEntries(n.flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}))}function dn(e,t,n={}){let r=Ge();return{now:()=>Date.now(),pid:process.pid,snapshotDir:r,log:N,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},captureMemoryReport:()=>Kt(qt(process.platform,process.pid)),writeMemoryReport:(e,t)=>s.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>ie.writeHeapSnapshot(e),listArtifacts:()=>{let e;try{e=s.readdirSync(r)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>sn(e)!==null).map(e=>v.join(r,e))},removeFile:e=>s.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function fn(e={}){if(Dn()!==null)return;let n=e.spawn??On,r=wn();if(r.kind===`contended`){let e=mn();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),pn(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),pn(n);return}try{pn(n)}finally{En()}}function pn(e){xn()&&hn(e)}function mn(){try{let e=s.statSync(tt());return Date.now()-e.mtimeMs}catch{return null}}function hn(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
5
5
  `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function gn(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function _n(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function vn(e){try{let t=s.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function yn(e,n){try{s.mkdirSync(v.dirname(e),{recursive:!0}),s.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function bn(){try{s.unlinkSync(rt())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function xn(){let e=nt(),n=rt(),r=vn(n),i=gn(Sn(e),_n(r));return i.kind===`deny`?!1:(i.kind===`allow-future-garbage`&&t.stderr.write(`cc-candybar: spawn.cooldown mtime is ${i.futureMs}ms in the future — ignoring and spawning\n`),Cn(e),yn(n,Math.min(r+1,5)),!0)}function Sn(e){try{return Date.now()-s.statSync(e).mtimeMs}catch{return null}}function Cn(e){try{s.mkdirSync(v.dirname(e),{recursive:!0}),s.writeFileSync(e,`${t.pid} ${Date.now()}\n`,{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.cooldown: ${e.message}\n`)}}let F=null;function wn(){let e=tt();for(let n=0;n<2;n++){try{let n=s.openSync(e,`wx`,384);try{s.writeSync(n,JSON.stringify({pid:t.pid,ts:Date.now()}))}catch{}return F={fd:n,path:e},{kind:`held`}}catch(t){let n=t.code;if(n!==`EEXIST`)return{kind:`error`,reason:`openSync(${e}): ${n??t.message}`}}if(!Tn(e))return{kind:`contended`};try{s.unlinkSync(e)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function Tn(e){try{let t=s.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function En(){if(!F)return;let{fd:e,path:t}=F;F=null;try{s.closeSync(e)}catch{}try{s.unlinkSync(t)}catch{}}function Dn(){try{return s.mkdirSync(Ge(),{recursive:!0}),null}catch(e){return`mkdir ${Ge()}: ${e.message}`}}function On(){let e=t.execPath,n=t.argv[1];return n?ze({bin:e,args:[`--max-old-space-size=${Qt(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const kn=`cc-candybar`,An=`dispatch`,jn=`set-state`,Mn=`step-state`,Nn=`copy`,Pn=`open-vscode`,Fn=`toolbar-toggle`,In=`show-config-error`,Ln=`show-config-warning`,Rn=`set-config`,zn=`step-config`,Bn=`save`,Vn=`save-preset`,Hn=`save-theme-default`,Un=`delete-preset`,Wn=`reset-config`,Gn=`apply-layout-op`,Kn=`undo`,qn=`redo`,Jn=`back`,Yn=`rewind`,Xn=`apply-update`,Zn=`doctor-run`,Qn=`doctor-fix`,$n=`doctor-mark`,er=`doctor-probe`,tr=`ceiling`,nr=`slash`;function rr(e){return e.map(encodeURIComponent).join(`/`)}function ir(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function I(e){return`${kn}://${An}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${rr(e.args)}`)}`).join(`&`)}`}function ar(e){return new r(e).getAll(`e`).map(lr)}const or=new Set([jn,Wn]);function sr(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&cr(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function cr(e,t){if(e.verb!==t.verb||!or.has(e.verb))return;let[n,r]=[lr(e.value),lr(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function lr(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const ur=`closed`,dr=`🍫`;function fr(e,t,n){if(t===0)return`${e} needs a display (the clickable text)`;if(t!==1&&t!==n)return`${e} cycles ${n} members; bind one display per member (${n}) or one static display, got ${t}`}function pr(e,t,n,r){let i=fr(e,t.length,n);if(i!==void 0)throw Error(i);return t.length===1?t[0]:t[r]}function mr(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function hr(e,t,n,r,i){return{kind:`segment`,name:e,opens:{ref:t,body:n,placement:r},...i!==void 0&&{when:i}}}function gr(e,...t){return`{{ and ${[e,...t].map(_r).join(` `)} }}`}function _r(e){return`(eq .${e.variable} "${mr(e.member)}")`}function vr(e,t,n){return`{{ ${yr(e,br(t),br(n))} }}`}function yr(e,t,n){return`action "${e}" ${t} ${n}`}function br(e){return`"${mr(e)}"`}function xr(e,t){return{kind:`state`,key:e,default:t}}function Sr(e,t){return{set:e,cycle:[ur,t]}}const Cr=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function wr(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Tr(e){return Cr.test(e)?e:wr(e)}var Er=we(((e,t)=>{t.exports.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,t.exports.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,t.exports.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/})),Dr=we(((e,t)=>{let n=Er();t.exports={isSpaceSeparator(e){return typeof e==`string`&&n.Space_Separator.test(e)},isIdStartChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`$`||e===`_`||n.ID_Start.test(e))},isIdContinueChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`$`||e===`_`||e===`‌`||e===`‍`||n.ID_Continue.test(e))},isDigit(e){return typeof e==`string`&&/[0-9]/.test(e)},isHexDigit(e){return typeof e==`string`&&/[0-9A-Fa-f]/.test(e)}}})),Or=we(((e,t)=>{let n=Dr(),r,i,a,o,s,c,l,u,d;t.exports=function(e,t){r=String(e),i=`start`,a=[],o=0,s=1,c=0,l=void 0,u=void 0,d=void 0;do l=v(),ne[i]();while(l.type!==`eof`);return typeof t==`function`?f({"":d},``,t):d};function f(e,t,n){let r=e[t];if(typeof r==`object`&&r)if(Array.isArray(r))for(let e=0;e<r.length;e++){let t=String(e),i=f(r,t,n);i===void 0?delete r[t]:Object.defineProperty(r,t,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let e in r){let t=f(r,e,n);t===void 0?delete r[e]:Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}return n.call(e,t,r)}let p,m,h,g,_;function v(){for(p=`default`,m=``,h=!1,g=1;;){_=y();let e=x[p]();if(e)return e}}function y(){if(r[o])return String.fromCodePoint(r.codePointAt(o))}function b(){let e=y();return e===`
@@ -54,7 +54,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
54
54
  `))throw Error(`drawStripCells: rich-js strip output did not end its last line`);return{text:s.text.slice(0,-1),moves:s.moves}}function dg(e,t){return ug(e,t).text}function fg(e){return Math.min(20,e??20)}const pg={heading:`ERROR`,glyph:`⚠`,colors:Np},mg={heading:`WARNING`,glyph:`⚠`,colors:Pp},hg={heading:`UPDATE`,glyph:`⬆`,colors:Pp};function gg(e,t){return{text:Dp(e),link:t}}function _g(e,t,n){let[r,...i]=[vg(e,pg,In),t,vg(n,mg,Ln)].flat();return r===void 0?null:{channels:[r,...i]}}function vg(e,t,n){let r=I([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>gg(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function yg(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
55
55
  `)}function bg(e,t,n,r){if(t===null)return e;let i=xg(r),a=t.channels.flatMap(e=>Sg(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[Cg(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
56
56
  `);return e?`${l}\n${e}`:l}function xg(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,colorCompatibility:e.colorCompatibility}}function Sg(e,t){let n=new U({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=ao(Math.max(2,t.width-1)),i=(e,t)=>new K(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>dg([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=>uo(e,r)).map(e=>i(e,t))})],t).split(`
57
- `))}function Cg(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:o,failedConfigFile:s}=t,c=new U({bgcolor:i.bg,color:i.fg}),l=(e,t)=>new K(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: ${Dp(o.reason)}`,c)]:[],d=s===null?[]:[l(`${u.length>0?` · `:``}open `,c),l(Dp(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=K.fromFragments([...f,...m]).truncate(r.width);return h.overflow=`ignore`,dg([h],r)}const wg=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Tg(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function Eg(e,t,n=wg){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=v.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Eg(e,r):[[v.relative(e,r).split(v.sep).join(`/`),Tg(r,i)]]})}function Dg(e){let t=O.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Og(e){return Dg(Eg(e,e))}const kg=[`Cargo.toml`,`Cargo.lock`,`src`];function Ag(e){return Dg(Eg(e,e,e=>kg.includes(e)))}const jg=e=>e.slice(0,7);function Mg(e){let t=v.dirname(v.dirname(e));return s.existsSync(v.join(t,`src`))?t:null}function Ng(){let e=Pg();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:Ft,digest:e}}function Pg(){return`17f912957df3846a382ecf71f9fd84524dacc9505a85bd355211c3e4d9afff5e`}function Fg(e){let t=JSON.parse(s.readFileSync(v.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${v.join(e,`package.json`)} has no version string`);return n}function Ig(e,t){try{let n=Mg(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Og(v.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:Fg(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}var q=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const Lg=new Map;function Rg(e){let t=Bg(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 zg(e,t){return e===`bar`?t:Rg(e)}function Bg(e){let t=Lg.get(e);if(t!==void 0)return t;let n=Sc(e);return n===null?null:(Lg.set(e,n),n)}function Vg(e,t){return Hg(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>Pc(e,t))}const Hg=Lp();function Ug(e){let t=Bg(e);return t===null?null:{kind:`decided`,name:e,value:t}}function Wg(e,t,n){let r=Ug(e);return r===null?(n(fh(t,`palette`,`"${e}" names no installed theme${Jm(e)}`)),Kg()):r}function Gg(e,t,n){return ih(e,t,n,Kg(),Ug)}function Kg(){return{kind:`decided`,name:Ym,value:Rg(Ym)}}const qg=[`vertical`,`horizontal`],Jg={vertical:`row`,horizontal:`cell`};function Yg(e){return e.id??e.name}function Xg(e){return[...$g(e)].flatMap(e=>e.kind===`segment`?[Yg(e)]:[])}function Zg(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function Qg(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 r_(e))yield*$g(t)}const e_=(e,t)=>`${e}.children[${t}]`,t_=e=>`${e}.opens.body`;function*n_(e,t){if(yield[e,t],e.kind===`container`)for(let[n,r]of e.children.entries())yield*n_(r,e_(t,n));else e.opens!==void 0&&(yield*n_(e.opens.body,t_(t)))}function r_(e){return e.kind===`container`?e.children:e.opens===void 0?[]:[e.opens.body]}const i_=[`shade`,`variation`,`style`];function a_(e){return e===void 0||`text`in e?`text`:`regex`in e?`regex`:`json`}const o_=[`ttl`,`watch_file`,`depends_on`,`key`,`never`];function s_(e){return e.kind===`file`||e.kind===`shell`}const c_=[`branch`,`sha`,`dirty`,`ahead`,`behind`,`stash`],l_=[`fail`,`ignore`];function u_(e){return e.missingData??`fail`}function*d_(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 f_=`theme`,p_=`effect`,m_=[f_,p_];function h_(e){return{...e.settings,[f_]:{label:f_,domain:`theme`,default:e.palette??`bar`},[p_]:{label:p_,domain:mh,default:`bar`}}}function g_(e){let t=e?.domain;return typeof t==`object`&&`min`in t?t:void 0}function __(e,t){return Object.entries(e).flatMap(([n,r])=>{let i=g_(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 v_(e,t){let{domain:n}=e;return n===`bool`?typeof t==`boolean`:n===`theme`?typeof t==`string`&&eh(t):`min`in n?typeof t==`number`&&Number.isInteger(t)&&t>=n.min&&t<=n.max:typeof t==`string`&&n.includes(t)}function y_(e){return String(e)}function b_(e,t){let{domain:n}=e;if(typeof n==`object`&&`min`in n)return Ih(t,n)??void 0;let r=n===`bool`?t===`true`?!0:t===`false`?!1:t:t;return v_(e,r)?r:void 0}function x_(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:b_(n,o))??i}function S_(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 C_=[`left`,`center`,`right`],w_=[`right`,`left`,`middle`],T_=/^[A-Za-z_][A-Za-z0-9_]*$/;function E_(e){return`#${e+1}`}const D_={rows:{}};function O_(e){return`rows`in e}function k_(e){return Object.fromEntries(e.map((e,t)=>[E_(t),e]))}function A_(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:k_(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:k_([n])}}function j_(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function M_(e){return O_(e)?j_(e):e}function*N_(e,t){if(!O_(e)){yield*n_(e,t);return}yield[j_(e),t];for(let[n,r]of Object.entries(e.rows))yield*n_(r,`${t}.rows.${n}`)}function P_(e,t){return O_(e)?{...t,...e,rows:{...t.rows,...e.rows}}:A_(e)}function F_(e){if(!O_(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const I_=`default`,L_={};function R_(e){return[...new Set([I_,...Object.keys(e)])]}function z_(e,t,n){return th(void 0,e,t,I_,n)}function B_(e,t){let n={[I_]:L_,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${I_}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function V_(e,t){let n=B_(e.presets,t).root??D_;return{node:j_(P_(n,e.root)),path:F_(n)?`presets.${t}.root`:`root`}}function H_(e,t){return{...e.globals,...B_(e.presets,t).globals}}const U_=new Map;function W_(e,t,n){U_.set(e,{permanent:!0,resolve:t,paletteOf:n})}W_(`themes`,()=>Zm(),e=>Rg(e));const G_=`placementThemes`;W_(G_,Qm,(e,t)=>zg(e,t.palette)),W_(`endcaps`,()=>vh),W_(`variations`,()=>Th),W_(`shades`,()=>Oh),W_(`colorCompatibilities`,()=>Ch);function K_(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>Vg(n.basePalette,e.styles[t])}],[`presets`,{members:R_(e.presets)}]])}function q_(e){return[...new Set([...U_.keys(),...e.keys()])]}function J_(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=U_.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(X_(e,t))}const Y_=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function X_(e,t){let n=Y_.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${q_(t).join(`, `)})`}const Z_=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*Q_(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 $_=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,ev=RegExp(`^(?:(\\$)(?:\\.(${$_}))?|\\.(${$_})?)(?=[\\s)]|$)`);function tv(e,t,n){let r=ev.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 nv=/^(\w+)\b\s*([\s\S]*)$/;function*rv(e,t){let n=[t];for(let r of Q_(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=nv.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:tv(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(tv(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const iv=/(?<![.$])\btemplate\s+$/;function*av(e,t,n){let r=0;for(let i of[...e.matchAll(Z_)]){let a=i.index+i[0].length;iv.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:tv(e.slice(a),t,n)}),r=a}}function*ov(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...rv(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...av(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 sv=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${$_})`,`g`);function*cv({code:e,dot:t,root:n}){let r=e.replace(Z_,``);for(let e of[...r.matchAll(sv)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function lv(e,t){let n=new Map;for(let r of ov(e,t))for(let e of cv(r))n.has(e)||n.set(e,r.via);return n}const uv=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,dv={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*fv(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(Z_)]){let o=e.slice(t,a.index),s=uv.exec(o);if(s!==null)n=dv[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 pv(e,t){let n=new Map;for(let{code:r,via:i}of ov(e,t))for(let{name:e,site:t}of fv(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function mv(e,t){return new Set([...hv(e,t)].filter(e=>Object.hasOwn(t,e)))}function hv(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of ov(e,t))for(let{name:e}of av(r,i,a))n.add(e);return n}function gv(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 _v(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),vv(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 vv(e){return e.kind===`dropped`||(e.kind===`shell`||e.kind===`file`)&&a_(e.parse)===`json`}function yv(e){let t=v.basename(e),n=v.dirname(e);for(;;){let r=bv(n);if(r!==null)return{dir:r,name:t,leaf:n===v.dirname(e)};t=v.basename(n),n=v.dirname(n)}}function bv(e){try{return s.statSync(e).isDirectory()?s.realpathSync(e):null}catch{return null}}var xv=we((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()===zt}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){Ft(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 It.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=Bt,n=Bt){let r=new Ut(e);return t!==Bt&&(r.onBOL=new Set([t])),n!==Bt&&(r.onBUOL=new Set([n])),r}function _(e,t){return Ot(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||$e(e)?e:Array.isArray(e)?an.array(e,{name:n}):o(e)?an.object(e,void 0,{name:n}):u(e)?an.map(e,{name:n}):d(e)?an.set(e,{name:n}):typeof e!=`function`||He(e)||Xe(e)?e:s(e)?Un(e):Fn(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:x,u:S}}function x(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:He(n.value)?1:(Ft(r,t,w(e,this,t,n,!1)),2)}function S(e,t,n,r){let i=w(e,this,t,n);return e.l(t,i,r)}function C(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return _e(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return He(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(He(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 w(e,t,n,r,i=F.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:_e(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 ee(e,t){return{t:e,i:t,o:te,u:ne}}function te(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)||!Xe(e.h[t]))&&this.u(e,t,n,!1)===null?0:Xe(n.value)?1:(Ft(r,t,re(e,0,0,n,!1,!1)),2)}function ne(e,t,n,r){let i=re(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function T(e,t,n){var r;let{name:i,addInitializer:a}=n;return Xe(t)||(t=Un(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 re(e,t,n,r,i,a=F.safeDescriptors){let{value:o}=r;return Xe(o)||(o=Un(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function E(e,t){return{t:e,i:t,o:D,u:ie}}function D(e,t,n){return this.u(e,t,n,!1)===null?0:1}function ie(e,t,n,r){return e.m(t,Nt({},this.i,{get:n.get,set:n.set}),r)}function O(e,t,n){function r(e){let n=Nt({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new _n(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=xt(this)[M],n=this,i=e.j.get(a);i instanceof _n&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[M],n=e.j.get(a);if(n instanceof _n&&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 ae(e,t){return{t:e,i:t,o:oe,u:se}}function oe(e,t,n){return this.u(e,t,n,!1)===null?0:1}function se(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function ce(e,t,n){function r(e,t){let n=xt(e)[M];return(n.V??=new Map).set(o,()=>new hn(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[M]??r(this,t.get.call(this)))._(o)},set(e){return(this[M]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function le(e){return{t:Kt,i:e,o:ue,u:de}}function ue(e,t,n,r){var i,a,o;if(n.get)return ln.o(e,t,n,r);if(n.set){let i=He(n.set)?n.set:_e(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!F.safeDescriptors||e.p,set:i})===null?0:2:(Ft(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?Wn:Un).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?Ln:Fn).o(e,t,n,r);let c=!1===this.i?.deep?en:an;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 de(e,t,n,r){var i;return n.get?ln.u(e,t,n,r):n.set?e.l(t,{configurable:!F.safeDescriptors||e.p,set:_e(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?en:an).u(e,t,n,r))}function fe(e,t){return Nt(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function pe(e){return e||Jt}function me(e){return fe(e,ce)}function he(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 ge(e){return fe(e,O)}function _e(e,t,n=!1,r){function i(){return ve(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),pn&&(mn.value=e,Ft(i,`name`,mn)),i}function ve(e,t,n,r,i){let a=ye(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{be(a)}}function ye(e,t){let n=F.trackingDerivation,r=!t||!n;Me();let i=F.allowStateChanges;r&&k();let a={R:r,k:n,C:i,I:F.allowStateReads,P:!1,T:0,B:fn++,D:dn};return dn=a.B,a}function be(e){dn!==e.B&&t(30),dn=e.D,e.N!==void 0&&(F.suppressReactionErrors=!0),Ne(),e.R&&De(e.k),F.suppressReactionErrors=!1}function xe(e,t){let n=function(e){let t=F.allowStateChanges;return F.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){F.allowStateChanges=e})(n)}}function Se(e){return e instanceof yn}function Ce(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=k(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(vn(r)){if(F.disableErrorBoundaries)r.get();else try{r.get()}catch{return De(t),!0}if(e.K===2)return De(t),!0}}return Oe(e),De(t),!1}}}function we(e,t,n){Oe(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++F.runId;let r=F.trackingDerivation,i;if(F.trackingDerivation=e,F.inBatch++,!0===F.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new yn(e)}return F.inBatch--,F.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&&Ae(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,ke(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function Te(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Ae(t[n],e);e.K=-1}function Ee(e){let t=k();try{return e()}finally{De(t)}}function k(){let e=F.trackingDerivation;return F.trackingDerivation=null,e}function De(e){F.trackingDerivation=e}function Oe(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function ke(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Ae(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&je(e))}function je(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,F.pendingUnobservations.push(e))}function Me(){F.inBatch++}function Ne(){--F.inBatch===0&&(Le(),!F.isRunningUnobservations&&F.pendingUnobservations.length>0&&function(){F.isRunningUnobservations=!0;try{let e=F.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 _n&&n.G())}F.pendingUnobservations=[]}finally{F.isRunningUnobservations=!1}}())}function Pe(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Pe))}function Fe(e){let t=F.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&F.inBatch>0&&je(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&F.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Ie(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 Le(){F.inBatch>0||F.isRunningReactions||En(Re)}function Re(){F.isRunningReactions=!0;let e=F.pendingReactions,t=0;for(;e.length>0;){++t===Tn&&(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()}F.isRunningReactions=!1}function ze(e){return fe(e,C)}function Be(e){return function(t,n){return n&&typeof n.kind==`string`?C(e?Mn:An,t,n):r(t)?_e(t.name||`<unnamed action>`,t,e):r(n)?_e(t,n,e):i(t)?ze(b(e?kn:On,{name:t,autoAction:e})):void 0}}function Ve(e){return ve(0,!1,e,this,void 0)}function He(e){return r(e)&&!0===e.isMobxAction}function Ue(e,t=Rt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=We(t),r=!1;a=new wn(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new wn(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 We(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Rn}function Ge(e,t,n,i){let a=typeof i==`function`?wt(t,n):wt(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 Ke(e,t,n,r){let i=Ht(t);return Dt(()=>{let t=xt(e,r)[M];Vt(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function qe(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(qe)),t}function Je(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),Je)),t}function Ye(e){r(e.cancel)&&e.cancel()}function Xe(e){return!0===e?.isMobXFlow}function Ze(e,t){var n;if(t===void 0)return vn(e);if(!1===Ct(e))return!1;let r=e[M];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?vn(wt(e,t)):!1}function Qe(e,t){if(!e)return!1;if(t!==void 0){if(Ct(e)){var n,r;let i=e[M];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return Ct(e)||!!e[M]||Wt(e)||Dn(e)||vn(e)}function $e(e){return Qe(e)}function et(e){return Ct(e)?e[M].nt():nr(e)||I(e)?Array.from(e.keys()):vt(e)?e.map((e,t)=>t):void t(5)}function tt(e,n){return Ct(e)?e[M].et(n):nr(e)||I(e)?e.has(n):vt(e)?n>=0&&n<e.length:void t(10)}function nt(e){if(Ct(e))return e[M].it();t(38)}function rt(e,t,n){if(vn(e)){let r,i=!0;return Ue(()=>{let a=e.get();if(!i||n){let n=k();t({observableKind:`computed`,debugObjectName:e.tt,type:Jn,object:e,newValue:a,oldValue:r}),De(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Jn,newValue:e.rt,oldValue:void 0}),ft(e,t)}function it(e,t,n){return e.set(t,n),n}function at(e,t){if(typeof e!=`object`||!e||e instanceof Date||!$e(e))return e;if(gn(e)||vn(e))return at(e.get(),t);if(t.has(e))return t.get(e);if(vt(e)){let n=it(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=at(e,t)}),n}if(I(e)){let n=it(t,e,new Set);return e.forEach(e=>{n.add(at(e,t))}),n}if(nr(e)){let n=it(t,e,new Map);return e.forEach((e,r)=>{n.set(r,at(e,t))}),n}{let n=it(t,e,{});return nt(e).forEach(r=>{It.propertyIsEnumerable.call(e,r)&&(n[r]=at(e[r],t))}),n}}function ot(e,t){Me();try{return e.apply(t)}finally{Ne()}}function st(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[M].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=_e(`When-effect`,t);var a=Ue(t=>{xe(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function ct(e){return e[M]}function lt(e){return e.st!==void 0&&e.st.length>0}function ut(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 A(e,n){let r=k();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{De(r)}}function dt(e){return e.ot!==void 0&&e.ot.length>0}function ft(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 pt(e,t){let n=k(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);De(n)}}function mt(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!==It;){let t=Pt(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 j(e,t){typeof Array.prototype[e]==`function`&&(Zn[e]=t(e))}function ht(e){return function(){let t=this[M];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function gt(e){return function(t,n){let r=this[M];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function _t(e){return function(){let t=this[M];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 vt(e){return a(e)&&Qn(e[M])}function yt(e){return e[Symbol.toStringTag]=`MapIterator`,jt(e)}function bt(e){return e[Symbol.toStringTag]=`SetIterator`,jt(e)}function xt(e,t){if(p(e,M))return e;let n=t?.name??`ObservableObject`;return c(e,M,new sr(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 P[r]??(P[r]=le({deep:t,autoBind:n}))}(e):void 0}(t))),e}function St(e){return ar[e]||(ar[e]={get(){return this[M]._(e)},set(t){return this[M].M(e,t)}})}function Ct(e){return!!a(e)&&cr(e[M])}function wt(e,n){if(typeof e==`object`&&e){if(vt(e))return n!==void 0&&t(23),e[M].ct;if(I(e))return e.ct;if(nr(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,Et(e)),r}if(Ct(e)){if(!n)return t(26);let r=e[M],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,Et(e)),i}if(Wt(e)||vn(e)||Dn(e))return e}else if(r(e)&&Dn(e[M]))return e[M];t(28)}function Tt(e,n){return e||t(29),n===void 0?Wt(e)||vn(e)||Dn(e)||nr(e)||I(e)?e:e[M]?e[M]:void t(24,e):Tt(wt(e,n))}function Et(e,t){let n;if(t!==void 0)n=wt(e,t);else{if(He(e))return e.name;n=Ct(e)||nr(e)||I(e)?Tt(e):wt(e)}return n.tt}function Dt(e){let t=k();Me();try{return e()}finally{Ne(),De(t)}}function Ot(e,t,n=-1){return kt(e,t,n)}function kt(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=lr.call(e);if(s!==lr.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=At(e),t=At(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(!kt(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)||!kt(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function At(e){return vt(e)?e.slice():u(e)||nr(e)||d(e)||I(e)?Array.from(e.entries()):e}function jt(e){return e[Symbol.iterator]=Mt,Nt(Object.create(ur),e)}function Mt(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let Nt=Object.assign,Pt=Object.getOwnPropertyDescriptor,Ft=Object.defineProperty,It=Object.prototype,Lt=[];Object.freeze(Lt);let Rt={};Object.freeze(Rt);let zt=Object.toString(),Bt=()=>{},Vt=Reflect.ownKeys,Ht=Object.getOwnPropertyDescriptors,M=Symbol(`mobx administration`);var Ut=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 Fe(this)}reportChanged(){Me(),Ie(this),Ne()}toString(){return this.tt}};let Wt=l(`Atom`,Ut),Gt=Object.is,N={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},Kt=`true`,qt=le(),P=[qt],Jt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Jt);let Yt=ae(`observable`),Xt=ae(`observable.ref`,{A:y}),Zt=ae(`observable.shallow`,{A:function(e,t,n){return e==null||Ct(e)||vt(e)||nr(e)||I(e)?e:Array.isArray(e)?an.array(e,{name:n,deep:!1}):o(e)?an.object(e,void 0,{name:n,deep:!1}):u(e)?an.map(e,{name:n,deep:!1}):d(e)?an.set(e,{name:n,deep:!1}):void 0}}),Qt=ae(`observable.struct`,{A:function(e,t){return Ot(e,t)?t:e}}),$t={box(e,t){let n=pe(t);return new hn(e,he(n),n.name,!0,n.equals)},array(e,t){let n=pe(t);return function(e,t,n=`ObservableArray`,r=!1){return Dt(()=>{let i=new Xn(n,t,r);Ft(i.j,M,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Yn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,he(n),n.name)},map(e,t){let n=pe(t);return new tr(e,he(n),n.name)},set(e,t){let n=pe(t);return new ir(e,he(n),n.name)},object:(e,t,n)=>Dt(()=>Ke(function(e,t){var n;return(n=(e=xt(e,t))[M]).v??(n.v=new Proxy(e,Gn))}({},n),e,t))},en=me(Xt),tn=me(Zt),nn=me(Yt),rn=me(Qt);var an=Nt(function(e,t,n){return t&&typeof t.kind==`string`?ce(Yt,e,t):$e(e)?e:o(e)?an.object(e,t,n):Array.isArray(e)?an.array(e,t):u(e)?an.map(e,t):d(e)?an.set(e,t):typeof e==`object`&&e?e:an.box(e,t)},Yt,$t);let on=`computed`,sn=E(on),cn=ge(E(`computed.struct`,{equals:_})),ln=function(e,t){if(t&&typeof t.kind==`string`)return O(sn,e,t);if(o(e))return ge(E(on,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new _n(n)};var un;Nt(ln,sn);let dn=0,fn=1,pn=(un=Pt(()=>{},`name`)?.configurable)!=null&&un,mn={value:`action`,configurable:!0,writable:!1,enumerable:!1};var hn=class extends Ut{constructor(e,t,n=`ObservableValue`,r=!0,i=Gt){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))!==F.UNCHANGED&&this.Ot(e)}jt(e){if(lt(this)){let t=A(this,{object:this,type:Jn,newValue:e});if(!t)return F.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?F.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),dt(this)&&pt(this,{type:Jn,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 gn=l(`ObservableValue`,hn);var _n=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 yn(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=_e(`ComputedValue-setter`,e.set)),this.xt=e.equals||Gt,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),F.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Fe(this),Ce(this)){let e=F.trackingContext;e||!this.Mt&&!this.isBeingObserved||(F.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),F.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Pe)}else Ce(this)&&(this.Nt(),Me(),this.rt=this.Rt(!1),Ne());let e=this.rt;if(Se(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||Se(e)||Se(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=we(this,this.derivation,this.At);else if(!0===F.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new yn(e)}return this.isComputing=!1,t}G(){this.Mt||(Te(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let vn=l(`ComputedValue`,_n);var yn=class{constructor(e){this.cause=void 0,this.cause=e}};let bn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var xn=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 Sn=!0,Cn=!1,F=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Sn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Sn=!1),Sn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new xn):(setTimeout(()=>{Cn||t(35)},1),new xn)}();var wn=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,F.pendingReactions.push(this),Le())}X(){if(!this.isDisposed){Me(),this.isScheduled=!1;let e=F.trackingContext;if(F.trackingContext=this,Ce(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}F.trackingContext=e,Ne()}}track(e){if(this.isDisposed)return;Me(),this.isRunning=!0;let t=F.trackingContext;F.trackingContext=this;let n=we(this,e,void 0);F.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Te(this),Se(n)&&this.Pt(n.cause),Ne()}Pt(e){if(this.kt)this.kt(e,this);else{if(F.disableErrorBoundaries)throw e;F.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),F.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(Me(),Te(this),Ne()))}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[M]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let Tn=100,En=e=>e(),Dn=l(`Reaction`,wn),On=`action`,kn=`autoAction`,An=b(On),jn=b(`action.bound`,{bound:!0}),Mn=b(kn,{autoAction:!0}),Nn=b(`autoAction.bound`,{autoAction:!0,bound:!0}),Pn=Be(!1);Nt(Pn,An);let Fn=Be(!0);Nt(Fn,Mn);let In=ze(jn),Ln=ze(Nn),Rn=e=>e(),zn=`always`;var Bn=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Vn=ee(`flow`),Hn=ee(`flow.bound`,{bound:!0}),Un=Nt(function(e,t){if(t&&typeof t.kind==`string`)return T(Vn,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=Pn(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=Pn(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=Pn(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=Pn(i,function(){try{o&&Ye(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Bt,Bt),Ye(n),a(new Bn)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Vn),Wn=fe(Hn,T),Gn={has:(e,t)=>ct(e).et(t),get:(e,t)=>ct(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=ct(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=ct(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=ct(e).l(t,n))==null||r},ownKeys:e=>ct(e).it(),preventExtensions(e){t(13)}},Kn=Symbol(`mobx-keys`),qn=`splice`,Jn=`update`,Yn={get(e,t){let n=e[M];return t===M?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p(Zn,t)?Zn[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[M];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var Xn=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 Ut(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=Lt),lt(this)){let r=A(this,{object:this.v,type:qn,index:e,removedCount:t,added:n});if(!r)return Lt;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=dt(this),i=r?{observableKind:`array`,object:this.v,type:Jn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&pt(this,i)}Ft(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:qn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&pt(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(lt(this)){let n=A(this,{type:Jn,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)}}},Zn={clear(){return this.splice(0)},replace(e){let t=this[M];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[M];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[M].wt(e,t,n)},push(...e){let t=this[M];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[M].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[M];return t.wt(0,0,e),t.j.length},reverse(){return F.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){F.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[M],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};j(`at`,ht),j(`concat`,ht),j(`flat`,ht),j(`includes`,ht),j(`indexOf`,ht),j(`join`,ht),j(`lastIndexOf`,ht),j(`slice`,ht),j(`toString`,ht),j(`toLocaleString`,ht),j(`toSorted`,ht),j(`toSpliced`,ht),j(`with`,ht),j(`every`,gt),j(`filter`,gt),j(`find`,gt),j(`findIndex`,gt),j(`findLast`,gt),j(`findLastIndex`,gt),j(`flatMap`,gt),j(`forEach`,gt),j(`map`,gt),j(`some`,gt),j(`toReversed`,gt),j(`reduce`,_t),j(`reduceRight`,_t);let Qn=l(`ObservableArrayAdministration`,Xn),$n={},er=`delete`;var tr=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[M]=$n,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,Dt(()=>{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(!F.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new hn(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(lt(this)){let r=A(this,{type:n?Jn:`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(lt(this)&&!A(this,{type:er,object:this,name:e}))return!1;if(this.et(e)){let t=dt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:er,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return ot(()=>{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&&pt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Jn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}}Jt(e,t){ot(()=>{var n;let r=new hn(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=dt(this);n&&pt(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 yt({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 yt({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 nr(e)&&(e=new Map(e)),ot(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>It.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(){ot(()=>{Ee(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return ot(()=>{let n=function(e){if(u(e)||nr(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`}},nr=l(`ObservableMap`,tr);let rr={};var ir=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[M]=rr,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),Dt(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){ot(()=>{Ee(()=>{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(lt(this)){let t=A(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){ot(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=dt(this);t&&pt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(lt(this)&&!A(this,{type:er,object:this,oldValue:e}))return!1;if(this.has(e)){let t=dt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:er,object:this,oldValue:e}:null;return ot(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return bt({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 bt({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 I(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?ot(()=>{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`}},I=l(`ObservableSet`,ir);let ar=Object.create(null),or=`remove`;var sr=class{constructor(e,t=new Map,n,r=qt){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 Ut(`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 _n)return n.set(t),!0;if(lt(this)){let n=A(this,{type:Jn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{type:Jn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}return!0}Tt(e){return F.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(!F.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new hn(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{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)){let n=A(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=Nt({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else Ft(this.h,e,t);this.Yt(e,t.value)}finally{Ne()}return!0}S(e,t,n,r=!1){try{Me();let i=this.Dt(e);if(!i)return i;if(lt(this)){let n=A(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=St(e),o={configurable:!F.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else Ft(this.h,e,o);let s=new hn(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Ne()}return!0}m(e,t,n=!1){try{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)&&!A(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=St(e),a={configurable:!F.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else Ft(this.h,e,a);this.j.set(e,new _n(t)),this.Yt(e,void 0)}finally{Ne()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(lt(this)&&!A(this,{object:this.v||this.h,name:e,type:or}))return null;try{var n;Me();let r=dt(this),i=this.j.get(e),a;if(i||!r||(a=Pt(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 hn&&(a=i.rt),Ie(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&pt(this,{type:or,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Ne()}return!0}Yt(e,t){var n;let r=dt(this);r&&r&&pt(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(),Vt(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let cr=l(`ObservableObjectAdministration`,sr),lr=It.toString,ur=globalThis.Iterator?.prototype||{};e.$mobx=M,e.FlowCancellationError=Bn,e.ObservableMap=tr,e.ObservableSet=ir,e.Reaction=wn,e._allowStateChanges=xe,e._allowStateChangesInsideComputed=Ve,e._allowStateReadsEnd=function(e){F.allowStateReads=e},e._allowStateReadsStart=function(e){let t=F.allowStateReads;return F.allowStateReads=e,t},e._autoAction=Fn,e._autoActionBound=Ln,e._endAction=be,e._getAdministration=Tt,e._getGlobalState=function(){return F},e._interceptReads=function(e,t,n){let r;return nr(e)||vt(e)||gn(e)?r=Tt(e):Ct(e)&&(r=Tt(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return F.trackingDerivation!==null},e._resetGlobalState=function(){let e=new xn;for(let t in e)bn.indexOf(t)===-1&&(F[t]=e[t]);F.allowStateChanges=!F.enforceActions},e._startAction=ye,e.action=Pn,e.actionBound=In,e.autorun=Ue,e.compareDefault=Gt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return Ot(e,t,1)},e.compareStructural=_,e.computed=ln,e.computedStruct=cn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((F.pendingReactions.length||F.inBatch||F.isRunningReactions)&&t(36),Cn=!0,Sn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),F=new xn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===zn?zn:n===`observed`;F.enforceActions=e,F.allowStateChanges=!0!==e&&e!==zn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(F[t]=!!e[t])}),F.allowStateReads=!F.observableRequiresReaction,e.reactionScheduler&&function(e){let t=En;En=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(Ct(e))return e[M].l(n,r);t(39)},e.entries=function(e){return Ct(e)?et(e).map(t=>[t,e[t]]):nr(e)?et(e).map(t=>[t,e.get(t)]):I(e)?Array.from(e.entries()):vt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ke,e.flow=Un,e.flowBound=Wn,e.flowResult=function(e){return e},e.get=function(e,n){if(tt(e,n))return Ct(e)?e[M].Tt(n):nr(e)?e.get(n):vt(e)?e[n]:void t(11)},e.getAtom=wt,e.getDebugName=Et,e.getDependencyTree=function(e,t){return qe(wt(e,t))},e.getObserverTree=function(e,t){return Je(wt(e,t))},e.has=tt,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return ut(Tt(e,t),n)}(e,t,n):function(e,t){return ut(Tt(e),t)}(e,t)},e.isAction=He,e.isBoxedObservable=gn,e.isComputed=function(e){return Ze(e)},e.isComputedProp=function(e,t){return Ze(e,t)},e.isFlow=Xe,e.isFlowCancellationError=function(e){return e instanceof Bn},e.isObservable=$e,e.isObservableArray=vt,e.isObservableMap=nr,e.isObservableObject=Ct,e.isObservableProp=function(e,t){return Qe(e,t)},e.isObservableSet=I,e.keys=et,e.makeAutoObservable=function(e,t,n){return o(e)?Ke(e,e,t,n):(Dt(()=>{let r=xt(e,n)[M];if(!e[Kn]){let t=Object.getPrototypeOf(e),n=new Set([...Vt(e),...Vt(t)]);n.delete(`constructor`),n.delete(M),c(t,Kn,n)}e[Kn].forEach(e=>mt(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return Dt(()=>{let r=xt(e,n)[M];Vt(t).forEach(e=>mt(r,e,t[e]))}),e},e.observable=an,e.observableDeep=nn,e.observableRef=en,e.observableShallow=tn,e.observableStruct=rn,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return rt(Tt(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Tt(e);if(vt(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(!nr(e)&&!I(e)&&!Ct(e))return rt(r,t,n);return ft(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return Ge(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return Ge(`onBUO`,e,t,n)},e.onReactionError=function(e){return F.globalReactionErrorHandlers.push(e),()=>{let t=F.globalReactionErrorHandlers.indexOf(e);t>=0&&F.globalReactionErrorHandlers.splice(t,1)}},e.override=N,e.ownKeys=nt,e.reaction=function(e,t,n=Rt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=xe(!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=Pn(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=We(n),d,f=!0,p=!1,m=n.equals||Gt,h=new wn(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){Ct(e)?e[M].Dt(n):nr(e)||I(e)?e.delete(n):vt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=Ve,e.set=function e(n,r,i){if(arguments.length===2&&!I(n)){Me();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Ne()}return}Ct(n)?n[M].Bt(r,i):nr(n)?n.set(r,i):I(n)?n.add(r):vt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),Me(),r>=n.length&&(n.length=r+1),n[r]=i,Ne()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return at(e,new Map)},e.transaction=ot,e.untracked=Ee,e.values=function(e){return Ct(e)?et(e).map(t=>e[t]):nr(e)?et(e).map(t=>e.get(t)):I(e)?Array.from(e.values()):vt(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 Nt(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=st(e,n,Nt({},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):st(e,t,n||{})}})),Sv=we((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++P.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=T(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 x(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function S(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function C(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function w(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let ee=Reflect.ownKeys;function te(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ne(e){return e===null?null:typeof e==`object`?``+e:e}function T(e,t){return o.hasOwnProperty.call(e,t)}let re=Object.getOwnPropertyDescriptors;function E(e,t){return!!(e&t)}function D(e,t,n){return n?e|=t:e&=~t,e}function ie(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let O=Symbol(`mobx administration`);var ae=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 E(this.flags_,1)}set isBeingObserved(e){this.flags_=D(this.flags_,1,e)}get isPendingUnobservation(){return E(this.flags_,2)}set isPendingUnobservation(e){this.flags_=D(this.flags_,2,e)}get diffValue(){return+!!E(this.flags_,4)}set diffValue(e){this.flags_=D(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return sn(this)}reportChanged(){nn(),cn(this),rn()}toString(){return this.name_}};let oe=b(`Atom`,ae);function se(e,t=f,n=f){let r=new ae(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function ce(e,t){return e===t}function le(e,t){return Mi(e,t)}function ue(e,t){return Mi(e,t,1)}let de=Object.is;function fe(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||vr(e)?e:Array.isArray(e)?A.array(e,{name:n}):g(e)?A.object(e,void 0,{name:n}):x(e)?A.map(e,{name:n}):C(e)?A.set(e,{name:n}):typeof e==`function`&&!Ln(e)&&!lr(e)?_(e)?ar(e):Nn(n,e):e}function pe(e,t,r){if(e==null||Di(e)||ui(e)||mi(e)||yi(e))return e;if(Array.isArray(e))return A.array(e,{name:r,deep:!1});if(g(e))return A.object(e,void 0,{name:r,deep:!1});if(x(e))return A.map(e,{name:r,deep:!1});if(C(e))return A.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function me(e){return e}function he(e,t){return vr(e)&&n(`observable.struct should not be used with observable values`),Mi(e,t)?t:e}let ge=`override`,_e={annotationType_:ge,make_:ye,extend_:be};function ve(e){return e.annotationType_===ge}function ye(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),T(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function be(e,t,r,i){n(44,this.annotationType_)}function xe(e,t){return{annotationType_:e,options_:t,make_:Se,extend_:Ce}}function Se(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:Ln(n.value)?1:(a(r,t,Ee(e,this,t,n,!1)),2)}function Ce(e,t,n,r){let i=Ee(e,this,t,n);return e.defineProperty_(t,i,r)}function we(e,t,r){ie(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>yt(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return Ln(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return Ln(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 Te(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 Ee(e,t,n,r,i=P.safeDescriptors){var a,o;Te(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:yt(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 k(e,t){return{annotationType_:e,options_:t,make_:De,extend_:Oe}}function De(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&&(!T(e.target_,t)||!lr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:lr(n.value)?1:(a(r,t,je(e,this,t,n,!1,!1)),2)}function Oe(e,t,n,r){let i=je(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function ke(e,t,n){var r;ie(n,[`method`]);let{name:i,addInitializer:a}=n;return lr(t)||(t=ar(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 Ae(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 je(e,t,n,r,i,a=P.safeDescriptors){Ae(e,t,n,r);let{value:o}=r;return lr(o)||(o=ar(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function Me(e,t){return{annotationType_:e,options_:t,make_:Ne,extend_:Pe}}function Ne(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Pe(e,t,n,i){return Ie(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Fe(e,t,n){ie(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 Ot(o)}return o(function(){let e=wi(this)[O],n=this,r=e.values_.get(a);r instanceof Ot&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[O],n=e.values_.get(a);if(n instanceof Ot&&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 Ie(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 Le(e,t){return{annotationType_:e,options_:t,make_:Re,extend_:ze}}function Re(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function ze(e,t,n,r){return Ve(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??fe,r)}function Be(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);ie(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=wi(e)[O];return(n.lazyObservableKeys_??=new Map).set(o,()=>new Et(t,i.options_?.enhancer_??fe,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[O]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[O]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function Ve(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 He=Ue();function Ue(e){return{annotationType_:`true`,options_:e,make_:Ke,extend_:qe}}let We=[He];function Ge(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return We[r]??(We[r]=Ue({deep:t,autoBind:n}))}function Ke(e,t,n,r){var i;if(n.get)return j.make_(e,t,n,r);if(n.set){let i=Ln(n.set)?n.set:yt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:P.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?or:ar).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Fn:Nn).make_(e,t,n,r)}let c=this.options_?.deep===!1?st:A;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 qe(e,t,n,r){var i;return n.get?j.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:P.safeDescriptors?e.isPlainObject_:!0,set:yt(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?st:A).extend_(e,t,n,r))}function Je(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 Ye={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Ye);function Xe(e){return e||Ye}let Ze=Le(`observable`),Qe=Le(`observable.ref`,{enhancer_:me}),$e=Le(`observable.shallow`,{enhancer_:pe}),et=Le(`observable.struct`,{enhancer_:he});function tt(e){return Je(e,Be)}function nt(e){return e.deep===!0?fe:e.deep===!1?me:it(e.defaultDecorator)}function rt(e){return e?e.defaultDecorator??Ge(e):void 0}function it(e){return e?e.options_?.enhancer_??fe:fe}function at(e,t,n){return t&&typeof t.kind==`string`?Be(Ze,e,t):vr(e)?e:g(e)?A.object(e,t,n):Array.isArray(e)?A.array(e,t):x(e)?A.map(e,t):C(e)?A.set(e,t):typeof e==`object`&&e?e:A.box(e,t)}let ot={box(e,t){let n=Xe(t);return new Et(e,nt(n),n.name,!0,n.equals)},array(e,t){let n=Xe(t);return ri(e,nt(n),n.name)},map(e,t){let n=Xe(t);return new pi(e,nt(n),n.name)},set(e,t){let n=Xe(t);return new vi(e,nt(n),n.name)},object(e,t,n){return Ai(()=>Jn(Hr({},n),e,t))}},st=tt(Qe),ct=tt($e),lt=tt(Ze),ut=tt(et);var A=r(at,Ze,ot);let dt=`computed`;function ft(e){return Je(e,Fe)}let pt=Me(dt),mt=ft(Me(`computed.struct`,{equals:le})),j=function(e,t){if(t&&typeof t.kind==`string`)return Fe(pt,e,t);if(g(e))return ft(Me(dt,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 Ot(r)};r(j,pt);let ht=0,gt=1,_t=i(()=>{},`name`)?.configurable??!1,vt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function yt(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 bt(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),_t&&(vt.value=e,a(o,`name`,vt)),o}function bt(e,t,n,r,i){let a=xt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{St(a)}}function xt(e,t,n,r){let i=vn()&&!!e,a=0;i&&(a=Date.now(),bn({type:F,name:e,object:n,arguments:r?Array.from(r):s}));let o=P.trackingDerivation,c=!t||!o;nn();let l=P.allowStateChanges;c&&(Vt(),l=wt(!0));let u=P.allowStateReads;M(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:gt++,parentActionId_:ht};return ht=d.actionId_,d}function St(e){ht!==e.actionId_&&n(30),ht=e.parentActionId_,e.error_!==void 0&&(P.suppressReactionErrors=!0),Tt(e.prevAllowStateChanges_),Ut(e.prevAllowStateReads_),rn(),e.runAsAction_&&Ht(e.prevDerivation_),e.notifySpy_&&Sn({time:Date.now()-e.startTime_}),P.suppressReactionErrors=!1}function Ct(e,t){let n=wt(e);try{return t()}finally{Tt(n)}}function wt(e){let t=P.allowStateChanges;return P.allowStateChanges=e,t}function Tt(e){P.allowStateChanges=e}var Et=class extends ae{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=de){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&&vn()&&yn({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!==P.UNCHANGED){let n=vn();n&&bn({type:ei,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Sn()}}prepareNewValue_(e){if(Pt(this),Ur(this)){let t=Gr(this,{object:this,type:ei,newValue:e});if(!t)return P.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?P.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),Kr(this)&&Jr(this,{type:ei,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 ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Dt=b(`ObservableValue`,Et);var Ot=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 At(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_=yt(this.name_+`-setter`,e.set)),this.equals_=e.equals||de,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){un(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return E(this.flags_,1)}set isComputing(e){this.flags_=D(this.flags_,1,e)}get isRunningSetter(){return E(this.flags_,2)}set isRunningSetter(e){this.flags_=D(this.flags_,2,e)}get isBeingObserved(){return E(this.flags_,4)}set isBeingObserved(e){this.flags_=D(this.flags_,4,e)}get isPendingUnobservation(){return E(this.flags_,8)}set isPendingUnobservation(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),P.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Mt(this)&&(this.warnAboutUntrackedRead_(),nn(),this.value_=this.computeValue_(!1),rn());else{let e=this.isBeingObserved;if(sn(this),Mt(this)){let e=P.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(P.trackingContext=this),this.trackAndCompute()&&ln(this),P.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(on)}let e=this.value_;if(jt(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||jt(e)||jt(n)||!this.equals_(e,n);return r&&(this.value_=n,vn()&&yn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=wt(!1),n;if(e)n=It(this,this.derivation,this.scope_);else if(P.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new At(e)}return Tt(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(zt(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:P.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 ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let kt=b(`ComputedValue`,Ot);var At=class{constructor(e){this.cause=void 0,this.cause=e}};function jt(e){return e instanceof At}function Mt(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=M(!0),n=Vt(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(kt(i)){if(P.disableErrorBoundaries)i.get();else try{i.get()}catch{return Ht(n),Ut(t),!0}if(e.dependenciesState_===2)return Ht(n),Ut(t),!0}}return Wt(e),Ht(n),Ut(t),!1}}}function Nt(){return P.trackingDerivation!==null}function Pt(e){let t=!!e.observers_&&e.observers_.size>0;!P.allowStateChanges&&(t||P.enforceActions===`always`)&&console.warn(`[MobX] `+(P.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 Ft(e){!P.allowStateReads&&P.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function It(e,t,n){let r=M(!0);Wt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++P.runId;let i=P.trackingDerivation;P.trackingDerivation=e,P.inBatch++;let a;if(P.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new At(e)}return P.inBatch--,P.trackingDerivation=i,Rt(e),Lt(e),Ut(r),a}function Lt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:P.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function Rt(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&&en(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,$t(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function zt(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)en(t[n],e);e.dependenciesState_=-1}function Bt(e){let t=Vt();try{return e()}finally{Ht(t)}}function Vt(){let e=P.trackingDerivation;return P.trackingDerivation=null,e}function Ht(e){P.trackingDerivation=e}function M(e){let t=P.allowStateReads;return P.allowStateReads=e,t}function Ut(e){P.allowStateReads=e}function Wt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Gt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var N=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 Kt=!0,qt=!1,P=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Kt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Kt=!1),Kt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new N):(setTimeout(()=>{qt||n(35)},1),new N)}();function Jt(){if((P.pendingReactions.length||P.inBatch||P.isRunningReactions)&&n(36),qt=!0,Kt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),P=new N}}function Yt(){return P}function Xt(){let e=new N;for(let t in e)Gt.indexOf(t)===-1&&(P[t]=e[t]);P.allowStateChanges=!P.enforceActions}function Zt(e){return!!e.observers_&&e.observers_.size>0}function Qt(e){return e.observers_??new Set}function $t(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function en(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&tn(e))}function tn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,P.pendingUnobservations.push(e))}function nn(){P.inBatch++}function rn(){--P.inBatch===0&&(mn(),!P.isRunningUnobservations&&P.pendingUnobservations.length>0&&an())}function an(){P.isRunningUnobservations=!0;try{let e=P.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 Ot&&n.suspend_())}P.pendingUnobservations=[]}finally{P.isRunningUnobservations=!1}}function on(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(on))}function sn(e){Ft(e);let t=P.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&P.inBatch>0&&tn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&P.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function cn(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 ln(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 un(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 dn=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 E(this.flags_,1)}set isDisposed(e){this.flags_=D(this.flags_,1,e)}get isScheduled(){return E(this.flags_,2)}set isScheduled(e){this.flags_=D(this.flags_,2,e)}get isTrackPending(){return E(this.flags_,4)}set isTrackPending(e){this.flags_=D(this.flags_,4,e)}get isRunning(){return E(this.flags_,8)}set isRunning(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,P.pendingReactions.push(this),mn())}runReaction_(){if(!this.isDisposed){nn(),this.isScheduled=!1;let e=P.trackingContext;if(P.trackingContext=this,Mt(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&vn()&&yn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}P.trackingContext=e,rn()}}track(e){if(this.isDisposed)return;nn();let t=vn(),n;t&&(n=Date.now(),bn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=P.trackingContext;P.trackingContext=this;let i=It(this,e,void 0);P.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&zt(this),jt(i)&&this.reportExceptionInDerivation_(i.cause),t&&Sn({time:Date.now()-n}),rn()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(P.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;P.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),vn()&&yn({type:`error`,name:this.name_,message:t,error:``+e}),P.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(nn(),zt(this),rn())}}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[O]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function fn(e){return P.globalReactionErrorHandlers.push(e),()=>{let t=P.globalReactionErrorHandlers.indexOf(e);t>=0&&P.globalReactionErrorHandlers.splice(t,1)}}let pn=e=>e();function mn(){P.inBatch>0||P.isRunningReactions||pn(hn)}function hn(){P.isRunningReactions=!0;let e=P.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_()}P.isRunningReactions=!1}let gn=b(`Reaction`,dn);function _n(e){let t=pn;pn=n=>e(()=>t(n))}function vn(){return!!P.spyListeners.length}function yn(e){if(!P.spyListeners.length)return;let t=P.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function bn(e){yn(r({},e,{spyReportStart:!0}))}let xn={type:`report-end`,spyReportEnd:!0};function Sn(e){yn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):xn)}function Cn(e){return P.spyListeners.push(e),d(()=>{P.spyListeners=P.spyListeners.filter(t=>t!==e)})}let F=`action`,wn=`autoAction`,Tn=`<unnamed action>`,En=xe(F),Dn=xe(`action.bound`,{bound:!0}),On=xe(wn,{autoAction:!0}),kn=xe(`autoAction.bound`,{autoAction:!0,bound:!0});function An(e){return Je(e,we)}function jn(e){return function(t,r){if(r&&typeof r.kind==`string`)return we(e?On:En,t,r);if(p(t))return yt(t.name||Tn,t,e);if(p(r))return yt(t,r,e);if(m(t))return An(xe(e?wn:F,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Mn=jn(!1);r(Mn,En);let Nn=jn(!0);r(Nn,On);let Pn=An(Dn),Fn=An(kn);function In(e){return bt(e.name||Tn,!1,e,this,void 0)}function Ln(e){return p(e)&&e.isMobxAction===!0}function Rn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),Ln(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 dn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Bn(t),n=!1;o=new dn(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 zn=e=>e();function Bn(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):zn}function Vn(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=Mn(a,r.onError?Hn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Bn(r),d=!0,f=!1,m,h=r.equals||de,_=new dn(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=Ct(!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 Hn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Un(e,t,n){return Gn(`onBO`,e,t,n)}function Wn(e,t,n){return Gn(`onBUO`,e,t,n)}function Gn(e,t,n,r){let i=typeof r==`function`?R(t,n):R(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 Kn=`always`;function qn(e){e.isolateGlobalState===!0&&Jt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Kn?Kn:t===`observed`;P.enforceActions=e,P.allowStateChanges=!(e===!0||e===Kn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(P[t]=!!e[t])}),P.allowStateReads=!P.observableRequiresReaction,P.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&_n(e.reactionScheduler)}function Jn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),mi(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(vr(t)||vr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=re(t);return Ai(()=>{let t=wi(e,i)[O];ee(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Yn(e,t){return Xn(R(e,t))}function Xn(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=$n(e.observing_).map(Xn)),t}function Zn(e,t){return Qn(R(e,t))}function Qn(e){let t={name:e.name_};return Zt(e)&&(t.observers=Array.from(Qt(e),Qn)),t}function $n(e){return Array.from(new Set(e))}let er=0;var tr=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function nr(e){return e instanceof tr}function rr(e){return Je(e,ke)}let ir=k(`flow`),I=k(`flow.bound`,{bound:!0}),ar=r(function(e,t){if(t&&typeof t.kind==`string`)return ke(ir,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=++er,a=Mn(`${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=Mn(`${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=Mn(`${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=Mn(`${i} - runid: ${n} - cancel`,function(){try{s&&sr(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),sr(t),o(new tr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},ir),or=rr(I);function sr(e){p(e.cancel)&&e.cancel()}function cr(e){return e}function lr(e){return e?.isMobXFlow===!0}function ur(e,t,r){let i;if(mi(e)||ui(e)||Dt(e))i=z(e);else if(Di(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=z(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 dr(e,t,n){return p(n)?pr(e,t,n):fr(e,t)}function fr(e,t){return Wr(z(e),t)}function pr(e,t,n){return Wr(z(e,t),n)}function mr(e,t){var n;if(t===void 0)return kt(e);if(Di(e)===!1)return!1;let r=e[O];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?kt(R(e,t)):!1}function hr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):mr(e)}function gr(e,t){return m(t)?mr(e,t):n(`isComputed expected a property name as second argument`)}function _r(e,t){if(!e)return!1;if(t!==void 0){if(mi(e)||ui(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(Di(e)){var r,i;let n=e[O];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return Di(e)||!!e[O]||oe(e)||gn(e)||kt(e)}function vr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),_r(e)}function yr(e,t){return m(t)?_r(e,t):n(`expected a property name as second argument`)}function br(e){if(Di(e))return e[O].keys_();if(mi(e)||yi(e))return Array.from(e.keys());if(ui(e))return e.map((e,t)=>t);n(5)}function xr(e){if(Di(e))return br(e).map(t=>e[t]);if(mi(e))return br(e).map(t=>e.get(t));if(yi(e))return Array.from(e.values());if(ui(e))return e.slice();n(6)}function Sr(e){if(Di(e))return br(e).map(t=>[t,e[t]]);if(mi(e))return br(e).map(t=>[t,e.get(t)]);if(yi(e))return Array.from(e.entries());if(ui(e))return e.map((e,t)=>[t,e]);n(7)}function Cr(e,t,r){if(arguments.length===2&&!yi(e)){nn();let n=t;try{for(let t in n)Cr(e,t,n[t])}finally{rn()}return}Di(e)?e[O].set_(t,r):mi(e)?e.set(t,r):yi(e)?e.add(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),nn(),t>=e.length&&(e.length=t+1),e[t]=r,rn()):n(8)}function wr(e,t){Di(e)?e[O].delete_(t):mi(e)||yi(e)?e.delete(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function Tr(e,t){if(Di(e))return e[O].has_(t);if(mi(e)||yi(e))return e.has(t);if(ui(e))return t>=0&&t<e.length;n(10)}function Er(e,t){if(Tr(e,t)){if(Di(e))return e[O].get_(t);if(mi(e))return e.get(t);if(ui(e))return e[t];n(11)}}function Dr(e,t,r){if(Di(e))return e[O].defineProperty_(t,r);n(39)}function Or(e){if(Di(e))return e[O].ownKeys_();n(38)}function kr(e,t,n,r){return p(n)?jr(e,t,n,r):Ar(e,t,n)}function Ar(e,t,r){let i=z(e);if(ui(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(mi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(yi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(Di(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Mr(i,t,r);return qr(i,t)}function jr(e,t,n,r){return Mr(z(e,t),n,r)}function Mr(e,t,n){if(kt(e)){let r=!0,i;return Rn(()=>{let a=e.get();if(!r||n){let n=Vt();t({observableKind:`computed`,debugObjectName:e.name_,type:ei,object:e,newValue:a,oldValue:i}),Ht(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ei,newValue:e.value_,oldValue:void 0}),qr(e,t)}function Nr(e,t,n){return e.set(t,n),n}function Pr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!vr(e))return e;if(Dt(e)||kt(e))return Pr(e.get(),t);if(t.has(e))return t.get(e);if(ui(e)){let n=Nr(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Pr(e,t)}),n}if(yi(e)){let n=Nr(t,e,new Set);return e.forEach(e=>{n.add(Pr(e,t))}),n}if(mi(e)){let n=Nr(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Pr(e,t))}),n}else{let n=Nr(t,e,{});return Or(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Pr(e[r],t))}),n}}function Fr(e,t){return t&&n(`toJS no longer supports options`),Pr(e,new Map)}function Ir(e,t=void 0){nn();try{return e.apply(t)}finally{rn()}}function Lr(e,t,n){return arguments.length===1||t&&typeof t==`object`?zr(e,t):Rr(e,t,n||{})}function Rr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[O].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=yt(n.name+`-effect`,t);var a=Rn(t=>{Ct(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function zr(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=Rr(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 Br(e){return e[O]}let Vr={has(e,t){return Br(e).has_(t)},get(e,t){return Br(e).get_(t)},set(e,t,n){return m(t)?Br(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Br(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Br(e).defineProperty_(t,n)??!0},ownKeys(e){return Br(e).ownKeys_()},preventExtensions(e){n(13)}};function Hr(e,t){var n;return e=wi(e,t),(n=e[O]).proxy_??(n.proxy_=new Proxy(e,Vr))}function Ur(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function Wr(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 Gr(e,t){let r=Vt();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{Ht(r)}}function Kr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function qr(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 Jr(e,t){let n=Vt(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ht(n)}}function Yr(e,t,n){return Ai(()=>{let r=wi(e,n)[O];ee(t).forEach(e=>Qr(r,e,t[e]))}),e}let Xr=Symbol(`mobx-keys`);function Zr(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),Di(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Jn(e,e,t,r):(Ai(()=>{let n=wi(e,r)[O];if(!e[Xr]){let t=Object.getPrototypeOf(e),n=new Set([...ee(e),...ee(t)]);n.delete(`constructor`),n.delete(O),v(t,Xr,n)}e[Xr].forEach(e=>Qr(n,e,t&&e in t?t[e]:!0))}),e)}function Qr(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;L(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)}Oi(e,r,t)}let $r=`splice`,ei=`update`,ti={get(e,t){let n=e[O];return t===O?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):T(ii,t)?ii[t]:e[t]},set(e,t,n){let r=e[O];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var ni=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 ae(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){Pt(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),Ur(this)){let r=Gr(this,{object:this.proxy_,type:$r,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_&&vn(),i=Kr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ei,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&bn(a),this.atom_.reportChanged(),i&&Jr(this,a),r&&Sn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&vn(),i=Kr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:$r,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&bn(a),this.atom_.reportChanged(),i&&Jr(this,a),r&&Sn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Pt(this.atom_);let r=n[e];if(Ur(this)){let n=Gr(this,{type:ei,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 ri(e,t,n=`ObservableArray@`+u(),r=!1){return Ai(()=>{let i=new ni(n,t,r);y(i.values_,O,i);let a=new Proxy(i.values_,ti);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var ii={clear(){return this.splice(0)},replace(e){let t=this[O];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[O];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[O].spliceWithArray_(e,t,n)},push(...e){let t=this[O];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[O].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[O];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return P.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){P.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[O],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};ai(`at`,oi),ai(`concat`,oi),ai(`flat`,oi),ai(`includes`,oi),ai(`indexOf`,oi),ai(`join`,oi),ai(`lastIndexOf`,oi),ai(`slice`,oi),ai(`toString`,oi),ai(`toLocaleString`,oi),ai(`toSorted`,oi),ai(`toSpliced`,oi),ai(`with`,oi),ai(`every`,si),ai(`filter`,si),ai(`find`,si),ai(`findIndex`,si),ai(`findLast`,si),ai(`findLastIndex`,si),ai(`flatMap`,si),ai(`forEach`,si),ai(`map`,si),ai(`some`,si),ai(`toReversed`,si),ai(`reduce`,ci),ai(`reduceRight`,ci);function ai(e,t){typeof Array.prototype[e]==`function`&&(ii[e]=t(e))}function oi(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function si(e){return function(t,n){let r=this[O];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function ci(e){return function(){let t=this[O];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 li=b(`ObservableArrayAdministration`,ni);function ui(e){return h(e)&&li(e[O])}let di={},fi=`delete`;var pi=class{constructor(e,t=fe,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[O]=di,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,Ai(()=>{this.keysAtom_=se(`${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(!P.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new Et(this.has_(e),me,`${this.name_}.${te(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(Ur(this)){let r=Gr(this,{type:n?ei:`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(Pt(this.keysAtom_),Ur(this)&&!Gr(this,{type:fi,object:this,name:e}))return!1;if(this.has_(e)){let t=vn(),n=Kr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:fi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&bn(r),Ir(()=>{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&&Jr(this,r),t&&Sn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=vn(),i=Kr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ei,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&bn(a),n.setNewValue_(t),i&&Jr(this,a),r&&Sn()}}addValue_(e,t){Pt(this.keysAtom_),Ir(()=>{var n;let r=new Et(t,this.enhancer_,`${this.name_}.${te(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=vn(),r=Kr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&bn(i),r&&Jr(this,i),n&&Sn()}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 hi({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 hi({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 mi(e)&&(e=new Map(e)),Ir(()=>{g(e)?w(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):x(e)?(S(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){Ir(()=>{Bt(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return Ir(()=>{let t=gi(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`}},mi=b(`ObservableMap`,pi);function hi(e){return e[Symbol.toStringTag]=`MapIterator`,Ii(e)}function gi(e){if(x(e)||mi(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 _i={};var vi=class{constructor(e,t=fe,n=`ObservableSet@`+u()){this.name_=void 0,this[O]=_i,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),Ai(()=>{this.atom_=se(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){Ir(()=>{Bt(()=>{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(Pt(this.atom_),Ur(this)){let t=Gr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){Ir(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=vn(),n=Kr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&bn(r),n&&Jr(this,r),t&&Sn()}return this}delete(e){if(Ur(this)&&!Gr(this,{type:fi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=vn(),n=Kr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:fi,object:this,oldValue:e}:null;return t&&bn(r),Ir(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Jr(this,r),t&&Sn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return bi({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 bi({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 yi(e)&&(e=new Set(e)),Array.isArray(e)||C(e)?Ir(()=>{let t=C(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`}},yi=b(`ObservableSet`,vi);function bi(e){return e[Symbol.toStringTag]=`SetIterator`,Ii(e)}let xi=Object.create(null),Si=`remove`;var Ci=class{constructor(e,t=new Map,r,i=He){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 ae(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Ri(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 Ot)return n.set(t),!0;if(Ur(this)){let n=Gr(this,{type:ei,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=Kr(this),i=vn(),a=r||i?{type:ei,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&bn(a),n.setNewValue_(t),r&&Jr(this,a),i&&Sn()}return!0}get_(e){return P.trackingDerivation&&!T(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return T(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(!P.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new Et(e in this.target_,me,`${this.name_}.${te(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);L(this,n,e);let i=n.extend_(this,e,t,r);return i&&Oi(this,n,e),i}defineProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Ur(this)){let n=Gr(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{rn()}return!0}defineObservableProperty_(e,t,n,r=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Ur(this)){let n=Gr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=Ei(e),s={configurable:P.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 Et(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{rn()}return!0}defineComputedProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let r=this.delete_(e);if(!r)return r;if(Ur(this)&&!Gr(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=Ei(e),o={configurable:P.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 Ot(t)),this.notifyPropertyAddition_(e,void 0)}finally{rn()}return!0}delete_(e,t=!1){if(Pt(this.keysAtom_),!T(this.target_,e))return!0;if(Ur(this)&&!Gr(this,{object:this.proxy_||this.target_,name:e,type:Si}))return null;try{var n;nn();let r=Kr(this),a=vn(),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 Et&&(s=o.value_),cn(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Si,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&bn(t),r&&Jr(this,t),a&&Sn()}}finally{rn()}return!0}notifyPropertyAddition_(e,t){var n;let r=Kr(this),i=vn();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&&bn(n),r&&Jr(this,n),i&&Sn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),ee(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function wi(e,t){if(t&&Di(e)&&n(`Options can't be provided for already observable objects.`),T(e,O))return z(e)instanceof Ci||n(`Cannot convert '${ki(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,O,new Ci(e,new Map,String(r),rt(t))),e}let Ti=b(`ObservableObjectAdministration`,Ci);function Ei(e){return xi[e]||(xi[e]={get(){return this[O].getObservablePropValue_(e)},set(t){return this[O].setObservablePropValue_(e,t)}})}function Di(e){return h(e)?Ti(e[O]):!1}function Oi(e,t,n){e.appliedAnnotations_[n]=t}function L(e,t,r){if(Ri(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!ve(t)&&T(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 R(e,t){if(typeof e==`object`&&e){if(ui(e))return t!==void 0&&n(23),e[O].atom_;if(yi(e))return e.atom_;if(mi(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,ki(e)),r}if(Di(e)){if(!t)return n(26);let r=e[O],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,ki(e)),i}if(oe(e)||kt(e)||gn(e))return e}else if(p(e)&&gn(e[O]))return e[O];n(28)}function z(e,t){if(e||n(29),t!==void 0)return z(R(e,t));if(oe(e)||kt(e)||gn(e)||mi(e)||yi(e))return e;if(e[O])return e[O];n(24,e)}function ki(e,t){let n;if(t!==void 0)n=R(e,t);else if(Ln(e))return e.name;else n=Di(e)||mi(e)||yi(e)?z(e):R(e);return n.name_}function Ai(e){let t=Vt(),n=wt(!0);nn();try{return e()}finally{rn(),Tt(n),Ht(t)}}let ji=o.toString;function Mi(e,t,n=-1){return Ni(e,t,n)}function Ni(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=ji.call(e);if(o!==ji.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=Pi(e),t=Pi(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(!Ni(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(!(T(t,o)&&Ni(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function Pi(e){return ui(e)?e.slice():x(e)||mi(e)||C(e)||yi(e)?Array.from(e.entries()):e}let Fi=globalThis.Iterator?.prototype||{};function Ii(e){return e[Symbol.iterator]=Li,r(Object.create(Fi),e)}function Li(){return this}function Ri(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:Cn,extras:{getDebugName:ki},$mobx:O}),e.$mobx=O,e.FlowCancellationError=tr,e.ObservableMap=pi,e.ObservableSet=vi,e.Reaction=dn,e._allowStateChanges=Ct,e._allowStateChangesInsideComputed=In,e._allowStateReadsEnd=Ut,e._allowStateReadsStart=M,e._autoAction=Nn,e._autoActionBound=Fn,e._endAction=St,e._getAdministration=z,e._getGlobalState=Yt,e._interceptReads=ur,e._isComputingDerivation=Nt,e._resetGlobalState=Xt,e._startAction=xt,e.action=Mn,e.actionBound=Pn,e.autorun=Rn,e.compareDefault=de,e.compareIdentity=ce,e.compareShallow=ue,e.compareStructural=le,e.computed=j,e.computedStruct=mt,e.configure=qn,e.createAtom=se,e.defineProperty=Dr,e.entries=Sr,e.extendObservable=Jn,e.flow=ar,e.flowBound=or,e.flowResult=cr,e.get=Er,e.getAtom=R,e.getDebugName=ki,e.getDependencyTree=Yn,e.getObserverTree=Zn,e.has=Tr,e.intercept=dr,e.isAction=Ln,e.isBoxedObservable=Dt,e.isComputed=hr,e.isComputedProp=gr,e.isFlow=lr,e.isFlowCancellationError=nr,e.isObservable=vr,e.isObservableArray=ui,e.isObservableMap=mi,e.isObservableObject=Di,e.isObservableProp=yr,e.isObservableSet=yi,e.keys=br,e.makeAutoObservable=Zr,e.makeObservable=Yr,e.observable=A,e.observableDeep=lt,e.observableRef=st,e.observableShallow=ct,e.observableStruct=ut,e.observe=kr,e.onBecomeObserved=Un,e.onBecomeUnobserved=Wn,e.onReactionError=fn,e.override=_e,e.ownKeys=Or,e.reaction=Vn,e.remove=wr,e.runInAction=In,e.set=Cr,e.spy=Cn,e.toJS=Fr,e.transaction=Ir,e.untracked=Bt,e.values=xr,e.when=Lr})),Cv=we(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=xv():t.exports=Sv()}))();function wv(e){if(Array.isArray(e))return Object.freeze(e.map(wv));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]=wv(r);return Object.freeze(t)}return e}function Tv(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 Ev(e){return typeof e==`string`?e:String(e)}function Dv(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 Ov(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 kv=class extends Error{constructor(e,t){super(t),this.variable=e}};function Av(e){return e instanceof kv||e instanceof Error&&e.cause!==void 0&&Av(e.cause)}var jv=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?Bv(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}},Mv=class extends jv{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},Nv=class extends jv{name=`EvalError`;kind=`EvalError`},Pv=class extends Nv{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=Vv(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}},Fv=class extends Nv{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}},Iv=class extends Nv{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}},Lv=class extends Iv{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)}`}},Rv=class extends Nv{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},zv=class extends Nv{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function Bv(e,t){let n=e.split(`
57
+ `))}function Cg(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:o,failedConfigFile:s}=t,c=new U({bgcolor:i.bg,color:i.fg}),l=(e,t)=>new K(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: ${Dp(o.reason)}`,c)]:[],d=s===null?[]:[l(`${u.length>0?` · `:``}open `,c),l(Dp(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=K.fromFragments([...f,...m]).truncate(r.width);return h.overflow=`ignore`,dg([h],r)}const wg=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Tg(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function Eg(e,t,n=wg){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=v.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Eg(e,r):[[v.relative(e,r).split(v.sep).join(`/`),Tg(r,i)]]})}function Dg(e){let t=O.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Og(e){return Dg(Eg(e,e))}const kg=[`Cargo.toml`,`Cargo.lock`,`src`];function Ag(e){return Dg(Eg(e,e,e=>kg.includes(e)))}const jg=e=>e.slice(0,7);function Mg(e){let t=v.dirname(v.dirname(e));return s.existsSync(v.join(t,`src`))?t:null}function Ng(){let e=Pg();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:Ft,digest:e}}function Pg(){return`58fb412fc680e35119c19f3043e3699a74097ca5ec9a391337495f3a3aa98527`}function Fg(e){let t=JSON.parse(s.readFileSync(v.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${v.join(e,`package.json`)} has no version string`);return n}function Ig(e,t){try{let n=Mg(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Og(v.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:Fg(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}var q=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const Lg=new Map;function Rg(e){let t=Bg(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 zg(e,t){return e===`bar`?t:Rg(e)}function Bg(e){let t=Lg.get(e);if(t!==void 0)return t;let n=Sc(e);return n===null?null:(Lg.set(e,n),n)}function Vg(e,t){return Hg(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>Pc(e,t))}const Hg=Lp();function Ug(e){let t=Bg(e);return t===null?null:{kind:`decided`,name:e,value:t}}function Wg(e,t,n){let r=Ug(e);return r===null?(n(fh(t,`palette`,`"${e}" names no installed theme${Jm(e)}`)),Kg()):r}function Gg(e,t,n){return ih(e,t,n,Kg(),Ug)}function Kg(){return{kind:`decided`,name:Ym,value:Rg(Ym)}}const qg=[`vertical`,`horizontal`],Jg={vertical:`row`,horizontal:`cell`};function Yg(e){return e.id??e.name}function Xg(e){return[...$g(e)].flatMap(e=>e.kind===`segment`?[Yg(e)]:[])}function Zg(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function Qg(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 r_(e))yield*$g(t)}const e_=(e,t)=>`${e}.children[${t}]`,t_=e=>`${e}.opens.body`;function*n_(e,t){if(yield[e,t],e.kind===`container`)for(let[n,r]of e.children.entries())yield*n_(r,e_(t,n));else e.opens!==void 0&&(yield*n_(e.opens.body,t_(t)))}function r_(e){return e.kind===`container`?e.children:e.opens===void 0?[]:[e.opens.body]}const i_=[`shade`,`variation`,`style`];function a_(e){return e===void 0||`text`in e?`text`:`regex`in e?`regex`:`json`}const o_=[`ttl`,`watch_file`,`depends_on`,`key`,`never`];function s_(e){return e.kind===`file`||e.kind===`shell`}const c_=[`branch`,`sha`,`dirty`,`ahead`,`behind`,`stash`],l_=[`fail`,`ignore`];function u_(e){return e.missingData??`fail`}function*d_(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 f_=`theme`,p_=`effect`,m_=[f_,p_];function h_(e){return{...e.settings,[f_]:{label:f_,domain:`theme`,default:e.palette??`bar`},[p_]:{label:p_,domain:mh,default:`bar`}}}function g_(e){let t=e?.domain;return typeof t==`object`&&`min`in t?t:void 0}function __(e,t){return Object.entries(e).flatMap(([n,r])=>{let i=g_(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 v_(e,t){let{domain:n}=e;return n===`bool`?typeof t==`boolean`:n===`theme`?typeof t==`string`&&eh(t):`min`in n?typeof t==`number`&&Number.isInteger(t)&&t>=n.min&&t<=n.max:typeof t==`string`&&n.includes(t)}function y_(e){return String(e)}function b_(e,t){let{domain:n}=e;if(typeof n==`object`&&`min`in n)return Ih(t,n)??void 0;let r=n===`bool`?t===`true`?!0:t===`false`?!1:t:t;return v_(e,r)?r:void 0}function x_(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:b_(n,o))??i}function S_(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 C_=[`left`,`center`,`right`],w_=[`right`,`left`,`middle`],T_=/^[A-Za-z_][A-Za-z0-9_]*$/;function E_(e){return`#${e+1}`}const D_={rows:{}};function O_(e){return`rows`in e}function k_(e){return Object.fromEntries(e.map((e,t)=>[E_(t),e]))}function A_(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:k_(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:k_([n])}}function j_(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function M_(e){return O_(e)?j_(e):e}function*N_(e,t){if(!O_(e)){yield*n_(e,t);return}yield[j_(e),t];for(let[n,r]of Object.entries(e.rows))yield*n_(r,`${t}.rows.${n}`)}function P_(e,t){return O_(e)?{...t,...e,rows:{...t.rows,...e.rows}}:A_(e)}function F_(e){if(!O_(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const I_=`default`,L_={};function R_(e){return[...new Set([I_,...Object.keys(e)])]}function z_(e,t,n){return th(void 0,e,t,I_,n)}function B_(e,t){let n={[I_]:L_,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${I_}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function V_(e,t){let n=B_(e.presets,t).root??D_;return{node:j_(P_(n,e.root)),path:F_(n)?`presets.${t}.root`:`root`}}function H_(e,t){return{...e.globals,...B_(e.presets,t).globals}}const U_=new Map;function W_(e,t,n){U_.set(e,{permanent:!0,resolve:t,paletteOf:n})}W_(`themes`,()=>Zm(),e=>Rg(e));const G_=`placementThemes`;W_(G_,Qm,(e,t)=>zg(e,t.palette)),W_(`endcaps`,()=>vh),W_(`variations`,()=>Th),W_(`shades`,()=>Oh),W_(`colorCompatibilities`,()=>Ch);function K_(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>Vg(n.basePalette,e.styles[t])}],[`presets`,{members:R_(e.presets)}]])}function q_(e){return[...new Set([...U_.keys(),...e.keys()])]}function J_(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=U_.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(X_(e,t))}const Y_=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function X_(e,t){let n=Y_.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${q_(t).join(`, `)})`}const Z_=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*Q_(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 $_=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,ev=RegExp(`^(?:(\\$)(?:\\.(${$_}))?|\\.(${$_})?)(?=[\\s)]|$)`);function tv(e,t,n){let r=ev.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 nv=/^(\w+)\b\s*([\s\S]*)$/;function*rv(e,t){let n=[t];for(let r of Q_(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=nv.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:tv(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(tv(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const iv=/(?<![.$])\btemplate\s+$/;function*av(e,t,n){let r=0;for(let i of[...e.matchAll(Z_)]){let a=i.index+i[0].length;iv.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:tv(e.slice(a),t,n)}),r=a}}function*ov(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...rv(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...av(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 sv=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${$_})`,`g`);function*cv({code:e,dot:t,root:n}){let r=e.replace(Z_,``);for(let e of[...r.matchAll(sv)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function lv(e,t){let n=new Map;for(let r of ov(e,t))for(let e of cv(r))n.has(e)||n.set(e,r.via);return n}const uv=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,dv={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*fv(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(Z_)]){let o=e.slice(t,a.index),s=uv.exec(o);if(s!==null)n=dv[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 pv(e,t){let n=new Map;for(let{code:r,via:i}of ov(e,t))for(let{name:e,site:t}of fv(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function mv(e,t){return new Set([...hv(e,t)].filter(e=>Object.hasOwn(t,e)))}function hv(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of ov(e,t))for(let{name:e}of av(r,i,a))n.add(e);return n}function gv(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 _v(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),vv(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 vv(e){return e.kind===`dropped`||(e.kind===`shell`||e.kind===`file`)&&a_(e.parse)===`json`}function yv(e){let t=v.basename(e),n=v.dirname(e);for(;;){let r=bv(n);if(r!==null)return{dir:r,name:t,leaf:n===v.dirname(e)};t=v.basename(n),n=v.dirname(n)}}function bv(e){try{return s.statSync(e).isDirectory()?s.realpathSync(e):null}catch{return null}}var xv=we((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()===zt}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){Ft(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 It.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=Bt,n=Bt){let r=new Ut(e);return t!==Bt&&(r.onBOL=new Set([t])),n!==Bt&&(r.onBUOL=new Set([n])),r}function _(e,t){return Ot(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||$e(e)?e:Array.isArray(e)?an.array(e,{name:n}):o(e)?an.object(e,void 0,{name:n}):u(e)?an.map(e,{name:n}):d(e)?an.set(e,{name:n}):typeof e!=`function`||He(e)||Xe(e)?e:s(e)?Un(e):Fn(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:x,u:S}}function x(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:He(n.value)?1:(Ft(r,t,w(e,this,t,n,!1)),2)}function S(e,t,n,r){let i=w(e,this,t,n);return e.l(t,i,r)}function C(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return _e(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return He(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(He(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 w(e,t,n,r,i=F.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:_e(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 ee(e,t){return{t:e,i:t,o:te,u:ne}}function te(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)||!Xe(e.h[t]))&&this.u(e,t,n,!1)===null?0:Xe(n.value)?1:(Ft(r,t,re(e,0,0,n,!1,!1)),2)}function ne(e,t,n,r){let i=re(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function T(e,t,n){var r;let{name:i,addInitializer:a}=n;return Xe(t)||(t=Un(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 re(e,t,n,r,i,a=F.safeDescriptors){let{value:o}=r;return Xe(o)||(o=Un(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function E(e,t){return{t:e,i:t,o:D,u:ie}}function D(e,t,n){return this.u(e,t,n,!1)===null?0:1}function ie(e,t,n,r){return e.m(t,Nt({},this.i,{get:n.get,set:n.set}),r)}function O(e,t,n){function r(e){let n=Nt({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new _n(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=xt(this)[M],n=this,i=e.j.get(a);i instanceof _n&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[M],n=e.j.get(a);if(n instanceof _n&&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 ae(e,t){return{t:e,i:t,o:oe,u:se}}function oe(e,t,n){return this.u(e,t,n,!1)===null?0:1}function se(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function ce(e,t,n){function r(e,t){let n=xt(e)[M];return(n.V??=new Map).set(o,()=>new hn(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[M]??r(this,t.get.call(this)))._(o)},set(e){return(this[M]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function le(e){return{t:Kt,i:e,o:ue,u:de}}function ue(e,t,n,r){var i,a,o;if(n.get)return ln.o(e,t,n,r);if(n.set){let i=He(n.set)?n.set:_e(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!F.safeDescriptors||e.p,set:i})===null?0:2:(Ft(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?Wn:Un).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?Ln:Fn).o(e,t,n,r);let c=!1===this.i?.deep?en:an;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 de(e,t,n,r){var i;return n.get?ln.u(e,t,n,r):n.set?e.l(t,{configurable:!F.safeDescriptors||e.p,set:_e(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?en:an).u(e,t,n,r))}function fe(e,t){return Nt(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function pe(e){return e||Jt}function me(e){return fe(e,ce)}function he(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 ge(e){return fe(e,O)}function _e(e,t,n=!1,r){function i(){return ve(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),pn&&(mn.value=e,Ft(i,`name`,mn)),i}function ve(e,t,n,r,i){let a=ye(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{be(a)}}function ye(e,t){let n=F.trackingDerivation,r=!t||!n;Me();let i=F.allowStateChanges;r&&k();let a={R:r,k:n,C:i,I:F.allowStateReads,P:!1,T:0,B:fn++,D:dn};return dn=a.B,a}function be(e){dn!==e.B&&t(30),dn=e.D,e.N!==void 0&&(F.suppressReactionErrors=!0),Ne(),e.R&&De(e.k),F.suppressReactionErrors=!1}function xe(e,t){let n=function(e){let t=F.allowStateChanges;return F.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){F.allowStateChanges=e})(n)}}function Se(e){return e instanceof yn}function Ce(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=k(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(vn(r)){if(F.disableErrorBoundaries)r.get();else try{r.get()}catch{return De(t),!0}if(e.K===2)return De(t),!0}}return Oe(e),De(t),!1}}}function we(e,t,n){Oe(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++F.runId;let r=F.trackingDerivation,i;if(F.trackingDerivation=e,F.inBatch++,!0===F.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new yn(e)}return F.inBatch--,F.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&&Ae(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,ke(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function Te(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Ae(t[n],e);e.K=-1}function Ee(e){let t=k();try{return e()}finally{De(t)}}function k(){let e=F.trackingDerivation;return F.trackingDerivation=null,e}function De(e){F.trackingDerivation=e}function Oe(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function ke(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Ae(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&je(e))}function je(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,F.pendingUnobservations.push(e))}function Me(){F.inBatch++}function Ne(){--F.inBatch===0&&(Le(),!F.isRunningUnobservations&&F.pendingUnobservations.length>0&&function(){F.isRunningUnobservations=!0;try{let e=F.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 _n&&n.G())}F.pendingUnobservations=[]}finally{F.isRunningUnobservations=!1}}())}function Pe(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Pe))}function Fe(e){let t=F.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&F.inBatch>0&&je(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&F.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Ie(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 Le(){F.inBatch>0||F.isRunningReactions||En(Re)}function Re(){F.isRunningReactions=!0;let e=F.pendingReactions,t=0;for(;e.length>0;){++t===Tn&&(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()}F.isRunningReactions=!1}function ze(e){return fe(e,C)}function Be(e){return function(t,n){return n&&typeof n.kind==`string`?C(e?Mn:An,t,n):r(t)?_e(t.name||`<unnamed action>`,t,e):r(n)?_e(t,n,e):i(t)?ze(b(e?kn:On,{name:t,autoAction:e})):void 0}}function Ve(e){return ve(0,!1,e,this,void 0)}function He(e){return r(e)&&!0===e.isMobxAction}function Ue(e,t=Rt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=We(t),r=!1;a=new wn(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new wn(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 We(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Rn}function Ge(e,t,n,i){let a=typeof i==`function`?wt(t,n):wt(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 Ke(e,t,n,r){let i=Ht(t);return Dt(()=>{let t=xt(e,r)[M];Vt(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function qe(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(qe)),t}function Je(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),Je)),t}function Ye(e){r(e.cancel)&&e.cancel()}function Xe(e){return!0===e?.isMobXFlow}function Ze(e,t){var n;if(t===void 0)return vn(e);if(!1===Ct(e))return!1;let r=e[M];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?vn(wt(e,t)):!1}function Qe(e,t){if(!e)return!1;if(t!==void 0){if(Ct(e)){var n,r;let i=e[M];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return Ct(e)||!!e[M]||Wt(e)||Dn(e)||vn(e)}function $e(e){return Qe(e)}function et(e){return Ct(e)?e[M].nt():nr(e)||I(e)?Array.from(e.keys()):vt(e)?e.map((e,t)=>t):void t(5)}function tt(e,n){return Ct(e)?e[M].et(n):nr(e)||I(e)?e.has(n):vt(e)?n>=0&&n<e.length:void t(10)}function nt(e){if(Ct(e))return e[M].it();t(38)}function rt(e,t,n){if(vn(e)){let r,i=!0;return Ue(()=>{let a=e.get();if(!i||n){let n=k();t({observableKind:`computed`,debugObjectName:e.tt,type:Jn,object:e,newValue:a,oldValue:r}),De(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Jn,newValue:e.rt,oldValue:void 0}),ft(e,t)}function it(e,t,n){return e.set(t,n),n}function at(e,t){if(typeof e!=`object`||!e||e instanceof Date||!$e(e))return e;if(gn(e)||vn(e))return at(e.get(),t);if(t.has(e))return t.get(e);if(vt(e)){let n=it(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=at(e,t)}),n}if(I(e)){let n=it(t,e,new Set);return e.forEach(e=>{n.add(at(e,t))}),n}if(nr(e)){let n=it(t,e,new Map);return e.forEach((e,r)=>{n.set(r,at(e,t))}),n}{let n=it(t,e,{});return nt(e).forEach(r=>{It.propertyIsEnumerable.call(e,r)&&(n[r]=at(e[r],t))}),n}}function ot(e,t){Me();try{return e.apply(t)}finally{Ne()}}function st(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[M].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=_e(`When-effect`,t);var a=Ue(t=>{xe(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function ct(e){return e[M]}function lt(e){return e.st!==void 0&&e.st.length>0}function ut(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 A(e,n){let r=k();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{De(r)}}function dt(e){return e.ot!==void 0&&e.ot.length>0}function ft(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 pt(e,t){let n=k(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);De(n)}}function mt(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!==It;){let t=Pt(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 j(e,t){typeof Array.prototype[e]==`function`&&(Zn[e]=t(e))}function ht(e){return function(){let t=this[M];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function gt(e){return function(t,n){let r=this[M];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function _t(e){return function(){let t=this[M];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 vt(e){return a(e)&&Qn(e[M])}function yt(e){return e[Symbol.toStringTag]=`MapIterator`,jt(e)}function bt(e){return e[Symbol.toStringTag]=`SetIterator`,jt(e)}function xt(e,t){if(p(e,M))return e;let n=t?.name??`ObservableObject`;return c(e,M,new sr(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 P[r]??(P[r]=le({deep:t,autoBind:n}))}(e):void 0}(t))),e}function St(e){return ar[e]||(ar[e]={get(){return this[M]._(e)},set(t){return this[M].M(e,t)}})}function Ct(e){return!!a(e)&&cr(e[M])}function wt(e,n){if(typeof e==`object`&&e){if(vt(e))return n!==void 0&&t(23),e[M].ct;if(I(e))return e.ct;if(nr(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,Et(e)),r}if(Ct(e)){if(!n)return t(26);let r=e[M],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,Et(e)),i}if(Wt(e)||vn(e)||Dn(e))return e}else if(r(e)&&Dn(e[M]))return e[M];t(28)}function Tt(e,n){return e||t(29),n===void 0?Wt(e)||vn(e)||Dn(e)||nr(e)||I(e)?e:e[M]?e[M]:void t(24,e):Tt(wt(e,n))}function Et(e,t){let n;if(t!==void 0)n=wt(e,t);else{if(He(e))return e.name;n=Ct(e)||nr(e)||I(e)?Tt(e):wt(e)}return n.tt}function Dt(e){let t=k();Me();try{return e()}finally{Ne(),De(t)}}function Ot(e,t,n=-1){return kt(e,t,n)}function kt(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=lr.call(e);if(s!==lr.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=At(e),t=At(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(!kt(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)||!kt(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function At(e){return vt(e)?e.slice():u(e)||nr(e)||d(e)||I(e)?Array.from(e.entries()):e}function jt(e){return e[Symbol.iterator]=Mt,Nt(Object.create(ur),e)}function Mt(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let Nt=Object.assign,Pt=Object.getOwnPropertyDescriptor,Ft=Object.defineProperty,It=Object.prototype,Lt=[];Object.freeze(Lt);let Rt={};Object.freeze(Rt);let zt=Object.toString(),Bt=()=>{},Vt=Reflect.ownKeys,Ht=Object.getOwnPropertyDescriptors,M=Symbol(`mobx administration`);var Ut=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 Fe(this)}reportChanged(){Me(),Ie(this),Ne()}toString(){return this.tt}};let Wt=l(`Atom`,Ut),Gt=Object.is,N={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},Kt=`true`,qt=le(),P=[qt],Jt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Jt);let Yt=ae(`observable`),Xt=ae(`observable.ref`,{A:y}),Zt=ae(`observable.shallow`,{A:function(e,t,n){return e==null||Ct(e)||vt(e)||nr(e)||I(e)?e:Array.isArray(e)?an.array(e,{name:n,deep:!1}):o(e)?an.object(e,void 0,{name:n,deep:!1}):u(e)?an.map(e,{name:n,deep:!1}):d(e)?an.set(e,{name:n,deep:!1}):void 0}}),Qt=ae(`observable.struct`,{A:function(e,t){return Ot(e,t)?t:e}}),$t={box(e,t){let n=pe(t);return new hn(e,he(n),n.name,!0,n.equals)},array(e,t){let n=pe(t);return function(e,t,n=`ObservableArray`,r=!1){return Dt(()=>{let i=new Xn(n,t,r);Ft(i.j,M,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Yn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,he(n),n.name)},map(e,t){let n=pe(t);return new tr(e,he(n),n.name)},set(e,t){let n=pe(t);return new ir(e,he(n),n.name)},object:(e,t,n)=>Dt(()=>Ke(function(e,t){var n;return(n=(e=xt(e,t))[M]).v??(n.v=new Proxy(e,Gn))}({},n),e,t))},en=me(Xt),tn=me(Zt),nn=me(Yt),rn=me(Qt);var an=Nt(function(e,t,n){return t&&typeof t.kind==`string`?ce(Yt,e,t):$e(e)?e:o(e)?an.object(e,t,n):Array.isArray(e)?an.array(e,t):u(e)?an.map(e,t):d(e)?an.set(e,t):typeof e==`object`&&e?e:an.box(e,t)},Yt,$t);let on=`computed`,sn=E(on),cn=ge(E(`computed.struct`,{equals:_})),ln=function(e,t){if(t&&typeof t.kind==`string`)return O(sn,e,t);if(o(e))return ge(E(on,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new _n(n)};var un;Nt(ln,sn);let dn=0,fn=1,pn=(un=Pt(()=>{},`name`)?.configurable)!=null&&un,mn={value:`action`,configurable:!0,writable:!1,enumerable:!1};var hn=class extends Ut{constructor(e,t,n=`ObservableValue`,r=!0,i=Gt){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))!==F.UNCHANGED&&this.Ot(e)}jt(e){if(lt(this)){let t=A(this,{object:this,type:Jn,newValue:e});if(!t)return F.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?F.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),dt(this)&&pt(this,{type:Jn,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 gn=l(`ObservableValue`,hn);var _n=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 yn(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=_e(`ComputedValue-setter`,e.set)),this.xt=e.equals||Gt,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),F.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Fe(this),Ce(this)){let e=F.trackingContext;e||!this.Mt&&!this.isBeingObserved||(F.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),F.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Pe)}else Ce(this)&&(this.Nt(),Me(),this.rt=this.Rt(!1),Ne());let e=this.rt;if(Se(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||Se(e)||Se(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=we(this,this.derivation,this.At);else if(!0===F.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new yn(e)}return this.isComputing=!1,t}G(){this.Mt||(Te(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let vn=l(`ComputedValue`,_n);var yn=class{constructor(e){this.cause=void 0,this.cause=e}};let bn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var xn=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 Sn=!0,Cn=!1,F=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Sn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Sn=!1),Sn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new xn):(setTimeout(()=>{Cn||t(35)},1),new xn)}();var wn=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,F.pendingReactions.push(this),Le())}X(){if(!this.isDisposed){Me(),this.isScheduled=!1;let e=F.trackingContext;if(F.trackingContext=this,Ce(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}F.trackingContext=e,Ne()}}track(e){if(this.isDisposed)return;Me(),this.isRunning=!0;let t=F.trackingContext;F.trackingContext=this;let n=we(this,e,void 0);F.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Te(this),Se(n)&&this.Pt(n.cause),Ne()}Pt(e){if(this.kt)this.kt(e,this);else{if(F.disableErrorBoundaries)throw e;F.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),F.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(Me(),Te(this),Ne()))}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[M]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let Tn=100,En=e=>e(),Dn=l(`Reaction`,wn),On=`action`,kn=`autoAction`,An=b(On),jn=b(`action.bound`,{bound:!0}),Mn=b(kn,{autoAction:!0}),Nn=b(`autoAction.bound`,{autoAction:!0,bound:!0}),Pn=Be(!1);Nt(Pn,An);let Fn=Be(!0);Nt(Fn,Mn);let In=ze(jn),Ln=ze(Nn),Rn=e=>e(),zn=`always`;var Bn=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Vn=ee(`flow`),Hn=ee(`flow.bound`,{bound:!0}),Un=Nt(function(e,t){if(t&&typeof t.kind==`string`)return T(Vn,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=Pn(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=Pn(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=Pn(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=Pn(i,function(){try{o&&Ye(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Bt,Bt),Ye(n),a(new Bn)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Vn),Wn=fe(Hn,T),Gn={has:(e,t)=>ct(e).et(t),get:(e,t)=>ct(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=ct(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=ct(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=ct(e).l(t,n))==null||r},ownKeys:e=>ct(e).it(),preventExtensions(e){t(13)}},Kn=Symbol(`mobx-keys`),qn=`splice`,Jn=`update`,Yn={get(e,t){let n=e[M];return t===M?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p(Zn,t)?Zn[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[M];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var Xn=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 Ut(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=Lt),lt(this)){let r=A(this,{object:this.v,type:qn,index:e,removedCount:t,added:n});if(!r)return Lt;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=dt(this),i=r?{observableKind:`array`,object:this.v,type:Jn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&pt(this,i)}Ft(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:qn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&pt(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(lt(this)){let n=A(this,{type:Jn,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)}}},Zn={clear(){return this.splice(0)},replace(e){let t=this[M];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[M];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[M].wt(e,t,n)},push(...e){let t=this[M];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[M].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[M];return t.wt(0,0,e),t.j.length},reverse(){return F.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){F.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[M],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};j(`at`,ht),j(`concat`,ht),j(`flat`,ht),j(`includes`,ht),j(`indexOf`,ht),j(`join`,ht),j(`lastIndexOf`,ht),j(`slice`,ht),j(`toString`,ht),j(`toLocaleString`,ht),j(`toSorted`,ht),j(`toSpliced`,ht),j(`with`,ht),j(`every`,gt),j(`filter`,gt),j(`find`,gt),j(`findIndex`,gt),j(`findLast`,gt),j(`findLastIndex`,gt),j(`flatMap`,gt),j(`forEach`,gt),j(`map`,gt),j(`some`,gt),j(`toReversed`,gt),j(`reduce`,_t),j(`reduceRight`,_t);let Qn=l(`ObservableArrayAdministration`,Xn),$n={},er=`delete`;var tr=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[M]=$n,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,Dt(()=>{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(!F.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new hn(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(lt(this)){let r=A(this,{type:n?Jn:`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(lt(this)&&!A(this,{type:er,object:this,name:e}))return!1;if(this.et(e)){let t=dt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:er,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return ot(()=>{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&&pt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Jn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}}Jt(e,t){ot(()=>{var n;let r=new hn(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=dt(this);n&&pt(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 yt({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 yt({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 nr(e)&&(e=new Map(e)),ot(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>It.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(){ot(()=>{Ee(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return ot(()=>{let n=function(e){if(u(e)||nr(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`}},nr=l(`ObservableMap`,tr);let rr={};var ir=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[M]=rr,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),Dt(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){ot(()=>{Ee(()=>{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(lt(this)){let t=A(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){ot(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=dt(this);t&&pt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(lt(this)&&!A(this,{type:er,object:this,oldValue:e}))return!1;if(this.has(e)){let t=dt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:er,object:this,oldValue:e}:null;return ot(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return bt({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 bt({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 I(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?ot(()=>{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`}},I=l(`ObservableSet`,ir);let ar=Object.create(null),or=`remove`;var sr=class{constructor(e,t=new Map,n,r=qt){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 Ut(`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 _n)return n.set(t),!0;if(lt(this)){let n=A(this,{type:Jn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{type:Jn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}return!0}Tt(e){return F.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(!F.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new hn(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{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)){let n=A(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=Nt({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else Ft(this.h,e,t);this.Yt(e,t.value)}finally{Ne()}return!0}S(e,t,n,r=!1){try{Me();let i=this.Dt(e);if(!i)return i;if(lt(this)){let n=A(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=St(e),o={configurable:!F.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else Ft(this.h,e,o);let s=new hn(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Ne()}return!0}m(e,t,n=!1){try{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)&&!A(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=St(e),a={configurable:!F.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else Ft(this.h,e,a);this.j.set(e,new _n(t)),this.Yt(e,void 0)}finally{Ne()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(lt(this)&&!A(this,{object:this.v||this.h,name:e,type:or}))return null;try{var n;Me();let r=dt(this),i=this.j.get(e),a;if(i||!r||(a=Pt(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 hn&&(a=i.rt),Ie(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&pt(this,{type:or,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Ne()}return!0}Yt(e,t){var n;let r=dt(this);r&&r&&pt(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(),Vt(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let cr=l(`ObservableObjectAdministration`,sr),lr=It.toString,ur=globalThis.Iterator?.prototype||{};e.$mobx=M,e.FlowCancellationError=Bn,e.ObservableMap=tr,e.ObservableSet=ir,e.Reaction=wn,e._allowStateChanges=xe,e._allowStateChangesInsideComputed=Ve,e._allowStateReadsEnd=function(e){F.allowStateReads=e},e._allowStateReadsStart=function(e){let t=F.allowStateReads;return F.allowStateReads=e,t},e._autoAction=Fn,e._autoActionBound=Ln,e._endAction=be,e._getAdministration=Tt,e._getGlobalState=function(){return F},e._interceptReads=function(e,t,n){let r;return nr(e)||vt(e)||gn(e)?r=Tt(e):Ct(e)&&(r=Tt(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return F.trackingDerivation!==null},e._resetGlobalState=function(){let e=new xn;for(let t in e)bn.indexOf(t)===-1&&(F[t]=e[t]);F.allowStateChanges=!F.enforceActions},e._startAction=ye,e.action=Pn,e.actionBound=In,e.autorun=Ue,e.compareDefault=Gt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return Ot(e,t,1)},e.compareStructural=_,e.computed=ln,e.computedStruct=cn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((F.pendingReactions.length||F.inBatch||F.isRunningReactions)&&t(36),Cn=!0,Sn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),F=new xn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===zn?zn:n===`observed`;F.enforceActions=e,F.allowStateChanges=!0!==e&&e!==zn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(F[t]=!!e[t])}),F.allowStateReads=!F.observableRequiresReaction,e.reactionScheduler&&function(e){let t=En;En=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(Ct(e))return e[M].l(n,r);t(39)},e.entries=function(e){return Ct(e)?et(e).map(t=>[t,e[t]]):nr(e)?et(e).map(t=>[t,e.get(t)]):I(e)?Array.from(e.entries()):vt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ke,e.flow=Un,e.flowBound=Wn,e.flowResult=function(e){return e},e.get=function(e,n){if(tt(e,n))return Ct(e)?e[M].Tt(n):nr(e)?e.get(n):vt(e)?e[n]:void t(11)},e.getAtom=wt,e.getDebugName=Et,e.getDependencyTree=function(e,t){return qe(wt(e,t))},e.getObserverTree=function(e,t){return Je(wt(e,t))},e.has=tt,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return ut(Tt(e,t),n)}(e,t,n):function(e,t){return ut(Tt(e),t)}(e,t)},e.isAction=He,e.isBoxedObservable=gn,e.isComputed=function(e){return Ze(e)},e.isComputedProp=function(e,t){return Ze(e,t)},e.isFlow=Xe,e.isFlowCancellationError=function(e){return e instanceof Bn},e.isObservable=$e,e.isObservableArray=vt,e.isObservableMap=nr,e.isObservableObject=Ct,e.isObservableProp=function(e,t){return Qe(e,t)},e.isObservableSet=I,e.keys=et,e.makeAutoObservable=function(e,t,n){return o(e)?Ke(e,e,t,n):(Dt(()=>{let r=xt(e,n)[M];if(!e[Kn]){let t=Object.getPrototypeOf(e),n=new Set([...Vt(e),...Vt(t)]);n.delete(`constructor`),n.delete(M),c(t,Kn,n)}e[Kn].forEach(e=>mt(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return Dt(()=>{let r=xt(e,n)[M];Vt(t).forEach(e=>mt(r,e,t[e]))}),e},e.observable=an,e.observableDeep=nn,e.observableRef=en,e.observableShallow=tn,e.observableStruct=rn,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return rt(Tt(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Tt(e);if(vt(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(!nr(e)&&!I(e)&&!Ct(e))return rt(r,t,n);return ft(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return Ge(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return Ge(`onBUO`,e,t,n)},e.onReactionError=function(e){return F.globalReactionErrorHandlers.push(e),()=>{let t=F.globalReactionErrorHandlers.indexOf(e);t>=0&&F.globalReactionErrorHandlers.splice(t,1)}},e.override=N,e.ownKeys=nt,e.reaction=function(e,t,n=Rt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=xe(!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=Pn(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=We(n),d,f=!0,p=!1,m=n.equals||Gt,h=new wn(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){Ct(e)?e[M].Dt(n):nr(e)||I(e)?e.delete(n):vt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=Ve,e.set=function e(n,r,i){if(arguments.length===2&&!I(n)){Me();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Ne()}return}Ct(n)?n[M].Bt(r,i):nr(n)?n.set(r,i):I(n)?n.add(r):vt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),Me(),r>=n.length&&(n.length=r+1),n[r]=i,Ne()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return at(e,new Map)},e.transaction=ot,e.untracked=Ee,e.values=function(e){return Ct(e)?et(e).map(t=>e[t]):nr(e)?et(e).map(t=>e.get(t)):I(e)?Array.from(e.values()):vt(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 Nt(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=st(e,n,Nt({},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):st(e,t,n||{})}})),Sv=we((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++P.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=T(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 x(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function S(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function C(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function w(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let ee=Reflect.ownKeys;function te(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ne(e){return e===null?null:typeof e==`object`?``+e:e}function T(e,t){return o.hasOwnProperty.call(e,t)}let re=Object.getOwnPropertyDescriptors;function E(e,t){return!!(e&t)}function D(e,t,n){return n?e|=t:e&=~t,e}function ie(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let O=Symbol(`mobx administration`);var ae=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 E(this.flags_,1)}set isBeingObserved(e){this.flags_=D(this.flags_,1,e)}get isPendingUnobservation(){return E(this.flags_,2)}set isPendingUnobservation(e){this.flags_=D(this.flags_,2,e)}get diffValue(){return+!!E(this.flags_,4)}set diffValue(e){this.flags_=D(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return sn(this)}reportChanged(){nn(),cn(this),rn()}toString(){return this.name_}};let oe=b(`Atom`,ae);function se(e,t=f,n=f){let r=new ae(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function ce(e,t){return e===t}function le(e,t){return Mi(e,t)}function ue(e,t){return Mi(e,t,1)}let de=Object.is;function fe(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||vr(e)?e:Array.isArray(e)?A.array(e,{name:n}):g(e)?A.object(e,void 0,{name:n}):x(e)?A.map(e,{name:n}):C(e)?A.set(e,{name:n}):typeof e==`function`&&!Ln(e)&&!lr(e)?_(e)?ar(e):Nn(n,e):e}function pe(e,t,r){if(e==null||Di(e)||ui(e)||mi(e)||yi(e))return e;if(Array.isArray(e))return A.array(e,{name:r,deep:!1});if(g(e))return A.object(e,void 0,{name:r,deep:!1});if(x(e))return A.map(e,{name:r,deep:!1});if(C(e))return A.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function me(e){return e}function he(e,t){return vr(e)&&n(`observable.struct should not be used with observable values`),Mi(e,t)?t:e}let ge=`override`,_e={annotationType_:ge,make_:ye,extend_:be};function ve(e){return e.annotationType_===ge}function ye(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),T(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function be(e,t,r,i){n(44,this.annotationType_)}function xe(e,t){return{annotationType_:e,options_:t,make_:Se,extend_:Ce}}function Se(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:Ln(n.value)?1:(a(r,t,Ee(e,this,t,n,!1)),2)}function Ce(e,t,n,r){let i=Ee(e,this,t,n);return e.defineProperty_(t,i,r)}function we(e,t,r){ie(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>yt(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return Ln(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return Ln(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 Te(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 Ee(e,t,n,r,i=P.safeDescriptors){var a,o;Te(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:yt(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 k(e,t){return{annotationType_:e,options_:t,make_:De,extend_:Oe}}function De(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&&(!T(e.target_,t)||!lr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:lr(n.value)?1:(a(r,t,je(e,this,t,n,!1,!1)),2)}function Oe(e,t,n,r){let i=je(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function ke(e,t,n){var r;ie(n,[`method`]);let{name:i,addInitializer:a}=n;return lr(t)||(t=ar(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 Ae(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 je(e,t,n,r,i,a=P.safeDescriptors){Ae(e,t,n,r);let{value:o}=r;return lr(o)||(o=ar(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function Me(e,t){return{annotationType_:e,options_:t,make_:Ne,extend_:Pe}}function Ne(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Pe(e,t,n,i){return Ie(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Fe(e,t,n){ie(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 Ot(o)}return o(function(){let e=wi(this)[O],n=this,r=e.values_.get(a);r instanceof Ot&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[O],n=e.values_.get(a);if(n instanceof Ot&&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 Ie(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 Le(e,t){return{annotationType_:e,options_:t,make_:Re,extend_:ze}}function Re(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function ze(e,t,n,r){return Ve(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??fe,r)}function Be(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);ie(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=wi(e)[O];return(n.lazyObservableKeys_??=new Map).set(o,()=>new Et(t,i.options_?.enhancer_??fe,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[O]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[O]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function Ve(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 He=Ue();function Ue(e){return{annotationType_:`true`,options_:e,make_:Ke,extend_:qe}}let We=[He];function Ge(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return We[r]??(We[r]=Ue({deep:t,autoBind:n}))}function Ke(e,t,n,r){var i;if(n.get)return j.make_(e,t,n,r);if(n.set){let i=Ln(n.set)?n.set:yt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:P.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?or:ar).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Fn:Nn).make_(e,t,n,r)}let c=this.options_?.deep===!1?st:A;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 qe(e,t,n,r){var i;return n.get?j.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:P.safeDescriptors?e.isPlainObject_:!0,set:yt(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?st:A).extend_(e,t,n,r))}function Je(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 Ye={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Ye);function Xe(e){return e||Ye}let Ze=Le(`observable`),Qe=Le(`observable.ref`,{enhancer_:me}),$e=Le(`observable.shallow`,{enhancer_:pe}),et=Le(`observable.struct`,{enhancer_:he});function tt(e){return Je(e,Be)}function nt(e){return e.deep===!0?fe:e.deep===!1?me:it(e.defaultDecorator)}function rt(e){return e?e.defaultDecorator??Ge(e):void 0}function it(e){return e?e.options_?.enhancer_??fe:fe}function at(e,t,n){return t&&typeof t.kind==`string`?Be(Ze,e,t):vr(e)?e:g(e)?A.object(e,t,n):Array.isArray(e)?A.array(e,t):x(e)?A.map(e,t):C(e)?A.set(e,t):typeof e==`object`&&e?e:A.box(e,t)}let ot={box(e,t){let n=Xe(t);return new Et(e,nt(n),n.name,!0,n.equals)},array(e,t){let n=Xe(t);return ri(e,nt(n),n.name)},map(e,t){let n=Xe(t);return new pi(e,nt(n),n.name)},set(e,t){let n=Xe(t);return new vi(e,nt(n),n.name)},object(e,t,n){return Ai(()=>Jn(Hr({},n),e,t))}},st=tt(Qe),ct=tt($e),lt=tt(Ze),ut=tt(et);var A=r(at,Ze,ot);let dt=`computed`;function ft(e){return Je(e,Fe)}let pt=Me(dt),mt=ft(Me(`computed.struct`,{equals:le})),j=function(e,t){if(t&&typeof t.kind==`string`)return Fe(pt,e,t);if(g(e))return ft(Me(dt,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 Ot(r)};r(j,pt);let ht=0,gt=1,_t=i(()=>{},`name`)?.configurable??!1,vt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function yt(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 bt(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),_t&&(vt.value=e,a(o,`name`,vt)),o}function bt(e,t,n,r,i){let a=xt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{St(a)}}function xt(e,t,n,r){let i=vn()&&!!e,a=0;i&&(a=Date.now(),bn({type:F,name:e,object:n,arguments:r?Array.from(r):s}));let o=P.trackingDerivation,c=!t||!o;nn();let l=P.allowStateChanges;c&&(Vt(),l=wt(!0));let u=P.allowStateReads;M(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:gt++,parentActionId_:ht};return ht=d.actionId_,d}function St(e){ht!==e.actionId_&&n(30),ht=e.parentActionId_,e.error_!==void 0&&(P.suppressReactionErrors=!0),Tt(e.prevAllowStateChanges_),Ut(e.prevAllowStateReads_),rn(),e.runAsAction_&&Ht(e.prevDerivation_),e.notifySpy_&&Sn({time:Date.now()-e.startTime_}),P.suppressReactionErrors=!1}function Ct(e,t){let n=wt(e);try{return t()}finally{Tt(n)}}function wt(e){let t=P.allowStateChanges;return P.allowStateChanges=e,t}function Tt(e){P.allowStateChanges=e}var Et=class extends ae{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=de){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&&vn()&&yn({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!==P.UNCHANGED){let n=vn();n&&bn({type:ei,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Sn()}}prepareNewValue_(e){if(Pt(this),Ur(this)){let t=Gr(this,{object:this,type:ei,newValue:e});if(!t)return P.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?P.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),Kr(this)&&Jr(this,{type:ei,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 ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Dt=b(`ObservableValue`,Et);var Ot=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 At(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_=yt(this.name_+`-setter`,e.set)),this.equals_=e.equals||de,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){un(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return E(this.flags_,1)}set isComputing(e){this.flags_=D(this.flags_,1,e)}get isRunningSetter(){return E(this.flags_,2)}set isRunningSetter(e){this.flags_=D(this.flags_,2,e)}get isBeingObserved(){return E(this.flags_,4)}set isBeingObserved(e){this.flags_=D(this.flags_,4,e)}get isPendingUnobservation(){return E(this.flags_,8)}set isPendingUnobservation(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),P.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Mt(this)&&(this.warnAboutUntrackedRead_(),nn(),this.value_=this.computeValue_(!1),rn());else{let e=this.isBeingObserved;if(sn(this),Mt(this)){let e=P.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(P.trackingContext=this),this.trackAndCompute()&&ln(this),P.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(on)}let e=this.value_;if(jt(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||jt(e)||jt(n)||!this.equals_(e,n);return r&&(this.value_=n,vn()&&yn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=wt(!1),n;if(e)n=It(this,this.derivation,this.scope_);else if(P.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new At(e)}return Tt(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(zt(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:P.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 ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let kt=b(`ComputedValue`,Ot);var At=class{constructor(e){this.cause=void 0,this.cause=e}};function jt(e){return e instanceof At}function Mt(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=M(!0),n=Vt(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(kt(i)){if(P.disableErrorBoundaries)i.get();else try{i.get()}catch{return Ht(n),Ut(t),!0}if(e.dependenciesState_===2)return Ht(n),Ut(t),!0}}return Wt(e),Ht(n),Ut(t),!1}}}function Nt(){return P.trackingDerivation!==null}function Pt(e){let t=!!e.observers_&&e.observers_.size>0;!P.allowStateChanges&&(t||P.enforceActions===`always`)&&console.warn(`[MobX] `+(P.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 Ft(e){!P.allowStateReads&&P.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function It(e,t,n){let r=M(!0);Wt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++P.runId;let i=P.trackingDerivation;P.trackingDerivation=e,P.inBatch++;let a;if(P.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new At(e)}return P.inBatch--,P.trackingDerivation=i,Rt(e),Lt(e),Ut(r),a}function Lt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:P.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function Rt(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&&en(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,$t(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function zt(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)en(t[n],e);e.dependenciesState_=-1}function Bt(e){let t=Vt();try{return e()}finally{Ht(t)}}function Vt(){let e=P.trackingDerivation;return P.trackingDerivation=null,e}function Ht(e){P.trackingDerivation=e}function M(e){let t=P.allowStateReads;return P.allowStateReads=e,t}function Ut(e){P.allowStateReads=e}function Wt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Gt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var N=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 Kt=!0,qt=!1,P=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Kt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Kt=!1),Kt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new N):(setTimeout(()=>{qt||n(35)},1),new N)}();function Jt(){if((P.pendingReactions.length||P.inBatch||P.isRunningReactions)&&n(36),qt=!0,Kt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),P=new N}}function Yt(){return P}function Xt(){let e=new N;for(let t in e)Gt.indexOf(t)===-1&&(P[t]=e[t]);P.allowStateChanges=!P.enforceActions}function Zt(e){return!!e.observers_&&e.observers_.size>0}function Qt(e){return e.observers_??new Set}function $t(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function en(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&tn(e))}function tn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,P.pendingUnobservations.push(e))}function nn(){P.inBatch++}function rn(){--P.inBatch===0&&(mn(),!P.isRunningUnobservations&&P.pendingUnobservations.length>0&&an())}function an(){P.isRunningUnobservations=!0;try{let e=P.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 Ot&&n.suspend_())}P.pendingUnobservations=[]}finally{P.isRunningUnobservations=!1}}function on(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(on))}function sn(e){Ft(e);let t=P.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&P.inBatch>0&&tn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&P.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function cn(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 ln(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 un(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 dn=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 E(this.flags_,1)}set isDisposed(e){this.flags_=D(this.flags_,1,e)}get isScheduled(){return E(this.flags_,2)}set isScheduled(e){this.flags_=D(this.flags_,2,e)}get isTrackPending(){return E(this.flags_,4)}set isTrackPending(e){this.flags_=D(this.flags_,4,e)}get isRunning(){return E(this.flags_,8)}set isRunning(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,P.pendingReactions.push(this),mn())}runReaction_(){if(!this.isDisposed){nn(),this.isScheduled=!1;let e=P.trackingContext;if(P.trackingContext=this,Mt(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&vn()&&yn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}P.trackingContext=e,rn()}}track(e){if(this.isDisposed)return;nn();let t=vn(),n;t&&(n=Date.now(),bn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=P.trackingContext;P.trackingContext=this;let i=It(this,e,void 0);P.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&zt(this),jt(i)&&this.reportExceptionInDerivation_(i.cause),t&&Sn({time:Date.now()-n}),rn()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(P.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;P.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),vn()&&yn({type:`error`,name:this.name_,message:t,error:``+e}),P.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(nn(),zt(this),rn())}}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[O]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function fn(e){return P.globalReactionErrorHandlers.push(e),()=>{let t=P.globalReactionErrorHandlers.indexOf(e);t>=0&&P.globalReactionErrorHandlers.splice(t,1)}}let pn=e=>e();function mn(){P.inBatch>0||P.isRunningReactions||pn(hn)}function hn(){P.isRunningReactions=!0;let e=P.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_()}P.isRunningReactions=!1}let gn=b(`Reaction`,dn);function _n(e){let t=pn;pn=n=>e(()=>t(n))}function vn(){return!!P.spyListeners.length}function yn(e){if(!P.spyListeners.length)return;let t=P.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function bn(e){yn(r({},e,{spyReportStart:!0}))}let xn={type:`report-end`,spyReportEnd:!0};function Sn(e){yn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):xn)}function Cn(e){return P.spyListeners.push(e),d(()=>{P.spyListeners=P.spyListeners.filter(t=>t!==e)})}let F=`action`,wn=`autoAction`,Tn=`<unnamed action>`,En=xe(F),Dn=xe(`action.bound`,{bound:!0}),On=xe(wn,{autoAction:!0}),kn=xe(`autoAction.bound`,{autoAction:!0,bound:!0});function An(e){return Je(e,we)}function jn(e){return function(t,r){if(r&&typeof r.kind==`string`)return we(e?On:En,t,r);if(p(t))return yt(t.name||Tn,t,e);if(p(r))return yt(t,r,e);if(m(t))return An(xe(e?wn:F,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Mn=jn(!1);r(Mn,En);let Nn=jn(!0);r(Nn,On);let Pn=An(Dn),Fn=An(kn);function In(e){return bt(e.name||Tn,!1,e,this,void 0)}function Ln(e){return p(e)&&e.isMobxAction===!0}function Rn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),Ln(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 dn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Bn(t),n=!1;o=new dn(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 zn=e=>e();function Bn(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):zn}function Vn(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=Mn(a,r.onError?Hn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Bn(r),d=!0,f=!1,m,h=r.equals||de,_=new dn(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=Ct(!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 Hn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Un(e,t,n){return Gn(`onBO`,e,t,n)}function Wn(e,t,n){return Gn(`onBUO`,e,t,n)}function Gn(e,t,n,r){let i=typeof r==`function`?R(t,n):R(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 Kn=`always`;function qn(e){e.isolateGlobalState===!0&&Jt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Kn?Kn:t===`observed`;P.enforceActions=e,P.allowStateChanges=!(e===!0||e===Kn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(P[t]=!!e[t])}),P.allowStateReads=!P.observableRequiresReaction,P.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&_n(e.reactionScheduler)}function Jn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),mi(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(vr(t)||vr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=re(t);return Ai(()=>{let t=wi(e,i)[O];ee(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Yn(e,t){return Xn(R(e,t))}function Xn(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=$n(e.observing_).map(Xn)),t}function Zn(e,t){return Qn(R(e,t))}function Qn(e){let t={name:e.name_};return Zt(e)&&(t.observers=Array.from(Qt(e),Qn)),t}function $n(e){return Array.from(new Set(e))}let er=0;var tr=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function nr(e){return e instanceof tr}function rr(e){return Je(e,ke)}let ir=k(`flow`),I=k(`flow.bound`,{bound:!0}),ar=r(function(e,t){if(t&&typeof t.kind==`string`)return ke(ir,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=++er,a=Mn(`${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=Mn(`${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=Mn(`${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=Mn(`${i} - runid: ${n} - cancel`,function(){try{s&&sr(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),sr(t),o(new tr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},ir),or=rr(I);function sr(e){p(e.cancel)&&e.cancel()}function cr(e){return e}function lr(e){return e?.isMobXFlow===!0}function ur(e,t,r){let i;if(mi(e)||ui(e)||Dt(e))i=z(e);else if(Di(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=z(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 dr(e,t,n){return p(n)?pr(e,t,n):fr(e,t)}function fr(e,t){return Wr(z(e),t)}function pr(e,t,n){return Wr(z(e,t),n)}function mr(e,t){var n;if(t===void 0)return kt(e);if(Di(e)===!1)return!1;let r=e[O];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?kt(R(e,t)):!1}function hr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):mr(e)}function gr(e,t){return m(t)?mr(e,t):n(`isComputed expected a property name as second argument`)}function _r(e,t){if(!e)return!1;if(t!==void 0){if(mi(e)||ui(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(Di(e)){var r,i;let n=e[O];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return Di(e)||!!e[O]||oe(e)||gn(e)||kt(e)}function vr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),_r(e)}function yr(e,t){return m(t)?_r(e,t):n(`expected a property name as second argument`)}function br(e){if(Di(e))return e[O].keys_();if(mi(e)||yi(e))return Array.from(e.keys());if(ui(e))return e.map((e,t)=>t);n(5)}function xr(e){if(Di(e))return br(e).map(t=>e[t]);if(mi(e))return br(e).map(t=>e.get(t));if(yi(e))return Array.from(e.values());if(ui(e))return e.slice();n(6)}function Sr(e){if(Di(e))return br(e).map(t=>[t,e[t]]);if(mi(e))return br(e).map(t=>[t,e.get(t)]);if(yi(e))return Array.from(e.entries());if(ui(e))return e.map((e,t)=>[t,e]);n(7)}function Cr(e,t,r){if(arguments.length===2&&!yi(e)){nn();let n=t;try{for(let t in n)Cr(e,t,n[t])}finally{rn()}return}Di(e)?e[O].set_(t,r):mi(e)?e.set(t,r):yi(e)?e.add(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),nn(),t>=e.length&&(e.length=t+1),e[t]=r,rn()):n(8)}function wr(e,t){Di(e)?e[O].delete_(t):mi(e)||yi(e)?e.delete(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function Tr(e,t){if(Di(e))return e[O].has_(t);if(mi(e)||yi(e))return e.has(t);if(ui(e))return t>=0&&t<e.length;n(10)}function Er(e,t){if(Tr(e,t)){if(Di(e))return e[O].get_(t);if(mi(e))return e.get(t);if(ui(e))return e[t];n(11)}}function Dr(e,t,r){if(Di(e))return e[O].defineProperty_(t,r);n(39)}function Or(e){if(Di(e))return e[O].ownKeys_();n(38)}function kr(e,t,n,r){return p(n)?jr(e,t,n,r):Ar(e,t,n)}function Ar(e,t,r){let i=z(e);if(ui(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(mi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(yi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(Di(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Mr(i,t,r);return qr(i,t)}function jr(e,t,n,r){return Mr(z(e,t),n,r)}function Mr(e,t,n){if(kt(e)){let r=!0,i;return Rn(()=>{let a=e.get();if(!r||n){let n=Vt();t({observableKind:`computed`,debugObjectName:e.name_,type:ei,object:e,newValue:a,oldValue:i}),Ht(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ei,newValue:e.value_,oldValue:void 0}),qr(e,t)}function Nr(e,t,n){return e.set(t,n),n}function Pr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!vr(e))return e;if(Dt(e)||kt(e))return Pr(e.get(),t);if(t.has(e))return t.get(e);if(ui(e)){let n=Nr(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Pr(e,t)}),n}if(yi(e)){let n=Nr(t,e,new Set);return e.forEach(e=>{n.add(Pr(e,t))}),n}if(mi(e)){let n=Nr(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Pr(e,t))}),n}else{let n=Nr(t,e,{});return Or(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Pr(e[r],t))}),n}}function Fr(e,t){return t&&n(`toJS no longer supports options`),Pr(e,new Map)}function Ir(e,t=void 0){nn();try{return e.apply(t)}finally{rn()}}function Lr(e,t,n){return arguments.length===1||t&&typeof t==`object`?zr(e,t):Rr(e,t,n||{})}function Rr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[O].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=yt(n.name+`-effect`,t);var a=Rn(t=>{Ct(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function zr(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=Rr(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 Br(e){return e[O]}let Vr={has(e,t){return Br(e).has_(t)},get(e,t){return Br(e).get_(t)},set(e,t,n){return m(t)?Br(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Br(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Br(e).defineProperty_(t,n)??!0},ownKeys(e){return Br(e).ownKeys_()},preventExtensions(e){n(13)}};function Hr(e,t){var n;return e=wi(e,t),(n=e[O]).proxy_??(n.proxy_=new Proxy(e,Vr))}function Ur(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function Wr(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 Gr(e,t){let r=Vt();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{Ht(r)}}function Kr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function qr(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 Jr(e,t){let n=Vt(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ht(n)}}function Yr(e,t,n){return Ai(()=>{let r=wi(e,n)[O];ee(t).forEach(e=>Qr(r,e,t[e]))}),e}let Xr=Symbol(`mobx-keys`);function Zr(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),Di(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Jn(e,e,t,r):(Ai(()=>{let n=wi(e,r)[O];if(!e[Xr]){let t=Object.getPrototypeOf(e),n=new Set([...ee(e),...ee(t)]);n.delete(`constructor`),n.delete(O),v(t,Xr,n)}e[Xr].forEach(e=>Qr(n,e,t&&e in t?t[e]:!0))}),e)}function Qr(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;L(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)}Oi(e,r,t)}let $r=`splice`,ei=`update`,ti={get(e,t){let n=e[O];return t===O?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):T(ii,t)?ii[t]:e[t]},set(e,t,n){let r=e[O];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var ni=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 ae(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){Pt(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),Ur(this)){let r=Gr(this,{object:this.proxy_,type:$r,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_&&vn(),i=Kr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ei,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&bn(a),this.atom_.reportChanged(),i&&Jr(this,a),r&&Sn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&vn(),i=Kr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:$r,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&bn(a),this.atom_.reportChanged(),i&&Jr(this,a),r&&Sn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Pt(this.atom_);let r=n[e];if(Ur(this)){let n=Gr(this,{type:ei,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 ri(e,t,n=`ObservableArray@`+u(),r=!1){return Ai(()=>{let i=new ni(n,t,r);y(i.values_,O,i);let a=new Proxy(i.values_,ti);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var ii={clear(){return this.splice(0)},replace(e){let t=this[O];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[O];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[O].spliceWithArray_(e,t,n)},push(...e){let t=this[O];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[O].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[O];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return P.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){P.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[O],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};ai(`at`,oi),ai(`concat`,oi),ai(`flat`,oi),ai(`includes`,oi),ai(`indexOf`,oi),ai(`join`,oi),ai(`lastIndexOf`,oi),ai(`slice`,oi),ai(`toString`,oi),ai(`toLocaleString`,oi),ai(`toSorted`,oi),ai(`toSpliced`,oi),ai(`with`,oi),ai(`every`,si),ai(`filter`,si),ai(`find`,si),ai(`findIndex`,si),ai(`findLast`,si),ai(`findLastIndex`,si),ai(`flatMap`,si),ai(`forEach`,si),ai(`map`,si),ai(`some`,si),ai(`toReversed`,si),ai(`reduce`,ci),ai(`reduceRight`,ci);function ai(e,t){typeof Array.prototype[e]==`function`&&(ii[e]=t(e))}function oi(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function si(e){return function(t,n){let r=this[O];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function ci(e){return function(){let t=this[O];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 li=b(`ObservableArrayAdministration`,ni);function ui(e){return h(e)&&li(e[O])}let di={},fi=`delete`;var pi=class{constructor(e,t=fe,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[O]=di,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,Ai(()=>{this.keysAtom_=se(`${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(!P.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new Et(this.has_(e),me,`${this.name_}.${te(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(Ur(this)){let r=Gr(this,{type:n?ei:`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(Pt(this.keysAtom_),Ur(this)&&!Gr(this,{type:fi,object:this,name:e}))return!1;if(this.has_(e)){let t=vn(),n=Kr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:fi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&bn(r),Ir(()=>{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&&Jr(this,r),t&&Sn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=vn(),i=Kr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ei,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&bn(a),n.setNewValue_(t),i&&Jr(this,a),r&&Sn()}}addValue_(e,t){Pt(this.keysAtom_),Ir(()=>{var n;let r=new Et(t,this.enhancer_,`${this.name_}.${te(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=vn(),r=Kr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&bn(i),r&&Jr(this,i),n&&Sn()}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 hi({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 hi({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 mi(e)&&(e=new Map(e)),Ir(()=>{g(e)?w(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):x(e)?(S(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){Ir(()=>{Bt(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return Ir(()=>{let t=gi(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`}},mi=b(`ObservableMap`,pi);function hi(e){return e[Symbol.toStringTag]=`MapIterator`,Ii(e)}function gi(e){if(x(e)||mi(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 _i={};var vi=class{constructor(e,t=fe,n=`ObservableSet@`+u()){this.name_=void 0,this[O]=_i,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),Ai(()=>{this.atom_=se(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){Ir(()=>{Bt(()=>{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(Pt(this.atom_),Ur(this)){let t=Gr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){Ir(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=vn(),n=Kr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&bn(r),n&&Jr(this,r),t&&Sn()}return this}delete(e){if(Ur(this)&&!Gr(this,{type:fi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=vn(),n=Kr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:fi,object:this,oldValue:e}:null;return t&&bn(r),Ir(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Jr(this,r),t&&Sn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return bi({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 bi({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 yi(e)&&(e=new Set(e)),Array.isArray(e)||C(e)?Ir(()=>{let t=C(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`}},yi=b(`ObservableSet`,vi);function bi(e){return e[Symbol.toStringTag]=`SetIterator`,Ii(e)}let xi=Object.create(null),Si=`remove`;var Ci=class{constructor(e,t=new Map,r,i=He){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 ae(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Ri(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 Ot)return n.set(t),!0;if(Ur(this)){let n=Gr(this,{type:ei,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=Kr(this),i=vn(),a=r||i?{type:ei,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&bn(a),n.setNewValue_(t),r&&Jr(this,a),i&&Sn()}return!0}get_(e){return P.trackingDerivation&&!T(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return T(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(!P.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new Et(e in this.target_,me,`${this.name_}.${te(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);L(this,n,e);let i=n.extend_(this,e,t,r);return i&&Oi(this,n,e),i}defineProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Ur(this)){let n=Gr(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{rn()}return!0}defineObservableProperty_(e,t,n,r=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Ur(this)){let n=Gr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=Ei(e),s={configurable:P.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 Et(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{rn()}return!0}defineComputedProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let r=this.delete_(e);if(!r)return r;if(Ur(this)&&!Gr(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=Ei(e),o={configurable:P.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 Ot(t)),this.notifyPropertyAddition_(e,void 0)}finally{rn()}return!0}delete_(e,t=!1){if(Pt(this.keysAtom_),!T(this.target_,e))return!0;if(Ur(this)&&!Gr(this,{object:this.proxy_||this.target_,name:e,type:Si}))return null;try{var n;nn();let r=Kr(this),a=vn(),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 Et&&(s=o.value_),cn(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Si,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&bn(t),r&&Jr(this,t),a&&Sn()}}finally{rn()}return!0}notifyPropertyAddition_(e,t){var n;let r=Kr(this),i=vn();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&&bn(n),r&&Jr(this,n),i&&Sn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),ee(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function wi(e,t){if(t&&Di(e)&&n(`Options can't be provided for already observable objects.`),T(e,O))return z(e)instanceof Ci||n(`Cannot convert '${ki(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,O,new Ci(e,new Map,String(r),rt(t))),e}let Ti=b(`ObservableObjectAdministration`,Ci);function Ei(e){return xi[e]||(xi[e]={get(){return this[O].getObservablePropValue_(e)},set(t){return this[O].setObservablePropValue_(e,t)}})}function Di(e){return h(e)?Ti(e[O]):!1}function Oi(e,t,n){e.appliedAnnotations_[n]=t}function L(e,t,r){if(Ri(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!ve(t)&&T(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 R(e,t){if(typeof e==`object`&&e){if(ui(e))return t!==void 0&&n(23),e[O].atom_;if(yi(e))return e.atom_;if(mi(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,ki(e)),r}if(Di(e)){if(!t)return n(26);let r=e[O],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,ki(e)),i}if(oe(e)||kt(e)||gn(e))return e}else if(p(e)&&gn(e[O]))return e[O];n(28)}function z(e,t){if(e||n(29),t!==void 0)return z(R(e,t));if(oe(e)||kt(e)||gn(e)||mi(e)||yi(e))return e;if(e[O])return e[O];n(24,e)}function ki(e,t){let n;if(t!==void 0)n=R(e,t);else if(Ln(e))return e.name;else n=Di(e)||mi(e)||yi(e)?z(e):R(e);return n.name_}function Ai(e){let t=Vt(),n=wt(!0);nn();try{return e()}finally{rn(),Tt(n),Ht(t)}}let ji=o.toString;function Mi(e,t,n=-1){return Ni(e,t,n)}function Ni(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=ji.call(e);if(o!==ji.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=Pi(e),t=Pi(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(!Ni(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(!(T(t,o)&&Ni(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function Pi(e){return ui(e)?e.slice():x(e)||mi(e)||C(e)||yi(e)?Array.from(e.entries()):e}let Fi=globalThis.Iterator?.prototype||{};function Ii(e){return e[Symbol.iterator]=Li,r(Object.create(Fi),e)}function Li(){return this}function Ri(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:Cn,extras:{getDebugName:ki},$mobx:O}),e.$mobx=O,e.FlowCancellationError=tr,e.ObservableMap=pi,e.ObservableSet=vi,e.Reaction=dn,e._allowStateChanges=Ct,e._allowStateChangesInsideComputed=In,e._allowStateReadsEnd=Ut,e._allowStateReadsStart=M,e._autoAction=Nn,e._autoActionBound=Fn,e._endAction=St,e._getAdministration=z,e._getGlobalState=Yt,e._interceptReads=ur,e._isComputingDerivation=Nt,e._resetGlobalState=Xt,e._startAction=xt,e.action=Mn,e.actionBound=Pn,e.autorun=Rn,e.compareDefault=de,e.compareIdentity=ce,e.compareShallow=ue,e.compareStructural=le,e.computed=j,e.computedStruct=mt,e.configure=qn,e.createAtom=se,e.defineProperty=Dr,e.entries=Sr,e.extendObservable=Jn,e.flow=ar,e.flowBound=or,e.flowResult=cr,e.get=Er,e.getAtom=R,e.getDebugName=ki,e.getDependencyTree=Yn,e.getObserverTree=Zn,e.has=Tr,e.intercept=dr,e.isAction=Ln,e.isBoxedObservable=Dt,e.isComputed=hr,e.isComputedProp=gr,e.isFlow=lr,e.isFlowCancellationError=nr,e.isObservable=vr,e.isObservableArray=ui,e.isObservableMap=mi,e.isObservableObject=Di,e.isObservableProp=yr,e.isObservableSet=yi,e.keys=br,e.makeAutoObservable=Zr,e.makeObservable=Yr,e.observable=A,e.observableDeep=lt,e.observableRef=st,e.observableShallow=ct,e.observableStruct=ut,e.observe=kr,e.onBecomeObserved=Un,e.onBecomeUnobserved=Wn,e.onReactionError=fn,e.override=_e,e.ownKeys=Or,e.reaction=Vn,e.remove=wr,e.runInAction=In,e.set=Cr,e.spy=Cn,e.toJS=Fr,e.transaction=Ir,e.untracked=Bt,e.values=xr,e.when=Lr})),Cv=we(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=xv():t.exports=Sv()}))();function wv(e){if(Array.isArray(e))return Object.freeze(e.map(wv));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]=wv(r);return Object.freeze(t)}return e}function Tv(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 Ev(e){return typeof e==`string`?e:String(e)}function Dv(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 Ov(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 kv=class extends Error{constructor(e,t){super(t),this.variable=e}};function Av(e){return e instanceof kv||e instanceof Error&&e.cause!==void 0&&Av(e.cause)}var jv=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?Bv(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}},Mv=class extends jv{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},Nv=class extends jv{name=`EvalError`;kind=`EvalError`},Pv=class extends Nv{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=Vv(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}},Fv=class extends Nv{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}},Iv=class extends Nv{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}},Lv=class extends Iv{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)}`}},Rv=class extends Nv{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},zv=class extends Nv{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function Bv(e,t){let n=e.split(`
58
58
  `),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(`
59
59
  `)}function Vv(e,t){if(t.length===0)return[];let n=t.map(t=>({name:t,dist:Hv(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 Hv(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 Uv(e){throw Error(`unhandled node kind: ${JSON.stringify(e)}`)}const Wv=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`]]),Gv={left:`{{`,right:`}}`};var Kv=class{src;leftDelim;rightDelim;offset=0;line=1;column=1;mode=`text`;pending;constructor(e,t=Gv){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 Mv(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&&qv(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);qv(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);qv(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(;qv(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`;qv(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&&(Yv(e)||Jv(e)&&Yv(this.src[this.offset+1]??``)||e===`.`&&Yv(this.src[this.offset+1]??``)))return this.readNumber(t);if(e===`.`)return this.readDotOrField(t);if(e!==void 0&&ey(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===`
60
60
  `)throw this.err(`newline in interpreted string`,e,{found:`\\n`});if(n===`"`)return this.advanceBy(1),this.makeToken(`String`,this.src.slice(t,this.offset),e);this.advanceBy(1)}throw this.err(`unterminated string literal`,e,{expected:`"`,found:`end of input`})}readRawString(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){if(this.src[this.offset]==="`")return this.advanceBy(1),this.makeToken(`String`,this.src.slice(t,this.offset),e);this.advanceBy(1)}throw this.err(`unterminated raw string literal`,e,{expected:"`",found:`end of input`})}readChar(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===`
@@ -86,8 +86,8 @@ Debugging:
86
86
  Configuration:
87
87
  Layout and segment options are defined in .cc-candybar.json5 (place in your
88
88
  project dir, cwd, or ~/.config/cc-candybar/config.json5). Use CC_CANDYBAR_CONFIG
89
- to point at a specific file. See the default config for all available options:
90
- node dist/index.mjs debug --project-dir . --cwd .
89
+ to point at a specific file. To see the effective merged config:
90
+ cc-candybar config
91
91
 
92
92
  Every bar carries a settings menu, whatever your config says — no config
93
93
  needed, and writing your own \`root\` cannot delete it. Click
@@ -123,18 +123,16 @@ Subcommands:
123
123
  daemon-stats [--json] Query the running daemon for runtime stats:
124
124
  uptime, RSS, cache hit rates, watcher count,
125
125
  request totals. Does not spawn a daemon.
126
- frames --lane LANE [--session ID | --config PATH] [--format response|band]
126
+ frames --lane LANE [--config PATH]
127
127
  One session's bar as the daemon pushes it — up to
128
128
  30 frames a second while it moves, at once on a
129
- click — one JSON render response per stdout line.
130
- Without --session, reads Claude Code's statusline
131
- JSON from stdin (one object a line) and sends it as
132
- the session's data (--config then rides with it).
133
- LANE is band, statusline or pane: the experimental
134
- lane this stream serves, which streams only while
135
- its toggle in the settings menu's ⚙ config tab is on.
136
- --format band writes each frame as rows of styled
137
- runs, for the mod in mod/.
129
+ click — one JSON message per stdout line. Reads
130
+ Claude Code's statusline JSON from stdin (one object
131
+ a line) and sends it as the session's data
132
+ (--config rides with it). LANE is band, statusline
133
+ or pane: the experimental lane this stream serves,
134
+ which streams only while its toggle in the settings
135
+ menu's ⚙ config tab is on.
138
136
  bar-pane PANE Draw the bar of the Claude Code session in tmux
139
137
  pane PANE (e.g. %3) in this pane, as the daemon
140
138
  pushes it, while this pane is shown. The bar is
@@ -186,17 +184,18 @@ print(json.dumps({"ceiling": "off" if ceiling == math.inf else ceiling,
186
184
  "session": layer.text if layer else None}))
187
185
  `,v.join(e,`lib`),t.sessionId,t.cwd],env:Cz(t),timeoutMs:3e3,category:`memento.read`});return n.ok?Tz(n.stdout):z(wz(n))}function Dz(e,t,n){let r=Re({bin:v.join(e,yz),args:n.kind===`set`?[`set`,`session`,n.to]:[`clear`,`session`],env:Cz(t),timeoutMs:5e3,category:`memento.move`});if(!r.ok)throw Error(wz(r))}function Oz(e,t){return Sz(wi(e),t)}function kz(){return{locate:e=>Oz(e.claudeConfigDir,e.projectDir),read:Ez,move:Dz}}function Az(e,t,n){let r=n===void 0?``:`CLAUDE_CONFIG_DIR=${Tr(n)} `,i=e.added_dirs.map(e=>` --add-dir ${Tr(e)}`).join(``);return`cd ${Tr(e.project_dir)} && ${r}claude --resume ${Tr(t)}${i}`}function jz(e,t,n){let r=z_(t(`preset`),e.globals.preset,e.presets),i=H_(e,r),a=t(`edit.mode`)===`arrange`?e.editGlobals:{},o=Gg(a.palette,t(`theme`),i.palette),s=tz(i,ez(o,e.themeDefaults));return{preset:r,presetCustomized:n(r),theme:o,style:lh(a.style,t(`style`),s.style,e.styles),effect:_h(a.effect,t(`effect`),s.effect),endcaps:Sh(a.endcaps,t(`endcaps`),s.endcaps),variation:Dh(a.variation,t(`variation`),s.variation),shade:Ah(a.shade,t(`shade`),s.shade),separator:a.default_separator??s.default_separator,autoWrap:Rh(a.autoWrap,t(`autoWrap`),s.autoWrap),padding:Vh(a.padding,t(`padding`),s.padding),updateNotice:zh(a.updateNotice,t(`updateNotice`),s.updateNotice),transitions:Bh(a.transitions,t(`transitions`),s.transitions),colorCompatibility:a.colorCompatibility??s.colorCompatibility??`truecolor`,lanes:Fa(e=>{let n=Na[e].setting;return Xm(a[n],t(n),s[n],!1,Fh)})}}function Mz(e,t){return{endcaps:e.endcaps,separator:e.separator,colorCompatibility:e.colorCompatibility,wrap:e.autoWrap,padding:e.padding,width:t}}function Nz(e){return{theme:e.theme,style:e.style,effect:e.effect,preset:e.preset,variation:e.variation,shade:e.shade,transitions:e.transitions}}function Pz(e){return{preset:{effective:e.preset,customized:e.presetCustomized,bundled:QR(e.preset)},endcaps:{effective:e.endcaps},variation:{effective:e.variation},shade:{effective:e.shade},colorCompatibility:{effective:e.colorCompatibility},autoWrap:{effective:e.autoWrap},padding:{effective:e.padding},updateNotice:{effective:e.updateNotice},transitions:{effective:e.transitions},lanes:Fa(t=>({effective:e.lanes[t]}))}}const Fz={prNumber:!0,prState:!0,prUrl:!0,prError:!0,prEarlier:!0};function Iz(e){return e?.prState===void 0?e?.prError===void 0?e?.prEarlier===void 0?`-`:`earlier-${e.prEarlier}`:`failed`:e.prState}const Lz=10*1e3;function Rz(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 zz(e,t){if(!(t<60))return e*3600/t}function Bz(e,t,n,r){let i=r-t;if(i<50||i>Lz)return;let a=n-e;if(!(a<=0))return a*1e3/i}function Vz(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=Bz(t.input,t.atMs,n.input,n.atMs),i=Bz(t.output,t.atMs,n.output,n.atMs),a=Bz(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 Hz(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>Lz)continue;let o=Bz(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function Uz(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function Wz(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`,()=>Uz(w.hostname())),i=n(`user`,()=>w.userInfo().username);return{host:{...r!==void 0&&{name:r},...i!==void 0&&{user:i},...e.ssh!==void 0&&{ssh:e.ssh}},failures:t}}function Gz(e,t){let n=[],r=t=>lv(t,e.helpers).keys(),i=H_(e,t);for(let e of nh){let t=i[e];if(rh(t))for(let e of r(t))n.push(e)}for(let i of $g(V_(e,t).node)){if(i.when)for(let e of r(i.when))n.push(e);i.kind===`segment`&&n.push(...Kz(e,i.name))}return Jz(e,n)}function Kz(e,t){let n=e.segments[t];return n?[n.template,n.when,n.bg,n.fg].flatMap(t=>t?[...lv(t,e.helpers).keys()]:[]):[]}function qz(e,t,n){return Jz(e,[...Kz(e,t),...n.flatMap(t=>[...lv(t,e.helpers).keys()])])}function Jz(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=>lv(t,e.helpers).keys(),o=new Set;for(;r.length>0;){let e=r.pop();for(let t of Xz(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 Yz(e){let t=new Map;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=Gz(e,n);return t.set(n,i),i}}function Xz(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 Zz(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function Qz(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(Fz).some(e=>t(`git.${e}`))&&{showPullRequest:!0}}}async function $z(e,t,n,r,i,a,o,{configPath:s,...c}){let l=e=>Zz(i,e),u=bE(t).getTime(),d=o.tmux??null,f=(e,t,n)=>t?n().catch(t=>z(`${e}: ${String(t)}`)):Promise.resolve(R),[p,m,h,g,_,v,y,b,x,S,C]=await Promise.all([f(`git`,l(`git`),()=>n.gitProvider.getGitInfo(r??e.workspace?.current_dir,Qz(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(R):n.tmuxService.getSessionName(d)),f(`cache`,l(`cache`),()=>mz(e.transcript_path)),f(`speed`,l(`speed`),()=>n.usageStore.observeSpeed(e.session_id,e.transcript_path,u)),f(`memento`,l(`memento`),()=>n.mementoProvider.getCeiling(_z({sessionId:e.session_id,projectDir:e.workspace?.project_dir??``,cwd:r??e.workspace?.current_dir??``},o))),f(`autocompact`,l(`autocompact`),()=>Promise.resolve(n.autoCompact(Ci(Si(o.claudeConfigDir)))))]),w=[],ee=e=>{if(e.kind===`failed`){w.push(e.reason);return}return e.kind===`ok`?e.value:void 0},te=sB(p,u);w.push(...te.failures);let ne=Wz(o);w.push(...ne.failures);let T=ee(m),re=ee(h),E=ee(g),D=ee(_),ie=ee(v),O=ee(y),ae=ee(b),oe=nB(S);S.kind===`failed`&&w.push(`memento: ${S.reason}`);let se=eB(C,E?.maxTokens);C.kind===`failed`&&w.push(`autocompact: ${C.reason}`);for(let e of w)n.log(`warn`,`provider fetch failed: ${e}`);let ce=e.rate_limits?.five_hour,le=e.rate_limits?.seven_day,ue=ce?Rz(ce.used_percentage,ce.resets_at,18e6,u):void 0,de=le?Rz(le.used_percentage,le.resets_at,6048e5,u):void 0,fe=T?.session.cost,pe=D?.sessionDuration,me=l(`burn`)&&fe!=null&&pe!=null?zz(fe,pe):void 0,he=ee(x),ge=he===void 0?void 0:Vz(he),_e=he===void 0?void 0:Hz(he),ve=ge!==void 0||_e!==void 0?{...ge,..._e!==void 0&&{history:_e}}:void 0,ye=oB(process.env.HOME??process.env.USERPROFILE),be=e.workspace?{...e.workspace,current_dir:oB(e.workspace.current_dir)??``,project_dir:oB(e.workspace.project_dir)??``,added_dirs:(e.workspace.added_dirs??[]).map(e=>oB(e)??e)}:e.workspace,xe=T===void 0?void 0:aB({cost:T.session.cost,tokens:T.session.tokens}),Se=re===void 0?void 0:{cost:re.cost,tokens:re.tokens},Ce=D===void 0?void 0:aB({lastResponseTime:D.lastResponseTime,responseTime:D.responseTime,sessionDuration:D.sessionDuration,messageCount:D.messageCount,nonPrompts:D.nonPrompts,linesAdded:D.linesAdded,linesRemoved:D.linesRemoved}),we=ie===void 0?void 0:rB(ie);return{...e,...be!==void 0&&{workspace:be},...ye!==void 0&&{home:ye},...te.git!==void 0&&{git:te.git},...d!==null&&{tmux:{pane:d.pane,...O!==void 0&&{session:O}}},host:ne.host,...Pz(a),history:n.history(e.session_id),navigation:{back:n.navigation(e.session_id)},...c,...s!==null&&{configPath:s},resumeCommand:Az(be,e.session_id,o.claudeConfigDir),...xe!==void 0&&{session:xe},...Se!==void 0&&{today:Se},...me!==void 0&&{burn:{costPerHour:me}},...ve!==void 0&&{speed:ve},...l(`block`)&&ce!==void 0&&{block:{nativeUtilization:ce.used_percentage,resetsAt:ce.resets_at,...ue!==void 0&&{etaMinutes:ue}}},...le!==void 0&&{weekly:{percentage:le.used_percentage,resetsAt:le.resets_at,...de!==void 0&&{etaMinutes:de}}},...ae!==void 0&&{cache:{expiresAt:ae}},...E!==void 0&&{context:{totalTokens:E.totalTokens,contextLeft:E.contextLeftPercentage}},...Ce!==void 0&&{metrics:Ce},...we!==void 0&&{activity:we},...oe!==void 0&&{memento:oe},...se!==void 0&&{autocompact:se}}}function eB(e,t){switch(e.kind){case`absent`:return;case`failed`:return{error:e.reason};case`ok`:return yj(e.value,t)}}const tB=e=>e.trim().split(`
188
186
  `).at(-1).trim();function nB(e){switch(e.kind){case`absent`:return;case`failed`:return{error:tB(e.reason)};case`ok`:{let{ceiling:t,session:n}=e.value;return{ceiling:t===`off`?0:t,off:t===`off`,session:n??``}}}}function rB(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=iB(e.running),i=iB(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 iB(e){return e.length===0?void 0:e.map(e=>`${e.name}:${e.count}`).join(`,`)}function aB(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 oB(e){return e===void 0||e.length===0||v.sep!==`\\`?e:e.replace(/\\/g,`/`)}function sB(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`,DT(n.upstream,n.aheadBehind)),p=i(`repoName`,n.repoName),m=i(`repoUrl`,n.repoUrl),h=n.pullRequest===void 0?void 0:OT(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}}const cB={theme:e=>e.theme.kind===`decided`?e.theme.name:null,preset:e=>e.preset,style:e=>e.style.kind===`decided`?e.style.name:null,effect:e=>e.effect.kind===`decided`?e.effect.name:null,endcaps:e=>e.endcaps,variation:e=>e.variation,shade:e=>e.shade,transitions:e=>e.transitions?jh:Mh,autoWrap:e=>e.autoWrap?jh:Mh,padding:e=>String(e.padding),updateNotice:e=>e.updateNotice?jh:Mh,experimentalBand:e=>e.lanes.band?jh:Mh,experimentalStatusline:e=>e.lanes.statusline?jh:Mh,experimentalPane:e=>e.lanes.pane?jh:Mh},lB=Object.entries(Ba),uB=new Set(Va.map(e=>e.sessionKey)),dB=()=>!1;function fB(e,t){return jz(e,e=>uB.has(e)?t(e):null,dB)}const pB=[`preset`,`theme`];function mB(e,t,n){let r=new Set(pB.slice(0,n).map(e=>Ba[e].sessionKey));return jz(e,e=>r.has(e)?t(e):null,dB)}function hB(e,t){let n=Array.from({length:pB.length+1},(n,r)=>mB(e,t,r));return e=>{let t=pB.indexOf(e);return n[t===-1?pB.length:t]}}function gB(e,t,n,r){return e.flatMap(([e,i])=>{let a=cB[e](t);return a===null||a===cB[e](n(e))?[]:[{...i,value:a,target:r(i)}]})}function _B(e,t,n){return cB[n](fB(e,t))}function vB(e,t){let n=fB(e,t);return gB(lB,n,hB(e,t),t=>yB(e,n.preset,t.configKey))}function yB(e,t,n){return n in(B_(e.presets,t).globals??{})?WO(t,n):n}function bB(e,t,n){let r=z_(t(Ba.preset.sessionKey),e.globals.preset,e.presets),i=GO(n);return{key:i?.scope===`globals`?yB(e,r,i.field):n,globals:H_(e,r)}}function xB(e,t){let{preset:n}=fB(e,t);return wB(e,n).flatMap(({id:e,setting:r,key:i,decl:a,saved:o})=>{let s=t(i),c=s===null?void 0:b_(a,s);return c===void 0||y_(c)===y_(o)?[]:[{preset:n,id:e,setting:r,key:i,value:c}]})}function SB(e,t,n){let r=new Map(n.map(e=>[e.key,e.value]));return R_(e.presets).flatMap(n=>{let i=wB(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 __(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:b_(e.decl,n);return[e.setting,i??e.saved]}))).map(({message:t})=>`placement "${e}": ${t}`)})})}const CB=new WeakMap;function wB(e,t){let n=CB.get(e)??new Map;CB.set(e,n);let r=n.get(t);if(r!==void 0)return r;let i=[...$g(V_(e,t).node)].flatMap(t=>t.kind!==`segment`||t.drafts===void 0?[]:Object.entries(t.drafts).map(([n,{id:r,key:i}])=>{let a=h_(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 TB(e,t){let n=fB(e,t);return{from:n.preset,globals:B_(e.presets,n.preset).globals??{},picks:gB(lB.filter(([e])=>e!==`preset`),n,hB(e,t),e=>e.configKey),placements:xB(e,t)}}function EB(e,t){return jz({...e,globals:{palette:t},presets:{}},()=>null,dB)}function DB(e,t){let n=fB(e,t),r=cB.theme(n);if(r===null)return{kind:`rule`};let i=EB(e,r),a=H_(e,n.preset),o=Object.fromEntries(i_.map(e=>[e,cB[e](a[e]===void 0?n:i)]));return{kind:`look`,theme:r,look:o,differs:i_.some(e=>o[e]!==cB[e](i))}}function OB(e){return{sessionKeys:Va.filter(t=>t.configKey===e).map(e=>e.sessionKey),fileKeys:[e,...SO(e)?ZR.map(t=>WO(t,e)):[],...UO(e)?Zm().map(t=>HO(t,e)):[]]}}function kB(e){return new Set(Va.map(e=>e.configKey).filter(t=>OB(t).fileKeys.some(t=>MB(e,jB(t)))))}function AB(e,t,n){let r=vB(e,n),i=new Set(r.map(e=>e.configKey)),a=Ka(e=>i.has(Ba[e].configKey)||t.has(Ba[e].configKey)),o=DB(e,n);return{unsaved:r.length+xB(e,n).length,resettable:a,themeDefault:o.kind===`look`&&o.differs?{differs:!0,theme:o.theme}:{differs:!1}}}function jB(e){let t=GO(e);if(t===null||t.scope===`preset-root`)throw Error(`reset layer "${e}" is not a value path`);return KO(t)}function MB(e,t){let[n,...r]=t;return n===void 0?e!==void 0:typeof e==`object`&&!!e&&MB(e[n],r)}const NB=Zm(),PB=new Set(NB),FB=new Set(vh),IB=e=>e?PB.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${NB.join(`, `)})`}:{ok:!1,reason:`theme name is required`},LB=e=>e?FB.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown endcaps "${e}" (have: ${vh.join(`, `)})`}:{ok:!1,reason:`endcaps name is required`},RB=new Set([`1`,`true`]),zB=new Set([`0`,`false`]),BB={endcaps:LB,theme:IB,"toolbar-expanded":e=>RB.has(e)?{ok:!0,value:`1`}:zB.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}},VB=YN(BB,`state`,JB);function HB(e,t){return VB.register(e,t)}function UB(e){return VB.gateFor(e)}function WB(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:J_(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 GB(e){return e.filter(e=>e.spec.kind!==`allow-list`||!Object.hasOwn(BB,e.key))}function KB(e,t,n){let r=qa.get(n);if(r!==void 0)return _B(e,t,r);for(let[,t]of d_(e))if(t.key===n)return t.default??null;return null}function qB(e){let t=vN(e);return GB(Object.values(e.actions).flatMap(e=>WB(e,t)))}function JB(e){return qN(qB(e))}const YB=`update.dismissed`,XB=`updateNotice`,ZB=Ba.updateNotice.sessionKey;function QB(e){return e.kind===`source`?e.newer.digest:Mi(e.newer)}const $B=e=>`${e.version} [${jg(e.digest)}]`;function eV(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:$B(e.newer),running:$B(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:Mi(e.newer),running:Mi(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${Pi}@${Mi(e.newer)}`,`install`]}}}}const tV={kind:`idle`},nV={kind:`running`};function rV(e,t,n){if(e===null)return[];let r=QB(e);if(!n.enabled||n.dismissed===r)return[];let i=eV(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(`
189
- `),c=I([{verb:Ln,args:[s]}]),l=t.kind===`running`?gg(`[${i.busy}]`,c):gg(`[${i.act}]`,I([{verb:Xn,args:[n.sessionId]}]));return[{severity:hg,message:s,lines:[[gg(a,c),l,gg(`[dismiss]`,I([{verb:jn,args:[n.sessionId,YB,r]}])),gg(`[disable]`,I([{verb:Rn,args:[n.sessionId,XB,`false`]},{verb:jn,args:[n.sessionId,ZB,`false`]}]))],...o.map(e=>[gg(e,c)])]}]}function iV(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 aV(e){switch(e.kind){case`current`:return[`info`,`build: current ${$B(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${$B(e.source)}, running ${$B(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function oV(e){switch(e.kind){case`current`:return[`info`,`release: current ${Mi(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${Mi(e.latest)}, running ${Mi(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${Mi(e.installed)}, latest ${Mi(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function sV(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const cV=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function lV(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=cV(e.stderr)??e.error??cV(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function uV(){let e=[ZN(XB,[`false`]),HB(ZB,[`false`]),HB(YB,[])];return()=>e.forEach(e=>e())}function dV(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=tV,d=null,f=sV(s),p=sV(s),m=()=>iV(c,l);function h(){let e=m(),t=e===null?null:QB(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:HB(YB,[t])})}function g(){c=Ig(t,Ng),f(aV(c)),h()}async function _(){l=Ii(Ft,await Fi(Pi,a,i)),p(oV(l)),h()}return{arm(){uV(),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 q(`apply-update: nothing newer is known to apply`);let t=eV(e);if(u.kind===`running`)throw new q(`apply-update: already ${t.busy}`);u=nV,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),Le({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=tV,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=lV(n);u={kind:`failed`,identity:QB(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}var fV=class{static CACHE_DIR=We();static USAGE_CACHE_DIR=v.join(this.CACHE_DIR,`usage`);static LOCKS_DIR=v.join(this.CACHE_DIR,`locks`);static isLocked(e){let t=v.join(this.LOCKS_DIR,e);if(!s.existsSync(t))return!1;try{let n=s.readFileSync(t,`utf-8`),r=parseInt(n.trim(),10);if(isNaN(r))return k(`Invalid PID in lock file ${e}, removing stale lock`),s.unlinkSync(t),!1;try{return process.kill(r,0),!0}catch(n){return n.code===`ESRCH`?(k(`Removing stale lock file ${e} for dead process ${r}`),s.unlinkSync(t),!1):(k(`Error checking process ${r} for lock ${e}:`,n),!0)}}catch(t){return k(`Error reading lock file ${e}:`,t),!0}}static async acquireLock(e,t=5e3){await this.ensureCacheDirectories();let n=v.join(this.LOCKS_DIR,e),r=Date.now(),i=String(process.pid);for(;Date.now()-r<t;)try{return await s.promises.writeFile(n,i,{flag:`wx`}),k(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await he(50);else throw e}return k(`Failed to acquire lock for ${e} within ${t}ms`),!1}static async releaseLock(e){let t=v.join(this.LOCKS_DIR,e);try{await s.promises.unlink(t),k(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&k(`Error releasing lock for ${e}:`,t)}}static async ensureCacheDirectories(){try{await Promise.all([s.promises.mkdir(this.CACHE_DIR,{recursive:!0}),s.promises.mkdir(this.USAGE_CACHE_DIR,{recursive:!0}),s.promises.mkdir(this.LOCKS_DIR,{recursive:!0})])}catch(e){k(`Failed to create cache directories:`,e)}}static createProjectHash(e){return ae(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t){await this.ensureCacheDirectories();let n=v.join(this.USAGE_CACHE_DIR,`${e}.json`),r=`${e}.usage.lock`;for(let i=0;i<3;i++){if(this.isLocked(r)){k(`Cache for ${e} is locked, waiting...`),await he(75);continue}try{let r=await s.promises.readFile(n,`utf-8`),i=JSON.parse(r);return!t||i.timestamp>=t?(k(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(i.data)):(k(`${e} cache outdated: cache=${i.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return k(`No shared ${e} usage cache found`),null;k(`Attempt ${i+1} failed to read ${e} cache: ${t.message}. Retrying...`),await he(75)}}return k(`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)){k(`Could not acquire lock to set usage cache for ${e}`);return}try{await this.ensureCacheDirectories();let r=v.join(this.USAGE_CACHE_DIR,`${e}.json`),i=JSON.stringify({data:t,timestamp:n||Date.now()});await s.promises.writeFile(r,i,`utf-8`),k(`[CACHE-SET] ${e} disk cache stored`)}catch(t){k(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(r)}}};const pV={"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 mV=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 fV.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await fV.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new n(this.GITHUB_PRICING_URL),r=me({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){k(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let n=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){k(`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)?(k(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),k(`Pricing last updated: ${r?.updated||`unknown`}`),e(i)):(k(`Invalid pricing data structure`),e(null))}catch(t){k(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{k(`Response error:`,t),e(null)})});r.on(`error`,t=>{k(`Request error:`,t),e(null)}),r.on(`timeout`,()=>{k(`Request timeout`),r.destroy(),e(null)}),r.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return k(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return k(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),k(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(k(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(pV).length} models`),this.executionCache=pV,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(pV).length} models`),pV)}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 k(`[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),k(`[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 hV=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function gV(e){if(typeof e==`string`)return hV.exec(e)?.[1]}function _V(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 vV(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 yV(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=_V(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`?gV(vV(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 bV(e){if(e!==void 0)return[e];let t=ee();return[S(t,`.config`,`claude`),S(t,`.claude`)].filter(e=>d(e))}async function xV(e){let t=[];for(let n of e){let e=S(n,`projects`);if(d(e))try{let n=await oz(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=S(e,r.name);t.push(n)}}catch(t){k(`Failed to read projects directory ${e}:`,t)}}return t}async function SV(e,t,n){let r=[],i=S(t,e,`subagents`);try{let t=(await oz(i)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let a of t){let t=S(i,a);if(n?.has(t)){r.push(t);continue}try{let n=(await sz(t,`utf-8`)).split(`
190
- `)[0];n&&JSON.parse(n).sessionId===e&&r.push(t)}catch{k(`Failed to check agent file ${t}`)}}}catch(e){k(`Failed to read subagents directory ${i}:`,e)}return r}function CV(e){let t=e.message;if((e.type||t?.role||t?.type)!==`user`)return;if(TV(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=vV(t?.content).trimStart();return r.startsWith(`[Request interrupted by user`)?`interrupt`:e.isMeta===!0||e.isCompactSummary===!0||wV.test(r)?`claude-code`:`prompt`}const wV=/^<(?:command-name|local-command-std(?:out|err)|bash-(?:input|stdout|stderr))>/;function TV(e){let t=e?.content;return Array.isArray(t)&&typeof t[0]==`object`&&t[0]?t[0].type:void 0}const EV=new Map;async function DV(e){try{let t=await cz(e),n=t.size,r=EV.get(e);if(r&&r.mtime===t.mtimeMs&&r.size===n)return k(`[parse-cache] hit ${e}`),EV.delete(e),EV.set(e,r),r.entries;let i;return n>1048576?(k(`Using streaming parser for large file ${e} (${Math.round(n/1024)}KB)`),i=await PV(e)):i=await MV(e),k(`Parsed ${i.length} entries from ${e}`),n>5242880?i:(EV.delete(e),EV.size>=16&&EV.delete(EV.keys().next().value),EV.set(e,{mtime:t.mtimeMs,size:n,entries:i}),i)}catch(t){if(t.code===`ENOENT`)return k(`Transcript not present yet: ${e}`),[];throw t}}function OV(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=CV(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:yV(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 kV(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 AV(e){let t=kV(e);if(t.kind===`unparsed`)return k(`Failed to parse JSONL line: ${t.reason}`),null;if(t.kind===`blank`)return null;try{return OV(t.value)}catch(e){return k(`Failed to project JSONL line: ${e}`),null}}function jV(e){let t=[];for(let n of e.split(`
191
- `)){let e=AV(n);e&&t.push(e)}return t}async function MV(e){return jV(await sz(e,`utf-8`))}async function NV(e,t){let n=await lz(e,t===void 0?void 0:{offset:t.offset,ino:t.ino});if(n.kind!==`ok`)return n;let{buf:r,start:i,stamp:a,ino:o,reset:s}=n.value,c=r.lastIndexOf(10);return L(c<0?{entries:[],cursor:{offset:i,stamp:a,ino:o},reset:s}:{entries:jV(r.subarray(0,c+1).toString(`utf-8`)),cursor:{offset:i+c+1,stamp:a,ino:o},reset:s})}async function PV(e){return new Promise((t,n)=>{let r=[],i=u(e,{encoding:`utf8`}),a=ge({input:i,crlfDelay:1/0});a.on(`line`,e=>{let t=AV(e);t&&r.push(t)}),a.on(`close`,()=>{t(r)}),a.on(`error`,t=>{k(`Streaming parser error for ${e}:`,t),n(t)}),i.on(`error`,t=>{k(`File stream error for ${e}:`,t),n(t)})})}var FV=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 IV(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 LV=new Map,RV={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0},zV={cost:null,calculatedCost:null,officialCost:null,tokens:null,tokenBreakdown:null};function BV(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function VV(){let e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()-1),e.getTime()}function HV(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}async function UV(e,t,n,r){let i=BV(new Date(VV())),a=e&&!t?e:void 0,o=a?.entries??0,s=a?.cost??0,c=a?{...a.breakdown}:HV(),l=new Map;if(a)for(let[e,t]of a.days)e>=i&&l.set(e,{...t});for(let e of n){let t=e.message?.usage;if(!t)continue;o++;let n=e.costUSD??await mV.calculateCostForEntry(e.raw);s+=n,c.input+=t.input_tokens||0,c.output+=t.output_tokens||0,c.cacheCreation+=t.cache_creation_input_tokens||0,c.cacheRead+=t.cache_read_input_tokens||0;let r=BV(new Date(e.timestamp));if(r<i)continue;let a=l.get(r)??{...RV};a.cost+=n,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,l.set(r,a)}return{cursor:r,entries:o,cost:s,breakdown:c,days:l}}function WV(e){let t=0,n=0,r=HV(),i=new Map;for(let 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)??{...RV};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:zV,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 GV(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 KV=class{sessions=new Map;flight=new FV;seeded=new Map;seededDay=``;rescanIntervalMs;speedFlight=new FV;staleAgeMs;log;renderTally={hits:0,misses:0};sweeps=0;scans={seed:0,rescan:0};sweepTimer=null;constructor(e={}){this.log=e.logger??Gt,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:zV,i=t?.cost?.total_cost_usd??null;return L({session:{...r,cost:i??r.cost,officialCost:i}})}async getTodayInfo(e,t,n){let r=BV(bE(n)),i=bV(t);try{await this.ensureSeeded(r,i,n*1e3)}catch(e){return z(`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=>S(e,`projects`)+C),s={...RV},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??LV:LV;c||=a.has(r);let l=a.get(r)??RV;s.cost+=l.cost,s.input+=l.input,s.output+=l.output,s.cacheCreation+=l.cacheCreation,s.cacheRead+=l.cacheRead}return c?L({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}):R}async observeSpeed(e,t,n){if(!e)return R;let r=nz(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=IV(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(),L({...s!==void 0&&{prev:s},cur:a,samples:[...o]})})}async ingest(e,t,n,r){if(!e)return R;let i=r??nz(t),a=this.see(e)?.record;if(a&&i!==``&&a.transcriptStamp===i)return n.hits++,L(a);if(!t)return a?L(a):R;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 z(`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),L(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 SV(e,b(t),n===void 0?void 0:new Set(n.files.keys())),i=new Map,a=``;for(let e of[t,...r]){let r=n?.files.get(e),o=await NV(e,r?.cursor);if(o.kind===`failed`)return o;if(o.kind===`absent`){r&&i.set(e,r);continue}let{entries:s,cursor:c,reset:l}=o.value;i.set(e,await UV(r,l,s,c)),e===t&&(a=c.stamp)}return L({files:i,...WV(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=VV(),i=await xV(e),a=[];for(let e of i){let t;try{t=await oz(e)}catch{continue}for(let n of t){if(!n.endsWith(`.jsonl`))continue;let t=S(e,n),i;try{i=await cz(t)}catch{continue}i.mtimeMs<r||a.push({sessionId:n.slice(0,-6),path:t,stamp:rz(i)})}}let o={hits:0,misses:0};await GV(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()}},qV=class{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 k(`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);k(`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){try{k(`Calculating context tokens from transcript: ${e}`);let n=await DV(e);if(n.length===0)return k(`No entries in transcript`),R;let r=null;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t&&t.message?.usage?.input_tokens&&t.isSidechain!==!0){r=t,k(`Context segment: Found most recent entry at ${t.timestamp.toISOString()}, stopping search`);break}}if(r?.message?.usage){let e=r.message.usage,n=(e.input_tokens||0)+(e.cache_read_input_tokens||0)+(e.cache_creation_input_tokens||0);return k(`Most recent main chain context: ${n} tokens (limit: ${t})`),L({totalTokens:n,maxTokens:t,...this.ratioPercentages(n,t)})}return k(`No main chain entries with usage data found`),R}catch(e){return z(`context transcript: ${e instanceof Error?e.message:String(e)}`)}}async getContextInfo(e){let t=this.calculateContextFromHookData(e);if(t)return L(t);let n=e.context_window?.context_window_size??2e5;return this.calculateContextTokensFromTranscript(e.transcript_path,n)}},JV=class{states=new Map;constructor(e,t,n=256){this.empty=e,this.step=t,this.maxSessions=n}async read(e,t){let n=this.states.get(e),r=nz(t);if(n&&r!==``&&n.cursor.stamp===r)return this.touch(e,n),{kind:`ok`,value:n.value};let i=await NV(t,n?.cursor);if(i.kind===`failed`)return i;if(i.kind===`absent`)return{kind:`ok`,value:n?.value??this.empty};let{entries:a,cursor:o,reset:s}=i.value,c=s||n===void 0?this.empty:n.value;for(let e of a)c=this.step(c,e);for(this.touch(e,{cursor:o,value:c});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:c}}touch(e,t){this.states.delete(e),this.states.set(e,t)}};const YV={messageCount:0,nonPrompts:0,recent:[]},XV=new Set([`turn`,`interrupt`,`claude-code`]);function ZV(e,t){if(t.isSidechain)return e;let n=[...e.recent,t];return{messageCount:e.messageCount+ +(t.userEntry===`prompt`),nonPrompts:e.nonPrompts+ +!!XV.has(t.userEntry),recent:n.length>20?n.slice(-20):n}}function QV(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 $V=class{fold=new JV(YV,ZV);async getMetricsInfo(e,t){if(k(`Getting metrics from hook data for session: ${e}`),!t.cost)return R;let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?z(`metrics (${e}): ${n.reason}`):L({responseTime:t.cost.total_api_duration_ms/1e3,lastResponseTime:QV(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 eH={command:null,todos:[],pending:[],done:[]};function tH(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 nH(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 rH(e,t){if(t.isSidechain)return e;let n=nH(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=tH(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 iH(e){return{command:e.command,todos:e.todos,running:e.pending.reduce((e,t)=>tH(e,t.name),[]),done:e.done}}var aH=class{fold=new JV(eH,rH);async getActivityInfo(e,t){let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?z(`activity (${e}): ${n.reason}`):L(iH(n.value))}};function oH(e,t,n,r){return{bin:`tmux`,args:[`-S`,e.socket,...n],timeoutMs:2e3,category:t,stdinInput:r}}function sH(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 cH(e,t,n,r){return sH(Re(oH(e,t,n,r)),n)}async function lH(e,t,n){return sH(await Le(oH(e,t,n)),n)}const uH=e=>`${e.socket}\n${e.pane}`;var dH=class{names=new Map;asking=new FV;constructor(e=Date.now){this.now=e}getSessionName(e){let t=uH(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){k(`Getting tmux session name for pane ${t.pane} on ${t.socket}`);let n=await lH(t,`tmux`,[`display-message`,`-p`,`-t`,t.pane,`#S`]),r=n.kind===`ok`?n.stdout.trim():``,i=n.kind===`ok`?r?L(r):R:z(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 fH=e=>JSON.stringify([e.sessionId,e.projectDir,e.cwd,e.claudeConfigDir,e.env===void 0?null:ot.map(t=>e.env?.[t]??null)]);var pH=class{readings=new Map;inFlight=new Map;constructor(e,t=Date.now){this.edge=e,this.now=t}getCeiling(e){let t=fH(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=fH(e);try{this.edge.move(n.value,e,t)}finally{this.readings.delete(r),this.inFlight.delete(r),this.fetch(r,e)}}};function mH(e){return{gitProvider:new mE({watchers:e.watchers,logger:e.logger}),usageStore:new KV({logger:e.logger}),contextProvider:new qV,metricsProvider:new $V,activityProvider:new aH,tmuxService:new dH,mementoProvider:new pH(kz()),autoCompact:vj,log:e.logger}}function hH(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}const gH={kind:`hidden`},_H={kind:`shown`};function vH(e,t){try{return hH(e,t)?_H:gH}catch(e){return{kind:`failed`,message:e instanceof Error?e.message:String(e)}}}function yH(e,t){let n=K.fromFragments(e);return n.end=``,n.overflow=`ignore`,t!==void 0&&!t.isNull&&(n.style=t),n}function bH(e,t,n){e.cellLength>t?e.truncate(t,{mode:n.truncate,marker:`…`}):e.cellLength<t&&e.align(n.justify,t)}function xH({lead:e,text:t,trail:n}){return[...e===void 0?[]:[e],t,...n===void 0?[]:[n]]}function SH({text:e,placement:t,lead:n,trail:r}){return{text:CH(e),placement:t,...n!==void 0&&{lead:CH(n)},...r!==void 0&&{trail:CH(r)}}}function CH(e){let t=e.blankCopy(e.plain);t.style=Ip(e.style).clearMetaAndLinks();for(let{start:n,end:r,style:i}of e.spans)t.stylize(Ip(i).clearMetaAndLinks(),n,r);return t}function wH(e){let t=xH(e);if(t.length===1)return e.text;let n=yH(t);return n.style=e.text.style,n}function TH(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=yH(e,a).pad(o),d=new K(` `.repeat(o)),f={placement:s,...c.length>0&&{lead:yH([d,...c],a)},...l.length>0&&{trail:yH([...l,d],a)}};if(n===`auto`)return[{text:u,...f}];let p={justify:r,truncate:i};return n===`fill`?[{text:u,fill:p,...f}]:(bH(u,n,p),[{text:u,...f}])}const EH=RegExp(`\\x1b\\[[0-9;]*m|${mu.source}`,`g`);function DH(e){return Math.max(0,...e.split(`
192
- `).map(e=>io(e.replace(EH,``))))}function OH(e,t){let n=()=>e.map(e=>({owner:wH(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=dg(e.map(wH),t).split(`
193
- `);if(i.length>1)return n();let a=Math.max(0,t.width-DH(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];bH(c,c.cellLength+a,n)}),n()}function kH(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=AH(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e){let e={frag:a,style:Ip(a.style)};if(e.style.link){i();let r=AH([e],t);r.plain.length>0&&n.push(r)}else r.push(e)}return i(),n}function AH(e,t){let n=t!==void 0&&!t.isNull?t:void 0,r=e.map(e=>jH(e.frag,n?n.add(e.style):e.style)),i=K.fromFragments(r);return i.end=``,i.overflow=`ignore`,r.length===1?i.style=r[0].style:n!==void 0&&(i.style=n),i}function jH(e,t){let n=e.copy();return n.style=t,n}function MH(e,t){if(e.look===void 0)throw Error(`${t} read the render's look before any render resolved one`);return e.look}function NH(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,PH(e,t,o,n,r,i));return i}function PH(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=J_(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=Wa.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=J_(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=J_(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:LH(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:LH(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:eI(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:LH(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 FH(e){return e.kind===`do`?FH(e.head):e}function IH(e){switch(FH(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 LH(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function RH(e,t){return e.has(t)?Ev(e.read(t)):``}function zH(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function BH(e,t,n,r){let i=new K(e,{style:U.combine([r,new U({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function VH(e,t,n=!1){let r=new U({link:t,bold:n?!0:void 0}),i=new K(e.plain,{style:U.combine([Ip(e.style),r])});for(let t of e.spans)i.stylize(U.combine([Ip(t.style),r]),t.start,t.end);return i.overflow=`ignore`,i.end=``,i}function HH(e,t){return Math.max(e.members.indexOf(RH(t,e.stateVar)),0)}function UH(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=RH(r,e.stateVar);return{effects:[{verb:jn,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=RH(r,e.stateVar);return{effects:[{verb:jn,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=RH(r,e.stateVar);return{effects:[{verb:jn,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(HH(e,r)+1)%e.members.length];return{effects:[{verb:jn,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:Mn,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:Nn,args:[zH(e.text,bT(r))]}],active:!1};case`open`:return{effects:[{verb:Pn,args:[zH(e.target,bT(r))]}],active:!1};case`persist-literal`:{let t=RH(r,e.stateVar);return{effects:[{verb:Rn,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=RH(r,e.stateVar);return{effects:[{verb:Rn,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(HH(e,r)+1)%e.members.length];return{effects:[{verb:Rn,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:zn,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:Wn,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:Kn,args:[i]}],active:!1};case`redo`:return{effects:[{verb:qn,args:[i]}],active:!1};case`back`:return{effects:[{verb:Jn,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:Yn,args:[i]}],active:!1};case`save`:return{effects:[{verb:Bn,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:Vn,args:[i]}],active:!1};case`theme-default-save`:return{effects:[{verb:Hn,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:Un,args:[i,zH(e.name,bT(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:Zn,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:Qn,args:[i,e.check]}],active:!1};case`doctor-mark`:return{effects:[{verb:$n,args:[i,e.check,e.mark]}],active:!1};case`ceiling`:return{effects:[{verb:tr,args:[i,...e.args]}],active:!1};case`slash`:return{effects:[{verb:nr,args:[i,e.line]}],active:!1};case`layout-op`:return{effects:[{verb:Gn,args:[i,e.key,LN(e.op)]}],active:!1};case`do`:{let a=UH(e.head,t,n,r,i);return{effects:[...a.effects,...e.rest.flatMap(e=>UH(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:Gn,args:[i,e.key,LN(r)]}],active:!1}}}}function WH(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:pr(`action "${e}"`,n,t.members.length,HH(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 GH(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=n.store,{display:a,boundValue:o}=WH(e,FH(r),t,i),s=RH(i,`session.id`),{effects:c,active:l}=UH(r,a.plain,o,i,s);return VH(a,I(c),l)}function KH(e){return{action:{fn:(t,...n)=>GH(t,n,e),argTypes:[`string`,`liftable`],arity:{kind:`variadic`},returnType:`T`}}}function qH(e,t){return BH(`✕`,I([{verb:jn,args:[RH(e,`session.id`),t,ur]}]),!1)}function JH(e,t,n){return new U({bgcolor:H.fromRgba(t),color:H.fromRgba(xm(e,t,n))})}function YH({tint:e,text:t}){return new U({bgcolor:H.fromRgba(e),color:H.fromRgba(t)})}function XH(e,t,n){return new U({color:H.fromRgba(Qs(dm(e,`warning`),t,bm,n))})}function ZH(e,t,n){return U.combine([JH(e,t,n),XH(e,t,n)])}function QH(e,t,n){return JH(e.palette,Hm(e.palette,e.disclosure,[t],n),n)}function $H(e){let t=H.fromRgba(dm(e,`background`)),n=K.fromFragments(Rp.map(n=>new K(`▀`,{style:new U({color:H.fromRgba(dm(e,n)),bgcolor:t})})));return n.overflow=`ignore`,n.end=``,n}const eU=(e,t)=>{let n=typeof e==`string`?new K(e,{style:t}):e;return n.overflow=`ignore`,n.end=``,n},tU=e=>new U({bold:e});function nU(e,t,n,r,i,a){if(r===void 0)return(n,r,a,o)=>eU(a,U.combine([QH(e,{...n,distribution:t},i),tU(o)]));let o=JH(e.palette,a,i);return(e,t,i,a)=>rU(i,U.combine([o,tU(a)]),r(t,n))}const rU=(e,t,n)=>eU(K.fromFragments([eU(e,t),eU(` `,t),$H(n)]));function iU(e,t){return t===void 0?(e,t,n)=>eU(n):(n,r,i)=>rU(i,void 0,t(r,e))}function aU(e,t,n,r,i){let a=JH(e.palette,i,r);return(e,r,i,o)=>eU(K.fromFragments([eU(o?`[`:` `,a),$H(n(r,t)),eU(o?`]`:` `,a)]))}function oU(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=>sU(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function sU(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function cU(e,t){return new K(e).truncate(t,{marker:`…`}).plain}function lU(e){return{current:null,drawnAt:e}}function uU(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 dU(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 fU(e){return new K(e).cellLength}function pU(e){return Math.max(1,e.width-e.chromeCols-2*e.padding)}function mU(e){return Math.max(1,pU(e)-(fU(`✕`)+2*e.padding+e.seamCols))}function hU(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 gU(e,t,n){let r=fU(`←`)+1+fU(`→`)+1,i=hU(e,t,n);return(i.length>1?hU(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function _U(e,t){let n=[];for(let t of e)n.length>0&&n.push(new K(` `)),n.push(t);let r=K.fromFragments(n);return r.overflow=t?`ignore`:void 0,r.end=``,r}function vU(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 yU(e,t,n){let r=e.compiled.get(t),i=r&&FH(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 bU(e,t,n,r,i,a,o,s,c=[]){let l=a.compiled.get(e),u=a.store,d=RH(u,`session.id`),f=`stateVar`in t?RH(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`?mU(a):pU(a):1/0,h=(r.kind===`led`?0:fU(`✕`)+1)+c.reduce((e,t)=>e+fU(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?gU(_.map(e=>e.cellLength),m,h):oU(g.entries,g.groups,i),y=parseInt(RH(u,n.stateVar),10),b=e=>Math.max(0,v.findIndex(t=>t.some(t=>t.indices.includes(e)))),x=b(f===void 0?-1:t.options.indexOf(f)),S=Number.isInteger(y)?y<0?x:Math.min(y,v.length-1):0,C=v[S]??[],w=e=>I([{verb:jn,args:[d,n.key,String(e)]}]),ee=r.kind===`led`?[]:[{verb:jn,args:[d,...r.writes.flatMap(([e,t])=>[e,t])]}],te=r.kind===`own`&&r.onPick?ee:[],ne=e=>I([...UH(l,e,e,u,d).effects,...te]),T=(e,n)=>VH(e,ne(t.options[n])),re=r.kind===`led`?[]:[BH(`✕`,I(ee),!1,s)];re.push(...c.map(({glyph:e,option:r})=>BH(e,I([...UH(l,r,r,u,d).effects,{verb:jn,args:[d,n.key,String(b(t.options.indexOf(r)))]}]),!1))),S>0&&re.push(BH(`←`,w(S-1),!1));let E=S<v.length-1?[BH(`→`,w(S+1),!1)]:[];if(g===void 0){let e=C.flatMap(e=>e.indices);return[_U([...re,...e.map(e=>T(_[e],e)),...E],i)]}let D=new U({bold:!0}),ie=v.length>1?` ${S+1}/${v.length}`:``,O=C.length===1?[new K(`${C[0].label}${ie}`,{style:D})]:[],ae=[_U([...re,...O,...E],i)];for(let e of C){C.length>1&&ae.push(_U([new K(e.label,{style:D})],i));let n=Math.max(...e.indices.map(e=>fU(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:Dp(a),s=` `.repeat(n-fU(e)+2),c=o===void 0?e:`${e}${s}${o}`;ae.push(_U([T(p(r,cU(c,m)),r)],i))}}return ae}function xU(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{mT(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=vU(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=yU(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=dU(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]=bU(n,l,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,nU(u,$p(void 0),MH(e,`{{ picker }}`),l.paletteOf,t.drawnAt(),u.bg),XH(u.palette,u.bg,t.drawnAt()));return d},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function SU(e,t){let n=e.length,r=Math.max(e.indexOf(t),0);return e=>((r+e)%n+n)%n}function CU(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 wU(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=n.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=RH(o,`session.id`),{options:l}=t,u=l.length;if(u===0)return _U([],!0);let d=RH(o,t.stateVar),f=SU(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=I(UH(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=VH(g(e),h(e));return _.set(e,n),n},y=a===void 0?v(0):VH(iU(MH(n,`{{ carousel }}`),t.paletteOf)({index:f(0),count:u},p(0),p(0),!1),I(UH(n.compiled.get(a),p(0),void 0,o,c).effects)),b=CU(e=>v(e).cellLength,u,fU(`◀`)+1+y.cellLength+1+fU(`▶`),mU(n),i),x=e=>Array.from({length:b},(t,n)=>v(e*(n+1)));return _U([...x(-1).reverse(),BH(`◀`,h(-1),!1),y,BH(`▶`,h(1),!1),...x(1)],!0)}function TU(e,t){return{carousel:{fn:(n,...r)=>{let[i,a,...o]=r;if(mT(`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&&IH(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=yU(e,n,`carousel`),l=dU(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 wU(n,c,e,nU(l,$p(void 0),MH(e,`{{ carousel }}`),c.paletteOf,t.drawnAt(),l.bg),s,a)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function EU(e,t,n){let r=yU(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 DU(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 OU(e,t,n,r){let i=EU(e,t,n),a=r??RH(e.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,MH(e,`{{ ${n} }}`))}function kU(e,t,n){return{swatch:{fn:(t,...n)=>{let[r,...i]=n;if(mT(`swatch "${t}"`,[`option`],i),r!==void 0&&typeof r!=`string`)throw Error(`swatch "${t}": option must be text, got ${JSON.stringify(r)}`);return $H(OU(e,t,`swatch`,r))},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`},swatches:{fn:(r,i)=>{let a=EU(e,r,`swatches`),o=vU(e,i,`set-int`,`an int action ({ set, int: true })`,`swatches`),s=dU(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]=bU(r,a,{key:o.key,stateVar:o.stateVar},{kind:`led`},!0,e,aU(s,MH(e,`{{ swatches }}`),a.paletteOf,c,s.bg),XH(s.palette,s.bg,c),u===0?[]:(()=>{let t=SU(l,RH(e.store,a.stateVar));return[{glyph:`◀`,option:l[t(-1)]},{glyph:`?`,option:l[DU(n().getTime(),u,t(0))]},{glyph:`▶`,option:l[t(1)]}]})());return d},argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}const AU=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function jU(e,t,n,r){let i=Nm(e,n,r),a=(t,n)=>({text:t,colour:n,ink:xm(e,n,r)});return[[Jp(t).map((n,i)=>{let a=fm(e,n);return{text:AU[i%AU.length],colour:a,ink:t.shade.text(e,n.hue,a,r)}})],[[a(`▾ open`,i.state),a(`menu`,i.plane)],[a(`warn`,dm(e,`warning`)),a(`error`,dm(e,`error`))]]]}function MU(e,t){let n=e.flatMap((e,t)=>e.map(({text:e,colour:n,ink:r},i)=>({gap:t>0&&i===0?` `:``,cell:new K(` ${e} `,{style:YH({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 K(e)),r.push(a)}return r}function NU(e,t,n,r,i){let a=jU(e,t,n,r).map(e=>MU(e,i)),o=K.fromFragments(a.flatMap((e,t)=>t===0?e:[new K(`
194
- `),...e]));return o.overflow=`ignore`,o.end=``,o}function PU(e,t){return{themePreview:{fn:(...n)=>{let[r,...i]=n;if(mT(`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}=MH(e,`{{ themePreview }}`);return NU(r===void 0?a:OU(e,r,`themePreview`),o,{...dU(t,`{{ themePreview }}`).disclosure,depth:0},t.drawnAt(),mU(e))},argTypes:[`value`],arity:{kind:`variadic`},returnType:`T`}}}const FU=e=>e.slice(e.lastIndexOf(`.`)+1),IU=(e,t)=>{let n=new K(FU(e));return n.truncate(t,{marker:`…`}),n.plain};function LU(e,t){let n=e.map(e=>e.map(({name:e})=>fU(FU(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 RU(e,t,n,r){let i=LU(e,r),a=e.map(e=>{let a=[],o=0;for(let{name:s,address:c,palette:l}of e){let e=new K(` ${IU(s,i)} `,{style:YH(Km(l,{kind:`bar`,decor:t,address:c},n))});if(o+=e.cellLength,o>r)break;a.push(e)}return a}),o=K.fromFragments(a.flatMap((e,t)=>t===0?e:[new K(`
195
- `),...e]));return o.overflow=`ignore`,o.end=``,o}function zU(e,t){return{layoutPreview:{fn:()=>RU(e.layout(),MH(e,`{{ layoutPreview }}`).decor,t.drawnAt(),mU(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function BU(e,t,n,r){let i=dU(r.activeSegment,`{{ menu }}`),a=r.action,o=cD(i.placementId,e,n.key),s=dD(o),c=sD(e),l=RH(a.store,o)===c,u=RH(a.store,`session.id`),d=l?ur:c,f=BH(pr(`{{ menu "${e}" }}`,t,2,+!!l),I([{verb:jn,args:[u,o,d,s,`0`]}]),!1);return i.drops.push(...l?(()=>{let t=r.activeSegment.drawnAt(),c=Nm(i.palette,i.disclosure,t).plane,l=yU(a,e,`menu`);return bU(e,l,{key:s,stateVar:s},{kind:`own`,writes:[[o,ur],[s,`0`]],onPick:n.closeOnPick},n.paged,a,nU(i,n.distribution,MH(a,`{{ menu }}`),l.paletteOf,t,c),XH(i.palette,c,t))})():[]),f}const VU=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function HU(e,t){let n=t[t.length-1],r=VU(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:hD(r??{})}}function UU(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=HU(t,n);return BU(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function WU(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=GU(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 K(t?i:a,{style:l===void 0?void 0:new U({color:l})}))}let l=K.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function GU(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 KU(e){let t={fn:(()=>{let t=dU(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:(()=>dU(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r={fn:((t,n)=>{let{palette:r}=dU(e,`{{ keptOn }}`),i=Us(r,t),a=Us(r,n),o=No(ec(i,V.TRUECOLOR),ec(a,V.TRUECOLOR)),s=Math.min(bm,Math.max(o,3));return($s(i,e.drawnAt(),(e,t)=>No(e,t(a))>=s)??i).hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},i=Qw(()=>dU(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),a={fn:((e,t,n,r,a,o,...s)=>{let c=o===void 0?void 0:[o,...qU(s)];return WU({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 qU(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 JU(e){let t=[],n=[];for(let r of e){if(!r.contains(`
187
+ `),c=I([{verb:Ln,args:[s]}]),l=t.kind===`running`?gg(`[${i.busy}]`,c):gg(`[${i.act}]`,I([{verb:Xn,args:[n.sessionId]}]));return[{severity:hg,message:s,lines:[[gg(a,c),l,gg(`[dismiss]`,I([{verb:jn,args:[n.sessionId,YB,r]}])),gg(`[disable]`,I([{verb:Rn,args:[n.sessionId,XB,`false`]},{verb:jn,args:[n.sessionId,ZB,`false`]}]))],...o.map(e=>[gg(e,c)])]}]}function iV(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 aV(e){switch(e.kind){case`current`:return[`info`,`build: current ${$B(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${$B(e.source)}, running ${$B(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function oV(e){switch(e.kind){case`current`:return[`info`,`release: current ${Mi(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${Mi(e.latest)}, running ${Mi(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${Mi(e.installed)}, latest ${Mi(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function sV(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const cV=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function lV(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=cV(e.stderr)??e.error??cV(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function uV(){let e=[ZN(XB,[`false`]),HB(ZB,[`false`]),HB(YB,[])];return()=>e.forEach(e=>e())}function dV(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=tV,d=null,f=sV(s),p=sV(s),m=()=>iV(c,l);function h(){let e=m(),t=e===null?null:QB(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:HB(YB,[t])})}function g(){c=Ig(t,Ng),f(aV(c)),h()}async function _(){l=Ii(Ft,await Fi(Pi,a,i)),p(oV(l)),h()}return{arm(){uV(),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 q(`apply-update: nothing newer is known to apply`);let t=eV(e);if(u.kind===`running`)throw new q(`apply-update: already ${t.busy}`);u=nV,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),Le({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=tV,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=lV(n);u={kind:`failed`,identity:QB(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}const fV=`${Ap}${kp}`;function pV(e){return`${fV}⚠ cc-candybar: ${mV(e)}${jp}\n`}function mV(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: ${Op(e.message,60)}`;case`render_failed`:return`render failed: ${Op(e.message,60)}`;case`switched_off`:return`switched off: ${Op(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${Op(e.message,60)}`}}function hV(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
188
+ `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:pV(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}const gV=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`blackBright`,`redBright`,`greenBright`,`yellowBright`,`blueBright`,`magentaBright`,`cyanBright`,`whiteBright`];function _V(e){if(e===void 0||e.isDefault)return;let t=e.fixedValue;if(t!==void 0)return t.hex;let n=e.type===V.STANDARD&&e.number!==void 0?gV[e.number]:void 0;if(n===void 0)throw Error(`frames: no band colour for ${e.name}`);return n}const vV={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},yV=Object.keys(vV);function bV(e,t){let n=_V(t.color),r=_V(t.bgcolor),i={};for(let e of yV){if(t[e]!==!0)continue;let n=vV[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 xV=new U;function SV(e){return{ok:!0,band:new ef().decode(e).map(e=>{let t=e.plain,n=[],r=0;for(let i of e.spans){if(!(i.style instanceof U))throw Error(`frames: the decoder gave a span a ${typeof i.style} style`);i.start>r&&n.push(bV(t.slice(r,i.start),xV)),n.push(bV(t.slice(i.start,i.end),i.style)),r=i.end}return r<t.length&&n.push(bV(t.slice(r),xV)),n})}}function CV(e){let t=hV(zt(e)).output;try{return SV(t)}catch(e){return SV(`${Ap}${kp}⚠ cc-candybar ${Dp(e instanceof Error?e.message:String(e))}${jp}\n`)}}const wV={band:e=>JSON.stringify(CV(e)),statusline:(e,t)=>t,pane:(e,t)=>t};var TV=class{static CACHE_DIR=We();static USAGE_CACHE_DIR=v.join(this.CACHE_DIR,`usage`);static LOCKS_DIR=v.join(this.CACHE_DIR,`locks`);static isLocked(e){let t=v.join(this.LOCKS_DIR,e);if(!s.existsSync(t))return!1;try{let n=s.readFileSync(t,`utf-8`),r=parseInt(n.trim(),10);if(isNaN(r))return k(`Invalid PID in lock file ${e}, removing stale lock`),s.unlinkSync(t),!1;try{return process.kill(r,0),!0}catch(n){return n.code===`ESRCH`?(k(`Removing stale lock file ${e} for dead process ${r}`),s.unlinkSync(t),!1):(k(`Error checking process ${r} for lock ${e}:`,n),!0)}}catch(t){return k(`Error reading lock file ${e}:`,t),!0}}static async acquireLock(e,t=5e3){await this.ensureCacheDirectories();let n=v.join(this.LOCKS_DIR,e),r=Date.now(),i=String(process.pid);for(;Date.now()-r<t;)try{return await s.promises.writeFile(n,i,{flag:`wx`}),k(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await he(50);else throw e}return k(`Failed to acquire lock for ${e} within ${t}ms`),!1}static async releaseLock(e){let t=v.join(this.LOCKS_DIR,e);try{await s.promises.unlink(t),k(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&k(`Error releasing lock for ${e}:`,t)}}static async ensureCacheDirectories(){try{await Promise.all([s.promises.mkdir(this.CACHE_DIR,{recursive:!0}),s.promises.mkdir(this.USAGE_CACHE_DIR,{recursive:!0}),s.promises.mkdir(this.LOCKS_DIR,{recursive:!0})])}catch(e){k(`Failed to create cache directories:`,e)}}static createProjectHash(e){return ae(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t){await this.ensureCacheDirectories();let n=v.join(this.USAGE_CACHE_DIR,`${e}.json`),r=`${e}.usage.lock`;for(let i=0;i<3;i++){if(this.isLocked(r)){k(`Cache for ${e} is locked, waiting...`),await he(75);continue}try{let r=await s.promises.readFile(n,`utf-8`),i=JSON.parse(r);return!t||i.timestamp>=t?(k(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(i.data)):(k(`${e} cache outdated: cache=${i.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return k(`No shared ${e} usage cache found`),null;k(`Attempt ${i+1} failed to read ${e} cache: ${t.message}. Retrying...`),await he(75)}}return k(`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)){k(`Could not acquire lock to set usage cache for ${e}`);return}try{await this.ensureCacheDirectories();let r=v.join(this.USAGE_CACHE_DIR,`${e}.json`),i=JSON.stringify({data:t,timestamp:n||Date.now()});await s.promises.writeFile(r,i,`utf-8`),k(`[CACHE-SET] ${e} disk cache stored`)}catch(t){k(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(r)}}};const EV={"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 DV=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 TV.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await TV.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new n(this.GITHUB_PRICING_URL),r=me({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){k(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let n=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){k(`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)?(k(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),k(`Pricing last updated: ${r?.updated||`unknown`}`),e(i)):(k(`Invalid pricing data structure`),e(null))}catch(t){k(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{k(`Response error:`,t),e(null)})});r.on(`error`,t=>{k(`Request error:`,t),e(null)}),r.on(`timeout`,()=>{k(`Request timeout`),r.destroy(),e(null)}),r.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return k(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return k(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),k(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(k(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(EV).length} models`),this.executionCache=EV,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(EV).length} models`),EV)}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 k(`[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),k(`[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 OV=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function kV(e){if(typeof e==`string`)return OV.exec(e)?.[1]}function AV(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 jV(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 MV(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=AV(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`?kV(jV(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 NV(e){if(e!==void 0)return[e];let t=ee();return[S(t,`.config`,`claude`),S(t,`.claude`)].filter(e=>d(e))}async function PV(e){let t=[];for(let n of e){let e=S(n,`projects`);if(d(e))try{let n=await oz(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=S(e,r.name);t.push(n)}}catch(t){k(`Failed to read projects directory ${e}:`,t)}}return t}async function FV(e,t,n){let r=[],i=S(t,e,`subagents`);try{let t=(await oz(i)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let a of t){let t=S(i,a);if(n?.has(t)){r.push(t);continue}try{let n=(await sz(t,`utf-8`)).split(`
189
+ `)[0];n&&JSON.parse(n).sessionId===e&&r.push(t)}catch{k(`Failed to check agent file ${t}`)}}}catch(e){k(`Failed to read subagents directory ${i}:`,e)}return r}function IV(e){let t=e.message;if((e.type||t?.role||t?.type)!==`user`)return;if(RV(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=jV(t?.content).trimStart();return r.startsWith(`[Request interrupted by user`)?`interrupt`:e.isMeta===!0||e.isCompactSummary===!0||LV.test(r)?`claude-code`:`prompt`}const LV=/^<(?:command-name|local-command-std(?:out|err)|bash-(?:input|stdout|stderr))>/;function RV(e){let t=e?.content;return Array.isArray(t)&&typeof t[0]==`object`&&t[0]?t[0].type:void 0}const zV=new Map;async function BV(e){try{let t=await cz(e),n=t.size,r=zV.get(e);if(r&&r.mtime===t.mtimeMs&&r.size===n)return k(`[parse-cache] hit ${e}`),zV.delete(e),zV.set(e,r),r.entries;let i;return n>1048576?(k(`Using streaming parser for large file ${e} (${Math.round(n/1024)}KB)`),i=await qV(e)):i=await GV(e),k(`Parsed ${i.length} entries from ${e}`),n>5242880?i:(zV.delete(e),zV.size>=16&&zV.delete(zV.keys().next().value),zV.set(e,{mtime:t.mtimeMs,size:n,entries:i}),i)}catch(t){if(t.code===`ENOENT`)return k(`Transcript not present yet: ${e}`),[];throw t}}function VV(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=IV(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:MV(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 HV(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 UV(e){let t=HV(e);if(t.kind===`unparsed`)return k(`Failed to parse JSONL line: ${t.reason}`),null;if(t.kind===`blank`)return null;try{return VV(t.value)}catch(e){return k(`Failed to project JSONL line: ${e}`),null}}function WV(e){let t=[];for(let n of e.split(`
190
+ `)){let e=UV(n);e&&t.push(e)}return t}async function GV(e){return WV(await sz(e,`utf-8`))}async function KV(e,t){let n=await lz(e,t===void 0?void 0:{offset:t.offset,ino:t.ino});if(n.kind!==`ok`)return n;let{buf:r,start:i,stamp:a,ino:o,reset:s}=n.value,c=r.lastIndexOf(10);return L(c<0?{entries:[],cursor:{offset:i,stamp:a,ino:o},reset:s}:{entries:WV(r.subarray(0,c+1).toString(`utf-8`)),cursor:{offset:i+c+1,stamp:a,ino:o},reset:s})}async function qV(e){return new Promise((t,n)=>{let r=[],i=u(e,{encoding:`utf8`}),a=ge({input:i,crlfDelay:1/0});a.on(`line`,e=>{let t=UV(e);t&&r.push(t)}),a.on(`close`,()=>{t(r)}),a.on(`error`,t=>{k(`Streaming parser error for ${e}:`,t),n(t)}),i.on(`error`,t=>{k(`File stream error for ${e}:`,t),n(t)})})}var JV=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 YV(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 XV=new Map,ZV={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0},QV={cost:null,calculatedCost:null,officialCost:null,tokens:null,tokenBreakdown:null};function $V(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function eH(){let e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()-1),e.getTime()}function tH(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}async function nH(e,t,n,r){let i=$V(new Date(eH())),a=e&&!t?e:void 0,o=a?.entries??0,s=a?.cost??0,c=a?{...a.breakdown}:tH(),l=new Map;if(a)for(let[e,t]of a.days)e>=i&&l.set(e,{...t});for(let e of n){let t=e.message?.usage;if(!t)continue;o++;let n=e.costUSD??await DV.calculateCostForEntry(e.raw);s+=n,c.input+=t.input_tokens||0,c.output+=t.output_tokens||0,c.cacheCreation+=t.cache_creation_input_tokens||0,c.cacheRead+=t.cache_read_input_tokens||0;let r=$V(new Date(e.timestamp));if(r<i)continue;let a=l.get(r)??{...ZV};a.cost+=n,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,l.set(r,a)}return{cursor:r,entries:o,cost:s,breakdown:c,days:l}}function rH(e){let t=0,n=0,r=tH(),i=new Map;for(let 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)??{...ZV};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:QV,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 iH(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 aH=class{sessions=new Map;flight=new JV;seeded=new Map;seededDay=``;rescanIntervalMs;speedFlight=new JV;staleAgeMs;log;renderTally={hits:0,misses:0};sweeps=0;scans={seed:0,rescan:0};sweepTimer=null;constructor(e={}){this.log=e.logger??Gt,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:QV,i=t?.cost?.total_cost_usd??null;return L({session:{...r,cost:i??r.cost,officialCost:i}})}async getTodayInfo(e,t,n){let r=$V(bE(n)),i=NV(t);try{await this.ensureSeeded(r,i,n*1e3)}catch(e){return z(`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=>S(e,`projects`)+C),s={...ZV},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??XV:XV;c||=a.has(r);let l=a.get(r)??ZV;s.cost+=l.cost,s.input+=l.input,s.output+=l.output,s.cacheCreation+=l.cacheCreation,s.cacheRead+=l.cacheRead}return c?L({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}):R}async observeSpeed(e,t,n){if(!e)return R;let r=nz(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=YV(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(),L({...s!==void 0&&{prev:s},cur:a,samples:[...o]})})}async ingest(e,t,n,r){if(!e)return R;let i=r??nz(t),a=this.see(e)?.record;if(a&&i!==``&&a.transcriptStamp===i)return n.hits++,L(a);if(!t)return a?L(a):R;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 z(`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),L(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 FV(e,b(t),n===void 0?void 0:new Set(n.files.keys())),i=new Map,a=``;for(let e of[t,...r]){let r=n?.files.get(e),o=await KV(e,r?.cursor);if(o.kind===`failed`)return o;if(o.kind===`absent`){r&&i.set(e,r);continue}let{entries:s,cursor:c,reset:l}=o.value;i.set(e,await nH(r,l,s,c)),e===t&&(a=c.stamp)}return L({files:i,...rH(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=eH(),i=await PV(e),a=[];for(let e of i){let t;try{t=await oz(e)}catch{continue}for(let n of t){if(!n.endsWith(`.jsonl`))continue;let t=S(e,n),i;try{i=await cz(t)}catch{continue}i.mtimeMs<r||a.push({sessionId:n.slice(0,-6),path:t,stamp:rz(i)})}}let o={hits:0,misses:0};await iH(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()}},oH=class{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 k(`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);k(`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){try{k(`Calculating context tokens from transcript: ${e}`);let n=await BV(e);if(n.length===0)return k(`No entries in transcript`),R;let r=null;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t&&t.message?.usage?.input_tokens&&t.isSidechain!==!0){r=t,k(`Context segment: Found most recent entry at ${t.timestamp.toISOString()}, stopping search`);break}}if(r?.message?.usage){let e=r.message.usage,n=(e.input_tokens||0)+(e.cache_read_input_tokens||0)+(e.cache_creation_input_tokens||0);return k(`Most recent main chain context: ${n} tokens (limit: ${t})`),L({totalTokens:n,maxTokens:t,...this.ratioPercentages(n,t)})}return k(`No main chain entries with usage data found`),R}catch(e){return z(`context transcript: ${e instanceof Error?e.message:String(e)}`)}}async getContextInfo(e){let t=this.calculateContextFromHookData(e);if(t)return L(t);let n=e.context_window?.context_window_size??2e5;return this.calculateContextTokensFromTranscript(e.transcript_path,n)}},sH=class{states=new Map;constructor(e,t,n=256){this.empty=e,this.step=t,this.maxSessions=n}async read(e,t){let n=this.states.get(e),r=nz(t);if(n&&r!==``&&n.cursor.stamp===r)return this.touch(e,n),{kind:`ok`,value:n.value};let i=await KV(t,n?.cursor);if(i.kind===`failed`)return i;if(i.kind===`absent`)return{kind:`ok`,value:n?.value??this.empty};let{entries:a,cursor:o,reset:s}=i.value,c=s||n===void 0?this.empty:n.value;for(let e of a)c=this.step(c,e);for(this.touch(e,{cursor:o,value:c});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:c}}touch(e,t){this.states.delete(e),this.states.set(e,t)}};const cH={messageCount:0,nonPrompts:0,recent:[]},lH=new Set([`turn`,`interrupt`,`claude-code`]);function uH(e,t){if(t.isSidechain)return e;let n=[...e.recent,t];return{messageCount:e.messageCount+ +(t.userEntry===`prompt`),nonPrompts:e.nonPrompts+ +!!lH.has(t.userEntry),recent:n.length>20?n.slice(-20):n}}function dH(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 fH=class{fold=new sH(cH,uH);async getMetricsInfo(e,t){if(k(`Getting metrics from hook data for session: ${e}`),!t.cost)return R;let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?z(`metrics (${e}): ${n.reason}`):L({responseTime:t.cost.total_api_duration_ms/1e3,lastResponseTime:dH(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 pH={command:null,todos:[],pending:[],done:[]};function mH(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 hH(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 gH(e,t){if(t.isSidechain)return e;let n=hH(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=mH(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 _H(e){return{command:e.command,todos:e.todos,running:e.pending.reduce((e,t)=>mH(e,t.name),[]),done:e.done}}var vH=class{fold=new sH(pH,gH);async getActivityInfo(e,t){let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?z(`activity (${e}): ${n.reason}`):L(_H(n.value))}};function yH(e,t,n,r){return{bin:`tmux`,args:[`-S`,e.socket,...n],timeoutMs:2e3,category:t,stdinInput:r}}function bH(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 xH(e,t,n,r){return bH(Re(yH(e,t,n,r)),n)}async function SH(e,t,n){return bH(await Le(yH(e,t,n)),n)}const CH=e=>`${e.socket}\n${e.pane}`;var wH=class{names=new Map;asking=new JV;constructor(e=Date.now){this.now=e}getSessionName(e){let t=CH(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){k(`Getting tmux session name for pane ${t.pane} on ${t.socket}`);let n=await SH(t,`tmux`,[`display-message`,`-p`,`-t`,t.pane,`#S`]),r=n.kind===`ok`?n.stdout.trim():``,i=n.kind===`ok`?r?L(r):R:z(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 TH=e=>JSON.stringify([e.sessionId,e.projectDir,e.cwd,e.claudeConfigDir,e.env===void 0?null:ot.map(t=>e.env?.[t]??null)]);var EH=class{readings=new Map;inFlight=new Map;constructor(e,t=Date.now){this.edge=e,this.now=t}getCeiling(e){let t=TH(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=TH(e);try{this.edge.move(n.value,e,t)}finally{this.readings.delete(r),this.inFlight.delete(r),this.fetch(r,e)}}};function DH(e){return{gitProvider:new mE({watchers:e.watchers,logger:e.logger}),usageStore:new aH({logger:e.logger}),contextProvider:new oH,metricsProvider:new fH,activityProvider:new vH,tmuxService:new wH,mementoProvider:new EH(kz()),autoCompact:vj,log:e.logger}}function OH(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}const kH={kind:`hidden`},AH={kind:`shown`};function jH(e,t){try{return OH(e,t)?AH:kH}catch(e){return{kind:`failed`,message:e instanceof Error?e.message:String(e)}}}function MH(e,t){let n=K.fromFragments(e);return n.end=``,n.overflow=`ignore`,t!==void 0&&!t.isNull&&(n.style=t),n}function NH(e,t,n){e.cellLength>t?e.truncate(t,{mode:n.truncate,marker:`…`}):e.cellLength<t&&e.align(n.justify,t)}function PH({lead:e,text:t,trail:n}){return[...e===void 0?[]:[e],t,...n===void 0?[]:[n]]}function FH({text:e,placement:t,lead:n,trail:r}){return{text:IH(e),placement:t,...n!==void 0&&{lead:IH(n)},...r!==void 0&&{trail:IH(r)}}}function IH(e){let t=e.blankCopy(e.plain);t.style=Ip(e.style).clearMetaAndLinks();for(let{start:n,end:r,style:i}of e.spans)t.stylize(Ip(i).clearMetaAndLinks(),n,r);return t}function LH(e){let t=PH(e);if(t.length===1)return e.text;let n=MH(t);return n.style=e.text.style,n}function RH(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=MH(e,a).pad(o),d=new K(` `.repeat(o)),f={placement:s,...c.length>0&&{lead:MH([d,...c],a)},...l.length>0&&{trail:MH([...l,d],a)}};if(n===`auto`)return[{text:u,...f}];let p={justify:r,truncate:i};return n===`fill`?[{text:u,fill:p,...f}]:(NH(u,n,p),[{text:u,...f}])}const zH=RegExp(`\\x1b\\[[0-9;]*m|${mu.source}`,`g`);function BH(e){return Math.max(0,...e.split(`
191
+ `).map(e=>io(e.replace(zH,``))))}function VH(e,t){let n=()=>e.map(e=>({owner:LH(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=dg(e.map(LH),t).split(`
192
+ `);if(i.length>1)return n();let a=Math.max(0,t.width-BH(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];NH(c,c.cellLength+a,n)}),n()}function HH(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=UH(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e){let e={frag:a,style:Ip(a.style)};if(e.style.link){i();let r=UH([e],t);r.plain.length>0&&n.push(r)}else r.push(e)}return i(),n}function UH(e,t){let n=t!==void 0&&!t.isNull?t:void 0,r=e.map(e=>WH(e.frag,n?n.add(e.style):e.style)),i=K.fromFragments(r);return i.end=``,i.overflow=`ignore`,r.length===1?i.style=r[0].style:n!==void 0&&(i.style=n),i}function WH(e,t){let n=e.copy();return n.style=t,n}function GH(e,t){if(e.look===void 0)throw Error(`${t} read the render's look before any render resolved one`);return e.look}function KH(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,qH(e,t,o,n,r,i));return i}function qH(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=J_(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=Wa.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=J_(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=J_(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:XH(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:XH(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:eI(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:XH(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 JH(e){return e.kind===`do`?JH(e.head):e}function YH(e){switch(JH(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 XH(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function ZH(e,t){return e.has(t)?Ev(e.read(t)):``}function QH(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function $H(e,t,n,r){let i=new K(e,{style:U.combine([r,new U({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function eU(e,t,n=!1){let r=new U({link:t,bold:n?!0:void 0}),i=new K(e.plain,{style:U.combine([Ip(e.style),r])});for(let t of e.spans)i.stylize(U.combine([Ip(t.style),r]),t.start,t.end);return i.overflow=`ignore`,i.end=``,i}function tU(e,t){return Math.max(e.members.indexOf(ZH(t,e.stateVar)),0)}function nU(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=ZH(r,e.stateVar);return{effects:[{verb:jn,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=ZH(r,e.stateVar);return{effects:[{verb:jn,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=ZH(r,e.stateVar);return{effects:[{verb:jn,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(tU(e,r)+1)%e.members.length];return{effects:[{verb:jn,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:Mn,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:Nn,args:[QH(e.text,bT(r))]}],active:!1};case`open`:return{effects:[{verb:Pn,args:[QH(e.target,bT(r))]}],active:!1};case`persist-literal`:{let t=ZH(r,e.stateVar);return{effects:[{verb:Rn,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=ZH(r,e.stateVar);return{effects:[{verb:Rn,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(tU(e,r)+1)%e.members.length];return{effects:[{verb:Rn,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:zn,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:Wn,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:Kn,args:[i]}],active:!1};case`redo`:return{effects:[{verb:qn,args:[i]}],active:!1};case`back`:return{effects:[{verb:Jn,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:Yn,args:[i]}],active:!1};case`save`:return{effects:[{verb:Bn,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:Vn,args:[i]}],active:!1};case`theme-default-save`:return{effects:[{verb:Hn,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:Un,args:[i,QH(e.name,bT(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:Zn,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:Qn,args:[i,e.check]}],active:!1};case`doctor-mark`:return{effects:[{verb:$n,args:[i,e.check,e.mark]}],active:!1};case`ceiling`:return{effects:[{verb:tr,args:[i,...e.args]}],active:!1};case`slash`:return{effects:[{verb:nr,args:[i,e.line]}],active:!1};case`layout-op`:return{effects:[{verb:Gn,args:[i,e.key,LN(e.op)]}],active:!1};case`do`:{let a=nU(e.head,t,n,r,i);return{effects:[...a.effects,...e.rest.flatMap(e=>nU(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:Gn,args:[i,e.key,LN(r)]}],active:!1}}}}function rU(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:pr(`action "${e}"`,n,t.members.length,tU(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 iU(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=n.store,{display:a,boundValue:o}=rU(e,JH(r),t,i),s=ZH(i,`session.id`),{effects:c,active:l}=nU(r,a.plain,o,i,s);return eU(a,I(c),l)}function aU(e){return{action:{fn:(t,...n)=>iU(t,n,e),argTypes:[`string`,`liftable`],arity:{kind:`variadic`},returnType:`T`}}}function oU(e,t){return $H(`✕`,I([{verb:jn,args:[ZH(e,`session.id`),t,ur]}]),!1)}function sU(e,t,n){return new U({bgcolor:H.fromRgba(t),color:H.fromRgba(xm(e,t,n))})}function cU({tint:e,text:t}){return new U({bgcolor:H.fromRgba(e),color:H.fromRgba(t)})}function lU(e,t,n){return new U({color:H.fromRgba(Qs(dm(e,`warning`),t,bm,n))})}function uU(e,t,n){return U.combine([sU(e,t,n),lU(e,t,n)])}function dU(e,t,n){return sU(e.palette,Hm(e.palette,e.disclosure,[t],n),n)}function fU(e){let t=H.fromRgba(dm(e,`background`)),n=K.fromFragments(Rp.map(n=>new K(`▀`,{style:new U({color:H.fromRgba(dm(e,n)),bgcolor:t})})));return n.overflow=`ignore`,n.end=``,n}const pU=(e,t)=>{let n=typeof e==`string`?new K(e,{style:t}):e;return n.overflow=`ignore`,n.end=``,n},mU=e=>new U({bold:e});function hU(e,t,n,r,i,a){if(r===void 0)return(n,r,a,o)=>pU(a,U.combine([dU(e,{...n,distribution:t},i),mU(o)]));let o=sU(e.palette,a,i);return(e,t,i,a)=>gU(i,U.combine([o,mU(a)]),r(t,n))}const gU=(e,t,n)=>pU(K.fromFragments([pU(e,t),pU(` `,t),fU(n)]));function _U(e,t){return t===void 0?(e,t,n)=>pU(n):(n,r,i)=>gU(i,void 0,t(r,e))}function vU(e,t,n,r,i){let a=sU(e.palette,i,r);return(e,r,i,o)=>pU(K.fromFragments([pU(o?`[`:` `,a),fU(n(r,t)),pU(o?`]`:` `,a)]))}function yU(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=>bU(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function bU(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function xU(e,t){return new K(e).truncate(t,{marker:`…`}).plain}function SU(e){return{current:null,drawnAt:e}}function CU(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 wU(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 TU(e){return new K(e).cellLength}function EU(e){return Math.max(1,e.width-e.chromeCols-2*e.padding)}function DU(e){return Math.max(1,EU(e)-(TU(`✕`)+2*e.padding+e.seamCols))}function OU(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 kU(e,t,n){let r=TU(`←`)+1+TU(`→`)+1,i=OU(e,t,n);return(i.length>1?OU(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function AU(e,t){let n=[];for(let t of e)n.length>0&&n.push(new K(` `)),n.push(t);let r=K.fromFragments(n);return r.overflow=t?`ignore`:void 0,r.end=``,r}function jU(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 MU(e,t,n){let r=e.compiled.get(t),i=r&&JH(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 NU(e,t,n,r,i,a,o,s,c=[]){let l=a.compiled.get(e),u=a.store,d=ZH(u,`session.id`),f=`stateVar`in t?ZH(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`?DU(a):EU(a):1/0,h=(r.kind===`led`?0:TU(`✕`)+1)+c.reduce((e,t)=>e+TU(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?kU(_.map(e=>e.cellLength),m,h):yU(g.entries,g.groups,i),y=parseInt(ZH(u,n.stateVar),10),b=e=>Math.max(0,v.findIndex(t=>t.some(t=>t.indices.includes(e)))),x=b(f===void 0?-1:t.options.indexOf(f)),S=Number.isInteger(y)?y<0?x:Math.min(y,v.length-1):0,C=v[S]??[],w=e=>I([{verb:jn,args:[d,n.key,String(e)]}]),ee=r.kind===`led`?[]:[{verb:jn,args:[d,...r.writes.flatMap(([e,t])=>[e,t])]}],te=r.kind===`own`&&r.onPick?ee:[],ne=e=>I([...nU(l,e,e,u,d).effects,...te]),T=(e,n)=>eU(e,ne(t.options[n])),re=r.kind===`led`?[]:[$H(`✕`,I(ee),!1,s)];re.push(...c.map(({glyph:e,option:r})=>$H(e,I([...nU(l,r,r,u,d).effects,{verb:jn,args:[d,n.key,String(b(t.options.indexOf(r)))]}]),!1))),S>0&&re.push($H(`←`,w(S-1),!1));let E=S<v.length-1?[$H(`→`,w(S+1),!1)]:[];if(g===void 0){let e=C.flatMap(e=>e.indices);return[AU([...re,...e.map(e=>T(_[e],e)),...E],i)]}let D=new U({bold:!0}),ie=v.length>1?` ${S+1}/${v.length}`:``,O=C.length===1?[new K(`${C[0].label}${ie}`,{style:D})]:[],ae=[AU([...re,...O,...E],i)];for(let e of C){C.length>1&&ae.push(AU([new K(e.label,{style:D})],i));let n=Math.max(...e.indices.map(e=>TU(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:Dp(a),s=` `.repeat(n-TU(e)+2),c=o===void 0?e:`${e}${s}${o}`;ae.push(AU([T(p(r,xU(c,m)),r)],i))}}return ae}function PU(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{mT(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=jU(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=MU(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=wU(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]=NU(n,l,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,hU(u,$p(void 0),GH(e,`{{ picker }}`),l.paletteOf,t.drawnAt(),u.bg),lU(u.palette,u.bg,t.drawnAt()));return d},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function FU(e,t){let n=e.length,r=Math.max(e.indexOf(t),0);return e=>((r+e)%n+n)%n}function IU(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 LU(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=n.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=ZH(o,`session.id`),{options:l}=t,u=l.length;if(u===0)return AU([],!0);let d=ZH(o,t.stateVar),f=FU(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=I(nU(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=eU(g(e),h(e));return _.set(e,n),n},y=a===void 0?v(0):eU(_U(GH(n,`{{ carousel }}`),t.paletteOf)({index:f(0),count:u},p(0),p(0),!1),I(nU(n.compiled.get(a),p(0),void 0,o,c).effects)),b=IU(e=>v(e).cellLength,u,TU(`◀`)+1+y.cellLength+1+TU(`▶`),DU(n),i),x=e=>Array.from({length:b},(t,n)=>v(e*(n+1)));return AU([...x(-1).reverse(),$H(`◀`,h(-1),!1),y,$H(`▶`,h(1),!1),...x(1)],!0)}function RU(e,t){return{carousel:{fn:(n,...r)=>{let[i,a,...o]=r;if(mT(`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&&YH(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=MU(e,n,`carousel`),l=wU(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 LU(n,c,e,hU(l,$p(void 0),GH(e,`{{ carousel }}`),c.paletteOf,t.drawnAt(),l.bg),s,a)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function zU(e,t,n){let r=MU(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 BU(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 VU(e,t,n,r){let i=zU(e,t,n),a=r??ZH(e.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,GH(e,`{{ ${n} }}`))}function HU(e,t,n){return{swatch:{fn:(t,...n)=>{let[r,...i]=n;if(mT(`swatch "${t}"`,[`option`],i),r!==void 0&&typeof r!=`string`)throw Error(`swatch "${t}": option must be text, got ${JSON.stringify(r)}`);return fU(VU(e,t,`swatch`,r))},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`},swatches:{fn:(r,i)=>{let a=zU(e,r,`swatches`),o=jU(e,i,`set-int`,`an int action ({ set, int: true })`,`swatches`),s=wU(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]=NU(r,a,{key:o.key,stateVar:o.stateVar},{kind:`led`},!0,e,vU(s,GH(e,`{{ swatches }}`),a.paletteOf,c,s.bg),lU(s.palette,s.bg,c),u===0?[]:(()=>{let t=FU(l,ZH(e.store,a.stateVar));return[{glyph:`◀`,option:l[t(-1)]},{glyph:`?`,option:l[BU(n().getTime(),u,t(0))]},{glyph:`▶`,option:l[t(1)]}]})());return d},argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}const UU=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function WU(e,t,n,r){let i=Nm(e,n,r),a=(t,n)=>({text:t,colour:n,ink:xm(e,n,r)});return[[Jp(t).map((n,i)=>{let a=fm(e,n);return{text:UU[i%UU.length],colour:a,ink:t.shade.text(e,n.hue,a,r)}})],[[a(`▾ open`,i.state),a(`menu`,i.plane)],[a(`warn`,dm(e,`warning`)),a(`error`,dm(e,`error`))]]]}function GU(e,t){let n=e.flatMap((e,t)=>e.map(({text:e,colour:n,ink:r},i)=>({gap:t>0&&i===0?` `:``,cell:new K(` ${e} `,{style:cU({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 K(e)),r.push(a)}return r}function KU(e,t,n,r,i){let a=WU(e,t,n,r).map(e=>GU(e,i)),o=K.fromFragments(a.flatMap((e,t)=>t===0?e:[new K(`
193
+ `),...e]));return o.overflow=`ignore`,o.end=``,o}function qU(e,t){return{themePreview:{fn:(...n)=>{let[r,...i]=n;if(mT(`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}=GH(e,`{{ themePreview }}`);return KU(r===void 0?a:VU(e,r,`themePreview`),o,{...wU(t,`{{ themePreview }}`).disclosure,depth:0},t.drawnAt(),DU(e))},argTypes:[`value`],arity:{kind:`variadic`},returnType:`T`}}}const JU=e=>e.slice(e.lastIndexOf(`.`)+1),YU=(e,t)=>{let n=new K(JU(e));return n.truncate(t,{marker:`…`}),n.plain};function XU(e,t){let n=e.map(e=>e.map(({name:e})=>TU(JU(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 ZU(e,t,n,r){let i=XU(e,r),a=e.map(e=>{let a=[],o=0;for(let{name:s,address:c,palette:l}of e){let e=new K(` ${YU(s,i)} `,{style:cU(Km(l,{kind:`bar`,decor:t,address:c},n))});if(o+=e.cellLength,o>r)break;a.push(e)}return a}),o=K.fromFragments(a.flatMap((e,t)=>t===0?e:[new K(`
194
+ `),...e]));return o.overflow=`ignore`,o.end=``,o}function QU(e,t){return{layoutPreview:{fn:()=>ZU(e.layout(),GH(e,`{{ layoutPreview }}`).decor,t.drawnAt(),DU(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function $U(e,t,n,r){let i=wU(r.activeSegment,`{{ menu }}`),a=r.action,o=cD(i.placementId,e,n.key),s=dD(o),c=sD(e),l=ZH(a.store,o)===c,u=ZH(a.store,`session.id`),d=l?ur:c,f=$H(pr(`{{ menu "${e}" }}`,t,2,+!!l),I([{verb:jn,args:[u,o,d,s,`0`]}]),!1);return i.drops.push(...l?(()=>{let t=r.activeSegment.drawnAt(),c=Nm(i.palette,i.disclosure,t).plane,l=MU(a,e,`menu`);return NU(e,l,{key:s,stateVar:s},{kind:`own`,writes:[[o,ur],[s,`0`]],onPick:n.closeOnPick},n.paged,a,hU(i,n.distribution,GH(a,`{{ menu }}`),l.paletteOf,t,c),lU(i.palette,c,t))})():[]),f}const eW=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function tW(e,t){let n=t[t.length-1],r=eW(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:hD(r??{})}}function nW(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=tW(t,n);return $U(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function rW(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=iW(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 K(t?i:a,{style:l===void 0?void 0:new U({color:l})}))}let l=K.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function iW(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 aW(e){let t={fn:(()=>{let t=wU(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:(()=>wU(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r={fn:((t,n)=>{let{palette:r}=wU(e,`{{ keptOn }}`),i=Us(r,t),a=Us(r,n),o=No(ec(i,V.TRUECOLOR),ec(a,V.TRUECOLOR)),s=Math.min(bm,Math.max(o,3));return($s(i,e.drawnAt(),(e,t)=>No(e,t(a))>=s)??i).hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},i=Qw(()=>wU(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),a={fn:((e,t,n,r,a,o,...s)=>{let c=o===void 0?void 0:[o,...oW(s)];return rW({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 oW(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 sW(e){let t=[],n=[];for(let r of e){if(!r.contains(`
196
195
  `)){n.push(r);continue}let e=r.split(`
197
- `);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function YU(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 XU(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 ZU(e){return{...e,cells:e.cells.map(SH)}}function QU(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,...$U(e,r)]}function $U(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 eW(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:QU(e.direction,e.children.map((t,i)=>n(t,[...r,tW(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function tW(e,t){return{index:t,count:e.children.length,distribution:e.distribution,axis:Jg[e.direction]}}const nW={compile(e,t){return{kind:`container`,direction:e.direction,when:t.when,distribution:$p(e.distribution),children:e.children.map((e,n)=>t.compileChild(e,e_(t.path,n)))}},render(e,t){return t.gate.kind===`failed`&&t.gate.report(),QU(e.direction,e.children.map((n,r)=>t.renderChild(n,t.gate.kind===`shown`,tW(e,r))))}},rW={drop:e=>e.place,above:()=>`above`},iW={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},aW={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:Yg(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(gr(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,t_(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,oW(e,t))};function oW(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=ST(t.scope,e.settings);if(t.gate.kind===`failed`)return sW(e,a,t,t.gate.message);try{if(!hH(i.when,a))return[];let n=zg(e.settings.theme,t.palette),o={id:e.id,effect:e.settings.effect,ground:hk(n)},s=e.opens!==void 0&&hH(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:rW[g.placement](e)})),v=JU(kH(l,m)).map((e,t)=>({cells:TH(e,{...h,lead:t===0?kH(u,m):[],trail:t===0?kH(d,m):[]}),band:`own`,place:`flow`})),y=f.map(e=>({cells:TH(kH([e],c.band),{...h,baseStyle:c.band}),band:`deeper`,place:`flow`})),b=(e,t,n)=>TH(kH([e],t),{...h,width:`auto`,baseStyle:t,padding:n}),x=_.findIndex(e=>e.band===`own`),{lead:S,stays:C}=g!==void 0&&x!==-1?iW[g.placement](v,()=>b(t.closeDisclosure(g.key),c.close,t.padding)):{lead:[],stays:v},w=S.flatMap(e=>b(new K(` `.repeat(xH(e).reduce((e,t)=>e+t.cellLength,0))),c.trigger,0)),ee=(e,t)=>e.band===`own`?t===x?S:w:[],te=_.map((e,t)=>({cells:[...ee(e,t),...e.cells],band:`deeper`,place:e.place})),ne=[...C,...y];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...ne.flatMap(e=>e.cells),..._.flatMap(ee)].flatMap(xH)),[...ne,...te]}catch(n){return sW(e,a,t,n.message??String(n))}}function sW(e,t,n,r){n.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:TH([new K(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,placement:{id:e.id,effect:`bar`,ground:hk(n.palette)},lead:cW(e.lead,e,t,n),trail:cW(e.trail,e,t,n)}),band:`own`,place:`flow`}]}function cW(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 lW={container:nW,segment:aW};function uW(e){return lW[e]}function dW(e){if(`ttl`in e)return{kind:`ttl`,durationMs:SE(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 fW(e,t){switch(a_(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 pW(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:dW(n.cache),parse:fW(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:dW(n.cache),parse:fW(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 mW(e,t){let n=ay.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}const hW=(e,t,n,r,i)=>{let a=tz(t,ez(n,e.themeDefaults));return{variation:qp[r??Dh(void 0,null,a.variation)],shade:Gp[i??Ah(void 0,null,a.shade)]}};function gW(e,t,n){let r=n.cwd,i={store:t.variableStore,compiled:new Map,chromeCols:ag({endcaps:`powerline`}),width:80,padding:1,seamCols:og({endcaps:`powerline`}),layout:()=>[],look:void 0},a=lU(t.drawnAt),o={action:i,activeSegment:a},s=Object.keys(e.styles),c=R_(e.presets),l=vN(e),u=yT({extraFuncs:{...KH(i),...xU(i,a),...TU(i,a),...PU(i,a),...kU(i,a,t.now),...zU(i,a),...UU(o),...KU(a),styles:{fn:()=>s,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>c,argTypes:[],arity:{kind:`exact`}}},clock:t.now,drawnAt:t.drawnAt}),d=mW(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;for(let[t,n]of Ga)n in e.variables&&h.set(t,n);for(let[t,n]of d_(e))h.has(n.key)||h.set(n.key,t);i.compiled=NH(f,e.actions,h,l);let g=[];for(let[n,i]of Object.entries(e.variables))try{pW(t,n,i,r)}catch(e){g.push(`Variable "${n}": ${e.message??String(e)}`)}for(let[n,i]of Object.entries(e.segments))if(i.vars)for(let[e,a]of Object.entries(i.vars))try{pW(t,`${n}.${e}`,a,r)}catch(t){g.push(`Variable "${n}.${e}": ${t.message??String(t)}`)}let _=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})}};_[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 v=(e,t,n)=>{try{return m(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},y=t.variableStore,b=t=>{let n=h_(e.segments[t.name]),r=Object.create(null);for(let[e,i]of Object.entries(n))Object.defineProperty(r,e,{enumerable:!0,get:()=>x_(t,e,i,e=>String(y.read(e.variable)))});return Object.freeze(r)},x=(e,t)=>{let n={path:t,when:e.when===void 0?void 0:v(e.when,t,`when`),parse:(e,n)=>v(e,t,n),compileChild:x,placementSettings:b};return uW(e.kind).compile(e,n)},S=new Map;for(let t of c){let{node:n,path:r}=V_(e,t);S.set(t,x(n,r))}let C=new Map(nh.map(e=>[e,new Map])),w=[[`globals`,e.globals],...Object.entries(e.presets).map(([e,t])=>[`presets.${e}.globals`,t.globals??{}])];for(let[e,t]of w)for(let n of nh){let r=t[n];if(!rh(r))continue;let i=`${e}.${n}`,a=C.get(n),o=a.get(r);a.set(r,o===void 0?{where:i,template:_W(f,i,r)}:{where:`${o.where}, ${i}`,template:o.template})}return{segments:_,roots:S,activeSegment:a,menuRuntime:o,globalExpressions:C,loadWarnings:g}}function _W(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 vW(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 yW(e,t,n,r){try{return t.template.evaluate(n).map(e=>e.plain).join(``)}catch(n){return r({kind:`rule`,slot:e,message:fh(t.where,e,`the rule failed — ${n instanceof Error?n.message:String(n)}`)}),dh[e]}}function bW(e,t){return e.kind===`decided`?e.name:dh[t]}function xW(e){return SW(e).filter(e=>!e.name.startsWith(nD)).map(e=>e.id)}function SW(e){return e.kind===`container`?e.children.flatMap(SW):[e,...e.opens===void 0?[]:SW(e.opens.body)]}function CW(...e){return wW(...e).text}function wW(e,t,n,r,i,a,o,s,c){let{perSegmentSink:l,onSegmentError:u,onRenderWarning:d}=s??{},f=e=>d?.(e),p=new Set;r.renderAt(a),r.drawAt(wh(o.colorCompatibility));let{preset:m=I_}=c??{},h=H_(e,m),g=c?.style??ch(`none`,e.styles),_=c?.theme??Gg(void 0,null,h.palette),v=hW(e,h,_,c?.variation,c?.shade),y=c?.effect??_h(void 0,null,h.effect),b=(e,t,n)=>({...i,term:{cols:o.width},theme:{effective:e},style:{effective:t},effect:{effective:n}});r.applyInput(b(bW(_,`palette`),bW(g,`style`),bW(y,`effect`))),t.menuRuntime.action.chromeCols=ag(o),t.menuRuntime.action.padding=o.padding,t.menuRuntime.action.width=o.width,t.menuRuntime.action.seamCols=og(o);let x=bT(n),S=ah(_,e=>{let n=vW(t,`palette`,e);return Wg(yW(`palette`,n,x,f),n.where,e=>f({kind:`rule`,slot:`palette`,message:e}))}),C=ah(g,n=>ch(yW(`style`,vW(t,`style`,n),x,f),e.styles)),w=ah(y,e=>gh(yW(`effect`,vW(t,`effect`,e),x,f)));(S!==_||C!==g||w!==y)&&r.applyInput(b(S.name,C.name,w.name));let ee=S.value,te=Vg(ee,C.value);t.menuRuntime.action.look={basePalette:ee,palette:te,decor:v};let ne=c?.transitions??Bh(void 0,null,h.transitions),T=(c?.effects??new Zh(``)).motion(w.value,a,{transitions:ne,source:{config:t,preset:m,revision:r.stateRevision(),width:o.width},returned:XU,hold:ZU});l?.clear();let re=n=>{let r=e.segments[n],i=t.segments[n];return r!==void 0&&i!==void 0?{seg:r,compiled:i}:void 0},E=(e,n,i,a,o,s)=>{try{let c=r.drawnAt(),{tint:l,text:u,disclosure:d}=Km(i,a,c),f=uU(t.activeSegment,e.name,e.id,i,d,l,u),m=_k(f,c,o.bg,o.fg,n),h=()=>Nm(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)p.add(t)}let v=o.lead?.evaluate(n)??[],y=o.trail?.evaluate(n)??[];return{styles:{closed:m,get trigger(){return JH(i,h().state,c)},get band(){return JH(i,h().plane,c)},get close(){return ZH(i,h().state,c)},disclosure:d},fragments:g,lead:v,trail:y,drops:f.drops,open:_}}finally{t.activeSegment.current=null}},D=(e,t,r)=>{let i=t?vH(e.when,x):gH,a=i.kind===`failed`?{...i,report:()=>{let t=`when over ${xW(e).join(`, `)||`no placement`}`;f({kind:`when`,where:t,error:i.message,message:`${t}: ${i.message} — what it gates is hidden`})}}:i,s={scope:x,palette:te,gate:a,padding:o.padding,region:r,perSegmentSink:l,onSegmentError:u,evaluateSegment:E,lookupSegment:re,renderChild:(e,t,n)=>D(e,t,Wm(r,n)),renderBody:(e,t,n)=>D(e,a.kind===`shown`&&t,Gm(n)),closeDisclosure:e=>qH(n,e),placed:T.placed};return uW(e.kind).render(e,s)},ie=t.roots.get(m);if(ie===void 0)throw Error(`Preset "${m}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${I_}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let O=e=>{let n=vH(e.when,x);if(e.kind===`container`)return n.kind===`shown`;if(kN(e.name)===void 0)return!1;if(n.kind!==`shown`)return n.kind===`failed`;try{return hH(t.segments[e.name].when,ST(x,e.settings))}catch{return!0}};t.menuRuntime.action.layout=()=>eW(ie,O).map(e=>e.flatMap(({name:e,address:t,settings:n})=>{let r=kN(e);return r===void 0?[]:[{name:r,address:t,palette:zg(n.theme,te)}]}));let ae=YU(D(ie,!0,Um(v))).map(({line:e,row:t})=>{let n=OH(e.cells,o);return ug(n.map(e=>e.owner),o,T.row(t,n))});T.drawn();let oe=ae.some(e=>e.moves)?`moves`:y.kind===`expression`||ne||SW(ie).some(({settings:e})=>e.effect!==`bar`&&e.effect!==`none`)?`can-move`:`still`;for(let e of p)f({kind:`band-floor`,message:e});for(let[e,t]of r.cachePolicyFaults())f({kind:`refresh`,variable:e,error:t.message,message:`variable "${e}" cannot refresh: ${t.message}`});return{text:ae.map(e=>e.text).join(`
198
- `),motion:oe}}function*TW(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*EW(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 R_(e.presets)){for(let n of $g(V_(e,t).node))n.when!==void 0&&(yield n.when);let n=H_(e,t);for(let e of nh){let t=n[e];rh(t)&&(yield t)}}for(let[,t]of TW(e))t.kind===`template`&&(yield t.template),s_(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 DW(e,t){return e===t||t.startsWith(`${e}.`)||e.startsWith(`${t}.`)}function OW(e,t){let n=new Set,r=new Set,i=new Set;for(let e of EW(t)){for(let r of lv(e,t.helpers).keys())n.add(r);for(let{name:n}of pv(e,t.helpers))r.add(n);for(let n of mv(e,t.helpers))i.add(n)}for(let[,e]of TW(t))if(s_(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 R_(t.presets))for(let n of $g(V_(t,e).node))n.kind===`segment`&&s.add(n.name);let c=(e,t)=>[...n].some(t=>DW(t,e))||t.kind===`state`&&o.has(t.key),l=e=>[...e].filter(e=>!iD(e)),u=(e,t,n)=>l(t).filter(e=>!n(e)).map(t=>({kind:e,name:t})),d=new Map(TW(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 kW=class{kind=`box`;cell;lastChangedAt;constructor(e,t,n){this.name=e,this.type=t,FW(e,t,n,`initial value`),this.cell=Cv.observable.box(n,{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){FW(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}},AW=class{kind=`computed`;cell;constructor(e,t,n){if(this.name=e,this.type=t,this.cell=(0,Cv.computed)(()=>{let e=n();return FW(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}},jW=class{kind=`document`;cell;lastChangedAt;constructor(e,t){this.name=e,this.cell=Cv.observable.box(PW(t),{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){let t=PW(e);NW(this.cell.get(),t)||(this.cell.set(t),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}};function MW(e){return JSON.stringify(e)}function NW(e,t){return MW(e)===MW(t)}function PW(e){return e.kind===`ok`?{kind:`ok`,value:wv(e.value)}:e}function FW(e,t,n,r){let i=Tv(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var IW=class{nodes=Cv.observable.map(void 0,{deep:!1});defineBox(e,t,n){this.declare(e,new kW(e,t,n))}defineDocument(e,t){this.declare(e,new jW(e,t))}defineComputed(e,t,n){let r=e=>this.read(e);this.declare(e,new AW(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,Cv.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,Cv.runInAction)(()=>n.set(t))}runInAction(e){(0,Cv.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 MW(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,Cv.runInAction)(()=>{for(let t of this.nodes.values())t instanceof AW&&(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,Cv.runInAction)(()=>this.nodes.set(e,t))}};function LW(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=FL(e),r=t===void 0?void 0:n.variables[LL(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 RW(e,t){return`config disposed reason=${e.reason} released=${t} held=${e.held}`}function zW(e,t,n){return e+`\0`+t+`\0`+(n??``)}function BW(e,t){return new Set(R_(e.presets).filter(n=>V_(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function VW(e,t){let n=new Map,{roots:r,loaded:i,dropped:a,unreached:o}=e.state.plugins;for(let t of[...fR(e.projectDir,e.cwd,e.configFile),...r,...i,...[...a,...o].map(e=>e.path)]){let{dir:e,name:r}=yv(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}=yv(v.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 HW(e){return e.filter(Boolean).join(`
199
- `)||null}function UW(e,t,n,r,i=()=>{}){let{layers:a,config:o,installed:s}=DR(t.layers,XR,{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??XR,l=a.find(e=>e.path===t.home)?.raw??{},u=new IW,d=new UE(u,o.globals.default_empty_value??``,r.gitService,r.sessionState),f;try{f=gW(o,d,{cwd:e}),n.push(...f.loadWarnings),UB(o),QN(o)}catch(e){throw d.dispose(),e}return{config:o,store:u,registry:d,compiled:f,neededInputPaths:Yz(o),lastRenderCellsBySegment:new Map,authoredRoots:BW(c,l),fileHeldSettings:kB(l),unused:[...new Map(a.flatMap(e=>OW(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 WW(e,t,n,r){let i=mR(e,t,n),a={layers:i.kind===`chain`?i.layers:[],home:i.home,projectDir:e},o=[yR(e,t),_R(i)],s,c=null;try{s=UW(t,a,o,r,e=>{c=e})}catch(e){return e instanceof YE&&o.push(...e.warnings),{layers:a.layers,home:a.home,failedFile:c,warning:HW(o),state:null,error:e instanceof YE||e instanceof Error?e.message:String(e)}}return{layers:a.layers,home:a.home,warning:HW(o),state:s,error:null}}function GW(e,t,n){return UW(e,{layers:[],home:``,projectDir:t},[],n)}var KW=class{entries=new Map;holds=new Map;deps;log;maxEntries;observers;constructor(e,t={}){this.deps=e,this.log=e.log??Gt,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{}}getOrCreate(e,t,n){let r=zW(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=WW(e,t,n,this.deps);a.state!==null&&this.log(`info`,LW(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??GW(t,e,this.deps),watcher:null,watcherKey:null};if(this.serve(o.state),this.entries.set(r,o),this.entries.size>this.maxEntries){let e=this.entries.entries().next().value;if(e!==void 0){let[t,n]=e;n.watcher?.release(),this.entries.delete(t),this.retire(n.state,`evict`)}}return 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}}serve(e){this.holds.set(e,{holders:0,retired:null})}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`,RW(t.retired,e.registry.dispose())))}reload(e,t,n){this.reloadInto(this.getOrCreate(e,t,n))}reloadInto(e){let t=WW(e.projectDir,e.cwd,e.configFile,this.deps);if(e.lastWarning=t.warning,e.lastError=t.error,t.state!==null){this.log(`info`,LW(t.layers,t.state));let n=e.state;e.state=t.state,this.serve(t.state),this.retire(n,`reload`)}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=VW(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 qW=16384;var JW=class e{startedAt=new Date;requestsTotal=0;requestsErrored=0;requestsTimedOut=0;inFlight=0;watchersOpened=0;watchersClosed=0;watchersEvicted=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<qW){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%qW}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,hits:0,misses:0,invalidations:0,watchers:0},usageCache:{size:0,hits:0,misses:0,sweeps:0},renderCache:{size:0,held:0,retired: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},watchersActive:0,handlerProbes:[],clients:[],bundle:`/`,daemon:{pid:0,rss:0,rssLimit:0,postMortems:{kind:`ok`,value:[]}}})}snapshot(e){let t=process.memoryUsage();return{pid:process.pid,version:Ft,sourceDigest:Pg(),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,renderCache:e.renderCache,effectCache:e.effectCache,sessionState:e.sessionState,frameFeeds:e.frameFeeds,watchers:{active:e.watchersActive,opened:this.watchersOpened,closed:this.watchersClosed,evicted:this.watchersEvicted},subprocesses:this.snapshotSubprocesses(),nextRestartReason:e.nextRestartReason??null,handlerProbes:e.handlerProbes,clients:e.clients,bundle:e.bundle,daemon:e.daemon}}};function YW(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 XW={load:()=>({}),save:()=>{},flush:()=>{}};var ZW=class{sessions;storage;head=0;atom=(0,Cv.createAtom)(`SessionState`);constructor(e=XW,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,Cv.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,Cv.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,Cv.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 QW(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 $W=class{timer=null;pending=null;constructor(e,t=500,n=Gt){this.filePath=e,this.debounceMs=t,this.logger=n}load(){let e;try{e=s.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 QW(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{s.mkdirSync(v.dirname(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp`;s.writeFileSync(t,JSON.stringify(e),{mode:384}),s.chmodSync(t,384),s.renameSync(t,this.filePath),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}};const eG={default_empty_value:`string`,default_separator:`string`,palette:`string`,style:`string`,effect:`string`,preset:`string`,endcaps:`string`,variation:`string`,shade:`string`,autoWrap:`boolean`,padding:`number`,updateNotice:`boolean`,transitions:`boolean`,experimentalBand:`boolean`,experimentalStatusline:`boolean`,experimentalPane:`boolean`,colorCompatibility:`string`,menuGlyph:`string`},tG=new Set([`1`,`true`]),nG=new Set([`0`,`false`,``]);function rG(e,t){let n=OG(e),r=n.scope===`segment-palette`?`string`:eG[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(tG.has(t))return`true`;if(nG.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function iG(e){try{return s.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function aG(e,t,n){try{if(t===null){s.rmSync(e,{force:!0});return}s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function oG(e){return/^\s*$/.test(e)?null:Lr(e)}function sG(e,t){return e!==null&&zr(e,t)!==void 0}function cG(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(cG),...i}}return e}function lG(e){if(!O_(e))return cG(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,cG(t)])),...n}}const uG=JR,dG=uG.segments,fG=uG.presets,pG=uG.root;function mG(e,t,n,r){if(!sG(e,t)&&n===void 0)throw new q(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function hG(e,t){let n=KO(t);return t.scope===`segment-palette`&&mG(e,[`segments`,t.segment],dG[t.segment],n.join(`.`)),n}function gG(e){return Lr(qr(e))}function _G(){return Object.entries(pG.rows).map(([e,t])=>{let n=cG(t);return{path:[`root`],fragment:gG({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function vG(e,t){let n=e===null?void 0:zr(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function yG(e,t){if(t===void 0)return null;let n=lG(t);return{path:e,fragment:gG(n),unit:{path:e,value:n}}}function bG(e,t){let n=[`presets`,t],r=[...n,`root`],i=fG[t];mG(e,n,i,r.join(`.`));let a=vG(e,r)??yG(r,i?.root);return a!==null&&mi(a.fragment)?a:null}function xG(e,t){let n=pi(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 SG(e,t){return[..._G(),vG(e,[`root`]),bG(e,t)].filter(e=>e!==null).reduce(xG,new Map)}function CG(e,t,n){for(let{node:r,...i}of SG(e,t).values())if(gi(r,n))return i;throw new q(`${wG(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 wG(e,t){return bG(e,t)?.path??[`root`]}function TG(e,t){return t.scope===`preset-root`?wG(e,t.preset):KO(t)}function EG(e,{unit:t}){return t===null?e:si(e,t.path,qr(t.value),Gr)}function DG(e){let t=GO(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function OG(e){let t=DG(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function kG(e,t,n,r,i){i(t,n,BG(t,r)),aG(t.path,r,e.logger),e.record(t.path,n,r)}function AG(e,t,n){let r=NG(e,t,n);if(r.length>0)throw new q(`refused: ${e.above.join(`, `)} sets ${r.join(`, `)} over ${e.path}, so this click would change nothing on the bar — edit it there`)}const jG=()=>{};function MG(e,t){try{return t()}catch(t){throw!(t instanceof q)||e.above.length===0?t:new q(`${t.message} — or it is declared by ${e.above.join(`, `)}, which the bar does not edit`)}}function NG(e,t,n){let r=PG(e,t);if(r===null)return[];let i=new Set(RG(LG(r),LG(n)));return RG(IG(e,r),IG(e,n)).filter(e=>!i.has(e))}function PG(e,t){try{return FG(e,t)}catch(e){if(e instanceof YE)return null;throw e}}function FG(e,t){return DR(t===null?e.above:[e.path,...e.above],XR,{entered:()=>{},warned:()=>{}},{projectDir:e.projectDir,cwd:e.cwd},n=>n===e.path&&t!==null?t:s.readFileSync(n,`utf8`))}function IG(e,t){let[n]=t.layers;return n?.path===e.path?n.config:t.base}function LG(e){return e.layers.at(-1)?.config??e.base}function RG(e,t,n=``){return!zG(e)||!zG(t)?JSON.stringify(e)===JSON.stringify(t)?[]:[n]:[...new Set([...Object.keys(e),...Object.keys(t)])].flatMap(r=>RG(e[r],t[r],n===``?r:`${n}.${r}`))}function zG(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function BG(e,t){try{return FG(e,t)}catch(e){throw e instanceof YE?new q(`refused: the config file would not load after this click — ${e.message}`):e}}function VG(e,t){let n=OG(t),r=oG(iG(e)??``),i=r===null?void 0:zr(r,KO(n));return i!==void 0&&`value`in i?i.value:void 0}function HG(e,t,n){UG(e,t,n,[])}function UG(e,t,n,r){let i=iG(t.path),a=n.reduce((e,[t,n])=>si(e,hG(oG(e),OG(t)),rG(t,n),Gr),i??``);kG(e,t,i,MG(t,()=>WG(a,t.path,r,e=>e)),AG)}function WG(e,t,n,r){return n.reduce((e,{preset:n,id:i,setting:a,value:o})=>{let s=r(e,n,i),c=CG(oG(s),n,i),l=bi(EG(s,c),c.path,i,a,qr(o));if(l===null)throw new q(`${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 GG(e,t,n){let r=oG(e),i=[`presets`,t,`root`];for(let[a,{path:o,unit:s,node:c}]of SG(r,t)){if(!gi(c,n))continue;if(i.every((e,t)=>o[t]===e))return e;let l=s===null?Vr(e,c):qr(s.value);if(a!==`#`)return si(e,[...i,`rows`,a],l,Gr);if(bG(r,t)!==null)throw new q(`cannot give preset "${t}" its own copy of ${o.join(`.`)}: it already stages rows of its own over that tree`);return si(e,i,l,Gr)}return e}function KG(e,t){return li(e,t,t[0]===`presets`&&t.length>2&&!QR(t[1])?2:0)}function qG(e,t,n){let r=n.map(DG),i=iG(t.path);if(i===null)return;let a=r.reduce((e,t)=>KG(e,TG(oG(e),t)),i);a!==i&&kG(e,t,i,a,jG)}function JG(e){let t=e===null?void 0:zr(e,[`presets`]);return t?.kind===`object`?t.entries.map(e=>e.key):[]}function YG(e,t){let n=new Set([...ZR,...JG(e),...t.above.flatMap(e=>Object.keys(Ar.default.parse(s.readFileSync(e,`utf8`)).presets??{}))].map(JE));return Array.from({length:n.size+1},(e,t)=>`custom-${t+1}`).find(e=>!n.has(JE(e)))}function XG(e,t,n,r,i,a){let o=iG(t.path),s=oG(o??``),c=YG(s,t),l=[`presets`,c],u=MG(t,()=>bG(s,n)),d=[...u===null?[]:[[[...l,`root`],u.unit===null?Vr(o??``,u.fragment):qr(u.unit.value)]],...Object.keys(r).length===0?[]:[[[...l,`globals`],qr(r)]]],f=i.map(([e,t])=>{let n=WO(c,e);return[hG(s,OG(n)),rG(n,t)]}),p=[...d,...f].reduce((e,[t,n])=>si(e,t,n,Gr),si(o??``,l,`{}`,Gr));return kG(e,t,o,MG(t,()=>WG(p,t.path,a.map(e=>({...e,preset:c})),GG)),AG),c}function ZG(e,t,n,r){let i=iG(t.path);kG(e,t,i,si(i??``,[`themeDefaults`,n],qr(r),Gr),AG)}function QG(e,t,n){if(QR(n))throw new q(`cannot delete preset "${n}": it is bundled — reset its settings instead`);let r=[`presets`,n],i=iG(t.path),a=oG(i??``);if(i===null||a===null||zr(a,r)===void 0)throw new q(`cannot delete preset "${n}": ${t.path} declares no ${r.join(`.`)} — the bar you clicked is stale; it reloads on the next render`);let o=zr(a,[`globals`,`preset`]);kG(e,t,i,[r,...o?.kind===`string`&&o.value===n?[[`globals`,`preset`]]:[]].reduce((e,t)=>KG(e,t),i),jG)}function $G(e,t,n,r){let i=DG(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=iG(t.path),o=r.op===`remove`?r.target:r.anchor,s=MG(t,()=>CG(oG(a??``),i.preset,o)),c=EG(a??``,s),{after:l,placed:u}=eK(c,s.path,r,()=>{let e=BG(t,c).config;return R_(e.presets).map(t=>V_(e,t).node)});if(l===null)throw new q(`${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 kG(e,t,a,l,AG),u}function eK(e,t,n,r){switch(n.op){case`remove`:return{after:vi(e,t,n.target),placed:null};case`insert`:{let i=zN(n.segment,n.anchor,r());return{after:yi(e,t,i,n.anchor,n.relation),placed:i}}}}const tK={load:()=>({}),save:()=>{}},nK=new Set(Va.map(e=>e.sessionKey)),rK=e=>nK.has(e)||e.startsWith(rk),iK=8*1024*1024,aK={past:[],future:[]},oK=e=>e.kind===`session`?`session:${e.key}`:`file:${e.file}`;var sK=class{state=new Map;constructor(e,t,n=tK){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)??aK;return{undo:t.length,redo:n.length,sinceEdit:r?.net.length??0}}history(e){return this.state.get(e)??aK}begin(){let e=new Map,t=(t,n)=>{let r=e.get(t)??new Map,i=r.get(oK(n));r.set(oK(n),i===void 0?n:{...n,before:i.before}),e.set(t,r)},n=new Map;return{sessionState:YW(this.sessionState,e=>rK(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:hK(i,n),o=r.get(e),s=o===void 0?a:yK(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 q(`undo: nothing to undo`);return this.apply(e,n,`before`,`undo`,_K(t,n)),n}rewind(e){let t=this.history(e),{savepoint:n}=t;if(n===void 0)throw new q(`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(oK)),a=n.net.filter(e=>!i.has(oK(e))),o=uK(bK(vK(t,n),i));if(this.apply(e,a,`before`,`rewind`,{past:o,future:[],savepoint:{at:o.length,net:[],below:[]}}),r.length>0)throw new q(`rewind: ${r.map(SK).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 q(`redo: nothing to redo`);let a=[...n,i],o=uK(a);return this.apply(e,i,`after`,`redo`,{past:o,future:r.slice(0,-1),...fK(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(oK)),{past:n,future:i,savepoint:a}=this.history(e);throw this.put(e,{past:bK(n,t),future:bK(i,t),...a!==void 0&&{savepoint:{at:bK([...n,...[...i].reverse()].slice(0,a.at),t).length,net:a.net.filter(e=>!t.has(oK(e))),below:bK(a.below,t)}}}),new q(`${r}: ${o.map(SK).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):iG(t.file)}write(e,t,n){t.kind===`file`?aG(t.file,n,this.logger):n===null?this.sessionState.clear(e,t.key):this.sessionState.set(e,t.key,n)}put(e,t){let n=new Map(this.state);for(n.delete(e),(t.past.length>0||t.future.length>0||t.savepoint!==void 0)&&n.set(e,t);n.size>32||cK(n)>iK;){let[e,t]=n.entries().next().value;n.size>1?n.delete(e):t.past.length+t.future.length>0?n.set(e,lK(t)):(this.logger(`warn`,`settings-history: edit mode's changes for session ${e} exceed ${iK} bytes; cancel is no longer available`),n.delete(e))}this.storage.save(Object.fromEntries(n)),this.state=n}};function cK(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 lK({past:e,future:t,savepoint:n}){return e.length>0?{past:e.slice(1),future:t,...fK(n,1,[])}:{past:e,future:t.slice(1),...fK(n,0,[])}}function uK(e){return e.slice(-50)}const dK=e=>e===ak.member;function fK(e,t,n){return e===void 0?{}:{savepoint:{at:Math.max(0,e.at-t),net:pK(e.net,n),below:e.below}}}function pK(e,t){let n=new Map(e.map(e=>[oK(e),e]));for(let e of t){let t=n.get(oK(e));n.set(oK(e),t===void 0?e:{...t,after:e.after})}return[...n.values()].filter(e=>e.before!==e.after)}const mK=e=>e.map(e=>({...e,before:e.after,after:e.before}));function hK(e,t){let n=[...e.past,t],r=uK(n),{savepoint:i}=e,a=i===void 0?0:Math.max(0,i.at-e.past.length);return{past:r,future:[],...fK(i&&{at:Math.min(i.at,e.past.length),net:i.net,below:[...gK(e.future,a),...i.below]},n.length-r.length,t)}}function gK(e,t){let n=Math.min(t,e.length);return e.slice(e.length-n).reverse()}function _K(e,t){return{past:e.past.slice(0,-1),future:uK([...e.future,t]),...fK(e.savepoint,0,mK(t))}}function vK(e,t){let{past:n,future:r}=e,i=n.slice(0,t.at);return[...i,...gK(r,t.at-i.length),...t.below]}function yK(e,t){if(dK(t.after)&&!dK(t.before))return{...e,savepoint:{at:e.past.length,net:[],below:[]}};if(!dK(t.after)&&dK(t.before)){let{past:t,future:n}=e;return{past:t,future:n}}return e}function bK(e,t){return e.map(e=>e.filter(e=>!t.has(oK(e)))).filter(e=>e.length>0)}function xK(e){return e.map(SK).join(`, `)}function SK(e){return e.kind===`session`?`session setting "${e.key}"`:e.file}function CK(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 wK(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(CK))}function TK(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(CK)&&wK(t.below)}function EK(e){if(typeof e!=`object`||!e)return!1;let t=e;return wK(t.past)&&wK(t.future)&&(t.savepoint===void 0||TK(t.savepoint))}function DK(e,t){let n=e=>e.kind===`file`||rK(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 OK(e,t){return{load:()=>{let n;try{n=s.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(EK)){let n=new Set,r=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,DK(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{s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(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 kK=e=>!rK(e)&&!sj(e)&&e!==`update.dismissed`;var AK=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:YW(e,kK,(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 q(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,Cv.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 jK=`click.error`;function MK(e,t,n,r){let i={text:n,at:r,answered:!1};e.set(t,jK,JSON.stringify(i))}function NK(e,t,n){let r=PK(e,t);!(r?.at===n.at&&r.text===n.text)||r.answered||e.set(t,jK,JSON.stringify({...r,answered:!0}))}function PK(e,t){let n=e.get(t,jK);return n===null?null:IK(n)}function FK(e,t,n,r){let i=PK(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 IK(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}const LK=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function RK(e,t){let n=e=>({kind:`failed`,reason:`${t} ${e}`}),r;try{r=JSON.parse(e)}catch(e){return n(`is not JSON: ${e.message}`)}if(!LK(r))return n(`is not an object`);for(let[e,t]of Object.entries(r)){if(!LK(t))return n(`holds ${JSON.stringify(e)} as something other than its sightings`);for(let[e,r]of Object.entries(t))if(!eA.includes(r))return n(`marks ${JSON.stringify(e)} ${JSON.stringify(r)}, not ${eA.join(` or `)}`)}return{kind:`ok`,value:r}}function zK(e,t,n,r){return{...e,[t]:{...e[t],[n]:r}}}function BK(e=v.join(Ue(),`doctor-marks.json`)){let t=()=>{let t;try{t=s.readFileSync(e,`utf8`)}catch(t){return t.code===`ENOENT`?{kind:`ok`,value:{}}:{kind:`failed`,reason:`${e}: ${t.message}`}}return RK(t,e)};return{read:t,record:(n,r,i)=>{let a=t();if(a.kind===`failed`)throw Error(`doctor: the mark book could not be read: ${a.reason}`);s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,`${JSON.stringify(zK(a.value,n,r,i),null,2)}\n`)}}}var VK=class extends Error{constructor(e){super(`the doctor looked at ${e} less than a second ago — click again`),this.name=`DoctorBusy`}};const HK={pullRequests:e=>Qz(e).showPullRequest===!0,rateLimits:e=>Zz(e,`block`)||Zz(e,`weekly`),memento:e=>Zz(e,`memento`)};function UK(e,t){let n=new Map;for(let r of $g(V_(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=>u_(e.segments[t])===`fail`),i=new Map(r.map(t=>[t,qz(e,t,n.get(t))])),a=e=>r.filter(t=>HK[e](i.get(t)));return{pullRequests:a(`pullRequests`),rateLimits:a(`rateLimits`),memento:a(`memento`)}}
196
+ `);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function cW(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 lW(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 uW(e){return{...e,cells:e.cells.map(FH)}}function dW(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,...fW(e,r)]}function fW(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 pW(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:dW(e.direction,e.children.map((t,i)=>n(t,[...r,mW(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function mW(e,t){return{index:t,count:e.children.length,distribution:e.distribution,axis:Jg[e.direction]}}const hW={compile(e,t){return{kind:`container`,direction:e.direction,when:t.when,distribution:$p(e.distribution),children:e.children.map((e,n)=>t.compileChild(e,e_(t.path,n)))}},render(e,t){return t.gate.kind===`failed`&&t.gate.report(),dW(e.direction,e.children.map((n,r)=>t.renderChild(n,t.gate.kind===`shown`,mW(e,r))))}},gW={drop:e=>e.place,above:()=>`above`},_W={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},vW={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:Yg(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(gr(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,t_(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,yW(e,t))};function yW(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=ST(t.scope,e.settings);if(t.gate.kind===`failed`)return bW(e,a,t,t.gate.message);try{if(!OH(i.when,a))return[];let n=zg(e.settings.theme,t.palette),o={id:e.id,effect:e.settings.effect,ground:hk(n)},s=e.opens!==void 0&&OH(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:gW[g.placement](e)})),v=sW(HH(l,m)).map((e,t)=>({cells:RH(e,{...h,lead:t===0?HH(u,m):[],trail:t===0?HH(d,m):[]}),band:`own`,place:`flow`})),y=f.map(e=>({cells:RH(HH([e],c.band),{...h,baseStyle:c.band}),band:`deeper`,place:`flow`})),b=(e,t,n)=>RH(HH([e],t),{...h,width:`auto`,baseStyle:t,padding:n}),x=_.findIndex(e=>e.band===`own`),{lead:S,stays:C}=g!==void 0&&x!==-1?_W[g.placement](v,()=>b(t.closeDisclosure(g.key),c.close,t.padding)):{lead:[],stays:v},w=S.flatMap(e=>b(new K(` `.repeat(PH(e).reduce((e,t)=>e+t.cellLength,0))),c.trigger,0)),ee=(e,t)=>e.band===`own`?t===x?S:w:[],te=_.map((e,t)=>({cells:[...ee(e,t),...e.cells],band:`deeper`,place:e.place})),ne=[...C,...y];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...ne.flatMap(e=>e.cells),..._.flatMap(ee)].flatMap(PH)),[...ne,...te]}catch(n){return bW(e,a,t,n.message??String(n))}}function bW(e,t,n,r){n.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:RH([new K(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,placement:{id:e.id,effect:`bar`,ground:hk(n.palette)},lead:xW(e.lead,e,t,n),trail:xW(e.trail,e,t,n)}),band:`own`,place:`flow`}]}function xW(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 SW={container:hW,segment:vW};function CW(e){return SW[e]}function wW(e){if(`ttl`in e)return{kind:`ttl`,durationMs:SE(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 TW(e,t){switch(a_(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 EW(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:wW(n.cache),parse:TW(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:wW(n.cache),parse:TW(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 DW(e,t){let n=ay.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}const OW=(e,t,n,r,i)=>{let a=tz(t,ez(n,e.themeDefaults));return{variation:qp[r??Dh(void 0,null,a.variation)],shade:Gp[i??Ah(void 0,null,a.shade)]}};function kW(e,t,n){let r=n.cwd,i={store:t.variableStore,compiled:new Map,chromeCols:ag({endcaps:`powerline`}),width:80,padding:1,seamCols:og({endcaps:`powerline`}),layout:()=>[],look:void 0},a=SU(t.drawnAt),o={action:i,activeSegment:a},s=Object.keys(e.styles),c=R_(e.presets),l=vN(e),u=yT({extraFuncs:{...aU(i),...PU(i,a),...RU(i,a),...qU(i,a),...HU(i,a,t.now),...QU(i,a),...nW(o),...aW(a),styles:{fn:()=>s,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>c,argTypes:[],arity:{kind:`exact`}}},clock:t.now,drawnAt:t.drawnAt}),d=DW(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;for(let[t,n]of Ga)n in e.variables&&h.set(t,n);for(let[t,n]of d_(e))h.has(n.key)||h.set(n.key,t);i.compiled=KH(f,e.actions,h,l);let g=[];for(let[n,i]of Object.entries(e.variables))try{EW(t,n,i,r)}catch(e){g.push(`Variable "${n}": ${e.message??String(e)}`)}for(let[n,i]of Object.entries(e.segments))if(i.vars)for(let[e,a]of Object.entries(i.vars))try{EW(t,`${n}.${e}`,a,r)}catch(t){g.push(`Variable "${n}.${e}": ${t.message??String(t)}`)}let _=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})}};_[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 v=(e,t,n)=>{try{return m(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},y=t.variableStore,b=t=>{let n=h_(e.segments[t.name]),r=Object.create(null);for(let[e,i]of Object.entries(n))Object.defineProperty(r,e,{enumerable:!0,get:()=>x_(t,e,i,e=>String(y.read(e.variable)))});return Object.freeze(r)},x=(e,t)=>{let n={path:t,when:e.when===void 0?void 0:v(e.when,t,`when`),parse:(e,n)=>v(e,t,n),compileChild:x,placementSettings:b};return CW(e.kind).compile(e,n)},S=new Map;for(let t of c){let{node:n,path:r}=V_(e,t);S.set(t,x(n,r))}let C=new Map(nh.map(e=>[e,new Map])),w=[[`globals`,e.globals],...Object.entries(e.presets).map(([e,t])=>[`presets.${e}.globals`,t.globals??{}])];for(let[e,t]of w)for(let n of nh){let r=t[n];if(!rh(r))continue;let i=`${e}.${n}`,a=C.get(n),o=a.get(r);a.set(r,o===void 0?{where:i,template:AW(f,i,r)}:{where:`${o.where}, ${i}`,template:o.template})}return{segments:_,roots:S,activeSegment:a,menuRuntime:o,globalExpressions:C,loadWarnings:g}}function AW(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 jW(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 MW(e,t,n,r){try{return t.template.evaluate(n).map(e=>e.plain).join(``)}catch(n){return r({kind:`rule`,slot:e,message:fh(t.where,e,`the rule failed — ${n instanceof Error?n.message:String(n)}`)}),dh[e]}}function NW(e,t){return e.kind===`decided`?e.name:dh[t]}function PW(e){return FW(e).filter(e=>!e.name.startsWith(nD)).map(e=>e.id)}function FW(e){return e.kind===`container`?e.children.flatMap(FW):[e,...e.opens===void 0?[]:FW(e.opens.body)]}function IW(...e){return LW(...e).text}function LW(e,t,n,r,i,a,o,s,c){let{perSegmentSink:l,onSegmentError:u,onRenderWarning:d}=s??{},f=e=>d?.(e),p=new Set;r.renderAt(a),r.drawAt(wh(o.colorCompatibility));let{preset:m=I_}=c??{},h=H_(e,m),g=c?.style??ch(`none`,e.styles),_=c?.theme??Gg(void 0,null,h.palette),v=OW(e,h,_,c?.variation,c?.shade),y=c?.effect??_h(void 0,null,h.effect),b=(e,t,n)=>({...i,term:{cols:o.width},theme:{effective:e},style:{effective:t},effect:{effective:n}});r.applyInput(b(NW(_,`palette`),NW(g,`style`),NW(y,`effect`))),t.menuRuntime.action.chromeCols=ag(o),t.menuRuntime.action.padding=o.padding,t.menuRuntime.action.width=o.width,t.menuRuntime.action.seamCols=og(o);let x=bT(n),S=ah(_,e=>{let n=jW(t,`palette`,e);return Wg(MW(`palette`,n,x,f),n.where,e=>f({kind:`rule`,slot:`palette`,message:e}))}),C=ah(g,n=>ch(MW(`style`,jW(t,`style`,n),x,f),e.styles)),w=ah(y,e=>gh(MW(`effect`,jW(t,`effect`,e),x,f)));(S!==_||C!==g||w!==y)&&r.applyInput(b(S.name,C.name,w.name));let ee=S.value,te=Vg(ee,C.value);t.menuRuntime.action.look={basePalette:ee,palette:te,decor:v};let ne=c?.transitions??Bh(void 0,null,h.transitions),T=(c?.effects??new Zh(``)).motion(w.value,a,{transitions:ne,source:{config:t,preset:m,revision:r.stateRevision(),width:o.width},returned:lW,hold:uW});l?.clear();let re=n=>{let r=e.segments[n],i=t.segments[n];return r!==void 0&&i!==void 0?{seg:r,compiled:i}:void 0},E=(e,n,i,a,o,s)=>{try{let c=r.drawnAt(),{tint:l,text:u,disclosure:d}=Km(i,a,c),f=CU(t.activeSegment,e.name,e.id,i,d,l,u),m=_k(f,c,o.bg,o.fg,n),h=()=>Nm(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)p.add(t)}let v=o.lead?.evaluate(n)??[],y=o.trail?.evaluate(n)??[];return{styles:{closed:m,get trigger(){return sU(i,h().state,c)},get band(){return sU(i,h().plane,c)},get close(){return uU(i,h().state,c)},disclosure:d},fragments:g,lead:v,trail:y,drops:f.drops,open:_}}finally{t.activeSegment.current=null}},D=(e,t,r)=>{let i=t?jH(e.when,x):kH,a=i.kind===`failed`?{...i,report:()=>{let t=`when over ${PW(e).join(`, `)||`no placement`}`;f({kind:`when`,where:t,error:i.message,message:`${t}: ${i.message} — what it gates is hidden`})}}:i,s={scope:x,palette:te,gate:a,padding:o.padding,region:r,perSegmentSink:l,onSegmentError:u,evaluateSegment:E,lookupSegment:re,renderChild:(e,t,n)=>D(e,t,Wm(r,n)),renderBody:(e,t,n)=>D(e,a.kind===`shown`&&t,Gm(n)),closeDisclosure:e=>oU(n,e),placed:T.placed};return CW(e.kind).render(e,s)},ie=t.roots.get(m);if(ie===void 0)throw Error(`Preset "${m}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${I_}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let O=e=>{let n=jH(e.when,x);if(e.kind===`container`)return n.kind===`shown`;if(kN(e.name)===void 0)return!1;if(n.kind!==`shown`)return n.kind===`failed`;try{return OH(t.segments[e.name].when,ST(x,e.settings))}catch{return!0}};t.menuRuntime.action.layout=()=>pW(ie,O).map(e=>e.flatMap(({name:e,address:t,settings:n})=>{let r=kN(e);return r===void 0?[]:[{name:r,address:t,palette:zg(n.theme,te)}]}));let ae=cW(D(ie,!0,Um(v))).map(({line:e,row:t})=>{let n=VH(e.cells,o);return ug(n.map(e=>e.owner),o,T.row(t,n))});T.drawn();let oe=ae.some(e=>e.moves)?`moves`:y.kind===`expression`||ne||FW(ie).some(({settings:e})=>e.effect!==`bar`&&e.effect!==`none`)?`can-move`:`still`;for(let e of p)f({kind:`band-floor`,message:e});for(let[e,t]of r.cachePolicyFaults())f({kind:`refresh`,variable:e,error:t.message,message:`variable "${e}" cannot refresh: ${t.message}`});return{text:ae.map(e=>e.text).join(`
197
+ `),motion:oe}}function*RW(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*zW(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 R_(e.presets)){for(let n of $g(V_(e,t).node))n.when!==void 0&&(yield n.when);let n=H_(e,t);for(let e of nh){let t=n[e];rh(t)&&(yield t)}}for(let[,t]of RW(e))t.kind===`template`&&(yield t.template),s_(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 BW(e,t){return e===t||t.startsWith(`${e}.`)||e.startsWith(`${t}.`)}function VW(e,t){let n=new Set,r=new Set,i=new Set;for(let e of zW(t)){for(let r of lv(e,t.helpers).keys())n.add(r);for(let{name:n}of pv(e,t.helpers))r.add(n);for(let n of mv(e,t.helpers))i.add(n)}for(let[,e]of RW(t))if(s_(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 R_(t.presets))for(let n of $g(V_(t,e).node))n.kind===`segment`&&s.add(n.name);let c=(e,t)=>[...n].some(t=>BW(t,e))||t.kind===`state`&&o.has(t.key),l=e=>[...e].filter(e=>!iD(e)),u=(e,t,n)=>l(t).filter(e=>!n(e)).map(t=>({kind:e,name:t})),d=new Map(RW(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 HW=class{kind=`box`;cell;lastChangedAt;constructor(e,t,n){this.name=e,this.type=t,JW(e,t,n,`initial value`),this.cell=Cv.observable.box(n,{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){JW(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}},UW=class{kind=`computed`;cell;constructor(e,t,n){if(this.name=e,this.type=t,this.cell=(0,Cv.computed)(()=>{let e=n();return JW(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}},WW=class{kind=`document`;cell;lastChangedAt;constructor(e,t){this.name=e,this.cell=Cv.observable.box(qW(t),{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){let t=qW(e);KW(this.cell.get(),t)||(this.cell.set(t),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}};function GW(e){return JSON.stringify(e)}function KW(e,t){return GW(e)===GW(t)}function qW(e){return e.kind===`ok`?{kind:`ok`,value:wv(e.value)}:e}function JW(e,t,n,r){let i=Tv(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var YW=class{nodes=Cv.observable.map(void 0,{deep:!1});defineBox(e,t,n){this.declare(e,new HW(e,t,n))}defineDocument(e,t){this.declare(e,new WW(e,t))}defineComputed(e,t,n){let r=e=>this.read(e);this.declare(e,new UW(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,Cv.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,Cv.runInAction)(()=>n.set(t))}runInAction(e){(0,Cv.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 GW(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,Cv.runInAction)(()=>{for(let t of this.nodes.values())t instanceof UW&&(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,Cv.runInAction)(()=>this.nodes.set(e,t))}};function XW(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=FL(e),r=t===void 0?void 0:n.variables[LL(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 ZW(e,t){return`config disposed reason=${e.reason} released=${t} held=${e.held}`}function QW(e,t,n){return e+`\0`+t+`\0`+(n??``)}function $W(e,t){return new Set(R_(e.presets).filter(n=>V_(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function eG(e,t){let n=new Map,{roots:r,loaded:i,dropped:a,unreached:o}=e.state.plugins;for(let t of[...fR(e.projectDir,e.cwd,e.configFile),...r,...i,...[...a,...o].map(e=>e.path)]){let{dir:e,name:r}=yv(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}=yv(v.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 tG(e){return e.filter(Boolean).join(`
198
+ `)||null}function nG(e,t,n,r,i=()=>{}){let{layers:a,config:o,installed:s}=DR(t.layers,XR,{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??XR,l=a.find(e=>e.path===t.home)?.raw??{},u=new YW,d=new UE(u,o.globals.default_empty_value??``,r.gitService,r.sessionState),f;try{f=kW(o,d,{cwd:e}),n.push(...f.loadWarnings),UB(o),QN(o)}catch(e){throw d.dispose(),e}return{config:o,store:u,registry:d,compiled:f,neededInputPaths:Yz(o),lastRenderCellsBySegment:new Map,authoredRoots:$W(c,l),fileHeldSettings:kB(l),unused:[...new Map(a.flatMap(e=>VW(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 rG(e,t,n,r){let i=mR(e,t,n),a={layers:i.kind===`chain`?i.layers:[],home:i.home,projectDir:e},o=[yR(e,t),_R(i)],s,c=null;try{s=nG(t,a,o,r,e=>{c=e})}catch(e){return e instanceof YE&&o.push(...e.warnings),{layers:a.layers,home:a.home,failedFile:c,warning:tG(o),state:null,error:e instanceof YE||e instanceof Error?e.message:String(e)}}return{layers:a.layers,home:a.home,warning:tG(o),state:s,error:null}}function iG(e,t,n){return nG(e,{layers:[],home:``,projectDir:t},[],n)}var aG=class{entries=new Map;holds=new Map;deps;log;maxEntries;observers;constructor(e,t={}){this.deps=e,this.log=e.log??Gt,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{}}getOrCreate(e,t,n){let r=QW(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=rG(e,t,n,this.deps);a.state!==null&&this.log(`info`,XW(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??iG(t,e,this.deps),watcher:null,watcherKey:null};if(this.serve(o.state),this.entries.set(r,o),this.entries.size>this.maxEntries){let e=this.entries.entries().next().value;if(e!==void 0){let[t,n]=e;n.watcher?.release(),this.entries.delete(t),this.retire(n.state,`evict`)}}return 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}}serve(e){this.holds.set(e,{holders:0,retired:null})}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`,ZW(t.retired,e.registry.dispose())))}reload(e,t,n){this.reloadInto(this.getOrCreate(e,t,n))}reloadInto(e){let t=rG(e.projectDir,e.cwd,e.configFile,this.deps);if(e.lastWarning=t.warning,e.lastError=t.error,t.state!==null){this.log(`info`,XW(t.layers,t.state));let n=e.state;e.state=t.state,this.serve(t.state),this.retire(n,`reload`)}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=eG(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 oG=16384;var sG=class e{startedAt=new Date;requestsTotal=0;requestsErrored=0;requestsTimedOut=0;inFlight=0;watchersOpened=0;watchersClosed=0;watchersEvicted=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<oG){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%oG}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,hits:0,misses:0,invalidations:0,watchers:0},usageCache:{size:0,hits:0,misses:0,sweeps:0},renderCache:{size:0,held:0,retired: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},watchersActive:0,handlerProbes:[],clients:[],bundle:`/`,daemon:{pid:0,rss:0,rssLimit:0,postMortems:{kind:`ok`,value:[]}}})}snapshot(e){let t=process.memoryUsage();return{pid:process.pid,version:Ft,sourceDigest:Pg(),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,renderCache:e.renderCache,effectCache:e.effectCache,sessionState:e.sessionState,frameFeeds:e.frameFeeds,watchers:{active:e.watchersActive,opened:this.watchersOpened,closed:this.watchersClosed,evicted:this.watchersEvicted},subprocesses:this.snapshotSubprocesses(),nextRestartReason:e.nextRestartReason??null,handlerProbes:e.handlerProbes,clients:e.clients,bundle:e.bundle,daemon:e.daemon}}};function cG(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 lG={load:()=>({}),save:()=>{},flush:()=>{}};var uG=class{sessions;storage;head=0;atom=(0,Cv.createAtom)(`SessionState`);constructor(e=lG,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,Cv.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,Cv.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,Cv.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 dG(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 fG=class{timer=null;pending=null;constructor(e,t=500,n=Gt){this.filePath=e,this.debounceMs=t,this.logger=n}load(){let e;try{e=s.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 dG(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{s.mkdirSync(v.dirname(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp`;s.writeFileSync(t,JSON.stringify(e),{mode:384}),s.chmodSync(t,384),s.renameSync(t,this.filePath),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}};const pG={default_empty_value:`string`,default_separator:`string`,palette:`string`,style:`string`,effect:`string`,preset:`string`,endcaps:`string`,variation:`string`,shade:`string`,autoWrap:`boolean`,padding:`number`,updateNotice:`boolean`,transitions:`boolean`,experimentalBand:`boolean`,experimentalStatusline:`boolean`,experimentalPane:`boolean`,colorCompatibility:`string`,menuGlyph:`string`},mG=new Set([`1`,`true`]),hG=new Set([`0`,`false`,``]);function gG(e,t){let n=VG(e),r=n.scope===`segment-palette`?`string`:pG[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(mG.has(t))return`true`;if(hG.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function _G(e){try{return s.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function vG(e,t,n){try{if(t===null){s.rmSync(e,{force:!0});return}s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function yG(e){return/^\s*$/.test(e)?null:Lr(e)}function bG(e,t){return e!==null&&zr(e,t)!==void 0}function xG(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(xG),...i}}return e}function SG(e){if(!O_(e))return xG(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,xG(t)])),...n}}const CG=JR,wG=CG.segments,TG=CG.presets,EG=CG.root;function DG(e,t,n,r){if(!bG(e,t)&&n===void 0)throw new q(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function OG(e,t){let n=KO(t);return t.scope===`segment-palette`&&DG(e,[`segments`,t.segment],wG[t.segment],n.join(`.`)),n}function kG(e){return Lr(qr(e))}function AG(){return Object.entries(EG.rows).map(([e,t])=>{let n=xG(t);return{path:[`root`],fragment:kG({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function jG(e,t){let n=e===null?void 0:zr(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function MG(e,t){if(t===void 0)return null;let n=SG(t);return{path:e,fragment:kG(n),unit:{path:e,value:n}}}function NG(e,t){let n=[`presets`,t],r=[...n,`root`],i=TG[t];DG(e,n,i,r.join(`.`));let a=jG(e,r)??MG(r,i?.root);return a!==null&&mi(a.fragment)?a:null}function PG(e,t){let n=pi(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 FG(e,t){return[...AG(),jG(e,[`root`]),NG(e,t)].filter(e=>e!==null).reduce(PG,new Map)}function IG(e,t,n){for(let{node:r,...i}of FG(e,t).values())if(gi(r,n))return i;throw new q(`${LG(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 LG(e,t){return NG(e,t)?.path??[`root`]}function RG(e,t){return t.scope===`preset-root`?LG(e,t.preset):KO(t)}function zG(e,{unit:t}){return t===null?e:si(e,t.path,qr(t.value),Gr)}function BG(e){let t=GO(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function VG(e){let t=BG(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function HG(e,t,n,r,i){i(t,n,$G(t,r)),vG(t.path,r,e.logger),e.record(t.path,n,r)}function UG(e,t,n){let r=KG(e,t,n);if(r.length>0)throw new q(`refused: ${e.above.join(`, `)} sets ${r.join(`, `)} over ${e.path}, so this click would change nothing on the bar — edit it there`)}const WG=()=>{};function GG(e,t){try{return t()}catch(t){throw!(t instanceof q)||e.above.length===0?t:new q(`${t.message} — or it is declared by ${e.above.join(`, `)}, which the bar does not edit`)}}function KG(e,t,n){let r=qG(e,t);if(r===null)return[];let i=new Set(ZG(XG(r),XG(n)));return ZG(YG(e,r),YG(e,n)).filter(e=>!i.has(e))}function qG(e,t){try{return JG(e,t)}catch(e){if(e instanceof YE)return null;throw e}}function JG(e,t){return DR(t===null?e.above:[e.path,...e.above],XR,{entered:()=>{},warned:()=>{}},{projectDir:e.projectDir,cwd:e.cwd},n=>n===e.path&&t!==null?t:s.readFileSync(n,`utf8`))}function YG(e,t){let[n]=t.layers;return n?.path===e.path?n.config:t.base}function XG(e){return e.layers.at(-1)?.config??e.base}function ZG(e,t,n=``){return!QG(e)||!QG(t)?JSON.stringify(e)===JSON.stringify(t)?[]:[n]:[...new Set([...Object.keys(e),...Object.keys(t)])].flatMap(r=>ZG(e[r],t[r],n===``?r:`${n}.${r}`))}function QG(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $G(e,t){try{return JG(e,t)}catch(e){throw e instanceof YE?new q(`refused: the config file would not load after this click — ${e.message}`):e}}function eK(e,t){let n=VG(t),r=yG(_G(e)??``),i=r===null?void 0:zr(r,KO(n));return i!==void 0&&`value`in i?i.value:void 0}function tK(e,t,n){nK(e,t,n,[])}function nK(e,t,n,r){let i=_G(t.path),a=n.reduce((e,[t,n])=>si(e,OG(yG(e),VG(t)),gG(t,n),Gr),i??``);HG(e,t,i,GG(t,()=>rK(a,t.path,r,e=>e)),UG)}function rK(e,t,n,r){return n.reduce((e,{preset:n,id:i,setting:a,value:o})=>{let s=r(e,n,i),c=IG(yG(s),n,i),l=bi(zG(s,c),c.path,i,a,qr(o));if(l===null)throw new q(`${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 iK(e,t,n){let r=yG(e),i=[`presets`,t,`root`];for(let[a,{path:o,unit:s,node:c}]of FG(r,t)){if(!gi(c,n))continue;if(i.every((e,t)=>o[t]===e))return e;let l=s===null?Vr(e,c):qr(s.value);if(a!==`#`)return si(e,[...i,`rows`,a],l,Gr);if(NG(r,t)!==null)throw new q(`cannot give preset "${t}" its own copy of ${o.join(`.`)}: it already stages rows of its own over that tree`);return si(e,i,l,Gr)}return e}function aK(e,t){return li(e,t,t[0]===`presets`&&t.length>2&&!QR(t[1])?2:0)}function oK(e,t,n){let r=n.map(BG),i=_G(t.path);if(i===null)return;let a=r.reduce((e,t)=>aK(e,RG(yG(e),t)),i);a!==i&&HG(e,t,i,a,WG)}function sK(e){let t=e===null?void 0:zr(e,[`presets`]);return t?.kind===`object`?t.entries.map(e=>e.key):[]}function cK(e,t){let n=new Set([...ZR,...sK(e),...t.above.flatMap(e=>Object.keys(Ar.default.parse(s.readFileSync(e,`utf8`)).presets??{}))].map(JE));return Array.from({length:n.size+1},(e,t)=>`custom-${t+1}`).find(e=>!n.has(JE(e)))}function lK(e,t,n,r,i,a){let o=_G(t.path),s=yG(o??``),c=cK(s,t),l=[`presets`,c],u=GG(t,()=>NG(s,n)),d=[...u===null?[]:[[[...l,`root`],u.unit===null?Vr(o??``,u.fragment):qr(u.unit.value)]],...Object.keys(r).length===0?[]:[[[...l,`globals`],qr(r)]]],f=i.map(([e,t])=>{let n=WO(c,e);return[OG(s,VG(n)),gG(n,t)]}),p=[...d,...f].reduce((e,[t,n])=>si(e,t,n,Gr),si(o??``,l,`{}`,Gr));return HG(e,t,o,GG(t,()=>rK(p,t.path,a.map(e=>({...e,preset:c})),iK)),UG),c}function uK(e,t,n,r){let i=_G(t.path);HG(e,t,i,si(i??``,[`themeDefaults`,n],qr(r),Gr),UG)}function dK(e,t,n){if(QR(n))throw new q(`cannot delete preset "${n}": it is bundled — reset its settings instead`);let r=[`presets`,n],i=_G(t.path),a=yG(i??``);if(i===null||a===null||zr(a,r)===void 0)throw new q(`cannot delete preset "${n}": ${t.path} declares no ${r.join(`.`)} — the bar you clicked is stale; it reloads on the next render`);let o=zr(a,[`globals`,`preset`]);HG(e,t,i,[r,...o?.kind===`string`&&o.value===n?[[`globals`,`preset`]]:[]].reduce((e,t)=>aK(e,t),i),WG)}function fK(e,t,n,r){let i=BG(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=_G(t.path),o=r.op===`remove`?r.target:r.anchor,s=GG(t,()=>IG(yG(a??``),i.preset,o)),c=zG(a??``,s),{after:l,placed:u}=pK(c,s.path,r,()=>{let e=$G(t,c).config;return R_(e.presets).map(t=>V_(e,t).node)});if(l===null)throw new q(`${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 HG(e,t,a,l,UG),u}function pK(e,t,n,r){switch(n.op){case`remove`:return{after:vi(e,t,n.target),placed:null};case`insert`:{let i=zN(n.segment,n.anchor,r());return{after:yi(e,t,i,n.anchor,n.relation),placed:i}}}}const mK={load:()=>({}),save:()=>{}},hK=new Set(Va.map(e=>e.sessionKey)),gK=e=>hK.has(e)||e.startsWith(rk),_K=8*1024*1024,vK={past:[],future:[]},yK=e=>e.kind===`session`?`session:${e.key}`:`file:${e.file}`;var bK=class{state=new Map;constructor(e,t,n=mK){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)??vK;return{undo:t.length,redo:n.length,sinceEdit:r?.net.length??0}}history(e){return this.state.get(e)??vK}begin(){let e=new Map,t=(t,n)=>{let r=e.get(t)??new Map,i=r.get(yK(n));r.set(yK(n),i===void 0?n:{...n,before:i.before}),e.set(t,r)},n=new Map;return{sessionState:cG(this.sessionState,e=>gK(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:OK(i,n),o=r.get(e),s=o===void 0?a:MK(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 q(`undo: nothing to undo`);return this.apply(e,n,`before`,`undo`,AK(t,n)),n}rewind(e){let t=this.history(e),{savepoint:n}=t;if(n===void 0)throw new q(`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(yK)),a=n.net.filter(e=>!i.has(yK(e))),o=CK(NK(jK(t,n),i));if(this.apply(e,a,`before`,`rewind`,{past:o,future:[],savepoint:{at:o.length,net:[],below:[]}}),r.length>0)throw new q(`rewind: ${r.map(FK).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 q(`redo: nothing to redo`);let a=[...n,i],o=CK(a);return this.apply(e,i,`after`,`redo`,{past:o,future:r.slice(0,-1),...TK(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(yK)),{past:n,future:i,savepoint:a}=this.history(e);throw this.put(e,{past:NK(n,t),future:NK(i,t),...a!==void 0&&{savepoint:{at:NK([...n,...[...i].reverse()].slice(0,a.at),t).length,net:a.net.filter(e=>!t.has(yK(e))),below:NK(a.below,t)}}}),new q(`${r}: ${o.map(FK).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):_G(t.file)}write(e,t,n){t.kind===`file`?vG(t.file,n,this.logger):n===null?this.sessionState.clear(e,t.key):this.sessionState.set(e,t.key,n)}put(e,t){let n=new Map(this.state);for(n.delete(e),(t.past.length>0||t.future.length>0||t.savepoint!==void 0)&&n.set(e,t);n.size>32||xK(n)>_K;){let[e,t]=n.entries().next().value;n.size>1?n.delete(e):t.past.length+t.future.length>0?n.set(e,SK(t)):(this.logger(`warn`,`settings-history: edit mode's changes for session ${e} exceed ${_K} bytes; cancel is no longer available`),n.delete(e))}this.storage.save(Object.fromEntries(n)),this.state=n}};function xK(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 SK({past:e,future:t,savepoint:n}){return e.length>0?{past:e.slice(1),future:t,...TK(n,1,[])}:{past:e,future:t.slice(1),...TK(n,0,[])}}function CK(e){return e.slice(-50)}const wK=e=>e===ak.member;function TK(e,t,n){return e===void 0?{}:{savepoint:{at:Math.max(0,e.at-t),net:EK(e.net,n),below:e.below}}}function EK(e,t){let n=new Map(e.map(e=>[yK(e),e]));for(let e of t){let t=n.get(yK(e));n.set(yK(e),t===void 0?e:{...t,after:e.after})}return[...n.values()].filter(e=>e.before!==e.after)}const DK=e=>e.map(e=>({...e,before:e.after,after:e.before}));function OK(e,t){let n=[...e.past,t],r=CK(n),{savepoint:i}=e,a=i===void 0?0:Math.max(0,i.at-e.past.length);return{past:r,future:[],...TK(i&&{at:Math.min(i.at,e.past.length),net:i.net,below:[...kK(e.future,a),...i.below]},n.length-r.length,t)}}function kK(e,t){let n=Math.min(t,e.length);return e.slice(e.length-n).reverse()}function AK(e,t){return{past:e.past.slice(0,-1),future:CK([...e.future,t]),...TK(e.savepoint,0,DK(t))}}function jK(e,t){let{past:n,future:r}=e,i=n.slice(0,t.at);return[...i,...kK(r,t.at-i.length),...t.below]}function MK(e,t){if(wK(t.after)&&!wK(t.before))return{...e,savepoint:{at:e.past.length,net:[],below:[]}};if(!wK(t.after)&&wK(t.before)){let{past:t,future:n}=e;return{past:t,future:n}}return e}function NK(e,t){return e.map(e=>e.filter(e=>!t.has(yK(e)))).filter(e=>e.length>0)}function PK(e){return e.map(FK).join(`, `)}function FK(e){return e.kind===`session`?`session setting "${e.key}"`:e.file}function IK(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 LK(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(IK))}function RK(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(IK)&&LK(t.below)}function zK(e){if(typeof e!=`object`||!e)return!1;let t=e;return LK(t.past)&&LK(t.future)&&(t.savepoint===void 0||RK(t.savepoint))}function BK(e,t){let n=e=>e.kind===`file`||gK(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 VK(e,t){return{load:()=>{let n;try{n=s.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(zK)){let n=new Set,r=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,BK(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{s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(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 HK=e=>!gK(e)&&!sj(e)&&e!==`update.dismissed`;var UK=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:cG(e,HK,(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 q(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,Cv.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 WK=`click.error`;function GK(e,t,n,r){let i={text:n,at:r,answered:!1};e.set(t,WK,JSON.stringify(i))}function KK(e,t,n){let r=qK(e,t);!(r?.at===n.at&&r.text===n.text)||r.answered||e.set(t,WK,JSON.stringify({...r,answered:!0}))}function qK(e,t){let n=e.get(t,WK);return n===null?null:YK(n)}function JK(e,t,n,r){let i=qK(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 YK(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}const XK=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function ZK(e,t){let n=e=>({kind:`failed`,reason:`${t} ${e}`}),r;try{r=JSON.parse(e)}catch(e){return n(`is not JSON: ${e.message}`)}if(!XK(r))return n(`is not an object`);for(let[e,t]of Object.entries(r)){if(!XK(t))return n(`holds ${JSON.stringify(e)} as something other than its sightings`);for(let[e,r]of Object.entries(t))if(!eA.includes(r))return n(`marks ${JSON.stringify(e)} ${JSON.stringify(r)}, not ${eA.join(` or `)}`)}return{kind:`ok`,value:r}}function QK(e,t,n,r){return{...e,[t]:{...e[t],[n]:r}}}function $K(e=v.join(Ue(),`doctor-marks.json`)){let t=()=>{let t;try{t=s.readFileSync(e,`utf8`)}catch(t){return t.code===`ENOENT`?{kind:`ok`,value:{}}:{kind:`failed`,reason:`${e}: ${t.message}`}}return ZK(t,e)};return{read:t,record:(n,r,i)=>{let a=t();if(a.kind===`failed`)throw Error(`doctor: the mark book could not be read: ${a.reason}`);s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,`${JSON.stringify(QK(a.value,n,r,i),null,2)}\n`)}}}var eq=class extends Error{constructor(e){super(`the doctor looked at ${e} less than a second ago — click again`),this.name=`DoctorBusy`}};const tq={pullRequests:e=>Qz(e).showPullRequest===!0,rateLimits:e=>Zz(e,`block`)||Zz(e,`weekly`),memento:e=>Zz(e,`memento`)};function nq(e,t){let n=new Map;for(let r of $g(V_(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=>u_(e.segments[t])===`fail`),i=new Map(r.map(t=>[t,qz(e,t,n.get(t))])),a=e=>r.filter(t=>tq[e](i.get(t)));return{pullRequests:a(`pullRequests`),rateLimits:a(`rateLimits`),memento:a(`memento`)}}
200
199
  /*!
201
200
  * Copyright (c) Squirrel Chat et al., All rights reserved.
202
201
  * SPDX-License-Identifier: BSD-3-Clause
@@ -224,9 +223,9 @@ print(json.dumps({"ceiling": "off" if ceiling == math.inf else ceiling,
224
223
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
225
224
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
226
225
  */
227
- function WK(e,t){let n=e.slice(0,t).split(/\r?\n/);return[n.length,n.pop().length+1]}function GK(e,t,n){let r=e.split(/\r?\n/),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
226
+ function rq(e,t){let n=e.slice(0,t).split(/\r?\n/);return[n.length,n.pop().length+1]}function iq(e,t,n){let r=e.split(/\r?\n/),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
228
227
  `,e===t&&(i+=` `.repeat(a+n+2),i+=`^
229
- `))}return i}var $=class e extends Error{line;column;codeblock;constructor(e,t){let[n,r]=WK(t.toml,t.ptr),i=GK(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}static x(t,n,r){throw new e(t,{toml:n.s,ptr:r??n.p})}};
228
+ `))}return i}var $=class e extends Error{line;column;codeblock;constructor(e,t){let[n,r]=rq(t.toml,t.ptr),i=iq(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}static x(t,n,r){throw new e(t,{toml:n.s,ptr:r??n.p})}};
230
229
  /*!
231
230
  * Copyright (c) Squirrel Chat et al., All rights reserved.
232
231
  * SPDX-License-Identifier: BSD-3-Clause
@@ -254,7 +253,7 @@ function WK(e,t){let n=e.slice(0,t).split(/\r?\n/);return[n.length,n.pop().lengt
254
253
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
255
254
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
256
255
  */
257
- function KK(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);a&&((n=e.s.charCodeAt(e.p+=2))===10?e.p++:n===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let o=``,s=e.p,c=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),a&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))c&&=3;else if(n<32&&n!==9||n===127)$.x(`control characters are not allowed in strings`,e);else if((!c||c===3)&&n===r&&(!a||e.s.charCodeAt(e.p+1)===r&&e.s.charCodeAt(e.p+2)===r)){if(a&&(e.s.charCodeAt(e.p+3)===r&&e.p++,e.s.charCodeAt(e.p+3)===r&&e.p++),!c){let t=e.s.slice(s,e.p);o=o?o+t:t}return e.p+=a?3:1,o}else if(!c)!i&&n===92&&(o+=e.s.slice(s,s=e.p),c=1);else if(c===1)if(n===120||n===117||n===85){let t=e.p++-1,r=0,i=n===120?2:n===117?4:8;for(let t=0;t<i;t++,e.p++){let t=e.s.charCodeAt(e.p),n=t>=48&&t<=57?t-48:t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:-1;n<0&&$.x(`invalid non-hex character in unicode escape`,e),r=r<<4|n}(r<0||r>1114111||r>=55296&&r<=57343)&&$.x(`invalid unicode escape`,e,t),o+=String.fromCodePoint(r),s=e.p--,c=0}else a&&(n===32||n===9)?c=2:(n===98?o+=`\b`:n===116?o+=` `:n===110?o+=`
256
+ function aq(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);a&&((n=e.s.charCodeAt(e.p+=2))===10?e.p++:n===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let o=``,s=e.p,c=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),a&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))c&&=3;else if(n<32&&n!==9||n===127)$.x(`control characters are not allowed in strings`,e);else if((!c||c===3)&&n===r&&(!a||e.s.charCodeAt(e.p+1)===r&&e.s.charCodeAt(e.p+2)===r)){if(a&&(e.s.charCodeAt(e.p+3)===r&&e.p++,e.s.charCodeAt(e.p+3)===r&&e.p++),!c){let t=e.s.slice(s,e.p);o=o?o+t:t}return e.p+=a?3:1,o}else if(!c)!i&&n===92&&(o+=e.s.slice(s,s=e.p),c=1);else if(c===1)if(n===120||n===117||n===85){let t=e.p++-1,r=0,i=n===120?2:n===117?4:8;for(let t=0;t<i;t++,e.p++){let t=e.s.charCodeAt(e.p),n=t>=48&&t<=57?t-48:t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:-1;n<0&&$.x(`invalid non-hex character in unicode escape`,e),r=r<<4|n}(r<0||r>1114111||r>=55296&&r<=57343)&&$.x(`invalid unicode escape`,e,t),o+=String.fromCodePoint(r),s=e.p--,c=0}else a&&(n===32||n===9)?c=2:(n===98?o+=`\b`:n===116?o+=` `:n===110?o+=`
258
257
  `:n===102?o+=`\f`:n===114?o+=`\r`:n===101?o+=`\x1B`:n===34?o+=`"`:n===92?o+=`\\`:$.x(`unrecognised escape sequence`,e),s=e.p+1,c=0);else n!==32&&n!==9&&(c===2&&$.x(`invalid escape: only line-ending whitespace may be escaped`,e,s),c=+(!i&&n===92),s=e.p);$.x(`unfinished string`,e,t)}
259
258
  /*!
260
259
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -283,7 +282,7 @@ function KK(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCode
283
282
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
284
283
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
285
284
  */
286
- let qK=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;var JK=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e,t,n){let r=!0,i=!0,a=`Z`,o;if(typeof e==`string`)if(t)prep:{if(t<3){if(+e.slice(11,13)>23){e=``;break prep}t===2?(a=null,e+=`Z`):(o=e.charCodeAt(e.length-1))!==90&&o!==122&&(a=e.slice(e.length-6)),n&&(e=e.slice(0,10)+`T`+e.slice(11))}else t===4&&(e=+e.slice(0,2)>23?``:`0000-01-01T${e}Z`);r=t!==4,i=t!==3}else{let t=e.match(qK);t?(t[1]||(r=!1,e=`0000-01-01T${e}`),i=!!t[2],i&&e[10]===` `&&(e=e.replace(` `,`T`)),t[2]&&+t[2]>23?e=``:(a=t[3]||null,!a&&i&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=r,this.#t=i,this.#n=a)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`||this.#n===`z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
285
+ let oq=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;var sq=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e,t,n){let r=!0,i=!0,a=`Z`,o;if(typeof e==`string`)if(t)prep:{if(t<3){if(+e.slice(11,13)>23){e=``;break prep}t===2?(a=null,e+=`Z`):(o=e.charCodeAt(e.length-1))!==90&&o!==122&&(a=e.slice(e.length-6)),n&&(e=e.slice(0,10)+`T`+e.slice(11))}else t===4&&(e=+e.slice(0,2)>23?``:`0000-01-01T${e}Z`);r=t!==4,i=t!==3}else{let t=e.match(oq);t?(t[1]||(r=!1,e=`0000-01-01T${e}`),i=!!t[2],i&&e[10]===` `&&(e=e.replace(` `,`T`)),t[2]&&+t[2]>23?e=``:(a=t[3]||null,!a&&i&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=r,this.#t=i,this.#n=a)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`||this.#n===`z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
287
286
  /*!
288
287
  * Copyright (c) Squirrel Chat et al., All rights reserved.
289
288
  * SPDX-License-Identifier: BSD-3-Clause
@@ -311,7 +310,7 @@ let qK=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[
311
310
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
312
311
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
313
312
  */
314
- function YK(e,t=10){return t===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+t}function XK(e,t){return e===32||e===9||e===10||e===13||t&&(e===t||e===44)||e===35}function ZK(e,t){let n=e.p,r=e.s.charCodeAt(e.p);if(r===91||r===123){e.d--||$.x(`document contains excessively nested structures. aborting.`,e);let t=r===91?cq(e):sq(e);return e.d++,t}return r===34||r===39?KK(e):r===116?((e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)&&$.x(`invalid value`,e,n),e.p++,!0):r===102?((e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)&&$.x(`invalid value`,e,n),e.p++,!1):r===43||r===45?QK(e,e.p,e.s.charCodeAt(++e.p),44-r,t):e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45?tq(e,r,t):e.s.charCodeAt(e.p+2)===58?nq(e,r,t):QK(e,e.p,r,0,t)}function QK(e,t,n,r,i){let a=n,o=0,s=!1;if(a===105)return(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)&&$.x(`invalid value`,e,t),e.p++,(r||1)/0;if(a===110)return(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)&&$.x(`invalid value`,e,t),e.p++,NaN;if(a===48){if(++e.p>=e.s.length||XK(a=e.s.charCodeAt(e.p),i))return e.bi===!0?0n:0;if(!r){if(a===120)return $K(e,t,16,i);if(a===98)return $K(e,t,2,i);if(a===111)return $K(e,t,8,i)}a===46?o=2:a===101||a===69?o=4:$.x(`illegal leading zero`,e,t)}else YK(a)||$.x(`invalid value`,e,t);for(;++e.p<e.s.length&&(a=e.s.charCodeAt(e.p),!XK(a,i));)o||=1,a===95?(o&1||$.x(`illegal underscore`,e),o+=11,s=!0):o===1&&a===46?o=2:(o===1||o===3)&&(a===101||a===69)?o=4:o===4&&(a===43||a===45)?o=6:YK(a)?o>9?o-=11:o&1||o++:$.x(`illegal character in numeric literal`,e);if(!o){let t=(n-48)*(r||1);return e.bi===!0?BigInt(t):t}o&1||$.x(`unfinished numeric value`,e,t);let c=e.s.slice(t,e.p);return s&&(c=c.replaceAll(`_`,``)),o>1?parseFloat(c):eq(e,c,10,t)}function $K(e,t,n,r){let i,a=1;for(;++e.p<e.s.length&&(i=e.s.charCodeAt(e.p),!XK(i,r));)i===95?(a&1&&$.x(`illegal underscore`,e),a=3):YK(i,n)?a&1&&a--:$.x(`illegal character in numeric literal`,e);a&1&&$.x(`unfinished numeric value`,e);let o=e.s.slice(t+2,e.p);return a&&(o=o.replaceAll(`_`,``)),eq(e,o,n,t)}function eq(e,t,n,r){if(e.bi!==!0)int:{let i=parseInt(t,n);if(!Number.isSafeInteger(i)){if(e.bi)break int;$.x(`integer value cannot be represented losslessly`,e,r)}return i}return BigInt(n===10?t:(n===2?`0b`:n===8?`0o`:`0x`)+t)}function tq(e,t,n){let r=e.p++,i;if(!YK(t)||!YK(e.s.charCodeAt(e.p++))||!YK(e.s.charCodeAt(e.p++))||!YK(e.s.charCodeAt(e.p++)))return QK(e,e.p=r,t,0,n);if(e.p+=5,YK(e.s.charCodeAt(e.p++))||$.x(`invalid date-time: date part is malformed`,e,r),e.p>=e.s.length||((t=e.s.charCodeAt(e.p))!==32||(i=!0,!YK(e.s.charCodeAt(e.p+1))))&&t!==84&&t!==116)return rq(e,e.s.slice(r,e.p),3,!1,r);if(e.s.charCodeAt(e.p+=3)!==58&&$.x(`invalid date-time: time part is malformed`,e,r),e.s.charCodeAt(e.p+=3)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;YK(e.s.charCodeAt(++e.p)););if(t=e.s.charCodeAt(e.p)){if(t===90||t===122)return rq(e,e.s.slice(r,++e.p),1,i,r,`[+00:00]`);if(t===43||t===45)return rq(e,e.s.slice(r,e.p+=6),1,i,r,!e.ld&&`[`+e.s.slice(e.p-6,e.p)+`]`)}return rq(e,e.s.slice(r,e.p),2,i,r)}function nq(e,t,n){let r=e.p;if(!YK(t)||!YK(e.s.charCodeAt(++e.p)))return QK(e,--e.p,t,0,n);if(e.s.charCodeAt(e.p+=4)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;YK(e.s.charCodeAt(++e.p)););return rq(e,e.s.slice(r,e.p),4,!1,r)}function rq(e,t,n,r,i,a){if(e.ld){let a=new JK(t,n,r);return a.isValid()||$.x(`invalid date`,e,i),a}try{switch(a&&(t+=a),n){case 1:return Temporal.ZonedDateTime.from(t);case 2:return Temporal.PlainDateTime.from(t);case 3:return Temporal.PlainDate.from(t);case 4:return Temporal.PlainTime.from(t)}}catch(t){$.x(t instanceof Error?t.message:``+t,e,i)}}
313
+ function cq(e,t=10){return t===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+t}function lq(e,t){return e===32||e===9||e===10||e===13||t&&(e===t||e===44)||e===35}function uq(e,t){let n=e.p,r=e.s.charCodeAt(e.p);if(r===91||r===123){e.d--||$.x(`document contains excessively nested structures. aborting.`,e);let t=r===91?xq(e):bq(e);return e.d++,t}return r===34||r===39?aq(e):r===116?((e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)&&$.x(`invalid value`,e,n),e.p++,!0):r===102?((e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)&&$.x(`invalid value`,e,n),e.p++,!1):r===43||r===45?dq(e,e.p,e.s.charCodeAt(++e.p),44-r,t):e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45?mq(e,r,t):e.s.charCodeAt(e.p+2)===58?hq(e,r,t):dq(e,e.p,r,0,t)}function dq(e,t,n,r,i){let a=n,o=0,s=!1;if(a===105)return(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)&&$.x(`invalid value`,e,t),e.p++,(r||1)/0;if(a===110)return(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)&&$.x(`invalid value`,e,t),e.p++,NaN;if(a===48){if(++e.p>=e.s.length||lq(a=e.s.charCodeAt(e.p),i))return e.bi===!0?0n:0;if(!r){if(a===120)return fq(e,t,16,i);if(a===98)return fq(e,t,2,i);if(a===111)return fq(e,t,8,i)}a===46?o=2:a===101||a===69?o=4:$.x(`illegal leading zero`,e,t)}else cq(a)||$.x(`invalid value`,e,t);for(;++e.p<e.s.length&&(a=e.s.charCodeAt(e.p),!lq(a,i));)o||=1,a===95?(o&1||$.x(`illegal underscore`,e),o+=11,s=!0):o===1&&a===46?o=2:(o===1||o===3)&&(a===101||a===69)?o=4:o===4&&(a===43||a===45)?o=6:cq(a)?o>9?o-=11:o&1||o++:$.x(`illegal character in numeric literal`,e);if(!o){let t=(n-48)*(r||1);return e.bi===!0?BigInt(t):t}o&1||$.x(`unfinished numeric value`,e,t);let c=e.s.slice(t,e.p);return s&&(c=c.replaceAll(`_`,``)),o>1?parseFloat(c):pq(e,c,10,t)}function fq(e,t,n,r){let i,a=1;for(;++e.p<e.s.length&&(i=e.s.charCodeAt(e.p),!lq(i,r));)i===95?(a&1&&$.x(`illegal underscore`,e),a=3):cq(i,n)?a&1&&a--:$.x(`illegal character in numeric literal`,e);a&1&&$.x(`unfinished numeric value`,e);let o=e.s.slice(t+2,e.p);return a&&(o=o.replaceAll(`_`,``)),pq(e,o,n,t)}function pq(e,t,n,r){if(e.bi!==!0)int:{let i=parseInt(t,n);if(!Number.isSafeInteger(i)){if(e.bi)break int;$.x(`integer value cannot be represented losslessly`,e,r)}return i}return BigInt(n===10?t:(n===2?`0b`:n===8?`0o`:`0x`)+t)}function mq(e,t,n){let r=e.p++,i;if(!cq(t)||!cq(e.s.charCodeAt(e.p++))||!cq(e.s.charCodeAt(e.p++))||!cq(e.s.charCodeAt(e.p++)))return dq(e,e.p=r,t,0,n);if(e.p+=5,cq(e.s.charCodeAt(e.p++))||$.x(`invalid date-time: date part is malformed`,e,r),e.p>=e.s.length||((t=e.s.charCodeAt(e.p))!==32||(i=!0,!cq(e.s.charCodeAt(e.p+1))))&&t!==84&&t!==116)return gq(e,e.s.slice(r,e.p),3,!1,r);if(e.s.charCodeAt(e.p+=3)!==58&&$.x(`invalid date-time: time part is malformed`,e,r),e.s.charCodeAt(e.p+=3)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;cq(e.s.charCodeAt(++e.p)););if(t=e.s.charCodeAt(e.p)){if(t===90||t===122)return gq(e,e.s.slice(r,++e.p),1,i,r,`[+00:00]`);if(t===43||t===45)return gq(e,e.s.slice(r,e.p+=6),1,i,r,!e.ld&&`[`+e.s.slice(e.p-6,e.p)+`]`)}return gq(e,e.s.slice(r,e.p),2,i,r)}function hq(e,t,n){let r=e.p;if(!cq(t)||!cq(e.s.charCodeAt(++e.p)))return dq(e,--e.p,t,0,n);if(e.s.charCodeAt(e.p+=4)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;cq(e.s.charCodeAt(++e.p)););return gq(e,e.s.slice(r,e.p),4,!1,r)}function gq(e,t,n,r,i,a){if(e.ld){let a=new sq(t,n,r);return a.isValid()||$.x(`invalid date`,e,i),a}try{switch(a&&(t+=a),n){case 1:return Temporal.ZonedDateTime.from(t);case 2:return Temporal.PlainDateTime.from(t);case 3:return Temporal.PlainDate.from(t);case 4:return Temporal.PlainTime.from(t)}}catch(t){$.x(t instanceof Error?t.message:``+t,e,i)}}
315
314
  /*!
316
315
  * Copyright (c) Squirrel Chat et al., All rights reserved.
317
316
  * SPDX-License-Identifier: BSD-3-Clause
@@ -339,7 +338,7 @@ function YK(e,t=10){return t===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48
339
338
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
340
339
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
341
340
  */
342
- function iq(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)break;if(t===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}(t<32&&t!==9||t===127)&&$.x(`control characters are not allowed in comments`,e)}}function aq(e,t,n){let r;for(;e.p<e.s.length;){for(;e.p<e.s.length&&((r=e.s.charCodeAt(e.p))===32||r===9||!t&&(r===10||r===13&&e.s.charCodeAt(e.p+1)===10));)e.p++;if(n||r!==35)break;iq(e)}}
341
+ function _q(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)break;if(t===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}(t<32&&t!==9||t===127)&&$.x(`control characters are not allowed in comments`,e)}}function vq(e,t,n){let r;for(;e.p<e.s.length;){for(;e.p<e.s.length&&((r=e.s.charCodeAt(e.p))===32||r===9||!t&&(r===10||r===13&&e.s.charCodeAt(e.p+1)===10));)e.p++;if(n||r!==35)break;_q(e)}}
343
342
  /*!
344
343
  * Copyright (c) Squirrel Chat et al., All rights reserved.
345
344
  * SPDX-License-Identifier: BSD-3-Clause
@@ -367,7 +366,7 @@ function iq(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)br
367
366
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
368
367
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
369
368
  */
370
- function oq(e,t=61){let n,r=0,i=[],a,o=e.s.charCodeAt(n=e.p);do if(o===t)return r||$.x(`unexpected end of key`,e),r===1&&i.push(e.s.slice(a,e.p)),e.p++,i;else o===46?(r||$.x(`illegal empty bare key`,e),r===1&&i.push(e.s.slice(a,e.p)),r=0):!r&&(o===34||o===39)?(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2)&&$.x(`illegal quoted key: multiline strings are not allowed`,e),i.push(KK(e)),r=2,e.p--):o===32||o===9?r===1&&(i.push(e.s.slice(a,e.p)),r=2):r===2||o<48&&o!==45||o>57&&o<65||o>90&&o<97&&o!==95||o>122?$.x(`illegal character in key`,e):r||(r=1,a=e.p);while(o=e.s.charCodeAt(++e.p));$.x(`incomplete key-value: cannot find end of key`,e,n)}function sq(e){let t=e.p++,n=Object.create(null),r=new Set,i;for(;e.p<e.s.length;){if(aq(e),(i=e.s.charCodeAt(e.p))===125)return e.p++,n;let t,a=n,o=!1,s=e.p,c=oq(e);for(let n=0;n<c.length;n++){n&&(a=o?a[t]:a[t]=Object.create(null)),t=c[n],(o=Object.hasOwn(a,t))&&(typeof a[t]!=`object`||r.has(a[t]))&&$.x(`trying to redefine an already defined value`,e,s);let i=t===`__proto__`;if(e.uk&&(i||t===`constructor`)){a=e.uk!==1&&$.x(`document contains an unsafe property`,e,s);break}!o&&i&&Object.defineProperty(a,t,{enumerable:!0,configurable:!0,writable:!0})}o&&$.x(`trying to redefine an already defined value`,e,s),aq(e,!0,!0);let l=ZK(e,125);if(a&&typeof(a[t]=l)==`object`&&r.add(l),aq(e),(i=e.s.charCodeAt(e.p++))===125)return n;i!==44&&$.x(`expected comma or end of structure`,e,e.p-1)}$.x(`unfinished table`,e,t)}function cq(e){let t=e.p++,n=[],r;for(;e.p<e.s.length;){if(aq(e),(r=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(ZK(e,93)),aq(e),(r=e.s.charCodeAt(e.p++))===93)return n;r!==44&&$.x(`expected comma or end of structure`,e,e.p-1)}$.x(`unfinished array`,e,t)}
369
+ function yq(e,t=61){let n,r=0,i=[],a,o=e.s.charCodeAt(n=e.p);do if(o===t)return r||$.x(`unexpected end of key`,e),r===1&&i.push(e.s.slice(a,e.p)),e.p++,i;else o===46?(r||$.x(`illegal empty bare key`,e),r===1&&i.push(e.s.slice(a,e.p)),r=0):!r&&(o===34||o===39)?(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2)&&$.x(`illegal quoted key: multiline strings are not allowed`,e),i.push(aq(e)),r=2,e.p--):o===32||o===9?r===1&&(i.push(e.s.slice(a,e.p)),r=2):r===2||o<48&&o!==45||o>57&&o<65||o>90&&o<97&&o!==95||o>122?$.x(`illegal character in key`,e):r||(r=1,a=e.p);while(o=e.s.charCodeAt(++e.p));$.x(`incomplete key-value: cannot find end of key`,e,n)}function bq(e){let t=e.p++,n=Object.create(null),r=new Set,i;for(;e.p<e.s.length;){if(vq(e),(i=e.s.charCodeAt(e.p))===125)return e.p++,n;let t,a=n,o=!1,s=e.p,c=yq(e);for(let n=0;n<c.length;n++){n&&(a=o?a[t]:a[t]=Object.create(null)),t=c[n],(o=Object.hasOwn(a,t))&&(typeof a[t]!=`object`||r.has(a[t]))&&$.x(`trying to redefine an already defined value`,e,s);let i=t===`__proto__`;if(e.uk&&(i||t===`constructor`)){a=e.uk!==1&&$.x(`document contains an unsafe property`,e,s);break}!o&&i&&Object.defineProperty(a,t,{enumerable:!0,configurable:!0,writable:!0})}o&&$.x(`trying to redefine an already defined value`,e,s),vq(e,!0,!0);let l=uq(e,125);if(a&&typeof(a[t]=l)==`object`&&r.add(l),vq(e),(i=e.s.charCodeAt(e.p++))===125)return n;i!==44&&$.x(`expected comma or end of structure`,e,e.p-1)}$.x(`unfinished table`,e,t)}function xq(e){let t=e.p++,n=[],r;for(;e.p<e.s.length;){if(vq(e),(r=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(uq(e,93)),vq(e),(r=e.s.charCodeAt(e.p++))===93)return n;r!==44&&$.x(`expected comma or end of structure`,e,e.p-1)}$.x(`unfinished array`,e,t)}
371
370
  /*!
372
371
  * Copyright (c) Squirrel Chat et al., All rights reserved.
373
372
  * SPDX-License-Identifier: BSD-3-Clause
@@ -395,7 +394,7 @@ function oq(e,t=61){let n,r=0,i=[],a,o=e.s.charCodeAt(n=e.p);do if(o===t)return
395
394
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
396
395
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
397
396
  */
398
- function lq(e,t,n,r,i){let a=n,o=r,s,c=!1,l;for(let n=0;n<t.length;n++){if(n){if(a=c?a[s]:a[s]=Object.create(null),o=(l=o[s]).c,i===0&&(l.t===1||l.t===2))return null;if(l.t===2){let e=a.length-1;a=a[e],o=o[e].c}}if(s=t[n],(c=Object.hasOwn(a,s))&&o[s]?.t===0&&o[s]?.d)return null;if(!c){let r=s===`__proto__`;if(e.uk&&(r||s===`constructor`))return!1;r&&(Object.defineProperty(a,s,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,s,{enumerable:!0,configurable:!0,writable:!0})),o[s]={t:n<t.length-1&&i===2?3:i,d:!1,i:0,c:Object.create(null)}}}if(l=o[s],l.t!==i&&!(i===1&&l.t===3)||(i===2&&(l.d||(l.d=!0,a[s]=[]),a[s].push(a=Object.create(null)),l.c[l.i++]=l={t:1,d:!1,i:0,c:Object.create(null)}),l.d))return null;if(l.d=!0,i===1)a=c?a[s]:a[s]=Object.create(null);else if(i===0&&c)return null;return[s,a,l.c]}function uq(e,t,n){(t===null||e.uk===2)&&$.x(t===null?`trying to redefine an already defined table or value`:`document contains an unsafe property`,e,n)}function dq(e,t={}){let n={s:e,p:0,d:t.maxDepth??1e3,bi:t.integersAsBigInt??!1,ld:t.useLegacyDate??!0,uk:t.unsafeKeyBehaviour===`throw`?2:+(t.unsafeKeyBehaviour===`drop`)},r=Object.create(null),i=Object.create(null),a,o=!1,s=r,c=i;for(e.charCodeAt(0)===65279&&n.p++,aq(n);n.p<e.length;){if(e.charCodeAt(n.p)===91){let t=e.charCodeAt(++n.p)===91;a=n.p+=+t,o=!1;let l=oq(n,93);t&&(e.charCodeAt(n.p)!==93&&$.x(`expected end of table array declaration`,n),n.p++);let u=lq(n,l,r,i,t?2:1);u?(c=u[2],s=u[1]):(uq(n,u,a),o=!0)}else{a=n.p;let e=lq(n,oq(n),s,c,0);!e&&!o&&uq(n,e,a),aq(n,!0,!0);let t=ZK(n,void 0);e&&!o&&(e[1][e[0]]=t)}aq(n,!0),n.p<e.length&&(a=e.charCodeAt(n.p))!==10&&(a!==13||e.charCodeAt(n.p+1)!==10)&&$.x(`each key-value declaration must be followed by an end-of-line`,n),aq(n)}return r}``.isWellFormed;
397
+ function Sq(e,t,n,r,i){let a=n,o=r,s,c=!1,l;for(let n=0;n<t.length;n++){if(n){if(a=c?a[s]:a[s]=Object.create(null),o=(l=o[s]).c,i===0&&(l.t===1||l.t===2))return null;if(l.t===2){let e=a.length-1;a=a[e],o=o[e].c}}if(s=t[n],(c=Object.hasOwn(a,s))&&o[s]?.t===0&&o[s]?.d)return null;if(!c){let r=s===`__proto__`;if(e.uk&&(r||s===`constructor`))return!1;r&&(Object.defineProperty(a,s,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,s,{enumerable:!0,configurable:!0,writable:!0})),o[s]={t:n<t.length-1&&i===2?3:i,d:!1,i:0,c:Object.create(null)}}}if(l=o[s],l.t!==i&&!(i===1&&l.t===3)||(i===2&&(l.d||(l.d=!0,a[s]=[]),a[s].push(a=Object.create(null)),l.c[l.i++]=l={t:1,d:!1,i:0,c:Object.create(null)}),l.d))return null;if(l.d=!0,i===1)a=c?a[s]:a[s]=Object.create(null);else if(i===0&&c)return null;return[s,a,l.c]}function Cq(e,t,n){(t===null||e.uk===2)&&$.x(t===null?`trying to redefine an already defined table or value`:`document contains an unsafe property`,e,n)}function wq(e,t={}){let n={s:e,p:0,d:t.maxDepth??1e3,bi:t.integersAsBigInt??!1,ld:t.useLegacyDate??!0,uk:t.unsafeKeyBehaviour===`throw`?2:+(t.unsafeKeyBehaviour===`drop`)},r=Object.create(null),i=Object.create(null),a,o=!1,s=r,c=i;for(e.charCodeAt(0)===65279&&n.p++,vq(n);n.p<e.length;){if(e.charCodeAt(n.p)===91){let t=e.charCodeAt(++n.p)===91;a=n.p+=+t,o=!1;let l=yq(n,93);t&&(e.charCodeAt(n.p)!==93&&$.x(`expected end of table array declaration`,n),n.p++);let u=Sq(n,l,r,i,t?2:1);u?(c=u[2],s=u[1]):(Cq(n,u,a),o=!0)}else{a=n.p;let e=Sq(n,yq(n),s,c,0);!e&&!o&&Cq(n,e,a),vq(n,!0,!0);let t=uq(n,void 0);e&&!o&&(e[1][e[0]]=t)}vq(n,!0),n.p<e.length&&(a=e.charCodeAt(n.p))!==10&&(a!==13||e.charCodeAt(n.p+1)!==10)&&$.x(`each key-value declaration must be followed by an end-of-line`,n),vq(n)}return r}``.isWellFormed;
399
398
  /*!
400
399
  * Copyright (c) Squirrel Chat et al., All rights reserved.
401
400
  * SPDX-License-Identifier: BSD-3-Clause
@@ -423,7 +422,7 @@ function lq(e,t,n,r,i){let a=n,o=r,s,c=!1,l;for(let n=0;n<t.length;n++){if(n){if
423
422
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
424
423
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
425
424
  */
426
- const fq=e=>e.codePointAt(0).toString(16).toUpperCase(),pq=String.raw`
425
+ const Tq=e=>e.codePointAt(0).toString(16).toUpperCase(),Eq=String.raw`
427
426
  ObjC.import("AppKit");
428
427
  ObjC.import("CoreText");
429
428
  function lacksOf(font, points) {
@@ -470,45 +469,44 @@ function run(argv) {
470
469
  : iterm(argv[1], points),
471
470
  );
472
471
  }
473
- `;function mq(e){let t=Re({bin:`osascript`,args:[`-l`,`JavaScript`,`-e`,pq,...e],timeoutMs:3e3,category:`doctor.font`});if(!t.ok){if(t.reason===`rate-limited`)throw new VK(`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 hq=e=>e.map(e=>String.fromCodePoint(parseInt(e,16))),gq=e=>[...e].map(fq).join(`,`);function _q(e,t){let n=mq([`font`,e.kind,e.name,gq(t)]);if(n.kind===`failed`)return n;let{lacks:r}=n.value;return{kind:`ok`,value:{font:e.name,lacks:r===null?null:hq(r)}}}function vq(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=>!Hk(t,e));return{kind:`ok`,value:{font:e.font,from:n,lacks:r}}}const yq=e=>e.kind===`ok`&&e.value.lacks!==null&&e.value.lacks.length===0;function bq(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=>vq(e,n));if(t!==null)return r[0];let i=r.find(e=>!yq(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 xq(e,t,n){if(process.platform!==`darwin`)return{kind:`failed`,reason:`iTerm2 runs only on macOS`};let r=t.ITERM_PROFILE??null,i=mq([`iterm`,r??``,gq(n)]);return i.kind===`failed`?i:bq(i.value.profiles.map(e=>({...e,lacks:e.lacks===null?null:hq(e.lacks)})),r,e)}function Sq(e,t){let n=e.split(`
474
- `).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 Cq=e=>e.replace(/[\\:,=-]/g,`\\$&`);function wq(e,t){let n=Re({bin:`fc-match`,args:[`--sort`,`--format`,`%{family[0]} %{charset}
475
- `,`:family=${Cq(e)}`],timeoutMs:3e3,category:`doctor.font`});if(!n.ok){if(n.reason===`rate-limited`)throw new VK(`the font`);return{kind:`failed`,reason:`fc-match failed (${n.error??`${n.reason}: ${n.stderr.trim()}`})`}}return Sq(n.stdout,t)}function Tq(e,t){return process.platform===`darwin`?_q(e,t):wq(e.name,t)}function Eq(e,t){let n=t||v.join(e,`.config`);return[v.join(n,`alacritty`,`alacritty.toml`),v.join(n,`alacritty.toml`),v.join(e,`.config`,`alacritty`,`alacritty.toml`),v.join(e,`.alacritty.toml`)]}function Dq(e){return e===`darwin`?`Menlo`:`monospace`}const Oq=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function kq(e){let t=Oq(e.font)?e.font:{},n=Oq(t.normal)?t.normal:{},r=(Oq(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 Aq(e,t,n){let r;try{r=s.readFileSync(e,`utf8`)}catch(t){return{kind:`failed`,reason:`cannot read ${e}: ${t.message}`}}let i;try{i=dq(r)}catch(t){return{kind:`failed`,reason:`cannot parse ${e}: ${t.message}`}}let a=kq(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(`~/`)?v.join(t,r.slice(2)):v.resolve(v.dirname(e),r);if(!s.existsSync(i))continue;let a=Aq(i,t,n+1);if(a.kind===`failed`)return a;o=a.value??o}return{kind:`ok`,value:o}}function jq(e,t){let n=w.homedir(),r=Eq(n,e.XDG_CONFIG_HOME).find(e=>s.existsSync(e)),i=r===void 0?{kind:`ok`,value:null}:Aq(r,n,0);if(i.kind===`failed`)return i;let a=i.value?.family??Dq(process.platform),o=i.value?.from??(r===void 0?`Alacritty's default, no config file`:`Alacritty's default, ${r} sets none`),c=Tq({kind:`family`,name:a},t);if(c.kind===`failed`)return c;let{font:l,lacks:u}=c.value;return{kind:`ok`,value:{font:l,from:l===a?o:`${o}; ${a} as fontconfig matches it`,lacks:u}}}const Mq={iterm2:xq,alacritty:(e,t,n)=>jq(t,n)};function Nq(e,t,n){return Mq[e.name](e.version,t,n)}function Pq(e,t){let n;try{n=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${t} is not JSON: ${e.message}`}}return Array.isArray(n)&&n.every(e=>typeof e==`string`)?{kind:`ok`,value:n}:{kind:`failed`,reason:`${t} is not a list of terminals`}}function Fq(e=v.join(Ue(),`doctor-clicked-terminals.json`)){let t=()=>{let t;try{t=s.readFileSync(e,`utf8`)}catch(t){return t.code===`ENOENT`?{kind:`ok`,value:[]}:{kind:`failed`,reason:`${e}: ${t.message}`}}return Pq(t,e)};return{read:t,record:n=>{let r=t();if(r.kind===`failed`)throw Error(`doctor: the clicked terminals could not be read: ${r.reason}`);r.value.includes(n)||(s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,`${JSON.stringify([...r.value,n],null,2)}\n`))}}}function Iq(e,t){let n;try{n=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${t} is not JSON: ${e.message}`}}let r=n?.through;return typeof r==`string`?{kind:`ok`,value:r}:{kind:`failed`,reason:`${t} names no post-mortem read`}}function Lq(e=v.join(Ue(),`doctor-post-mortems-read.json`)){return{read:()=>{let t;try{t=s.readFileSync(e,`utf8`)}catch(t){return t.code===`ENOENT`?{kind:`ok`,value:null}:{kind:`failed`,reason:`${e}: ${t.message}`}}return Iq(t,e)},record:t=>{s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,`${JSON.stringify({through:t},null,2)}\n`)}}}function Rq(e){try{return{kind:`ok`,value:e()}}catch(e){return{kind:`failed`,reason:e instanceof Error?e.message:String(e)}}}const zq={realpath:e=>Rq(()=>s.realpathSync(e)),checkoutOf:Mg,digest:e=>Rq(()=>Ag(e)),nativeShipped:zi(process.platform,process.arch)};function Bq(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(v.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})}}}function Vq(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 Hq=/^(sshd|mosh-server)\b/;function Uq(e,t){let n=new Map;for(let t of e.split(`
476
- `)){let e=/^\s*(\d+)\s+(\d+)\s+(.*)$/.exec(t);if(e===null)continue;let r=e[3].trim();n.set(Number(e[1]),{ppid:Number(e[2]),name:r.slice(r.lastIndexOf(`/`)+1)})}if(!n.has(t))return{kind:`failed`,reason:`process ${t} is not running`};let r=new Set;for(let e=n.get(t);e!==void 0;e=n.get(e.ppid)){if(Hq.test(e.name))return{kind:`ok`,value:!0};if(r.has(e.ppid))break;r.add(e.ppid)}return{kind:`ok`,value:!1}}function Wq(e){let t=Re({bin:`ps`,args:[`-A`,`-o`,`pid=,ppid=,comm=`],timeoutMs:2e3,category:`doctor.process`});if(!t.ok){if(t.reason===`rate-limited`)throw new VK(`the processes`);return{kind:`failed`,reason:`ps failed (${t.error??`${t.reason}: ${t.stderr.trim()}`})`}}return Uq(t.stdout,e)}const Gq=/^(.*)\/(?:dist\/index\.mjs|src\/index\.ts|bin\/cc-candybar)$/;function Kq(e,t){let n=[];for(let r of e.split(`
477
- `)){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 qq(e){let t;try{t=s.realpathSync(e)}catch{return!1}let n=Gq.exec(t)?.[1];return n!==void 0&&s.existsSync(v.join(n,`bin`,`cc-candybar`))}function Jq(){let e=Re({bin:`ps`,args:[`-U`,String(w.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:Kq(e.stdout,qq)}:{kind:`failed`,reason:`ps failed (${e.error??`${e.reason}: ${e.stderr.trim()}`})`}}function Yq(e){let t=cH(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 VK(`tmux`);return t.kind===`failed`?{kind:`failed`,reason:t.reason}:Vq(t.stdout)}function Xq(e){return{probeTmux:Yq,remoteLogin:Wq,fontInUse:Nq,loadConfig:e,marks:BK(),clicked:Fq(),install:zq,daemons:Jq,postMortemsRead:Lq(),forge:tJ,memento:Oz,transcript:Qq}}function Zq(e,t){let n=e.toString(`utf-8`),r=t?0:n.indexOf(`
472
+ `;function Dq(e){let t=Re({bin:`osascript`,args:[`-l`,`JavaScript`,`-e`,Eq,...e],timeoutMs:3e3,category:`doctor.font`});if(!t.ok){if(t.reason===`rate-limited`)throw new eq(`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 Oq=e=>e.map(e=>String.fromCodePoint(parseInt(e,16))),kq=e=>[...e].map(Tq).join(`,`);function Aq(e,t){let n=Dq([`font`,e.kind,e.name,kq(t)]);if(n.kind===`failed`)return n;let{lacks:r}=n.value;return{kind:`ok`,value:{font:e.name,lacks:r===null?null:Oq(r)}}}function jq(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=>!Hk(t,e));return{kind:`ok`,value:{font:e.font,from:n,lacks:r}}}const Mq=e=>e.kind===`ok`&&e.value.lacks!==null&&e.value.lacks.length===0;function Nq(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=>jq(e,n));if(t!==null)return r[0];let i=r.find(e=>!Mq(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 Pq(e,t,n){if(process.platform!==`darwin`)return{kind:`failed`,reason:`iTerm2 runs only on macOS`};let r=t.ITERM_PROFILE??null,i=Dq([`iterm`,r??``,kq(n)]);return i.kind===`failed`?i:Nq(i.value.profiles.map(e=>({...e,lacks:e.lacks===null?null:Oq(e.lacks)})),r,e)}function Fq(e,t){let n=e.split(`
473
+ `).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 Iq=e=>e.replace(/[\\:,=-]/g,`\\$&`);function Lq(e,t){let n=Re({bin:`fc-match`,args:[`--sort`,`--format`,`%{family[0]} %{charset}
474
+ `,`:family=${Iq(e)}`],timeoutMs:3e3,category:`doctor.font`});if(!n.ok){if(n.reason===`rate-limited`)throw new eq(`the font`);return{kind:`failed`,reason:`fc-match failed (${n.error??`${n.reason}: ${n.stderr.trim()}`})`}}return Fq(n.stdout,t)}function Rq(e,t){return process.platform===`darwin`?Aq(e,t):Lq(e.name,t)}function zq(e,t){let n=t||v.join(e,`.config`);return[v.join(n,`alacritty`,`alacritty.toml`),v.join(n,`alacritty.toml`),v.join(e,`.config`,`alacritty`,`alacritty.toml`),v.join(e,`.alacritty.toml`)]}function Bq(e){return e===`darwin`?`Menlo`:`monospace`}const Vq=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Hq(e){let t=Vq(e.font)?e.font:{},n=Vq(t.normal)?t.normal:{},r=(Vq(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 Uq(e,t,n){let r;try{r=s.readFileSync(e,`utf8`)}catch(t){return{kind:`failed`,reason:`cannot read ${e}: ${t.message}`}}let i;try{i=wq(r)}catch(t){return{kind:`failed`,reason:`cannot parse ${e}: ${t.message}`}}let a=Hq(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(`~/`)?v.join(t,r.slice(2)):v.resolve(v.dirname(e),r);if(!s.existsSync(i))continue;let a=Uq(i,t,n+1);if(a.kind===`failed`)return a;o=a.value??o}return{kind:`ok`,value:o}}function Wq(e,t){let n=w.homedir(),r=zq(n,e.XDG_CONFIG_HOME).find(e=>s.existsSync(e)),i=r===void 0?{kind:`ok`,value:null}:Uq(r,n,0);if(i.kind===`failed`)return i;let a=i.value?.family??Bq(process.platform),o=i.value?.from??(r===void 0?`Alacritty's default, no config file`:`Alacritty's default, ${r} sets none`),c=Rq({kind:`family`,name:a},t);if(c.kind===`failed`)return c;let{font:l,lacks:u}=c.value;return{kind:`ok`,value:{font:l,from:l===a?o:`${o}; ${a} as fontconfig matches it`,lacks:u}}}const Gq={iterm2:Pq,alacritty:(e,t,n)=>Wq(t,n)};function Kq(e,t,n){return Gq[e.name](e.version,t,n)}function qq(e,t){let n;try{n=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${t} is not JSON: ${e.message}`}}return Array.isArray(n)&&n.every(e=>typeof e==`string`)?{kind:`ok`,value:n}:{kind:`failed`,reason:`${t} is not a list of terminals`}}function Jq(e=v.join(Ue(),`doctor-clicked-terminals.json`)){let t=()=>{let t;try{t=s.readFileSync(e,`utf8`)}catch(t){return t.code===`ENOENT`?{kind:`ok`,value:[]}:{kind:`failed`,reason:`${e}: ${t.message}`}}return qq(t,e)};return{read:t,record:n=>{let r=t();if(r.kind===`failed`)throw Error(`doctor: the clicked terminals could not be read: ${r.reason}`);r.value.includes(n)||(s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,`${JSON.stringify([...r.value,n],null,2)}\n`))}}}function Yq(e,t){let n;try{n=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${t} is not JSON: ${e.message}`}}let r=n?.through;return typeof r==`string`?{kind:`ok`,value:r}:{kind:`failed`,reason:`${t} names no post-mortem read`}}function Xq(e=v.join(Ue(),`doctor-post-mortems-read.json`)){return{read:()=>{let t;try{t=s.readFileSync(e,`utf8`)}catch(t){return t.code===`ENOENT`?{kind:`ok`,value:null}:{kind:`failed`,reason:`${e}: ${t.message}`}}return Yq(t,e)},record:t=>{s.mkdirSync(v.dirname(e),{recursive:!0}),Ve(e,`${JSON.stringify({through:t},null,2)}\n`)}}}function Zq(e){try{return{kind:`ok`,value:e()}}catch(e){return{kind:`failed`,reason:e instanceof Error?e.message:String(e)}}}const Qq={realpath:e=>Zq(()=>s.realpathSync(e)),checkoutOf:Mg,digest:e=>Zq(()=>Ag(e)),nativeShipped:zi(process.platform,process.arch)};function $q(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(v.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})}}}function eJ(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 tJ=/^(sshd|mosh-server)\b/;function nJ(e,t){let n=new Map;for(let t of e.split(`
475
+ `)){let e=/^\s*(\d+)\s+(\d+)\s+(.*)$/.exec(t);if(e===null)continue;let r=e[3].trim();n.set(Number(e[1]),{ppid:Number(e[2]),name:r.slice(r.lastIndexOf(`/`)+1)})}if(!n.has(t))return{kind:`failed`,reason:`process ${t} is not running`};let r=new Set;for(let e=n.get(t);e!==void 0;e=n.get(e.ppid)){if(tJ.test(e.name))return{kind:`ok`,value:!0};if(r.has(e.ppid))break;r.add(e.ppid)}return{kind:`ok`,value:!1}}function rJ(e){let t=Re({bin:`ps`,args:[`-A`,`-o`,`pid=,ppid=,comm=`],timeoutMs:2e3,category:`doctor.process`});if(!t.ok){if(t.reason===`rate-limited`)throw new eq(`the processes`);return{kind:`failed`,reason:`ps failed (${t.error??`${t.reason}: ${t.stderr.trim()}`})`}}return nJ(t.stdout,e)}const iJ=/^(.*)\/(?:dist\/index\.mjs|src\/index\.ts|bin\/cc-candybar)$/;function aJ(e,t){let n=[];for(let r of e.split(`
476
+ `)){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 oJ(e){let t;try{t=s.realpathSync(e)}catch{return!1}let n=iJ.exec(t)?.[1];return n!==void 0&&s.existsSync(v.join(n,`bin`,`cc-candybar`))}function sJ(){let e=Re({bin:`ps`,args:[`-U`,String(w.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:aJ(e.stdout,oJ)}:{kind:`failed`,reason:`ps failed (${e.error??`${e.reason}: ${e.stderr.trim()}`})`}}function cJ(e){let t=xH(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 eq(`tmux`);return t.kind===`failed`?{kind:`failed`,reason:t.reason}:eJ(t.stdout)}function lJ(e){return{probeTmux:cJ,remoteLogin:rJ,fontInUse:Kq,loadConfig:e,marks:$K(),clicked:Jq(),install:Qq,daemons:sJ,postMortemsRead:Xq(),forge:mJ,memento:Oz,transcript:dJ}}function uJ(e,t){let n=e.toString(`utf-8`),r=t?0:n.indexOf(`
478
477
  `)+1,i=n.lastIndexOf(`
479
478
  `)+1,a=0,o=0;for(let e of n.slice(r,i).split(`
480
- `)){let t=kV(e);t.kind!==`blank`&&(a++,t.kind===`unparsed`&&o++)}return{lines:a,unparsed:o,whole:t}}function Qq(e){let t=dz(e,tA+1);return t.kind===`ok`?L(Zq(t.value.buf,t.value.fromStart)):t}function $q(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 eJ={github:{loginHost:()=>`github.com`,args:e=>[`auth`,`token`,`--hostname`,e],nonZero:`logged-out`},gitlab:{loginHost:e=>e,args:()=>[`--version`],nonZero:`failed`}};function tJ(e){if(TT(e)===void 0)return{kind:`ok`,value:null};let t=WT(Re({bin:`git`,args:[...UT],cwd:e,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:2e3,category:`doctor.forge`}));if(t.kind===`failed`)return t;let n=YT(t.value);if(n===null)return{kind:`ok`,value:null};let r=HT(n);if(r===null)return{kind:`ok`,value:null};let i=LT[r],a=eJ[r],o=a.loginHost(VT(n)),s=Re({bin:i,args:[...a.args(o)],cwd:e,timeoutMs:2e3,category:`doctor.forge`});return nJ(i,o,a.nonZero,s)}function nJ(e,t,n,r){let i=n=>({kind:`ok`,value:{cli:e,host:t,status:n}});return r.ok?i(`ready`):RT(r)?i(`missing`):r.reason===`non-zero`&&n===`logged-out`?i({loggedOut:PT(r.stderr)}):{kind:`failed`,reason:NT(e,r)}}function rJ(e){let t={layers:e.layers,warnings:e.warning===null?[]:e.warning.split(`
481
- `)};return e.error===null?{...t,kind:`loaded`,unused:e.unused}:{...t,kind:`failed`,error:e.error}}function iJ(e){let{env:t,statusLine:n}=Ei(e);if(t!==void 0&&!Di(t))throw Error(`cannot read ${e}: \`env\` is not an object`);return{path:e,env:t??{},statusLine:n===void 0?{kind:`absent`}:Di(n)?{kind:`present`,refreshInterval:n.refreshInterval}:{kind:`not-an-object`,value:n}}}function aJ(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,client:e.probeTmux(t)}}function oJ(e,t){switch(e.kind){case`unreported`:return{kind:`unreported`};case`outside`:return t===void 0?{kind:`unreported`}:{kind:`seen`,identified:Yk(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:Jk(t),tmuxClient:t}}}}function sJ(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(Rk(s))return{kind:`bundling`,name:s,version:c};if(!zk(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 cJ(e){return{kind:`arrived`,handler:e,bar:Ft}}function lJ(e,t){let[n,...r]=e;return n===void 0?{kind:`unneeded`}:{kind:`needed`,segments:[n,...r],fact:t()}}function uJ(e,t,n,r,i){return{pullRequests:lJ(t.pullRequests,()=>e.forge(n.cwd)),rateLimits:lJ(t.rateLimits,()=>i),memento:lJ(t.memento,()=>({located:e.memento(r,n.projectDir),claudeConfigDir:r}))}}function dJ(e,t,n,r,i,a,o,s){let c=e.loadConfig(n),l=jz(c.config,r,()=>!1),u=aJ(e,t.tmux),d=oJ(u,t.terminalEnv),f=[...new Set([...lg(l),...cg(JSON.stringify(c.config))])].join(``);return{tmux:u,termCols:t.termCols??null,terminal:d,nerdFont:f===``?{kind:`none`}:{kind:`glyphs`,glyphs:f,terminal:sJ(e,d,t,f)},marks:e.marks.read(),clicked:e.clicked.read(),daemon:{serving:i,processes:e.daemons(),read:e.postMortemsRead.read()},config:rJ(c),frames:s,data:uJ(e,UK(c.config,l.preset),n,Si(t.claudeConfigDir),a),transcripts:$q(e,o),claudeSettings:iJ(Ci(Si(t.claudeConfigDir)))}}function fJ(e,t,n){let r=n.claudeSettings.path;switch(t.kind){case`claude-settings`:{let e=si(Ti(r),t.path,JSON.stringify(t.value),Kr);return s.mkdirSync(v.dirname(r),{recursive:!0}),Ve(r,e),{...n,claudeSettings:iJ(r)}}case`post-mortems-read`:return e.postMortemsRead.record(t.through),{...n,daemon:{...n.daemon,read:e.postMortemsRead.read()}};default:return t}}const pJ={connectMs:200,budgetMs:500};async function mJ(e){let n=e.includes(`--json`),r=await hJ();r.kind!==`ok`&&(t.stderr.write(`daemon-stats: ${Pt(r)}\n`),t.exit(1)),n&&t.stdout.write(JSON.stringify(r.value,null,2)+`
482
- `);let i=gJ(r.value);if(i!==null){t.stderr.write(`daemon-stats: ${i}\n`),t.exitCode=1;return}n||t.stdout.write(wJ(r.value))}function hJ(){return Ot({kind:`stats`},pJ,e=>`stats`in e?e.stats:void 0)}function gJ(e,t=_J){let n=JW.referenceSnapshot(),r=vJ(Object.fromEntries(t.map(e=>[e,n[e]])),e);if(r.length===0)return null;let i=bJ(e.version,e.sourceDigest??null),a=bJ(Ft,Pg());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 _J=Object.keys(JW.referenceSnapshot());function vJ(e,t,n=``){if(Array.isArray(e))return Array.isArray(t)?[]:[n||`<snapshot>`];if(!yJ(e))return[];if(!yJ(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(...vJ(e[i],t[i],a)):r.push(a)}return r}function yJ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bJ(e,t){return`${e} [${t===null?`no digest`:jg(t)}]`}function xJ(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function SJ(e,t){let n=e+t;return n===0?`n/a`:`${(e/n*100).toFixed(1)}%`}function CJ(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 wJ(e){let t=[];t.push(`cc-candybar daemon stats`),t.push(``),t.push(`process`),t.push(` pid ${e.pid}`),t.push(` build ${bJ(e.version,e.sourceDigest)}`),t.push(` protocol ${e.protocolVersion}`),t.push(` startedAt ${e.startedAt}`),t.push(` uptime ${CJ(e.uptimeSec)}`),t.push(` rss ${xJ(e.rssBytes)}`),t.push(` heapUsed ${xJ(e.heapUsedBytes)}`),t.push(` heapTotal ${xJ(e.heapTotalBytes)}`),t.push(` external ${xJ(e.externalBytes)}`),t.push(` arrayBuffers ${xJ(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(` hit rate ${SJ(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 ${SJ(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(`renderCache`),t.push(` size ${e.renderCache.size}`),t.push(` held ${e.renderCache.held}`),t.push(` retired ${e.renderCache.retired}`),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(` evicted ${e.watchers.evicted}`),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(`
479
+ `)){let t=HV(e);t.kind!==`blank`&&(a++,t.kind===`unparsed`&&o++)}return{lines:a,unparsed:o,whole:t}}function dJ(e){let t=dz(e,tA+1);return t.kind===`ok`?L(uJ(t.value.buf,t.value.fromStart)):t}function fJ(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 pJ={github:{loginHost:()=>`github.com`,args:e=>[`auth`,`token`,`--hostname`,e],nonZero:`logged-out`},gitlab:{loginHost:e=>e,args:()=>[`--version`],nonZero:`failed`}};function mJ(e){if(TT(e)===void 0)return{kind:`ok`,value:null};let t=WT(Re({bin:`git`,args:[...UT],cwd:e,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:2e3,category:`doctor.forge`}));if(t.kind===`failed`)return t;let n=YT(t.value);if(n===null)return{kind:`ok`,value:null};let r=HT(n);if(r===null)return{kind:`ok`,value:null};let i=LT[r],a=pJ[r],o=a.loginHost(VT(n)),s=Re({bin:i,args:[...a.args(o)],cwd:e,timeoutMs:2e3,category:`doctor.forge`});return hJ(i,o,a.nonZero,s)}function hJ(e,t,n,r){let i=n=>({kind:`ok`,value:{cli:e,host:t,status:n}});return r.ok?i(`ready`):RT(r)?i(`missing`):r.reason===`non-zero`&&n===`logged-out`?i({loggedOut:PT(r.stderr)}):{kind:`failed`,reason:NT(e,r)}}function gJ(e){let t={layers:e.layers,warnings:e.warning===null?[]:e.warning.split(`
480
+ `)};return e.error===null?{...t,kind:`loaded`,unused:e.unused}:{...t,kind:`failed`,error:e.error}}function _J(e){let{env:t,statusLine:n}=Ei(e);if(t!==void 0&&!Di(t))throw Error(`cannot read ${e}: \`env\` is not an object`);return{path:e,env:t??{},statusLine:n===void 0?{kind:`absent`}:Di(n)?{kind:`present`,refreshInterval:n.refreshInterval}:{kind:`not-an-object`,value:n}}}function vJ(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,client:e.probeTmux(t)}}function yJ(e,t){switch(e.kind){case`unreported`:return{kind:`unreported`};case`outside`:return t===void 0?{kind:`unreported`}:{kind:`seen`,identified:Yk(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:Jk(t),tmuxClient:t}}}}function bJ(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(Rk(s))return{kind:`bundling`,name:s,version:c};if(!zk(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 xJ(e){return{kind:`arrived`,handler:e,bar:Ft}}function SJ(e,t){let[n,...r]=e;return n===void 0?{kind:`unneeded`}:{kind:`needed`,segments:[n,...r],fact:t()}}function CJ(e,t,n,r,i){return{pullRequests:SJ(t.pullRequests,()=>e.forge(n.cwd)),rateLimits:SJ(t.rateLimits,()=>i),memento:SJ(t.memento,()=>({located:e.memento(r,n.projectDir),claudeConfigDir:r}))}}function wJ(e,t,n,r,i,a,o,s){let c=e.loadConfig(n),l=jz(c.config,r,()=>!1),u=vJ(e,t.tmux),d=yJ(u,t.terminalEnv),f=[...new Set([...lg(l),...cg(JSON.stringify(c.config))])].join(``);return{tmux:u,termCols:t.termCols??null,terminal:d,nerdFont:f===``?{kind:`none`}:{kind:`glyphs`,glyphs:f,terminal:bJ(e,d,t,f)},marks:e.marks.read(),clicked:e.clicked.read(),daemon:{serving:i,processes:e.daemons(),read:e.postMortemsRead.read()},config:gJ(c),frames:s,data:CJ(e,nq(c.config,l.preset),n,Si(t.claudeConfigDir),a),transcripts:fJ(e,o),claudeSettings:_J(Ci(Si(t.claudeConfigDir)))}}function TJ(e,t,n){let r=n.claudeSettings.path;switch(t.kind){case`claude-settings`:{let e=si(Ti(r),t.path,JSON.stringify(t.value),Kr);return s.mkdirSync(v.dirname(r),{recursive:!0}),Ve(r,e),{...n,claudeSettings:_J(r)}}case`post-mortems-read`:return e.postMortemsRead.record(t.through),{...n,daemon:{...n.daemon,read:e.postMortemsRead.read()}};default:return t}}const EJ={connectMs:200,budgetMs:500};async function DJ(e){let n=e.includes(`--json`),r=await OJ();r.kind!==`ok`&&(t.stderr.write(`daemon-stats: ${Pt(r)}\n`),t.exit(1)),n&&t.stdout.write(JSON.stringify(r.value,null,2)+`
481
+ `);let i=kJ(r.value);if(i!==null){t.stderr.write(`daemon-stats: ${i}\n`),t.exitCode=1;return}n||t.stdout.write(LJ(r.value))}function OJ(){return Ot({kind:`stats`},EJ,e=>`stats`in e?e.stats:void 0)}function kJ(e,t=AJ){let n=sG.referenceSnapshot(),r=jJ(Object.fromEntries(t.map(e=>[e,n[e]])),e);if(r.length===0)return null;let i=NJ(e.version,e.sourceDigest??null),a=NJ(Ft,Pg());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 AJ=Object.keys(sG.referenceSnapshot());function jJ(e,t,n=``){if(Array.isArray(e))return Array.isArray(t)?[]:[n||`<snapshot>`];if(!MJ(e))return[];if(!MJ(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(...jJ(e[i],t[i],a)):r.push(a)}return r}function MJ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function NJ(e,t){return`${e} [${t===null?`no digest`:jg(t)}]`}function PJ(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function FJ(e,t){let n=e+t;return n===0?`n/a`:`${(e/n*100).toFixed(1)}%`}function IJ(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 LJ(e){let t=[];t.push(`cc-candybar daemon stats`),t.push(``),t.push(`process`),t.push(` pid ${e.pid}`),t.push(` build ${NJ(e.version,e.sourceDigest)}`),t.push(` protocol ${e.protocolVersion}`),t.push(` startedAt ${e.startedAt}`),t.push(` uptime ${IJ(e.uptimeSec)}`),t.push(` rss ${PJ(e.rssBytes)}`),t.push(` heapUsed ${PJ(e.heapUsedBytes)}`),t.push(` heapTotal ${PJ(e.heapTotalBytes)}`),t.push(` external ${PJ(e.externalBytes)}`),t.push(` arrayBuffers ${PJ(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(` hit rate ${FJ(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 ${FJ(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(`renderCache`),t.push(` size ${e.renderCache.size}`),t.push(` held ${e.renderCache.held}`),t.push(` retired ${e.renderCache.retired}`),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(` evicted ${e.watchers.evicted}`),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(`
483
482
  `)+`
484
- `}const TJ=e=>({kind:`ok`,value:e}),EJ=e=>({kind:`failed`,reason:e});var DJ=class{arrivals=[];arrive(e){this.arrivals=[...this.arrivals,e].slice(-16)}list(){return this.arrivals}};const OJ=/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;function kJ(e){return OJ.test(e)?e:null}function AJ(e){let t=e.opener();if(t.kind===`failed`)return t;if(t.value===null)return TJ(null);let n=t.value,r=e.script(n);if(r.kind===`failed`)return TJ({app:n,missing:EJ(`its script could not be read (${r.reason})`)});let i=Yi(r.value);return TJ({app:n,missing:i===null?EJ("its script is not one `cc-candybar install` wrote"):TJ([i.node,i.script].filter(t=>!e.exists(t)))})}async function jJ(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 MJ(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(`${kn}://${er}/${n}`);return(r===null?await jJ(e,n):null)??{kind:`lost`,unopened:r,opener:AJ(e)}}function NJ(e,t,n){let r=Re({bin:t,args:[...n],category:e,timeoutMs:5e3});return r.ok?TJ(r.stdout):EJ(r.stderr.trim()||r.error||r.reason)}const PJ=`ObjC.import("AppKit");var u = $.NSWorkspace.sharedWorkspace.URLForApplicationToOpenURL($.NSURL.URLWithString("${kn}://probe"));u.isNil() ? "" : u.path.js`;async function FJ(){let e=await hJ();if(e.kind!==`ok`)return EJ(Pt(e).split(`
485
- `).join(` — `));let t=gJ(e.value,[`handlerProbes`]);if(t!==null)return EJ(t);let{version:n,handlerProbes:r}=e.value;return TJ({version:n,arrivals:r})}function IJ(){return{platform:process.platform,sockets:{own:Ke(),handler:qe()},now:Date.now,nonce:oe,daemon:FJ,open:e=>{let t=NJ(`doctor.open`,`/usr/bin/open`,[`-g`,e]);return t.kind===`ok`?null:t.reason},pause:()=>new Promise(e=>setTimeout(e,100)),opener:()=>{let e=NJ(`doctor.launch-services`,`/usr/bin/osascript`,[`-l`,`JavaScript`,`-e`,PJ]);if(e.kind===`failed`)return e;let t=e.value.trim();return TJ(t===``?null:t)},script:e=>NJ(`doctor.osadecompile`,`/usr/bin/osadecompile`,[Xi(e)]),exists:s.existsSync}}const LJ=/^─{20,}/,RJ=/^❯(\s|$)/,zJ=/›\s*stashed$/;function BJ(e){if(e.inMode)return{kind:`in-mode`};let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>LJ.test(e)?[t]:[]).at(-2);return n===void 0||!RJ.test(t[n+1]??``)?{kind:`no-prompt`}:zJ.test(t[n-1]??``)?{kind:`stashed`}:{kind:`ready`}}const VJ={"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 HJ(e,t,n){if(t===void 0)return{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`};if(t===null)return{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only type into a tmux pane`};let r=BJ(e.read(t));if(r.kind!==`ready`)return{kind:`refused`,reason:VJ[r.kind]};let i=e.type(t,n);return i.kind===`typed`?{kind:`typed`,pane:t.pane}:i}const UJ=`cc-candybar-slash`;function WJ(e,t,n,r){let i=cH(e,t,n,r);if(i.kind===`failed`)throw Error(i.reason);return i}function GJ(e){let t=WJ(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(`
486
- `);return{inMode:n!==`0`,screen:r}}function KJ(e,t){let n=WJ(e,`claude-input.type`,[`load-buffer`,`-b`,UJ,`-`,`;`,`send-keys`,`-t`,e.pane,`C-s`,`;`,`paste-buffer`,`-p`,`-d`,`-b`,UJ,`-t`,e.pane,`;`,`send-keys`,`-t`,e.pane,`Enter`],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 qJ(){return{read:GJ,type:KJ}}function JJ(e){if(!e)throw new q(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new q(`invalid session id "${e}"`);return e}function YJ(e){return XJ(()=>decodeURIComponent(e))}function XJ(e){try{return e()}catch(e){throw e instanceof URIError?new q(`malformed wire encoding: ${e.message}`):e}}function ZJ(e,t){let n=Re({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 QJ=(e,t)=>ZJ(YJ(e),t),$J=(e,t)=>{let n=Re({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,YJ(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`})`)}},eY=(e,t)=>ZJ(YJ(e),t),tY=(e,t)=>ZJ(YJ(e),t),nY=(e,t)=>{let n=JJ(YJ(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},rY=(e,t)=>{let[n=``,...r]=XJ(()=>ir(e)),i=JJ(n),a=UB(_Y(t,i));if(r.length===0)throw new q(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new q(`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 q(`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 q(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}sY(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})`)},iY=/^-?\d+$/;function aY(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const oY=(e,t)=>{let[n=``,r=``,i=``]=XJ(()=>ir(e)),a=JJ(n);if(!r)throw new q(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!iY.test(i))throw new q(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=_Y(t,a),c=UB(s),l=c.rangeParamsFor(r);if(!l)throw new q(`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&&iY.test(u)?cY(l,parseInt(u,10)):lY(`step-state`,r,l,KB(s,e=>t.sessionState.get(a,e),r)),f=aY(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new q(`step-state: ${p.reason}`);sY(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 sY(e,t,n,r){let i=r.filter(e=>e.key.startsWith(rk));if(i.length===0)return;let a=SB(_Y(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new q(`${n}: refused — ${a.join(`; `)}`)}function cY(e,t){return Math.max(e.min,Math.min(e.max,t))}function lY(e,t,n,r){if(r===null)return n.min;if(!iY.test(r))throw new q(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return cY(n,parseInt(r,10))}const uY=`render-origin`;function dY(e,t,n){return{...e,configFile:t.get(n,`config-override`)??e.configFile}}function fY(e){return JSON.stringify(e)}function pY(e){let t;try{t=JSON.parse(e)}catch{throw new q(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new q(`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 q(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,configFile:i}}function mY(e,t){let n=hY(e,t);if(n===null)throw new q(`session ${t} has not rendered yet — no config to act on`);return n}function hY(e,t){let n=e.sessionState.get(t,uY);return n===null?null:dY(pY(n),e.sessionState,t)}function gY(e,t,n){let r=hY(e,t);if(r===null)return;let{path:i}=vY(r);n.some(e=>e.kind===`file`&&e.file===i)&&e.reloadConfig(r)}function _Y(e,t){return e.configFor(mY(e,t))}function vY(e){return gR(e.projectDir,e.cwd,e.configFile??void 0)}function yY(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.dlog}}const bY=(e,t)=>{let[n=``,r=``,i=``]=XJ(()=>ir(e)),a=JJ(n),o=mY(t,a),s=t.configFor(o),c=QN(s);if(!r)throw new q(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new q(`set-config: ${l.reason}`);let u=vY(o),d=bB(s,e=>t.sessionState.get(a,e),r);HG(yY(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.dlog(`info`,`set-config: ${d.key}=${l.value} → ${u.path} (session=${a})`)},xY=(e,t)=>{let[n=``,r=``,i=``]=XJ(()=>ir(e)),a=JJ(n);if(!r)throw new q(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!iY.test(i))throw new q(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=mY(t,a),c=t.configFor(s),l=QN(c),u=l.rangeParamsFor(r);if(!u)throw new q(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=vY(s),f=bB(c,e=>t.sessionState.get(a,e),r),p=VG(d.path,f.key),m=typeof p==`number`?cY(u,p):lY(`step-config`,r,u,eP(f.globals,r)),h=aY(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new q(`step-config: ${g.reason}`);HG(yY(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})`)},SY=(e,t)=>{let[n=``]=XJ(()=>ir(e)),r=JJ(n),i=mY(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=vB(a,o),c=xB(a,o);if(s.length+c.length===0){t.dlog(`info`,`save: nothing unsaved (session=${r})`);return}let l=UB(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new q(`save: ${t.reason}`);return[e.target,t.value]});wY(`save`,l,c);let d=vY(i);UG(yY(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(CY)].join(` `)} → ${d.path} (session=${r})`)},CY=e=>`${e.preset}/${e.id}.settings.${e.setting}=${y_(e.value)}`;function wY(e,t,n){for(let r of n){let n=t.validate(r.key,y_(r.value));if(!n.ok)throw new q(`${e}: ${n.reason}`)}}const TY=(e,t)=>{let[n=``]=XJ(()=>ir(e)),r=JJ(n),i=mY(t,r),a=t.configFor(i),o=TB(a,e=>t.sessionState.get(r,e)),s=UB(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new q(`save-preset: ${t.reason}`);return[e.configKey,t.value]});wY(`save-preset`,s,o.placements);let l=vY(i),u=XG(yY(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...Va.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,Ba.preset.sessionKey,u),t.dlog(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(CY)].join(` `)} → ${l.path} (session=${r})`)},EY=(e,t)=>{let[n=``]=XJ(()=>ir(e)),r=JJ(n),i=mY(t,r),a=DB(t.configFor(i),e=>t.sessionState.get(r,e));if(a.kind===`rule`)throw new q(`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=vY(i);ZG(yY(t,r),o,a.theme,a.look),t.reloadConfig(i);let s=new Set(vB(t.configFor(i),e=>t.sessionState.get(r,e)).map(e=>e.sessionKey)),c=i_.map(e=>Ba[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} ${i_.map(e=>`${e}=${a.look[e]}`).join(` `)} → ${o.path} (session=${r})`)},DY=(e,t)=>{let[n=``,r=``]=XJ(()=>ir(e)),i=JJ(n);if(!r)throw new q(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=mY(t,i),o=vY(a);QG(yY(t,i),o,r),t.reloadConfig(a);let s=Ba.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.dlog(`info`,`delete-preset: ${r} ← ${o.path} (session=${i})`)},OY=(e,t)=>{let[n=``,...r]=XJ(()=>ir(e)),i=JJ(n),a=mY(t,i),o=QN(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new q(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=vY(a),l=r.map(OB),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);qG(yY(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 kY(e,t){let n=(e,t)=>[...$g(V_(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(R_(t.presets).flatMap(e=>n(t,e).map(t=>ik(JE(e),Yg(t)))));return R_(e.presets).flatMap(t=>n(e,t).map(e=>({member:ik(JE(t),Yg(e)),node:e})).filter(({member:e})=>!r.has(e)))}function AY(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[QO]:[]])}const jY=(e,t)=>{let[n=``,r=``,i=``]=XJ(()=>ir(e)),a=JJ(n),o=mY(t,a),s=t.configFor(o),c=QN(s);if(!r)throw new q(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new q(`apply-layout-op: ${l.reason}`);let u=RN(l.value);if(u===null)throw new q(`apply-layout-op: "${l.value}" is not a layout op token`);let d=vY(o),f=$G(yY(t,a),d,r,u);t.reloadConfig(o);let p=AY(kY(s,t.configFor(o)),t.sessionState.get(a,QO)).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})`)},MY=(e,t)=>{let[n=``]=XJ(()=>ir(e)),r=JJ(n);t.journal.commit();let i=t.history.undo(r);gY(t,r,i),t.dlog(`info`,`undo: restored ${xK(i)} (session=${r})`)},NY=(e,t)=>{let n=JJ(YJ(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,UB(_Y(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.dlog(`info`,`back: ${a} discarded=${i} (session=${n})`)},PY=(e,t)=>{let n=JJ(YJ(e));t.journal.commit();let r=t.history.rewind(n);gY(t,n,r),t.dlog(`info`,`rewind: put back ${xK(r)||`nothing`} as edit mode found it (session=${n})`)},FY=(e,t)=>{let[n=``]=XJ(()=>ir(e)),r=JJ(n);t.journal.commit();let i=t.history.redo(r);gY(t,r,i),t.dlog(`info`,`redo: re-applied ${xK(i)} (session=${r})`)},IY=(e,t)=>{JJ(YJ(e)),t.applyUpdate()},LY=`client-hints`;function RY(e,t){let n=e.sessionState.get(t,LY);if(n===null)throw new q(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new q(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new q(`client hints record is not an object: ${n}`);return ft(r)}function zY(e,t,n){let r=HA(n);e.sessionState.setBatch(t,tj(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} ${$A(n.nerdFont,n.marks)} ${KA(n.terminal,n.clicked)} ${qA(n.terminal,n.termCols)} ${JA(n.install)} ${YA(n.daemon)} ${XA(n.data)} ${QA(n.transcripts)} ${ZA(n.frames)} (session=${t})`)}function BY(e,t){let n=e.clients.ofSession(t),r;try{r=dJ(e.doctor,RY(e,t),mY(e,t),n=>e.sessionState.get(t,n),{kind:`ok`,value:e.serving()},{kind:`ok`,value:n.map(e=>e.rateLimits)},{kind:`ok`,value:n.map(e=>e.transcript)},{kind:`ok`,value:n.map(({role:e,frame:t})=>({role:e,frame:t}))})}catch(e){throw e instanceof VK?new q(e.message):e}return{...r,urlHandler:cJ(e.clientVersion),install:Bq(e.doctor.install,e.bundle,n.map(e=>e.client)),askedBy:`click`,clicked:VY(e,r)}}function VY(e,{terminal:t,clicked:n}){let r=t.kind===`seen`?Xk(t.identified):null;if(r===null||n.kind===`failed`)return n;try{e.doctor.clicked.record(r)}catch(t){return e.dlog(`warn`,`doctor: clicked terminal not filed for ${JSON.stringify(r)}: ${t instanceof Error?t.message:String(t)}`),n}return{kind:`ok`,value:n.value.includes(r)?n.value:[...n.value,r]}}const HY=(e,t)=>{let n=JJ(YJ(e));zY(t,n,BY(t,n))},UY=(e,t)=>{let n=kJ(YJ(e));if(n===null)throw new q(`doctor-probe: the value is not a probe nonce`);t.probes.arrive({nonce:n,handler:t.clientVersion}),t.dlog(`info`,`doctor-probe: arrived nonce=${n} handler=${t.clientVersion??`unreported`}`)},WY=(e,t)=>{let[n=``,r=``]=XJ(()=>ir(e)),i=JJ(n),a=UA(r);if(a===void 0)throw new q(`doctor-fix: unknown check "${r}"`);let o=BY(t,i),s=a.probe(o);if(s.ok||s.fix===void 0)throw new q(`doctor-fix: ${a.label} — ${s.ok?`nothing to fix`:s.reason}`);let c=fJ(t.doctor,s.fix,o);t.dlog(`info`,`doctor-fix: ${a.name} → ${nA(s.fix)} (session=${i})`),zY(t,i,c)},GY=(e,t)=>{let[n=``,r=``,i=``]=XJ(()=>ir(e)),a=JJ(n),o=UA(r);if(o===void 0)throw new q(`doctor-mark: unknown check "${r}"`);if(!eA.includes(i))throw new q(`doctor-mark: the mark is ${JSON.stringify(i)}, not ${eA.join(` or `)}`);let s=BY(t,a),c=o.probe(s);if(c.ok||c.sighting===void 0)throw new q(`doctor-mark: ${o.label} — ${c.ok?`nothing to mark`:`shows nothing to look at`}`);if(s.marks.kind===`failed`)throw new q(`doctor-mark: ${s.marks.reason}`);let l=[o.name,c.sighting.id,i];t.doctor.marks.record(...l),t.dlog(`info`,`doctor-mark: ${o.name} ${i} on ${c.sighting.id} (session=${a})`),zY(t,a,{...s,marks:{kind:`ok`,value:zK(s.marks.value,...l)}})},KY=(e,t)=>{let[n=``,...r]=XJ(()=>ir(e)),i=JJ(n),a=mY(t,i),o=Object.values(t.configFor(a).actions).filter(e=>`ceiling`in e).find(e=>{let t=eI(e);return t.length===r.length&&t.every((e,t)=>e===r[t])});if(o===void 0)throw new q(`ceiling: "${r.join(` `)}" is not a move this config declares`);let s=o.ceiling===`set`?{kind:`set`,to:o.to}:{kind:`clear`},c=_z({sessionId:i,projectDir:a.projectDir,cwd:a.cwd},RY(t,i));t.memento.move(c,s),t.dlog(`info`,`ceiling: ${r.join(` `)} (session=${i} claudeConfigDir=${c.claudeConfigDir})`)},qY=(e,t)=>{let[n=``,r=``]=XJ(()=>ir(e)),i=JJ(n),a=Object.values(t.configFor(mY(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new q(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=HJ(t.claudeInput,RY(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.dlog(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new q(`${r} was not typed: ${s.reason}`);t.dlog(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)},JY=`config-override`,YY=new Map([[Nn,QJ],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new q(`load-config: expected <sessionId>/<path> (missing separator)`);let r=JJ(XJ(()=>decodeURIComponent(e.slice(0,n)))),i=XJ(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new q(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new q(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,JY),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,JY,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[Pn,$J],[jn,rY],[Mn,oY],[Rn,bY],[zn,xY],[Wn,OY],[Bn,SY],[Vn,TY],[Hn,EY],[Un,DY],[Gn,jY],[Kn,MY],[qn,FY],[Jn,NY],[Yn,PY],[In,eY],[Ln,tY],[Fn,nY],[Xn,IY],[Zn,HY],[Qn,WY],[$n,GY],[er,UY],[tr,KY],[nr,qY]]),XY=new Set([jn,Mn,Rn,zn,Wn,Bn,Vn,Hn,Un,Gn,Kn,qn,Jn,Yn,Fn,Xn,Zn,Qn,$n,tr,nr]),ZY=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of sr(ar(e))){if(!i&&XY.has(a)){let e=ir(o);e.length>0&&e[0]&&(i=e[0])}let e=YY.get(a);if(!e){n.push(`unknown effect verb "${a}"`);continue}try{e(o,t)}catch(e){e instanceof q||(r=!0),n.push(`${a}: ${e instanceof Error?e.message:String(e)}`)}}if(n.length>0){i&&MK(t.sessionState,i,n.join(`
487
- `),yE(new Date));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new q(e)}};function QY(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 $Y=new Map([...YY,[An,ZY]].map(([e,t])=>[e,QY(t)]));Object.freeze([...$Y.keys()]);const eX=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`]),tX=[[`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`]],nX=[[`workspace.added_dirs`,`string-list`]];function rX(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of tX){let i=oX(n,e);if(i==null)t.missingRequired.push(e);else{let n=iX(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of nX){let i=oX(n,e),a=i===void 0?r:aX(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))eX.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function iX(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function aX(e){return Array.isArray(e)&&e.every(e=>iX(e)===`string`)?`string-list`:iX(e)}function oX(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 sX(e,t){switch(e){case`vars`:return{what:e,vars:cX(t)};case`segments`:return{what:e,segments:pX(t)};case`config`:return{what:e,config:_X(t)}}}function cX(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=dX(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=lX(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:uX(r.lastUpdatedMs())})}return o}function lX(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 uX(e){return e===null?null:Math.max(0,Date.now()-e)}function dX(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,fX(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}`,fX(i));return t}function fX(e){return e.kind}function pX(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=hX(n),o=mX(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:gX(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function mX(e){let t=new Map;for(let n of R_(e.presets))for(let r of $g(V_(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=Yg(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function hX(e){let t=[],n=new Set;for(let r of $g(j_(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 gX(e,t,n){let r=new Set;for(let i of lv(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 _X(e){return e===null?null:e.config}const vX=[`vars`,`segments`,`config`];function yX(e){return typeof e==`string`&&vX.includes(e)}function bX(e){return Math.max(1,e-2)}const xX={moving:1e3/30,still:1e3};var SX=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,r){let i=this.requests.get(e);if(i!==void 0&&i.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 a=this.feeds.get(e);if(a===void 0)return;if(a.last!==null&&r.drawnAt<a.last.drawnAt){this.wake(e);return}if(a.noted++,this.countFailure(a,r),this.push(a,r),this.feeds.get(e)!==a)return;let o=this.deps.now();switch(a.phase.kind){case`drawing`:a.phase.superseded={frame:r,at:o};return;case`due`:clearTimeout(a.phase.timer);break;case`waiting`:break}this.schedule(a,r,o,o)}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.sinks.add(t),r.last!==null&&t.frame(r.last.resp,r.last.bytes),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${r.sinks.size} data=${this.requests.has(e)?`Y`:`N`}`),()=>this.unsubscribe(r,t)}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}]})}getStats(){let e=0;for(let t of this.feeds.values())e+=t.sinks.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,sinks:new Set,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,drawMs:0,summarizedAt:t};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),this.draw(n),n}unsubscribe(e,t){!e.sinks.delete(t)||e.sinks.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: ${T(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,superseded:null};e.phase=r;let i=this.deps.now(),a=await this.deps.render(n),o=this.deps.now();if(this.drawn++,e.drawn++,e.drawMs+=o-i,this.feeds.get(e.sessionId)!==e||(this.countFailure(e,a),this.requests.get(e.sessionId)===t&&(this.push(e,a),this.feeds.get(e.sessionId)!==e)))return;if(o-e.summarizedAt>=6e4&&this.summarize(e,`running`),r.again){this.draw(e);return}let s=r.superseded??{frame:a,at:i};this.schedule(e,s.frame,s.at,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.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.sinks])t[n.lane]||(this.unsubscribe(e,n),this.refuse(e.sessionId,n))}if(e.sinks.size===0)return;let{resp:r}=t,i=JSON.stringify(r);if(e.last?.bytes!==i){e.last={resp:r,bytes:i,drawnAt:t.drawnAt},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);for(let t of e.sinks)t.frame(r,i)}}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:Ra(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.sinks.size} lanes=${[...e.sinks].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} meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};function CX(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 wX=`#{pane_id} #{session_id} #{session_attached} #{window_active} #{window_zoomed_flag} #{pane_active}`,TX=`#{session_id} #{client_control_mode}`;function EX(e){let t=new Set;for(let n of e.split(`
488
- `)){let[e,r]=n.trim().split(` `);e!==void 0&&r===`1`&&t.add(e)}return t}function DX(e,t){let n=new Set;for(let r of e.split(`
489
- `)){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}var OX=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: ${T(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:DX(t.stdout,EX(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),!kX(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`))}n.size>0&&this.deps.onChange(n)}};function kX(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 AX={order:-1/0,text:null,failure:null};var jX=class{synced=new Map;constructor(e){this.dir=e}pathFor(e){return v.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t,n){let r=this.synced.get(e)??AX;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)??AX;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?s.rmSync(n,{force:!0}):(s.mkdirSync(this.dir,{recursive:!0,mode:448}),s.writeFileSync(n,t,{mode:384})),null}catch(e){return`${n}: ${e.message}`}}reset(){this.synced.clear();try{return s.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};function MX(e,t){for(let n of Object.entries(t))e.push(n)}const NX={ok:`info`,"bad-request":`warn`,threw:`error`};function PX(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,T(e.error)]]}}const FX=/^[^\s"=\\]+$/,IX=e=>FX.test(e)?e:JSON.stringify(e);function LX(e,t,n){let r=[...e,[`took`,`${n}ms`],[`outcome`,t.kind],...PX(t)];return{level:NX[t.kind],line:`render${r.map(([e,t])=>` ${e}=${IX(t)}`).join(``)}`}}function RX(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}const zX=new JW,BX=new DJ,VX=new Fk,HX=i(import.meta.url);Fe(zX.launchStats);const UX=new sE({counters:zX,logger:N}),WX=mH({watchers:UX,logger:N}),{gitProvider:GX,usageStore:KX,mementoProvider:qX}=WX,JX=new ZW,YX=new sK(JX,N),XX=new AK,ZX=new Qh,QX=new SX({render:e=>zZ(e),watch:(e,t)=>(0,Cv.reaction)(()=>JX.revision(e),t,{scheduler:e=>fe(e)}),lanes:e=>VZ(e),shown:e=>$X.shown(e.hints.tmux),watching:()=>$X.follow(),periods:xX,now:()=>Date.now(),log:N}),$X=new OX({listPanes:e=>lH({socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,wX]),listClients:e=>lH({socket:e},`frames.visibility`,[`list-clients`,`-F`,TX]),sockets:()=>new Set(QX.watched().flatMap(({req:e})=>eZ(e))),onChange:e=>QX.wakeWhere(t=>eZ(t).some(t=>e.has(t))),intervalMs:1e3,log:N});function eZ({hints:{tmux:e}}){return e==null?[]:[e.socket]}const tZ=new jX(it()),nZ=new KW({gitService:GX,sessionState:JX,watchers:UX,log:N},{observers:{onReload:e=>N(`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)}`)}}),rZ=60*1e3;function iZ(){let e=import.meta.url,n=[];e.startsWith(`file://`)&&n.push(i(e)),t.argv[1]&&n.push(t.argv[1]);let r=new Map;for(let e of n)try{r.set(e,s.statSync(e).mtimeMs)}catch{}let a=null,o=()=>{for(let[e,t]of r)try{if(s.statSync(e).mtimeMs!==t){N(`info`,`binary mtime changed (${e}); shutting down`),a&&clearInterval(a),xZ(0);return}}catch(e){N(`warn`,`bin stat failed: ${e.message}`)}};return{arm(){r.size!==0&&(a=setInterval(o,rZ),a.unref())},checkNow:o}}const aZ=iZ(),oZ=dV({entryUrl:import.meta.url,intervalMs:rZ,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>aZ.checkNow(),log:N});let sZ=null,cZ=null,lZ=0;function uZ(){t.on(`uncaughtException`,e=>{N(`error`,`uncaughtException: ${e.stack||e.message}`),xZ(1)}),t.on(`unhandledRejection`,e=>{N(`error`,`unhandledRejection: ${String(e)}`),xZ(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{N(`info`,`received ${e}, shutting down`),xZ(0)});try{_Z(t.env)}catch(e){N(`error`,`refusing to boot: ${e.message}`),xZ(1);return}sZ=ba(t.pid);let e=Aa(Ma(sZ));if(!e.decision.allow){N(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),xZ(1);return}cZ=e.registryPath,s.mkdirSync(Ge(),{recursive:!0}),Ye(Ke()),JX.useStorage(new $W(Qe(),500,N)),YX.useStorage(OK($e(),N)),Ca({anchor:Sa(t.env),isAlive:wa,onOrphaned:e=>{N(`info`,`parent watchdog: ${e}; shutting down`),xZ(0)}}),dZ(D.createServer({allowHalfOpen:!1},e=>{SZ(e)}),Ke(),!1)}function dZ(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){N(`error`,`server error: ${i.message}`),xZ(1);return}if(r){N(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}fZ(e,n)}),e.listen(n,()=>pZ(n))}function fZ(e,n){let r=ua(da(Xe(n)),(e,t)=>ya(e,t,{readStartTime:va,pidAlive:wa}));if(r.kind===`attach-and-exit`){N(`info`,`EADDRINUSE: ${r.reason} — exiting`),t.exit(0);return}N(`warn`,`EADDRINUSE: ${r.reason} — unlinking stale socket and rebinding`);try{s.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){N(`error`,`cannot unlink stale socket ${n}: ${e.message}`),xZ(1);return}}dZ(e,n,!0)}function pZ(e){let n=ma(e);if(n.kind!==`present`){N(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),xZ(0);return}vZ(e);try{s.chmodSync(e,384)}catch(e){N(`warn`,`chmod socket failed: ${e.message}`)}N(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${en(ie.getHeapStatistics().heap_size_limit)}MB rssLimit=${en(lZ)}MB`),bn();let r=tZ.reset();r!==null&&N(`warn`,`diagnostic dump wipe failed: ${r}`),aZ.arm(),oZ.arm(),gZ().arm(),mZ(e,n.identity)}function mZ(e,n){_a({bound:n,myPid:t.pid,readIdentity:()=>ma(e),readLease:()=>da(Xe(e)),shutdown:e=>xZ(e),log:N}).arm()}let hZ=null;function gZ(){if(hZ===null)throw Error(`daemon: limits not yet established`);return hZ}function _Z(e){lZ=tn(e),hZ=cn(dn(zX.startedAt.getTime(),e=>xZ(e),{rssLimitBytes:lZ}))}function vZ(e){let n=fa(Xe(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:sZ});n!==null&&N(`warn`,`lease write failed: ${n}`)}let yZ=0,bZ=!1;function xZ(e){if(!bZ){bZ=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{GX.close()}catch(e){N(`warn`,`gitService close failed: ${e.message}`)}try{KX.close()}catch(e){N(`warn`,`usageStore close failed: ${e.message}`)}try{UX.closeAll()}catch(e){N(`warn`,`watcherRegistry close failed: ${e.message}`)}try{JX.flush()}catch(e){N(`warn`,`sessionState flush failed: ${e.message}`)}pa(Ze(),t.pid),cZ!==null&&ja(cZ,t.pid,Oa,e=>s.unlinkSync(e)),t.exit(e)}}function SZ(e){yZ++,zX.inFlight=yZ;let t=!1,n=!0,r=()=>{n&&(n=!1,yZ=Math.max(0,yZ-1),zX.inFlight=yZ)},i=(n,r,i)=>{if(t){r!==null&&N(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let a=r===null?void 0:()=>xZ(r);try{e.end(Ct(n),e=>{e??i(),a?.()})}catch(e){N(`warn`,`response write failed: ${e.message}`),a?.()}},a=!1,o=setTimeout(()=>{a=!0,zX.requestsTimedOut++,i({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,CZ)},200),s=Tt(e=>{AZ(e,()=>a).then(e=>e.kind===`reply`?i(e.resp,e.exitAfterFlush,e.delivered):c(e.sessionId,e.lane)).catch(e=>{N(`error`,`handler threw: ${T(e)}`),i(DZ(e),null,CZ)})},e=>{N(`warn`,`frame parse failed: ${e.message}`),i({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null,CZ)}),c=(n,i)=>{if(t||e.destroyed)return;clearTimeout(o),r(),e.off(`data`,s);let a=CX(e),c=QX.subscribe(n,{lane:i,frame:(e,t)=>a(wt(t)),refused:t=>e.end(Ct(t))});t=!0,e.on(`close`,c)};e.on(`data`,s),e.on(`error`,e=>{N(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(o),r()})}const CZ=()=>{},wZ=e=>({resp:e,exitAfterFlush:null,delivered:CZ}),TZ=e=>({kind:`reply`,...e}),EZ={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},DZ=e=>({ok:!1,error:e instanceof Error?e.message:T(e),code:`RENDER_FAILED`,daemonV:3}),OZ=(e,t)=>TZ(wZ({ok:!1,error:t,code:e,daemonV:3}));function kZ(e){if(typeof e.sessionId!=`string`||e.sessionId===``)return OZ(`BAD_REQUEST`,`subscribe needs a non-empty string sessionId`);if(e.lane===void 0)return OZ(`VERSION_MISMATCH`,`this client's subscribe names no lane (${Pa.join(`, `)}): it predates the lane toggles — update it`);let t=Ia(e.lane);return t===null?OZ(`BAD_REQUEST`,`subscribe needs a lane, one of ${Pa.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:e.sessionId,lane:t}}async function AZ(e,t){return!e||typeof e!=`object`||typeof e.v!=`number`?OZ(`BAD_REQUEST`,`malformed request`):e.v===3?e.kind===`subscribe`?kZ(e):typeof e.kind!=`string`||!Object.hasOwn(EZ,e.kind)?OZ(`BAD_REQUEST`,`unknown kind`):TZ(await jZ(e,t)):(e.v>3?N(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):N(`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:CZ})}async function jZ(e,t){if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,delivered:CZ};if(e.kind===`pane-session`){let{socket:t,pane:n}=e;return wZ(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:QX.newestWhere(({hints:{tmux:e}})=>e!=null&&e.socket===t&&e.pane===n)})}if(e.kind===`stats`)return wZ({ok:!0,stats:zX.snapshot({gitCache:GX.getStats(),usageCache:KX.getStats(),renderCache:nZ.stats,effectCache:ZX.getStats(),sessionState:{sessions:JX.size(),observers:JX.observers(),revision:JX.latestRevision()},frameFeeds:QX.getStats(),watchersActive:UX.size(),nextRestartReason:gZ().describeNextRestart(),handlerProbes:BX.list(),clients:VX.list(yE(new Date)),bundle:HX,daemon:gZ().serving()})});if(e.kind===`render`){let n=new Date,r=yE(n),i=n.getTime(),a=[],o=++zX.requestsTotal,s=HZ(e),c=(e,t)=>VX.see(e.hookData.session_id,{client:e.hints.client??null,rateLimits:e.rateLimits,claudeConfigDir:Si(e.hints.claudeConfigDir),transcript:jk(e.hookData),frame:t},r,o);s.ok&&c(s.req,`drawing`);let l=s.ok?await JZ(s.req,o,r,a).then(({output:e,motion:t,clickShown:n})=>{c(s.req,t);let r={ok:!0,output:e};return QX.note(s.req.hookData.session_id,s.req,o,{resp:r,drawnAt:i,moves:t===`moves`,failure:null}),{outcome:{kind:`ok`},resp:r,delivered:n===null?CZ:()=>NK(JX,s.req.hookData.session_id,n)}},e=>(c(s.req,`failed`),{outcome:{kind:`threw`,error:e},resp:DZ(e),delivered:CZ})):UZ(s.problems);l.outcome.kind!==`ok`&&zX.requestsErrored++,MX(a,{timedOut:t()?`Y`:`N`});let{level:u,line:d}=LX(a,l.outcome,Date.now()-i);return N(u,d),{resp:l.resp,exitAfterFlush:null,delivered:l.delivered}}if(e.kind===`click`)return wZ(RZ(e.verb,e.value,xt(e.clientVersion)));if(e.kind===`debug`){if(!yX(e.what))return wZ({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${vX.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=nZ.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?IZ(t.lastRenderCellsBySegment,t.config.globals.colorCompatibility??`truecolor`):FZ};return wZ({ok:!0,debug:sX(e.what,n)})}throw Error(`no reply for request ${T(e)}`)}function MZ(e,t){let{values:n,tokens:r}=re({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),i=[...new Set((r??[]).filter(e=>e.kind===`option`&&e.name!==`config`).map(e=>`--${e.name}`))];return{configFile:AL(t,n.config),unknownFlagsError:i.length>0?`Unknown flags: ${i.join(`, `)}`:null}}const NZ={sessionState:JX,dlog:N,applyUpdate:()=>oZ.act(),doctor:Xq(e=>{let t=[e.projectDir,e.cwd,e.configFile??void 0];nZ.reload(...t);let n=nZ.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}}),probes:BX,clients:VX,bundle:HX,serving:()=>gZ().serving(),memento:qX,claudeInput:qJ(),history:YX,navigation:XX,configFor:e=>nZ.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>nZ.reload(e.projectDir,e.cwd,e.configFile??void 0)};NZ.reloadConfig;const PZ={endcaps:`powerline`,colorCompatibility:`truecolor`,wrap:!0,padding:1,width:1/0},FZ=new Map;function IZ(e,t){let n=new Map;for(let[r,i]of e)n.set(r,dg(i,{...PZ,colorCompatibility:t}));return n}const LZ={...WX,history:e=>YX.depth(e)};function RZ(e,t,n){let r=$Y.get(e);if(!r)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return r(t,{...NZ,clientVersion:n}),{ok:!0,output:``}}catch(e){let t=e instanceof q?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}async function zZ(e){let t=new Date,n=[];try{let{drawn:r,motion:i}=await WZ(e,yE(t),n,`frame`);return{resp:{ok:!0,output:GZ(r,tZ.linkFor(e.hookData.session_id,KZ(r)))},drawnAt:t.getTime(),moves:i===`moves`,failure:null}}catch(e){let{level:r,line:i}=LX(n,{kind:`threw`,error:e},Date.now()-t.getTime());return{resp:DZ(e),drawnAt:t.getTime(),moves:!1,failure:{level:r,line:`frame ${i}`}}}}function BZ(e,t){return jz(t.config,t=>JX.get(e,t),e=>t.authoredRoots.has(e))}function VZ(e){try{var t=RX();let n=e.hookData.session_id,r=dY(e.requested,JX,n);return BZ(n,t.u(nZ.hold(r.projectDir,r.cwd,r.configFile??void 0)).state).lanes}catch(e){t.e=e}finally{t.d()}}function HZ(e){let{report:t}=rX(e.hookData);for(let e of t.unknownTopLevelFields)N(`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`||!x(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=ft(e),{configFile:i,unknownFlagsError:a}=MZ(e.args,e.cwd);return{ok:!0,req:{...e,hints:r,rateLimits:Ak(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,configFile:i??r.configEnv??null},unknownFlagsError:a}}}const UZ=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},delivered:CZ});async function WZ(e,t,n,r){try{var i=RX();MX(n,{sid:e.hookData.session_id,at:t.toFixed(3)});let{unknownFlagsError:a}=e,o=e.hookData.session_id,s=e.hints,c=pt(e,s),l=mt(c);MX(n,{termCols:String(s.termCols??`?`),termRows:String(s.termRows??`?`),refused:c.map(e=>e.hint).join(`,`)||`-`,client:s.client?.kind??`unreported`,rateLimits:e.rateLimits});let u=dY(e.requested,JX,o),{entry:d,state:f}=i.u(nZ.hold(u.projectDir,u.cwd,u.configFile??void 0)),p=s.termCols,m=bX(p??120),h=fg(s.termRows);MX(n,{width:String(m)});let g=t=>JX.get(e.hookData.session_id,t),_=BZ(o,f);MX(n,{lanes:Pa.filter(e=>_.lanes[e]).join(`,`)||`-`});let v=await $z(e.hookData,t,{...LZ,navigation:e=>XX.depth(e,JX,UB(f.config))},e.cwd,f.neededInputPaths(_.preset),_,s,{...AB(f.config,f.fileHeldSettings,g),configPath:d.configLayers.includes(d.configHome)?d.configHome:null});MX(n,{prompts:String(v.metrics?.messageCount??`-`),nonPrompts:String(v.metrics?.nonPrompts??`-`),pr:Iz(v.git)});let y=[],b=Mz(_,m),x=ZX.of(o),S=wW(f.config,f.compiled,f.store,f.registry,v,t,b,{perSegmentSink:f.lastRenderCellsBySegment,onRenderWarning:e=>y.push(e)},{...Nz(_),effects:x}),C=FK(JX,o,t,r),w=C.kind===`held`||C.kind===`owed`?C.error:null,ee=w?.text??null,te=[a,l,d.lastError,ee].filter(Boolean).join(`
490
- `),ne=oZ.notice({sessionId:o,dismissed:JX.get(o,YB),enabled:_.updateNotice}),T=d.lastError===null?null:d.failedFile,re=[...d.lastWarning===null?[]:[{kind:`load`,message:d.lastWarning}],...y],E=_g(te,ne,re.map(e=>e.message).join(`
491
- `)),D=GX.getStats(),ie=KX.getStats(),O=x.lastFrame(),ae=O.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,oe=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,se=re.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 MX(n,{git:`${D.size}/${D.hits}h/${D.misses}m`,usage:`${ie.size}/${ie.hits}h/${ie.misses}m`,effect:O.effect,effectT:O.t.toFixed(3),effectRows:`${O.made}made/${O.reused}reused`,effectOwn:ae,fadeBasis:O.basis,stateRev:String(O.revision),fades:oe(O.fades),leaves:oe(O.leaves),motion:S.motion,err:te?`Y`:`N`,clickError:C.kind===`none`?`-`:C.kind,upd:String(ne.length),warn:se}),{drawn:{body:S.text,diagnostics:E,failedConfigFile:T,geometry:{width:m,rowCap:h,colorCompatibility:_.colorCompatibility}},motion:S.motion,clickShown:w}}catch(e){i.e=e}finally{i.d()}}function GZ(e,t){return bg(e.body,e.diagnostics,{fullText:t,failedConfigFile:e.failedConfigFile},e.geometry)+`
492
- `}function KZ(e){return e.diagnostics===null?null:yg(e.diagnostics)}function qZ(e){let t=e.hookData.session_id,{client:n,...r}=e.hints,i=JSON.stringify(r);JX.get(t,`client-hints`)!==i&&JX.set(t,LY,i);let a=fY(e.requested);JX.get(t,`render-origin`)!==a&&JX.set(t,uY,a)}async function JZ(e,t,n,r){qZ(e);let{drawn:i,motion:a,clickShown:o}=await WZ(e,n,r,`request`),{link:s,failure:c}=tZ.sync(e.hookData.session_id,t,KZ(i));return MX(r,{dumpFailed:c===null?`-`:JSON.stringify(c)}),{output:GZ(i,s),motion:a,clickShown:o}}const YZ={connectMs:200,budgetMs:500};async function XZ(e,n){let r=n.includes(`--json`),i=await ZZ(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${Pt(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
493
- `);return}t.stdout.write(QZ(i.value))}function ZZ(e){return Ot({kind:`debug`,what:e},YZ,e=>`debug`in e?e.debug:void 0)}function QZ(e){switch(e.what){case`vars`:return $Z(e.vars);case`segments`:return eQ(e.segments);case`config`:return tQ(e.config);default:return e}}function $Z(e){if(e.length===0)return`no variables (DSL not active)
494
- `;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?``:` ${rQ(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${nQ(a.value)}${e}${o}`)}return t.join(`
483
+ `}const RJ=e=>({kind:`ok`,value:e}),zJ=e=>({kind:`failed`,reason:e});var BJ=class{arrivals=[];arrive(e){this.arrivals=[...this.arrivals,e].slice(-16)}list(){return this.arrivals}};const VJ=/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;function HJ(e){return VJ.test(e)?e:null}function UJ(e){let t=e.opener();if(t.kind===`failed`)return t;if(t.value===null)return RJ(null);let n=t.value,r=e.script(n);if(r.kind===`failed`)return RJ({app:n,missing:zJ(`its script could not be read (${r.reason})`)});let i=Yi(r.value);return RJ({app:n,missing:i===null?zJ("its script is not one `cc-candybar install` wrote"):RJ([i.node,i.script].filter(t=>!e.exists(t)))})}async function WJ(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 GJ(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(`${kn}://${er}/${n}`);return(r===null?await WJ(e,n):null)??{kind:`lost`,unopened:r,opener:UJ(e)}}function KJ(e,t,n){let r=Re({bin:t,args:[...n],category:e,timeoutMs:5e3});return r.ok?RJ(r.stdout):zJ(r.stderr.trim()||r.error||r.reason)}const qJ=`ObjC.import("AppKit");var u = $.NSWorkspace.sharedWorkspace.URLForApplicationToOpenURL($.NSURL.URLWithString("${kn}://probe"));u.isNil() ? "" : u.path.js`;async function JJ(){let e=await OJ();if(e.kind!==`ok`)return zJ(Pt(e).split(`
484
+ `).join(` — `));let t=kJ(e.value,[`handlerProbes`]);if(t!==null)return zJ(t);let{version:n,handlerProbes:r}=e.value;return RJ({version:n,arrivals:r})}function YJ(){return{platform:process.platform,sockets:{own:Ke(),handler:qe()},now:Date.now,nonce:oe,daemon:JJ,open:e=>{let t=KJ(`doctor.open`,`/usr/bin/open`,[`-g`,e]);return t.kind===`ok`?null:t.reason},pause:()=>new Promise(e=>setTimeout(e,100)),opener:()=>{let e=KJ(`doctor.launch-services`,`/usr/bin/osascript`,[`-l`,`JavaScript`,`-e`,qJ]);if(e.kind===`failed`)return e;let t=e.value.trim();return RJ(t===``?null:t)},script:e=>KJ(`doctor.osadecompile`,`/usr/bin/osadecompile`,[Xi(e)]),exists:s.existsSync}}const XJ=/^─{20,}/,ZJ=/^❯(\s|$)/,QJ=/›\s*stashed$/;function $J(e){if(e.inMode)return{kind:`in-mode`};let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>XJ.test(e)?[t]:[]).at(-2);return n===void 0||!ZJ.test(t[n+1]??``)?{kind:`no-prompt`}:QJ.test(t[n-1]??``)?{kind:`stashed`}:{kind:`ready`}}const eY={"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 tY(e,t,n){if(t===void 0)return{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`};if(t===null)return{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only type into a tmux pane`};let r=$J(e.read(t));if(r.kind!==`ready`)return{kind:`refused`,reason:eY[r.kind]};let i=e.type(t,n);return i.kind===`typed`?{kind:`typed`,pane:t.pane}:i}const nY=`cc-candybar-slash`;function rY(e,t,n,r){let i=xH(e,t,n,r);if(i.kind===`failed`)throw Error(i.reason);return i}function iY(e){let t=rY(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(`
485
+ `);return{inMode:n!==`0`,screen:r}}function aY(e,t){let n=rY(e,`claude-input.type`,[`load-buffer`,`-b`,nY,`-`,`;`,`send-keys`,`-t`,e.pane,`C-s`,`;`,`paste-buffer`,`-p`,`-d`,`-b`,nY,`-t`,e.pane,`;`,`send-keys`,`-t`,e.pane,`Enter`],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 oY(){return{read:iY,type:aY}}function sY(e){if(!e)throw new q(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new q(`invalid session id "${e}"`);return e}function cY(e){return lY(()=>decodeURIComponent(e))}function lY(e){try{return e()}catch(e){throw e instanceof URIError?new q(`malformed wire encoding: ${e.message}`):e}}function uY(e,t){let n=Re({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 dY=(e,t)=>uY(cY(e),t),fY=(e,t)=>{let n=Re({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,cY(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`})`)}},pY=(e,t)=>uY(cY(e),t),mY=(e,t)=>uY(cY(e),t),hY=(e,t)=>{let n=sY(cY(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},gY=(e,t)=>{let[n=``,...r]=lY(()=>ir(e)),i=sY(n),a=UB(AY(t,i));if(r.length===0)throw new q(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new q(`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 q(`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 q(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}bY(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})`)},_Y=/^-?\d+$/;function vY(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const yY=(e,t)=>{let[n=``,r=``,i=``]=lY(()=>ir(e)),a=sY(n);if(!r)throw new q(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!_Y.test(i))throw new q(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=AY(t,a),c=UB(s),l=c.rangeParamsFor(r);if(!l)throw new q(`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&&_Y.test(u)?xY(l,parseInt(u,10)):SY(`step-state`,r,l,KB(s,e=>t.sessionState.get(a,e),r)),f=vY(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new q(`step-state: ${p.reason}`);bY(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 bY(e,t,n,r){let i=r.filter(e=>e.key.startsWith(rk));if(i.length===0)return;let a=SB(AY(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new q(`${n}: refused — ${a.join(`; `)}`)}function xY(e,t){return Math.max(e.min,Math.min(e.max,t))}function SY(e,t,n,r){if(r===null)return n.min;if(!_Y.test(r))throw new q(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return xY(n,parseInt(r,10))}const CY=`render-origin`;function wY(e,t,n){return{...e,configFile:t.get(n,`config-override`)??e.configFile}}function TY(e){return JSON.stringify(e)}function EY(e){let t;try{t=JSON.parse(e)}catch{throw new q(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new q(`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 q(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,configFile:i}}function DY(e,t){let n=OY(e,t);if(n===null)throw new q(`session ${t} has not rendered yet — no config to act on`);return n}function OY(e,t){let n=e.sessionState.get(t,CY);return n===null?null:wY(EY(n),e.sessionState,t)}function kY(e,t,n){let r=OY(e,t);if(r===null)return;let{path:i}=jY(r);n.some(e=>e.kind===`file`&&e.file===i)&&e.reloadConfig(r)}function AY(e,t){return e.configFor(DY(e,t))}function jY(e){return gR(e.projectDir,e.cwd,e.configFile??void 0)}function MY(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.dlog}}const NY=(e,t)=>{let[n=``,r=``,i=``]=lY(()=>ir(e)),a=sY(n),o=DY(t,a),s=t.configFor(o),c=QN(s);if(!r)throw new q(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new q(`set-config: ${l.reason}`);let u=jY(o),d=bB(s,e=>t.sessionState.get(a,e),r);tK(MY(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.dlog(`info`,`set-config: ${d.key}=${l.value} → ${u.path} (session=${a})`)},PY=(e,t)=>{let[n=``,r=``,i=``]=lY(()=>ir(e)),a=sY(n);if(!r)throw new q(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!_Y.test(i))throw new q(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=DY(t,a),c=t.configFor(s),l=QN(c),u=l.rangeParamsFor(r);if(!u)throw new q(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=jY(s),f=bB(c,e=>t.sessionState.get(a,e),r),p=eK(d.path,f.key),m=typeof p==`number`?xY(u,p):SY(`step-config`,r,u,eP(f.globals,r)),h=vY(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new q(`step-config: ${g.reason}`);tK(MY(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})`)},FY=(e,t)=>{let[n=``]=lY(()=>ir(e)),r=sY(n),i=DY(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=vB(a,o),c=xB(a,o);if(s.length+c.length===0){t.dlog(`info`,`save: nothing unsaved (session=${r})`);return}let l=UB(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new q(`save: ${t.reason}`);return[e.target,t.value]});LY(`save`,l,c);let d=jY(i);nK(MY(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(IY)].join(` `)} → ${d.path} (session=${r})`)},IY=e=>`${e.preset}/${e.id}.settings.${e.setting}=${y_(e.value)}`;function LY(e,t,n){for(let r of n){let n=t.validate(r.key,y_(r.value));if(!n.ok)throw new q(`${e}: ${n.reason}`)}}const RY=(e,t)=>{let[n=``]=lY(()=>ir(e)),r=sY(n),i=DY(t,r),a=t.configFor(i),o=TB(a,e=>t.sessionState.get(r,e)),s=UB(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new q(`save-preset: ${t.reason}`);return[e.configKey,t.value]});LY(`save-preset`,s,o.placements);let l=jY(i),u=lK(MY(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...Va.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,Ba.preset.sessionKey,u),t.dlog(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(IY)].join(` `)} → ${l.path} (session=${r})`)},zY=(e,t)=>{let[n=``]=lY(()=>ir(e)),r=sY(n),i=DY(t,r),a=DB(t.configFor(i),e=>t.sessionState.get(r,e));if(a.kind===`rule`)throw new q(`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=jY(i);uK(MY(t,r),o,a.theme,a.look),t.reloadConfig(i);let s=new Set(vB(t.configFor(i),e=>t.sessionState.get(r,e)).map(e=>e.sessionKey)),c=i_.map(e=>Ba[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} ${i_.map(e=>`${e}=${a.look[e]}`).join(` `)} → ${o.path} (session=${r})`)},BY=(e,t)=>{let[n=``,r=``]=lY(()=>ir(e)),i=sY(n);if(!r)throw new q(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=DY(t,i),o=jY(a);dK(MY(t,i),o,r),t.reloadConfig(a);let s=Ba.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.dlog(`info`,`delete-preset: ${r} ← ${o.path} (session=${i})`)},VY=(e,t)=>{let[n=``,...r]=lY(()=>ir(e)),i=sY(n),a=DY(t,i),o=QN(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new q(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=jY(a),l=r.map(OB),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);oK(MY(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 HY(e,t){let n=(e,t)=>[...$g(V_(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(R_(t.presets).flatMap(e=>n(t,e).map(t=>ik(JE(e),Yg(t)))));return R_(e.presets).flatMap(t=>n(e,t).map(e=>({member:ik(JE(t),Yg(e)),node:e})).filter(({member:e})=>!r.has(e)))}function UY(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[QO]:[]])}const WY=(e,t)=>{let[n=``,r=``,i=``]=lY(()=>ir(e)),a=sY(n),o=DY(t,a),s=t.configFor(o),c=QN(s);if(!r)throw new q(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new q(`apply-layout-op: ${l.reason}`);let u=RN(l.value);if(u===null)throw new q(`apply-layout-op: "${l.value}" is not a layout op token`);let d=jY(o),f=fK(MY(t,a),d,r,u);t.reloadConfig(o);let p=UY(HY(s,t.configFor(o)),t.sessionState.get(a,QO)).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})`)},GY=(e,t)=>{let[n=``]=lY(()=>ir(e)),r=sY(n);t.journal.commit();let i=t.history.undo(r);kY(t,r,i),t.dlog(`info`,`undo: restored ${PK(i)} (session=${r})`)},KY=(e,t)=>{let n=sY(cY(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,UB(AY(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.dlog(`info`,`back: ${a} discarded=${i} (session=${n})`)},qY=(e,t)=>{let n=sY(cY(e));t.journal.commit();let r=t.history.rewind(n);kY(t,n,r),t.dlog(`info`,`rewind: put back ${PK(r)||`nothing`} as edit mode found it (session=${n})`)},JY=(e,t)=>{let[n=``]=lY(()=>ir(e)),r=sY(n);t.journal.commit();let i=t.history.redo(r);kY(t,r,i),t.dlog(`info`,`redo: re-applied ${PK(i)} (session=${r})`)},YY=(e,t)=>{sY(cY(e)),t.applyUpdate()},XY=`client-hints`;function ZY(e,t){let n=e.sessionState.get(t,XY);if(n===null)throw new q(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new q(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new q(`client hints record is not an object: ${n}`);return ft(r)}function QY(e,t,n){let r=HA(n);e.sessionState.setBatch(t,tj(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} ${$A(n.nerdFont,n.marks)} ${KA(n.terminal,n.clicked)} ${qA(n.terminal,n.termCols)} ${JA(n.install)} ${YA(n.daemon)} ${XA(n.data)} ${QA(n.transcripts)} ${ZA(n.frames)} (session=${t})`)}function $Y(e,t){let n=e.clients.ofSession(t),r;try{r=wJ(e.doctor,ZY(e,t),DY(e,t),n=>e.sessionState.get(t,n),{kind:`ok`,value:e.serving()},{kind:`ok`,value:n.map(e=>e.rateLimits)},{kind:`ok`,value:n.map(e=>e.transcript)},{kind:`ok`,value:n.map(({role:e,frame:t})=>({role:e,frame:t}))})}catch(e){throw e instanceof eq?new q(e.message):e}return{...r,urlHandler:xJ(e.clientVersion),install:$q(e.doctor.install,e.bundle,n.map(e=>e.client)),askedBy:`click`,clicked:eX(e,r)}}function eX(e,{terminal:t,clicked:n}){let r=t.kind===`seen`?Xk(t.identified):null;if(r===null||n.kind===`failed`)return n;try{e.doctor.clicked.record(r)}catch(t){return e.dlog(`warn`,`doctor: clicked terminal not filed for ${JSON.stringify(r)}: ${t instanceof Error?t.message:String(t)}`),n}return{kind:`ok`,value:n.value.includes(r)?n.value:[...n.value,r]}}const tX=(e,t)=>{let n=sY(cY(e));QY(t,n,$Y(t,n))},nX=(e,t)=>{let n=HJ(cY(e));if(n===null)throw new q(`doctor-probe: the value is not a probe nonce`);t.probes.arrive({nonce:n,handler:t.clientVersion}),t.dlog(`info`,`doctor-probe: arrived nonce=${n} handler=${t.clientVersion??`unreported`}`)},rX=(e,t)=>{let[n=``,r=``]=lY(()=>ir(e)),i=sY(n),a=UA(r);if(a===void 0)throw new q(`doctor-fix: unknown check "${r}"`);let o=$Y(t,i),s=a.probe(o);if(s.ok||s.fix===void 0)throw new q(`doctor-fix: ${a.label} — ${s.ok?`nothing to fix`:s.reason}`);let c=TJ(t.doctor,s.fix,o);t.dlog(`info`,`doctor-fix: ${a.name} → ${nA(s.fix)} (session=${i})`),QY(t,i,c)},iX=(e,t)=>{let[n=``,r=``,i=``]=lY(()=>ir(e)),a=sY(n),o=UA(r);if(o===void 0)throw new q(`doctor-mark: unknown check "${r}"`);if(!eA.includes(i))throw new q(`doctor-mark: the mark is ${JSON.stringify(i)}, not ${eA.join(` or `)}`);let s=$Y(t,a),c=o.probe(s);if(c.ok||c.sighting===void 0)throw new q(`doctor-mark: ${o.label} — ${c.ok?`nothing to mark`:`shows nothing to look at`}`);if(s.marks.kind===`failed`)throw new q(`doctor-mark: ${s.marks.reason}`);let l=[o.name,c.sighting.id,i];t.doctor.marks.record(...l),t.dlog(`info`,`doctor-mark: ${o.name} ${i} on ${c.sighting.id} (session=${a})`),QY(t,a,{...s,marks:{kind:`ok`,value:QK(s.marks.value,...l)}})},aX=(e,t)=>{let[n=``,...r]=lY(()=>ir(e)),i=sY(n),a=DY(t,i),o=Object.values(t.configFor(a).actions).filter(e=>`ceiling`in e).find(e=>{let t=eI(e);return t.length===r.length&&t.every((e,t)=>e===r[t])});if(o===void 0)throw new q(`ceiling: "${r.join(` `)}" is not a move this config declares`);let s=o.ceiling===`set`?{kind:`set`,to:o.to}:{kind:`clear`},c=_z({sessionId:i,projectDir:a.projectDir,cwd:a.cwd},ZY(t,i));t.memento.move(c,s),t.dlog(`info`,`ceiling: ${r.join(` `)} (session=${i} claudeConfigDir=${c.claudeConfigDir})`)},oX=(e,t)=>{let[n=``,r=``]=lY(()=>ir(e)),i=sY(n),a=Object.values(t.configFor(DY(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new q(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=tY(t.claudeInput,ZY(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.dlog(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new q(`${r} was not typed: ${s.reason}`);t.dlog(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)},sX=`config-override`,cX=new Map([[Nn,dY],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new q(`load-config: expected <sessionId>/<path> (missing separator)`);let r=sY(lY(()=>decodeURIComponent(e.slice(0,n)))),i=lY(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new q(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new q(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,sX),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,sX,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[Pn,fY],[jn,gY],[Mn,yY],[Rn,NY],[zn,PY],[Wn,VY],[Bn,FY],[Vn,RY],[Hn,zY],[Un,BY],[Gn,WY],[Kn,GY],[qn,JY],[Jn,KY],[Yn,qY],[In,pY],[Ln,mY],[Fn,hY],[Xn,YY],[Zn,tX],[Qn,rX],[$n,iX],[er,nX],[tr,aX],[nr,oX]]),lX=new Set([jn,Mn,Rn,zn,Wn,Bn,Vn,Hn,Un,Gn,Kn,qn,Jn,Yn,Fn,Xn,Zn,Qn,$n,tr,nr]),uX=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of sr(ar(e))){if(!i&&lX.has(a)){let e=ir(o);e.length>0&&e[0]&&(i=e[0])}let e=cX.get(a);if(!e){n.push(`unknown effect verb "${a}"`);continue}try{e(o,t)}catch(e){e instanceof q||(r=!0),n.push(`${a}: ${e instanceof Error?e.message:String(e)}`)}}if(n.length>0){i&&GK(t.sessionState,i,n.join(`
486
+ `),yE(new Date));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new q(e)}};function dX(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 fX=new Map([...cX,[An,uX]].map(([e,t])=>[e,dX(t)]));Object.freeze([...fX.keys()]);const pX=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`]),mX=[[`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`]],hX=[[`workspace.added_dirs`,`string-list`]];function gX(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of mX){let i=yX(n,e);if(i==null)t.missingRequired.push(e);else{let n=_X(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of hX){let i=yX(n,e),a=i===void 0?r:vX(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))pX.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function _X(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function vX(e){return Array.isArray(e)&&e.every(e=>_X(e)===`string`)?`string-list`:_X(e)}function yX(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 bX(e,t){switch(e){case`vars`:return{what:e,vars:xX(t)};case`segments`:return{what:e,segments:EX(t)};case`config`:return{what:e,config:AX(t)}}}function xX(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=wX(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=SX(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:CX(r.lastUpdatedMs())})}return o}function SX(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 CX(e){return e===null?null:Math.max(0,Date.now()-e)}function wX(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,TX(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}`,TX(i));return t}function TX(e){return e.kind}function EX(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=OX(n),o=DX(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:kX(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function DX(e){let t=new Map;for(let n of R_(e.presets))for(let r of $g(V_(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=Yg(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function OX(e){let t=[],n=new Set;for(let r of $g(j_(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 kX(e,t,n){let r=new Set;for(let i of lv(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 AX(e){return e===null?null:e.config}const jX=[`vars`,`segments`,`config`];function MX(e){return typeof e==`string`&&jX.includes(e)}function NX(e){return Math.max(1,e-2)}const PX={moving:1e3/30,still:1e3};var FX=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,r){let i=this.requests.get(e);if(i!==void 0&&i.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 a=this.feeds.get(e);if(a===void 0)return;if(a.last!==null&&r.drawnAt<a.last.drawnAt){this.wake(e);return}if(a.noted++,this.countFailure(a,r),this.push(a,r),this.feeds.get(e)!==a)return;let o=this.deps.now();switch(a.phase.kind){case`drawing`:a.phase.superseded={frame:r,at:o};return;case`due`:clearTimeout(a.phase.timer);break;case`waiting`:break}this.schedule(a,r,o,o)}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.sinks.add(t),r.last!==null&&t.frame(r.last.resp,r.last.bytes),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${r.sinks.size} data=${this.requests.has(e)?`Y`:`N`}`),()=>this.unsubscribe(r,t)}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}]})}getStats(){let e=0;for(let t of this.feeds.values())e+=t.sinks.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,sinks:new Set,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,drawMs:0,summarizedAt:t};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),this.draw(n),n}unsubscribe(e,t){!e.sinks.delete(t)||e.sinks.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: ${T(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,superseded:null};e.phase=r;let i=this.deps.now(),a=await this.deps.render(n),o=this.deps.now();if(this.drawn++,e.drawn++,e.drawMs+=o-i,this.feeds.get(e.sessionId)!==e||(this.countFailure(e,a),this.requests.get(e.sessionId)===t&&(this.push(e,a),this.feeds.get(e.sessionId)!==e)))return;if(o-e.summarizedAt>=6e4&&this.summarize(e,`running`),r.again){this.draw(e);return}let s=r.superseded??{frame:a,at:i};this.schedule(e,s.frame,s.at,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.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.sinks])t[n.lane]||(this.unsubscribe(e,n),this.refuse(e.sessionId,n))}if(e.sinks.size===0)return;let{resp:r}=t,i=JSON.stringify(r);if(e.last?.bytes!==i){e.last={resp:r,bytes:i,drawnAt:t.drawnAt},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);for(let t of e.sinks)t.frame(r,i)}}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:Ra(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.sinks.size} lanes=${[...e.sinks].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} meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};function IX(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 LX=`#{pane_id} #{session_id} #{session_attached} #{window_active} #{window_zoomed_flag} #{pane_active}`,RX=`#{session_id} #{client_control_mode}`;function zX(e){let t=new Set;for(let n of e.split(`
487
+ `)){let[e,r]=n.trim().split(` `);e!==void 0&&r===`1`&&t.add(e)}return t}function BX(e,t){let n=new Set;for(let r of e.split(`
488
+ `)){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}var VX=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: ${T(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:BX(t.stdout,zX(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),!HX(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`))}n.size>0&&this.deps.onChange(n)}};function HX(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 UX={order:-1/0,text:null,failure:null};var WX=class{synced=new Map;constructor(e){this.dir=e}pathFor(e){return v.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t,n){let r=this.synced.get(e)??UX;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)??UX;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?s.rmSync(n,{force:!0}):(s.mkdirSync(this.dir,{recursive:!0,mode:448}),s.writeFileSync(n,t,{mode:384})),null}catch(e){return`${n}: ${e.message}`}}reset(){this.synced.clear();try{return s.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};function GX(e,t){for(let n of Object.entries(t))e.push(n)}const KX={ok:`info`,"bad-request":`warn`,threw:`error`};function qX(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,T(e.error)]]}}const JX=/^[^\s"=\\]+$/,YX=e=>JX.test(e)?e:JSON.stringify(e);function XX(e,t,n){let r=[...e,[`took`,`${n}ms`],[`outcome`,t.kind],...qX(t)];return{level:KX[t.kind],line:`render${r.map(([e,t])=>` ${e}=${YX(t)}`).join(``)}`}}function ZX(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}const QX=new sG,$X=new BJ,eZ=new Fk,tZ=i(import.meta.url);Fe(QX.launchStats);const nZ=new sE({counters:QX,logger:N}),rZ=DH({watchers:nZ,logger:N}),{gitProvider:iZ,usageStore:aZ,mementoProvider:oZ}=rZ,sZ=new uG,cZ=new bK(sZ,N),lZ=new UK,uZ=new Qh,dZ=new FX({render:e=>QZ(e),watch:(e,t)=>(0,Cv.reaction)(()=>sZ.revision(e),t,{scheduler:e=>fe(e)}),lanes:e=>eQ(e),shown:e=>fZ.shown(e.hints.tmux),watching:()=>fZ.follow(),periods:PX,now:()=>Date.now(),log:N}),fZ=new VX({listPanes:e=>SH({socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,LX]),listClients:e=>SH({socket:e},`frames.visibility`,[`list-clients`,`-F`,RX]),sockets:()=>new Set(dZ.watched().flatMap(({req:e})=>pZ(e))),onChange:e=>dZ.wakeWhere(t=>pZ(t).some(t=>e.has(t))),intervalMs:1e3,log:N});function pZ({hints:{tmux:e}}){return e==null?[]:[e.socket]}const mZ=new WX(it()),hZ=new aG({gitService:iZ,sessionState:sZ,watchers:nZ,log:N},{observers:{onReload:e=>N(`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)}`)}}),gZ=60*1e3;function _Z(){let e=import.meta.url,n=[];e.startsWith(`file://`)&&n.push(i(e)),t.argv[1]&&n.push(t.argv[1]);let r=new Map;for(let e of n)try{r.set(e,s.statSync(e).mtimeMs)}catch{}let a=null,o=()=>{for(let[e,t]of r)try{if(s.statSync(e).mtimeMs!==t){N(`info`,`binary mtime changed (${e}); shutting down`),a&&clearInterval(a),PZ(0);return}}catch(e){N(`warn`,`bin stat failed: ${e.message}`)}};return{arm(){r.size!==0&&(a=setInterval(o,gZ),a.unref())},checkNow:o}}const vZ=_Z(),yZ=dV({entryUrl:import.meta.url,intervalMs:gZ,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>vZ.checkNow(),log:N});let bZ=null,xZ=null,SZ=0;function CZ(){t.on(`uncaughtException`,e=>{N(`error`,`uncaughtException: ${e.stack||e.message}`),PZ(1)}),t.on(`unhandledRejection`,e=>{N(`error`,`unhandledRejection: ${String(e)}`),PZ(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{N(`info`,`received ${e}, shutting down`),PZ(0)});try{AZ(t.env)}catch(e){N(`error`,`refusing to boot: ${e.message}`),PZ(1);return}bZ=ba(t.pid);let e=Aa(Ma(bZ));if(!e.decision.allow){N(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),PZ(1);return}xZ=e.registryPath,s.mkdirSync(Ge(),{recursive:!0}),Ye(Ke()),sZ.useStorage(new fG(Qe(),500,N)),cZ.useStorage(VK($e(),N)),Ca({anchor:Sa(t.env),isAlive:wa,onOrphaned:e=>{N(`info`,`parent watchdog: ${e}; shutting down`),PZ(0)}}),wZ(D.createServer({allowHalfOpen:!1},e=>{FZ(e)}),Ke(),!1)}function wZ(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){N(`error`,`server error: ${i.message}`),PZ(1);return}if(r){N(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}TZ(e,n)}),e.listen(n,()=>EZ(n))}function TZ(e,n){let r=ua(da(Xe(n)),(e,t)=>ya(e,t,{readStartTime:va,pidAlive:wa}));if(r.kind===`attach-and-exit`){N(`info`,`EADDRINUSE: ${r.reason} — exiting`),t.exit(0);return}N(`warn`,`EADDRINUSE: ${r.reason} — unlinking stale socket and rebinding`);try{s.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){N(`error`,`cannot unlink stale socket ${n}: ${e.message}`),PZ(1);return}}wZ(e,n,!0)}function EZ(e){let n=ma(e);if(n.kind!==`present`){N(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),PZ(0);return}jZ(e);try{s.chmodSync(e,384)}catch(e){N(`warn`,`chmod socket failed: ${e.message}`)}N(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${en(ie.getHeapStatistics().heap_size_limit)}MB rssLimit=${en(SZ)}MB`),bn();let r=mZ.reset();r!==null&&N(`warn`,`diagnostic dump wipe failed: ${r}`),vZ.arm(),yZ.arm(),kZ().arm(),DZ(e,n.identity)}function DZ(e,n){_a({bound:n,myPid:t.pid,readIdentity:()=>ma(e),readLease:()=>da(Xe(e)),shutdown:e=>PZ(e),log:N}).arm()}let OZ=null;function kZ(){if(OZ===null)throw Error(`daemon: limits not yet established`);return OZ}function AZ(e){SZ=tn(e),OZ=cn(dn(QX.startedAt.getTime(),e=>PZ(e),{rssLimitBytes:SZ}))}function jZ(e){let n=fa(Xe(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:bZ});n!==null&&N(`warn`,`lease write failed: ${n}`)}let MZ=0,NZ=!1;function PZ(e){if(!NZ){NZ=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{iZ.close()}catch(e){N(`warn`,`gitService close failed: ${e.message}`)}try{aZ.close()}catch(e){N(`warn`,`usageStore close failed: ${e.message}`)}try{nZ.closeAll()}catch(e){N(`warn`,`watcherRegistry close failed: ${e.message}`)}try{sZ.flush()}catch(e){N(`warn`,`sessionState flush failed: ${e.message}`)}pa(Ze(),t.pid),xZ!==null&&ja(xZ,t.pid,Oa,e=>s.unlinkSync(e)),t.exit(e)}}function FZ(e){MZ++,QX.inFlight=MZ;let t=!1,n=!0,r=()=>{n&&(n=!1,MZ=Math.max(0,MZ-1),QX.inFlight=MZ)},i=(n,r,i)=>{if(t){r!==null&&N(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let a=r===null?void 0:()=>PZ(r);try{e.end(Ct(n),e=>{e??i(),a?.()})}catch(e){N(`warn`,`response write failed: ${e.message}`),a?.()}},a=!1,o=setTimeout(()=>{a=!0,QX.requestsTimedOut++,i({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,IZ)},200),s=Tt(e=>{UZ(e,()=>a).then(e=>e.kind===`reply`?i(e.resp,e.exitAfterFlush,e.delivered):c(e.sessionId,e.lane)).catch(e=>{N(`error`,`handler threw: ${T(e)}`),i(BZ(e),null,IZ)})},e=>{N(`warn`,`frame parse failed: ${e.message}`),i({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null,IZ)}),c=(n,i)=>{if(t||e.destroyed)return;clearTimeout(o),r(),e.off(`data`,s);let a=IX(e),c=dZ.subscribe(n,{lane:i,frame:(e,t)=>a(wt(wV[i](e,t))),refused:t=>e.end(Ct(t))});t=!0,e.on(`close`,c)};e.on(`data`,s),e.on(`error`,e=>{N(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(o),r()})}const IZ=()=>{},LZ=e=>({resp:e,exitAfterFlush:null,delivered:IZ}),RZ=e=>({kind:`reply`,...e}),zZ={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},BZ=e=>({ok:!1,error:e instanceof Error?e.message:T(e),code:`RENDER_FAILED`,daemonV:3}),VZ=(e,t)=>RZ(LZ({ok:!1,error:t,code:e,daemonV:3}));function HZ(e){if(typeof e.sessionId!=`string`||e.sessionId===``)return VZ(`BAD_REQUEST`,`subscribe needs a non-empty string sessionId`);if(e.lane===void 0)return VZ(`VERSION_MISMATCH`,`this client's subscribe names no lane (${Pa.join(`, `)}): it predates the lane toggles — update it`);let t=Ia(e.lane);return t===null?VZ(`BAD_REQUEST`,`subscribe needs a lane, one of ${Pa.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:e.sessionId,lane:t}}async function UZ(e,t){return!e||typeof e!=`object`||typeof e.v!=`number`?VZ(`BAD_REQUEST`,`malformed request`):e.v===3?e.kind===`subscribe`?HZ(e):typeof e.kind!=`string`||!Object.hasOwn(zZ,e.kind)?VZ(`BAD_REQUEST`,`unknown kind`):RZ(await WZ(e,t)):(e.v>3?N(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):N(`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:IZ})}async function WZ(e,t){if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,delivered:IZ};if(e.kind===`pane-session`){let{socket:t,pane:n}=e;return LZ(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:dZ.newestWhere(({hints:{tmux:e}})=>e!=null&&e.socket===t&&e.pane===n)})}if(e.kind===`stats`)return LZ({ok:!0,stats:QX.snapshot({gitCache:iZ.getStats(),usageCache:aZ.getStats(),renderCache:hZ.stats,effectCache:uZ.getStats(),sessionState:{sessions:sZ.size(),observers:sZ.observers(),revision:sZ.latestRevision()},frameFeeds:dZ.getStats(),watchersActive:nZ.size(),nextRestartReason:kZ().describeNextRestart(),handlerProbes:$X.list(),clients:eZ.list(yE(new Date)),bundle:tZ,daemon:kZ().serving()})});if(e.kind===`render`){let n=new Date,r=yE(n),i=n.getTime(),a=[],o=++QX.requestsTotal,s=tQ(e),c=(e,t)=>eZ.see(e.hookData.session_id,{client:e.hints.client??null,rateLimits:e.rateLimits,claudeConfigDir:Si(e.hints.claudeConfigDir),transcript:jk(e.hookData),frame:t},r,o);s.ok&&c(s.req,`drawing`);let l=s.ok?await sQ(s.req,o,r,a).then(({output:e,motion:t,clickShown:n})=>{c(s.req,t);let r={ok:!0,output:e};return dZ.note(s.req.hookData.session_id,s.req,o,{resp:r,drawnAt:i,moves:t===`moves`,failure:null}),{outcome:{kind:`ok`},resp:r,delivered:n===null?IZ:()=>KK(sZ,s.req.hookData.session_id,n)}},e=>(c(s.req,`failed`),{outcome:{kind:`threw`,error:e},resp:BZ(e),delivered:IZ})):nQ(s.problems);l.outcome.kind!==`ok`&&QX.requestsErrored++,GX(a,{timedOut:t()?`Y`:`N`});let{level:u,line:d}=XX(a,l.outcome,Date.now()-i);return N(u,d),{resp:l.resp,exitAfterFlush:null,delivered:l.delivered}}if(e.kind===`click`)return LZ(ZZ(e.verb,e.value,xt(e.clientVersion)));if(e.kind===`debug`){if(!MX(e.what))return LZ({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${jX.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=hZ.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?YZ(t.lastRenderCellsBySegment,t.config.globals.colorCompatibility??`truecolor`):JZ};return LZ({ok:!0,debug:bX(e.what,n)})}throw Error(`no reply for request ${T(e)}`)}function GZ(e,t){let{values:n,tokens:r}=re({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),i=[...new Set((r??[]).filter(e=>e.kind===`option`&&e.name!==`config`).map(e=>`--${e.name}`))];return{configFile:AL(t,n.config),unknownFlagsError:i.length>0?`Unknown flags: ${i.join(`, `)}`:null}}const KZ={sessionState:sZ,dlog:N,applyUpdate:()=>yZ.act(),doctor:lJ(e=>{let t=[e.projectDir,e.cwd,e.configFile??void 0];hZ.reload(...t);let n=hZ.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}}),probes:$X,clients:eZ,bundle:tZ,serving:()=>kZ().serving(),memento:oZ,claudeInput:oY(),history:cZ,navigation:lZ,configFor:e=>hZ.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>hZ.reload(e.projectDir,e.cwd,e.configFile??void 0)};KZ.reloadConfig;const qZ={endcaps:`powerline`,colorCompatibility:`truecolor`,wrap:!0,padding:1,width:1/0},JZ=new Map;function YZ(e,t){let n=new Map;for(let[r,i]of e)n.set(r,dg(i,{...qZ,colorCompatibility:t}));return n}const XZ={...rZ,history:e=>cZ.depth(e)};function ZZ(e,t,n){let r=fX.get(e);if(!r)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return r(t,{...KZ,clientVersion:n}),{ok:!0,output:``}}catch(e){let t=e instanceof q?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}async function QZ(e){let t=new Date,n=[];try{let{drawn:r,motion:i}=await rQ(e,yE(t),n,`frame`);return{resp:{ok:!0,output:iQ(r,mZ.linkFor(e.hookData.session_id,aQ(r)))},drawnAt:t.getTime(),moves:i===`moves`,failure:null}}catch(e){let{level:r,line:i}=XX(n,{kind:`threw`,error:e},Date.now()-t.getTime());return{resp:BZ(e),drawnAt:t.getTime(),moves:!1,failure:{level:r,line:`frame ${i}`}}}}function $Z(e,t){return jz(t.config,t=>sZ.get(e,t),e=>t.authoredRoots.has(e))}function eQ(e){try{var t=ZX();let n=e.hookData.session_id,r=wY(e.requested,sZ,n);return $Z(n,t.u(hZ.hold(r.projectDir,r.cwd,r.configFile??void 0)).state).lanes}catch(e){t.e=e}finally{t.d()}}function tQ(e){let{report:t}=gX(e.hookData);for(let e of t.unknownTopLevelFields)N(`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`||!x(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=ft(e),{configFile:i,unknownFlagsError:a}=GZ(e.args,e.cwd);return{ok:!0,req:{...e,hints:r,rateLimits:Ak(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,configFile:i??r.configEnv??null},unknownFlagsError:a}}}const nQ=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},delivered:IZ});async function rQ(e,t,n,r){try{var i=ZX();GX(n,{sid:e.hookData.session_id,at:t.toFixed(3)});let{unknownFlagsError:a}=e,o=e.hookData.session_id,s=e.hints,c=pt(e,s),l=mt(c);GX(n,{termCols:String(s.termCols??`?`),termRows:String(s.termRows??`?`),refused:c.map(e=>e.hint).join(`,`)||`-`,client:s.client?.kind??`unreported`,rateLimits:e.rateLimits});let u=wY(e.requested,sZ,o),{entry:d,state:f}=i.u(hZ.hold(u.projectDir,u.cwd,u.configFile??void 0)),p=s.termCols,m=NX(p??120),h=fg(s.termRows);GX(n,{width:String(m)});let g=t=>sZ.get(e.hookData.session_id,t),_=$Z(o,f);GX(n,{lanes:Pa.filter(e=>_.lanes[e]).join(`,`)||`-`});let v=await $z(e.hookData,t,{...XZ,navigation:e=>lZ.depth(e,sZ,UB(f.config))},e.cwd,f.neededInputPaths(_.preset),_,s,{...AB(f.config,f.fileHeldSettings,g),configPath:d.configLayers.includes(d.configHome)?d.configHome:null});GX(n,{prompts:String(v.metrics?.messageCount??`-`),nonPrompts:String(v.metrics?.nonPrompts??`-`),pr:Iz(v.git)});let y=[],b=Mz(_,m),x=uZ.of(o),S=LW(f.config,f.compiled,f.store,f.registry,v,t,b,{perSegmentSink:f.lastRenderCellsBySegment,onRenderWarning:e=>y.push(e)},{...Nz(_),effects:x}),C=JK(sZ,o,t,r),w=C.kind===`held`||C.kind===`owed`?C.error:null,ee=w?.text??null,te=[a,l,d.lastError,ee].filter(Boolean).join(`
489
+ `),ne=yZ.notice({sessionId:o,dismissed:sZ.get(o,YB),enabled:_.updateNotice}),T=d.lastError===null?null:d.failedFile,re=[...d.lastWarning===null?[]:[{kind:`load`,message:d.lastWarning}],...y],E=_g(te,ne,re.map(e=>e.message).join(`
490
+ `)),D=iZ.getStats(),ie=aZ.getStats(),O=x.lastFrame(),ae=O.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,oe=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,se=re.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 GX(n,{git:`${D.size}/${D.hits}h/${D.misses}m`,usage:`${ie.size}/${ie.hits}h/${ie.misses}m`,effect:O.effect,effectT:O.t.toFixed(3),effectRows:`${O.made}made/${O.reused}reused`,effectOwn:ae,fadeBasis:O.basis,stateRev:String(O.revision),fades:oe(O.fades),leaves:oe(O.leaves),motion:S.motion,err:te?`Y`:`N`,clickError:C.kind===`none`?`-`:C.kind,upd:String(ne.length),warn:se}),{drawn:{body:S.text,diagnostics:E,failedConfigFile:T,geometry:{width:m,rowCap:h,colorCompatibility:_.colorCompatibility}},motion:S.motion,clickShown:w}}catch(e){i.e=e}finally{i.d()}}function iQ(e,t){return bg(e.body,e.diagnostics,{fullText:t,failedConfigFile:e.failedConfigFile},e.geometry)+`
491
+ `}function aQ(e){return e.diagnostics===null?null:yg(e.diagnostics)}function oQ(e){let t=e.hookData.session_id,{client:n,...r}=e.hints,i=JSON.stringify(r);sZ.get(t,`client-hints`)!==i&&sZ.set(t,XY,i);let a=TY(e.requested);sZ.get(t,`render-origin`)!==a&&sZ.set(t,CY,a)}async function sQ(e,t,n,r){oQ(e);let{drawn:i,motion:a,clickShown:o}=await rQ(e,n,r,`request`),{link:s,failure:c}=mZ.sync(e.hookData.session_id,t,aQ(i));return GX(r,{dumpFailed:c===null?`-`:JSON.stringify(c)}),{output:iQ(i,s),motion:a,clickShown:o}}const cQ={connectMs:200,budgetMs:500};async function lQ(e,n){let r=n.includes(`--json`),i=await uQ(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${Pt(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
492
+ `);return}t.stdout.write(dQ(i.value))}function uQ(e){return Ot({kind:`debug`,what:e},cQ,e=>`debug`in e?e.debug:void 0)}function dQ(e){switch(e.what){case`vars`:return fQ(e.vars);case`segments`:return pQ(e.segments);case`config`:return mQ(e.config);default:return e}}function fQ(e){if(e.length===0)return`no variables (DSL not active)
493
+ `;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?``:` ${gQ(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${hQ(a.value)}${e}${o}`)}return t.join(`
495
494
  `)+`
496
- `}function eQ(e){if(e.length===0)return`no segments (DSL not active)
495
+ `}function pQ(e){if(e.length===0)return`no segments (DSL not active)
497
496
  `;let t=[`segments (${e.length})`,``];for(let n of e){t.push(` ${n.name}`),n.description!==null&&t.push(` shows ${n.description}`),t.push(` template ${n.template}`),n.referencedVars.length>0&&t.push(` vars ${n.referencedVars.join(`, `)}`);for(let{id:e,lastRender:r}of n.placements)r!==null&&t.push(` last ${e}: ${r}`)}return t.join(`
498
497
  `)+`
499
- `}function tQ(e){return e===null?`config: DSL not active
498
+ `}function mQ(e){return e===null?`config: DSL not active
500
499
  `:JSON.stringify(e,null,2)+`
501
- `}function nQ(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function rQ(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function iQ(){let e=oQ();return e===null?null:s.readFileSync(e,`utf-8`)}function aQ(){let e;try{e=iQ()}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 oQ(){let e=v.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=v.dirname(v.resolve(n));for(;;){let t=v.join(r,e);if(s.existsSync(t))return t;let n=v.dirname(r);if(n===r)return null;r=n}}function sQ(e,t){return AL(t,e.CC_CANDYBAR_CONFIG)}const cQ=5e3;function lQ(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:yj(4e5,1e6),...Pz(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:Ka(()=>!0),themeDefault:{differs:!0,theme:`<theme>`},resumeCommand:Az(o,a,void 0),configPath:t??`${r}/.config/cc-candybar/config.json5`}}function uQ(e,t){let n=mR(e,e),r=_R(n);return r!==null&&t.push(r),n.kind===`chain`?n.layers:[]}async function dQ(e,n=t.cwd()){let r=[],i=AL(n,e)??null,a=i===null?uQ(n,r):[i];if(i!==null){let e;try{e=s.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=yR(n,n);o!==null&&r.push(o);try{return{kind:`clean`,layers:a,warnings:r,rendered:await mQ(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 YE&&r.push(...e.warnings),{kind:`fatal`,layers:a,message:e instanceof YE||e instanceof Error?e.message:String(e),warnings:r})}}async function fQ(e,t,n){let r=DR(e,XR,{entered:()=>{},warned:e=>n.push(...e)},{projectDir:t,cwd:t}),{config:i}=r,a=new IW,o=new UE(a,i.globals.default_empty_value??``,void 0,new ZW);try{let s=gW(i,o,{cwd:t});n.push(...s.loadWarnings);let c=await o.settled(cQ);return c.length>0&&n.push(`source${c.length===1?``:`s`} still running after ${cQ} 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 pQ({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=new Map,l=new Set;return{rendered:CW(t,n,r,i,lQ(a,e.at(-1)??null,s),s,Mz(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:}}},Nz(a)),failures:c,advisories:l}}async function mQ(e,t,n){let r=await fQ(e,t,n),{config:i}=r,a=yE(new Date);try{let e=uV();try{UB(i),QN(i)}finally{e()}let t=z_(null,i.globals.preset,i.presets),o=(e,t)=>{let n=jz(i,t=>t===`preset`?e:null,()=>t),o;try{o=pQ(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),...R_(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(`
500
+ `}function hQ(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function gQ(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function _Q(){let e=yQ();return e===null?null:s.readFileSync(e,`utf-8`)}function vQ(){let e;try{e=_Q()}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 yQ(){let e=v.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=v.dirname(v.resolve(n));for(;;){let t=v.join(r,e);if(s.existsSync(t))return t;let n=v.dirname(r);if(n===r)return null;r=n}}function bQ(e,t){return AL(t,e.CC_CANDYBAR_CONFIG)}const xQ=5e3;function SQ(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:yj(4e5,1e6),...Pz(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:Ka(()=>!0),themeDefault:{differs:!0,theme:`<theme>`},resumeCommand:Az(o,a,void 0),configPath:t??`${r}/.config/cc-candybar/config.json5`}}function CQ(e,t){let n=mR(e,e),r=_R(n);return r!==null&&t.push(r),n.kind===`chain`?n.layers:[]}async function wQ(e,n=t.cwd()){let r=[],i=AL(n,e)??null,a=i===null?CQ(n,r):[i];if(i!==null){let e;try{e=s.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=yR(n,n);o!==null&&r.push(o);try{return{kind:`clean`,layers:a,warnings:r,rendered:await DQ(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 YE&&r.push(...e.warnings),{kind:`fatal`,layers:a,message:e instanceof YE||e instanceof Error?e.message:String(e),warnings:r})}}async function TQ(e,t,n){let r=DR(e,XR,{entered:()=>{},warned:e=>n.push(...e)},{projectDir:t,cwd:t}),{config:i}=r,a=new YW,o=new UE(a,i.globals.default_empty_value??``,void 0,new uG);try{let s=kW(i,o,{cwd:t});n.push(...s.loadWarnings);let c=await o.settled(xQ);return c.length>0&&n.push(`source${c.length===1?``:`s`} still running after ${xQ} 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 EQ({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=new Map,l=new Set;return{rendered:IW(t,n,r,i,SQ(a,e.at(-1)??null,s),s,Mz(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:}}},Nz(a)),failures:c,advisories:l}}async function DQ(e,t,n){let r=await TQ(e,t,n),{config:i}=r,a=yE(new Date);try{let e=uV();try{UB(i),QN(i)}finally{e()}let t=z_(null,i.globals.preset,i.presets),o=(e,t)=>{let n=jz(i,t=>t===`preset`?e:null,()=>t),o;try{o=EQ(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),...R_(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(`
502
501
  `)]:[]];if(p.length>0||d===void 0)throw Error(p.join(`
503
- `));return d}finally{r.registry.dispose()}}function hQ(e){return e.map(e=>`warning: ${e}\n`).join(``)}function gQ(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:hQ(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:hQ(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 _Q=`--render`,vQ=`Usage: cc-candybar check [${_Q}] [config-file]\n`;function yQ(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==_Q);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${vQ}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${vQ}`}:{kind:`run`,target:n[0],render:t.includes(_Q)}}async function bQ(e){let n=yQ(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:gQ(await dQ(n.target??sQ(t.env,t.cwd())),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const xQ=/^[a-z][a-z0-9+.-]*:\/\//i,SQ=/^[^@\s/]+@[^:\s/]+:/,CQ=/^([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;function wQ(e){if(!URL.canParse(e))return e;let t=new URL(e);return t.password===``?e:(t.password=`***`,t.href)}function TQ(e,t,n){let r=kL(t,e);if(n(r))return{kind:`path`,dir:r};if(xQ.test(e)||SQ.test(e))return{kind:`git`,url:e,shown:wQ(e)};let i=CQ.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 EQ(e,t){let n=v.join(e,aR),r=cR(n);if(`error`in r)throw Error(`${t}: could not list ${aR}: ${r.error}`);if(r.folders.length===0)throw Error(`${t} has no plugins: none at ${aR}/<name>/${NL}`);return r.folders.map(e=>v.join(n,e,NL))}function DQ(e,t,n){let r=(n,...r)=>{let i=Re({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(`
504
- `))delete i[e];r(i,`clone`,`--quiet`,`--depth`,`1`,`--filter=blob:none`,`--sparse`,`--`,e,n),r(i,`-C`,n,`sparse-checkout`,`set`,`--no-cone`,`/${aR}/`)}function OQ(e,t){switch(e.kind){case`path`:return t(e.dir);case`git`:{let n=s.mkdtempSync(v.join(w.tmpdir(),`cc-candybar-plugin-`));try{return DQ(e.url,e.shown,v.join(n,`repo`)),t(v.join(n,`repo`))}finally{s.rmSync(n,{recursive:!0,force:!0})}}}}function kQ(e){let t;try{t=s.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 AQ(e,t,n,r){switch(r){case`updated`:s.renameSync(v.join(e,NL),v.join(t,NL));return;case`replaced`:s.renameSync(t,n),s.renameSync(e,t);return;case`installed`:s.renameSync(e,t);return}}function jQ(e,t,n){let r=EQ(e,n);s.mkdirSync(t,{recursive:!0});let i=s.mkdtempSync(v.join(t,`.install-`));try{let a=r.map(e=>{let t=v.join(i,v.basename(v.dirname(e)));s.mkdirSync(t);try{s.copyFileSync(e,v.join(t,NL))}catch(e){if(e.code!==`ENOENT`)throw e}return t}),o=TR(a.map(e=>v.join(e,NL)),XR,{root:e,git:!1});if(o.length>0)throw Error(o.map(e=>`${n}: ${v.join(aR,v.relative(i,e.path))} would not load: ${e.reason.split(i).join(v.join(n,aR))}`).join(`
505
- `));let c=a.map(e=>{let n=v.basename(e),r=v.join(t,n);return{folder:e,name:n,target:r,placed:kQ(r)}}),l=[];try{for(let{folder:e,name:t,target:n,placed:r}of c)AQ(e,n,v.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:v.join(e,NL),placed:t}))}finally{s.rmSync(i,{recursive:!0,force:!0})}}function MQ(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=TQ(n,process.cwd(),FE);if(`error`in i)return console.error(`plugin install: ${i.error}`),2;try{let e=i.kind===`path`?i.dir:i.shown,t=OQ(i,t=>jQ(t,iR(),e));for(let{path:n,placed:r}of t)console.log(`${r} plugin ${v.basename(v.dirname(n))} → ${n} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}const NQ=`${Ap}${kp}`;function PQ(e){return`${NQ}⚠ cc-candybar: ${FQ(e)}${jp}\n`}function FQ(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: ${Op(e.message,60)}`;case`render_failed`:return`render failed: ${Op(e.message,60)}`;case`switched_off`:return`switched off: ${Op(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${Op(e.message,60)}`}}function IQ(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
506
- `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:PQ(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}function LQ(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 RQ=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function zQ(e,t,n){return{termCols:LQ(e.COLUMNS,n.columns),termRows:LQ(e.LINES,n.rows),ssh:RQ.some(t=>(e[t]??``)!==``),tmux:Ek(e),configEnv:sQ(e,t),claudeConfigDir:xi(e,t),mementoEnv:st(e,t),terminalEnv:lt(e)}}function BQ(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function VQ(e){let t=gJ(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=BQ(e);return n.every(e=>typeof e.ago==`number`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:Dt(e.client)??null,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age: ${JSON.stringify(e.clients)}`}}const HQ=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)};function UQ(e){let t=gJ(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=n?.postMortems;return typeof n?.pid==`number`&&typeof n.rss==`number`&&typeof n.rssLimit==`number`&&(r?.kind===`ok`&&Array.isArray(r.value)&&r.value.every(HQ)||r?.kind===`failed`&&typeof r.reason==`string`)?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function WQ(e){let t=gJ(e,[`clients`]);if(t!==null)return{kind:`failed`,reason:t};let n=BQ(e);return n.every(e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&kk.includes(e.rateLimits))?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without the rate-limit windows they carried — restart it on this build: ${JSON.stringify(e.clients)}`}}function GQ(e){let t=gJ(e,[`clients`]);if(t!==null)return{kind:`failed`,reason:t};let n=BQ(e);return n.every(e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof t?.path==`string`&&typeof t.answered==`boolean`})?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without their transcripts — restart it on this build: ${JSON.stringify(e.clients)}`}}function KQ(e){let t=gJ(e,[`clients`]);if(t!==null)return{kind:`failed`,reason:t};let n=BQ(e);return n.every(e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&Nk.includes(e.role)&&Mk.includes(e.frame))?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without what they drew — restart it on this build: ${JSON.stringify(e.clients)}`}}async function qQ(){let e=await hJ();if(e.kind!==`ok`){let t={kind:`failed`,reason:Pt(e).split(`
507
- `).join(` — `)};return{clients:t,rateLimits:t,transcripts:t,frames:t,serving:t}}return{clients:VQ(e.value),rateLimits:WQ(e.value),transcripts:GQ(e.value),frames:KQ(e.value),serving:UQ(e.value)}}const JQ=` (fix: click the settings menu (${dr} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,YQ=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${dr} by default) › 🧰 tools › 🩺 doctor`;function XQ({check:e,verdict:t}){return t.ok?`✓ ${e.label}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:JQ}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${YQ}\n`)}function ZQ(e){let t={sessionState:new ZW},n=WW(e.projectDir,e.cwd,e.configFile??void 0,t),r=n.state??GW(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 QQ(e,t){return t.kind===`failed`?t:Bq(e,t.value.bundle,t.value.clients.filter(({ago:e})=>e<=300).map(({client:e})=>e))}function $Q(e,t){return e.kind===`failed`?e:{kind:`ok`,value:e.value.filter(e=>e.ago<=300&&e.claudeConfigDir===t).map(e=>e.rateLimits)}}function e$(e){return e.kind===`failed`?e:{kind:`ok`,value:e.value.filter(e=>e.ago<=300).map(e=>e.transcript)}}function t$(e,t){return e.kind===`failed`?e:{kind:`ok`,value:e.value.filter(e=>e.ago<=300&&e.claudeConfigDir===t).map(({role:e,frame:t})=>({role:e,frame:t}))}}async function n$(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=zQ(r,i,a());s={...dJ(e,l,{projectDir:i,cwd:i,configFile:AL(i,o)??sQ(r,i)??null},()=>null,c.serving,$Q(c.rateLimits,Si(l.claudeConfigDir)),e$(c.transcripts),t$(c.frames,Si(l.claudeConfigDir))),urlHandler:await MJ(t),install:QQ(e.install,c.clients),askedBy:`command`}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=HA(s);return{stdout:c.map(XQ).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function r$(){if(t.stderr.isTTY)return t.stderr;let e;try{e=p(`/dev/tty`,`r+`)}catch{return{}}let n=new _e(e),{columns:r}=n;return n.destroy(),{columns:r}}async function i$(e){(e.length>1||e[0]===``||e[0]?.startsWith(`--`))&&(t.stderr.write(`doctor: expected at most one config file
502
+ `));return d}finally{r.registry.dispose()}}function OQ(e){return e.map(e=>`warning: ${e}\n`).join(``)}function kQ(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:OQ(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:OQ(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 AQ=`--render`,jQ=`Usage: cc-candybar check [${AQ}] [config-file]\n`;function MQ(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==AQ);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${jQ}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${jQ}`}:{kind:`run`,target:n[0],render:t.includes(AQ)}}async function NQ(e){let n=MQ(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:kQ(await wQ(n.target??bQ(t.env,t.cwd())),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const PQ=/^[a-z][a-z0-9+.-]*:\/\//i,FQ=/^[^@\s/]+@[^:\s/]+:/,IQ=/^([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;function LQ(e){if(!URL.canParse(e))return e;let t=new URL(e);return t.password===``?e:(t.password=`***`,t.href)}function RQ(e,t,n){let r=kL(t,e);if(n(r))return{kind:`path`,dir:r};if(PQ.test(e)||FQ.test(e))return{kind:`git`,url:e,shown:LQ(e)};let i=IQ.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 zQ(e,t){let n=v.join(e,aR),r=cR(n);if(`error`in r)throw Error(`${t}: could not list ${aR}: ${r.error}`);if(r.folders.length===0)throw Error(`${t} has no plugins: none at ${aR}/<name>/${NL}`);return r.folders.map(e=>v.join(n,e,NL))}function BQ(e,t,n){let r=(n,...r)=>{let i=Re({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(`
503
+ `))delete i[e];r(i,`clone`,`--quiet`,`--depth`,`1`,`--filter=blob:none`,`--sparse`,`--`,e,n),r(i,`-C`,n,`sparse-checkout`,`set`,`--no-cone`,`/${aR}/`)}function VQ(e,t){switch(e.kind){case`path`:return t(e.dir);case`git`:{let n=s.mkdtempSync(v.join(w.tmpdir(),`cc-candybar-plugin-`));try{return BQ(e.url,e.shown,v.join(n,`repo`)),t(v.join(n,`repo`))}finally{s.rmSync(n,{recursive:!0,force:!0})}}}}function HQ(e){let t;try{t=s.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 UQ(e,t,n,r){switch(r){case`updated`:s.renameSync(v.join(e,NL),v.join(t,NL));return;case`replaced`:s.renameSync(t,n),s.renameSync(e,t);return;case`installed`:s.renameSync(e,t);return}}function WQ(e,t,n){let r=zQ(e,n);s.mkdirSync(t,{recursive:!0});let i=s.mkdtempSync(v.join(t,`.install-`));try{let a=r.map(e=>{let t=v.join(i,v.basename(v.dirname(e)));s.mkdirSync(t);try{s.copyFileSync(e,v.join(t,NL))}catch(e){if(e.code!==`ENOENT`)throw e}return t}),o=TR(a.map(e=>v.join(e,NL)),XR,{root:e,git:!1});if(o.length>0)throw Error(o.map(e=>`${n}: ${v.join(aR,v.relative(i,e.path))} would not load: ${e.reason.split(i).join(v.join(n,aR))}`).join(`
504
+ `));let c=a.map(e=>{let n=v.basename(e),r=v.join(t,n);return{folder:e,name:n,target:r,placed:HQ(r)}}),l=[];try{for(let{folder:e,name:t,target:n,placed:r}of c)UQ(e,n,v.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:v.join(e,NL),placed:t}))}finally{s.rmSync(i,{recursive:!0,force:!0})}}function GQ(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=RQ(n,process.cwd(),FE);if(`error`in i)return console.error(`plugin install: ${i.error}`),2;try{let e=i.kind===`path`?i.dir:i.shown,t=VQ(i,t=>WQ(t,iR(),e));for(let{path:n,placed:r}of t)console.log(`${r} plugin ${v.basename(v.dirname(n))} → ${n} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}function KQ(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 qQ=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function JQ(e,t,n){return{termCols:KQ(e.COLUMNS,n.columns),termRows:KQ(e.LINES,n.rows),ssh:qQ.some(t=>(e[t]??``)!==``),tmux:Ek(e),configEnv:bQ(e,t),claudeConfigDir:xi(e,t),mementoEnv:st(e,t),terminalEnv:lt(e)}}function YQ(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function XQ(e){let t=kJ(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=YQ(e);return n.every(e=>typeof e.ago==`number`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:Dt(e.client)??null,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age: ${JSON.stringify(e.clients)}`}}const ZQ=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)};function QQ(e){let t=kJ(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=n?.postMortems;return typeof n?.pid==`number`&&typeof n.rss==`number`&&typeof n.rssLimit==`number`&&(r?.kind===`ok`&&Array.isArray(r.value)&&r.value.every(ZQ)||r?.kind===`failed`&&typeof r.reason==`string`)?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function $Q(e){let t=kJ(e,[`clients`]);if(t!==null)return{kind:`failed`,reason:t};let n=YQ(e);return n.every(e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&kk.includes(e.rateLimits))?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without the rate-limit windows they carried — restart it on this build: ${JSON.stringify(e.clients)}`}}function e$(e){let t=kJ(e,[`clients`]);if(t!==null)return{kind:`failed`,reason:t};let n=YQ(e);return n.every(e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof t?.path==`string`&&typeof t.answered==`boolean`})?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without their transcripts — restart it on this build: ${JSON.stringify(e.clients)}`}}function t$(e){let t=kJ(e,[`clients`]);if(t!==null)return{kind:`failed`,reason:t};let n=YQ(e);return n.every(e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&Nk.includes(e.role)&&Mk.includes(e.frame))?{kind:`ok`,value:n}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without what they drew — restart it on this build: ${JSON.stringify(e.clients)}`}}async function n$(){let e=await OJ();if(e.kind!==`ok`){let t={kind:`failed`,reason:Pt(e).split(`
505
+ `).join(` — `)};return{clients:t,rateLimits:t,transcripts:t,frames:t,serving:t}}return{clients:XQ(e.value),rateLimits:$Q(e.value),transcripts:e$(e.value),frames:t$(e.value),serving:QQ(e.value)}}const r$=` (fix: click the settings menu (${dr} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,i$=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${dr} by default) › 🧰 tools › 🩺 doctor`;function a$({check:e,verdict:t}){return t.ok?`✓ ${e.label}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:r$}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${i$}\n`)}function o$(e){let t={sessionState:new uG},n=rG(e.projectDir,e.cwd,e.configFile??void 0,t),r=n.state??iG(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 s$(e,t){return t.kind===`failed`?t:$q(e,t.value.bundle,t.value.clients.filter(({ago:e})=>e<=300).map(({client:e})=>e))}function c$(e,t){return e.kind===`failed`?e:{kind:`ok`,value:e.value.filter(e=>e.ago<=300&&e.claudeConfigDir===t).map(e=>e.rateLimits)}}function l$(e){return e.kind===`failed`?e:{kind:`ok`,value:e.value.filter(e=>e.ago<=300).map(e=>e.transcript)}}function u$(e,t){return e.kind===`failed`?e:{kind:`ok`,value:e.value.filter(e=>e.ago<=300&&e.claudeConfigDir===t).map(({role:e,frame:t})=>({role:e,frame:t}))}}async function d$(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=JQ(r,i,a());s={...wJ(e,l,{projectDir:i,cwd:i,configFile:AL(i,o)??bQ(r,i)??null},()=>null,c.serving,c$(c.rateLimits,Si(l.claudeConfigDir)),l$(c.transcripts),u$(c.frames,Si(l.claudeConfigDir))),urlHandler:await GJ(t),install:s$(e.install,c.clients),askedBy:`command`}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=HA(s);return{stdout:c.map(a$).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function f$(){if(t.stderr.isTTY)return t.stderr;let e;try{e=p(`/dev/tty`,`r+`)}catch{return{}}let n=new _e(e),{columns:r}=n;return n.destroy(),{columns:r}}async function p$(e){(e.length>1||e[0]===``||e[0]?.startsWith(`--`))&&(t.stderr.write(`doctor: expected at most one config file
508
506
  Usage: cc-candybar doctor [config-file]
509
- `),t.exit(2));let n=t.cwd(),r=await n$(Xq(ZQ),IJ(),qQ,t.env,n,r$,e[0]);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}function a$(e,t,n,r,i){let a=null,o=e=>{a===null&&(a=e,s.destroy(),i(e))},s=D.createConnection({path:e}),c={v:3,kind:`subscribe`,sessionId:t,lane:n};return s.once(`connect`,()=>s.write(Ct(c))),s.on(`data`,Tt(e=>{let t=e;!t.ok&&t.code!==`RENDER_FAILED`?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 o$(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 s$(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=a$(e,t,n,e=>{e.ok&&(s=250),r.frame(e)},e=>{if(e.kind===`closed-here`||o)return;let t=o$(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&&fn();let e=s;s=Math.min(2e3,s*2),c(e,!0);return}}})};return l(),{close:()=>{o=!0,a!==null&&clearTimeout(a),i?.close()}}}const c$=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`blackBright`,`redBright`,`greenBright`,`yellowBright`,`blueBright`,`magentaBright`,`cyanBright`,`whiteBright`];function l$(e){if(e===void 0||e.isDefault)return;let t=e.fixedValue;if(t!==void 0)return t.hex;let n=e.type===V.STANDARD&&e.number!==void 0?c$[e.number]:void 0;if(n===void 0)throw Error(`frames: no band colour for ${e.name}`);return n}const u$={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},d$=Object.keys(u$);function f$(e,t){let n=l$(t.color),r=l$(t.bgcolor),i={};for(let e of d$){if(t[e]!==!0)continue;let n=u$[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 p$=new U;function m$(e){return{kind:`bar`,rows:new ef().decode(e).map(e=>{let t=e.plain,n=[],r=0;for(let i of e.spans){if(!(i.style instanceof U))throw Error(`frames: the decoder gave a span a ${typeof i.style} style`);i.start>r&&n.push(f$(t.slice(r,i.start),p$)),n.push(f$(t.slice(i.start,i.end),i.style)),r=i.end}return r<t.length&&n.push(f$(t.slice(r),p$)),n})}}function h$(e){if(!e.ok&&e.code===`SWITCHED_OFF`)return JSON.stringify({kind:`off`,reason:e.error});let t=IQ(zt(e)).output;try{return JSON.stringify(m$(t))}catch(e){let t=Dp(e instanceof Error?e.message:String(e));return JSON.stringify(m$(`${Ap}${kp}⚠ cc-candybar ${t}${jp}\n`))}}const g$={response:e=>JSON.stringify(e),band:h$};function _$(e){return Object.hasOwn(g$,e)}function v$(e,t){return t.kind===`frame`||t.kind!==e.kind?!0:t.kind===`fault`&&e.kind===`fault`&&t.reason!==e.reason}async function y$(e,n){let{values:r,tokens:i}=re({args:e.slice(3),options:{session:{type:`string`},config:{type:`string`},lane:{type:`string`},format:{type:`string`,default:`response`}},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`)};r.session===``&&(s(`--session needs a session id`),t.exit(2));let c=Ia(r.lane);c===null&&(s(`--lane needs one of ${Pa.join(`, `)}`),t.exit(2)),_$(r.format)||(s(`--format must be one of ${Object.keys(g$).join(`, `)}, got ${JSON.stringify(r.format)}`),t.exit(2));let l=g$[r.format];r.session!==void 0&&r.config!==void 0&&(s(`--config has no effect with --session: the session's own statusline client sends its config`),t.exit(2)),t.stdout.on(`error`,()=>t.exit(0));let u=CX(t.stdout),d=r.session??null,f=null,p=null,m={kind:`none`},h=(e,t)=>{v$(m,e)&&t(),m=e},g=async e=>{let r=await Bt(e,a,o,{...zQ(t.env,o,t.stderr),client:A(`frames`,n)});r.kind!==`ok`&&(s(Pt(r)),r.kind===`transient`&&fn())},_=e=>{p?.close(),p=s$(Ke(),e,c,{frame:e=>h({kind:`frame`},()=>u(`${l(e)}\n`)),off:e=>h({kind:`off`},()=>u(`${l(e)}\n`)),fault:(e,t)=>h({kind:`fault`,reason:e},()=>s(`${e}; reconnecting in ${t}ms`)),exit:e=>{s(e),t.exit(1)},beforeReconnect:()=>f===null?Promise.resolve():g(f)})};if(d!==null){_(d);return}for await(let e of ge({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}f=t,await g(t),t.session_id!==d&&(d=t.session_id,_(d))}t.exit(0)}function b$(e){let t=e.replace(/\n+$/,``).split(`
510
- `);return{bytes:t.map((e,t)=>`\x1b[${t+1}H${e}`).join(``)+`\x1B[J`,rows:t.length}}const x$=5e3,S$=`usage: cc-candybar bar-pane <claude-code-pane-id, e.g. %3>`;function C$(e,t,n,r){let i=e.split(`
511
- `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?DX(e,EX(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function w$(e,t){let[n,r]=await Promise.all([lH(e,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${t}},#{==:#{pane_id},${e.pane}}}`,`-F`,wX]),lH(e,`bar-pane.tmux`,[`list-clients`,`-F`,TX])]);return n.kind===`ok`?r.kind===`ok`?{kind:`ok`,placement:C$(n.stdout,r.stdout,t,e.pane)}:r:n}function T$(){let e=Date.now();return t=>{if(t.kind===`ok`)e=Date.now();else if(Date.now()-e>x$)throw Error(`tmux has not answered for ${x$/1e3} s: ${t.reason}`)}}function E$(e){let{positionals:t}=(()=>{try{return re({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${S$}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(S$);return{pane:n}}async function D$(e){try{return await O$(e),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function O$(e){let{pane:n}=E$(e),r=Ek(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 w$(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=T$(),f=async()=>{if(a.kind!==`shown`)return;let e=b$(l());e.rows!==t.stdout.rows&&!a.zoomed&&d(await lH(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:s$(Ke(),e,`pane`,{frame:e=>n(IQ(zt(e)).output),off:e=>n(e.error),fault:n,exit:e=>o(Error(e))})}},_=T$();for(;a.kind!==`gone`;){if(a.kind===`hidden`)g(null);else{let e=await Vt(r.socket,n);e.kind===`ok`?(g(e.value),c=e.value===null?`waiting for pane ${n}'s statusline to render on ${Ke()}`:`waiting for pane ${n}'s bar`):(e.kind===`transient`&&(fn(),u=``),c=Pt(e))}h(),await he(500);let e=await w$(r,n);_(e),e.kind===`ok`&&(a=e.placement)}g(null),t.stderr.write(`cc-candybar bar-pane: pane ${n} closed\n`)}const k$=i(import.meta.url),A$=e=>e.some(e=>t.argv.includes(e));function j$(){console.log(Ck)}async function M$(){try{A$(xk.help)&&(j$(),t.exit(0)),A$(xk.version)&&(console.log(`cc-candybar ${Ft}`),t.exit(0));let e=t.argv[2];if(e===`install`&&(await ca(t.argv.slice(3),k$),t.exit(0)),e===`install-url-handler`&&(ra(k$),t.exit(0)),e===`url-handle`){await aa(t.argv[3]);return}if(e===`daemon`){uZ();return}if(e===`daemon-stats`&&(await mJ(t.argv.slice(3)),t.exit(0)),e===`frames`){await y$(t.argv,k$);return}if(e===`check`||e===`lint`){await bQ(t.argv.slice(3));return}if(e===`plugin`&&t.exit(MQ(t.argv.slice(3))),e===`schema`){aQ();return}if(e===`doctor`){await i$(t.argv.slice(3));return}e===`bar-pane`&&t.exit(await D$(t.argv.slice(3))),yX(e)&&(await XZ(e,t.argv.slice(3)),t.exit(0)),t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
507
+ `),t.exit(2));let n=t.cwd(),r=await d$(lJ(o$),YJ(),n$,t.env,n,f$,e[0]);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}function m$(e){return!e.ok&&e.code!==`RENDER_FAILED`}function h$(e,t,n,r,i){let a=null,o=e=>{a===null&&(a=e,s.destroy(),i(e))},s=D.createConnection({path:e}),c={v:3,kind:`subscribe`,sessionId:t,lane:n};return s.once(`connect`,()=>s.write(Ct(c))),s.on(`data`,Tt(e=>{let t=e;m$(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 g$(e,t){switch(t){case`frame-ok`:return 250;case`frame-failed`:return e;case`fault`:return Math.min(2e3,e*2)}}function _$(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 v$(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=h$(e,t,n,e=>{s=g$(s,e.ok?`frame-ok`:`frame-failed`),r.frame(e)},e=>{if(e.kind===`closed-here`||o)return;let t=_$(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&&fn();let e=s;s=g$(s,`fault`),c(e,!0);return}}})};return l(),{close:()=>{o=!0,a!==null&&clearTimeout(a),i?.close()}}}function y$(e,t){return t.kind===`frame`||t.kind!==e.kind?!0:t.kind===`fault`&&e.kind===`fault`&&t.reason!==e.reason}async function b$(e,n){let{values:r,tokens:i}=re({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=Ia(r.lane);c===null&&(s(`--lane needs one of ${Pa.join(`, `)}`),t.exit(2)),t.stdout.on(`error`,()=>t.exit(0));let l=IX(t.stdout),u=null,d=null,f=null,p={kind:`none`},m=(e,t)=>{y$(p,e)&&t(),p=e},h=async e=>{let r=await Bt(e,a,o,{...JQ(t.env,o,t.stderr),client:A(`frames`,n)});r.kind!==`ok`&&(s(Pt(r)),r.kind===`transient`&&fn())},g=e=>{f?.close(),f=v$(Ke(),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 ge({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 x$(e){let t=e.replace(/\n+$/,``).split(`
508
+ `);return{bytes:t.map((e,t)=>`\x1b[${t+1}H${e}`).join(``)+`\x1B[J`,rows:t.length}}const S$=5e3,C$=`usage: cc-candybar bar-pane <claude-code-pane-id, e.g. %3>`;function w$(e,t,n,r){let i=e.split(`
509
+ `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?BX(e,zX(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function T$(e,t){let[n,r]=await Promise.all([SH(e,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${t}},#{==:#{pane_id},${e.pane}}}`,`-F`,LX]),SH(e,`bar-pane.tmux`,[`list-clients`,`-F`,RX])]);return n.kind===`ok`?r.kind===`ok`?{kind:`ok`,placement:w$(n.stdout,r.stdout,t,e.pane)}:r:n}function E$(){let e=Date.now();return t=>{if(t.kind===`ok`)e=Date.now();else if(Date.now()-e>S$)throw Error(`tmux has not answered for ${S$/1e3} s: ${t.reason}`)}}function D$(e){let{positionals:t}=(()=>{try{return re({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${C$}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(C$);return{pane:n}}async function O$(e){try{return await k$(e),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function k$(e){let{pane:n}=D$(e),r=Ek(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 T$(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=E$(),f=async()=>{if(a.kind!==`shown`)return;let e=x$(l());e.rows!==t.stdout.rows&&!a.zoomed&&d(await SH(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:v$(Ke(),e,`pane`,{frame:e=>n(hV(zt(e)).output),off:e=>n(e.error),fault:n,exit:e=>o(Error(e))})}},_=E$();for(;a.kind!==`gone`;){if(a.kind===`hidden`)g(null);else{let e=await Vt(r.socket,n);e.kind===`ok`?(g(e.value),c=e.value===null?`waiting for pane ${n}'s statusline to render on ${Ke()}`:`waiting for pane ${n}'s bar`):(e.kind===`transient`&&(fn(),u=``),c=Pt(e))}h(),await he(500);let e=await T$(r,n);_(e),e.kind===`ok`&&(a=e.placement)}g(null),t.stderr.write(`cc-candybar bar-pane: pane ${n} closed\n`)}const A$=i(import.meta.url),j$=e=>e.some(e=>t.argv.includes(e));function M$(){console.log(Ck)}const N$={install:async e=>{await ca(e,A$),t.exit(0)},"install-url-handler":async()=>{ra(A$),t.exit(0)},"url-handle":async e=>{await aa(e[0])},daemon:async()=>{CZ()},"daemon-stats":async e=>{await DJ(e),t.exit(0)},frames:async()=>{await b$(t.argv,A$)},check:async e=>{await NQ(e)},lint:async e=>{await NQ(e)},plugin:async e=>{t.exit(GQ(e))},schema:async()=>{vQ()},doctor:async e=>{await p$(e)},"bar-pane":async e=>{t.exit(await O$(e))},...Object.fromEntries(jX.map(e=>[e,async n=>{await lQ(e,n),t.exit(0)}]))};async function P$(){try{let e=t.argv[2],n=e!==void 0&&!e.startsWith(`-`)?e:null;if(n!==null&&!Object.hasOwn(N$,n)&&(console.error(`cc-candybar: unknown subcommand ${JSON.stringify(n)} — see --help`),t.exit(2)),j$(xk.help)&&(M$(),t.exit(0)),j$(xk.version)&&(console.log(`cc-candybar ${Ft}`),t.exit(0)),n!==null){await N$[n](t.argv.slice(3));return}t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
512
510
 
513
511
  cc-candybar is designed to be used as a Claude Code statusLine command.
514
512
  It reads hook data from stdin and outputs formatted statusline.
@@ -524,4 +522,4 @@ Add to ~/.claude/settings.json:
524
522
  Run with --help for more options.
525
523
 
526
524
  To test output manually:
527
- echo '{"session_id":"test-session","workspace":{"project_dir":"/path/to/project"},"model":{"id":"claude-sonnet-4-5","display_name":"Claude"}}' | cc-candybar`),t.exit(1)),k(`Working directory: ${t.cwd()}`),k(`Process args:`,t.argv);let n=await o(t.stdin);k(`Received hook data:`,JSON.stringify(n,null,2)),n||(console.error(`Error: No input data received from stdin`),j$(),t.exit(1));let r=IQ(await Bt(n,t.argv,t.cwd(),{...zQ(t.env,t.cwd(),t.stderr),client:A(`node`,k$)}));r.debug!==null&&k(r.debug),r.kick&&fn(),t.stdout.write(r.output),t.exit(0)}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`Error generating statusline:`,n),t.exit(1)}}M$();export{};
525
+ echo '{"session_id":"test-session","workspace":{"project_dir":"/path/to/project"},"model":{"id":"claude-sonnet-4-5","display_name":"Claude"}}' | cc-candybar`),t.exit(1)),k(`Working directory: ${t.cwd()}`),k(`Process args:`,t.argv);let r=await o(t.stdin);k(`Received hook data:`,JSON.stringify(r,null,2)),r||(console.error(`Error: No input data received from stdin`),M$(),t.exit(1));let i=hV(await Bt(r,t.argv,t.cwd(),{...JQ(t.env,t.cwd(),t.stderr),client:A(`node`,A$)}));i.debug!==null&&k(i.debug),i.kick&&fn(),t.stdout.write(i.output),t.exit(0)}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`Error generating statusline:`,n),t.exit(1)}}P$();export{};