@promptctl/cc-candybar 1.152.0 → 1.152.2

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 +25 -25
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i,pathToFileURL as a}from"node:url";import{json as o}from"node:stream/consumers";import s,{basename as c,dirname as l,isAbsolute as u,join as d,sep as f}from"node:path";import p,{closeSync as m,constants as h,existsSync as g,fstatSync as _,openSync as v,readSync as y,realpathSync as b,statSync as ee,watch as x}from"node:fs";import S,{homedir as te}from"node:os";import{spawn as ne,spawnSync as re}from"node:child_process";import{inspect as ie,parseArgs as ae,types as oe}from"node:util";import C from"node:net";import w from"node:v8";import{open as se,readFile as T,readdir as ce,stat as le}from"node:fs/promises";import ue,{createHash as de,randomUUID as fe}from"node:crypto";import{clearInterval as pe,setImmediate as me,setInterval as he}from"node:timers";import{get as ge}from"node:https";import{setTimeout as _e}from"node:timers/promises";import{WriteStream as ve}from"node:tty";import{createInterface as ye}from"node:readline";var be=Object.create,xe=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyNames,we=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty,Ee=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),De=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ce(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Te.call(e,s)&&s!==n&&xe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Se(t,s))||r.enumerable});return e},Oe=(e,t,n)=>(n=e==null?{}:be(we(e)),De(t||!e||!e.__esModule?xe(n,`default`,{value:e,enumerable:!0}):n,e));function E(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}const ke=(e,t)=>E(t),Ae=`cc-extra`;function je(e){return s.join(s.dirname(e),Ae,`src`,`bun-attach.js`)}function Me(e){return s.join(s.dirname(e),`bun-graph.js`)}function Ne(e,t){return oe.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!g(t)?`working directory does not exist: ${t}`:e.message:String(e)}const Pe={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3},Fe=new Map;function Ie(e){let t=Pe[e];if(t===void 0)return{allowed:!0};let n=Fe.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 Le(e){Fe.set(e,Date.now())}function Re(e){return e.env??process.env}function ze(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 Be=null;function Ve(e){Be=e}function He(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Ue(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=Ie(e.category);if(!t.allowed)return ze(e.category,t.minIntervalMs,t.sinceLastMs);Le(e.category);let n=Date.now();return Be?.onStart(e.category),new Promise(t=>{let r;try{r=ne(e.bin,e.args??[],{cwd:e.cwd,env:Re(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){Be?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:Ne(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),Be?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{He(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:Ne(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 We(e){let t=Ie(e.category);if(!t.allowed)return ze(e.category,t.minIntervalMs,t.sinceLastMs);Le(e.category);let n=Date.now();Be?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=re(e.bin,e.args??[],{cwd:e.cwd,env:Re(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});Be?.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:Ne(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 Be?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:Ne(t,e.cwd)}}}function Ge(e){let t=Ie(e.category);if(!t.allowed)return ze(e.category,t.minIntervalMs,t.sinceLastMs);Le(e.category);let n=Date.now();Be?.onStart(e.category);let r=Ke(e);return Be?.onEnd(e.category,Date.now()-n),r}function Ke(e){let t;try{t=ne(e.bin,e.args??[],{cwd:e.cwd,env:Re(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:Ne(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 qe(e,t,n){let r=Je(e);p.mkdirSync(s.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??p.statSync(r,{throwIfNoEntry:!1})?.mode;try{p.writeFileSync(i,t,a===void 0?{}:{mode:a}),p.renameSync(i,r)}catch(e){throw p.rmSync(i,{force:!0}),e}}function Je(e){let t=e;for(let e=0;e<Ye;e++){let e;try{e=p.lstatSync(t)}catch(e){if(e.code===`ENOENT`)return t;throw e}if(!e.isSymbolicLink())return t;t=s.resolve(p.realpathSync(s.dirname(t)),p.readlinkSync(t))}throw Error(`${e}: more than ${Ye} symbolic links`)}const Ye=40;function Xe(e,t){let n=e[t];return n&&n.length>0?n:void 0}function Ze(e=process.env){let t=Xe(e,`XDG_STATE_HOME`)??s.join(S.homedir(),`.local`,`state`);return s.join(t,`cc-candybar`)}function Qe(){let e=Xe(process.env,`XDG_CACHE_HOME`)??s.join(S.homedir(),`.cache`);return s.join(e,`cc-candybar`)}function $e(){return Ze()}function et(){return process.env.CC_CANDYBAR_SOCKET||tt()}function tt(){let e=S.userInfo().uid;return s.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function nt(e){p.mkdirSync(e,{recursive:!0,mode:448});let t=p.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=S.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 rt(e){nt(s.dirname(e));for(let t of[e,it(e)])try{if(p.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function it(e){return`${e}.lease`}function at(){return it(et())}function ot(){return s.join(Ze(),`session-state.json`)}function st(){return s.join(Ze(),`settings-history.json`)}function ct(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=S.userInfo().uid;return s.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function lt(){return s.join(Ze(),`spawn.lock`)}function ut(){return s.join(Ze(),`spawn.cooldown`)}function dt(){return s.join(Ze(),`spawn.backoff`)}function ft(){return s.join(Ze(),`diagnostics`)}function pt(e=process.env){return s.join(Ze(e),`daemon.log`)}const D=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function mt(e,t){return Object.fromEntries(D.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,s.resolve(t,r)]]}))}const ht=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function gt(e){return Object.fromEntries(ht.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const _t=[`native`,`node`,`frames`];function O(e,t){return{kind:e,bundle:t,source:null}}const vt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,mementoEnv:!0,terminalEnv:!0,client:!0});function yt(e){let t=kt(e.termCols),n=kt(e.termRows),r=At(e.ssh),i=Dt(e.tmux),a=Et(e.configEnv),o=Et(e.claudeConfigDir),s=wt(e.mementoEnv),c=Tt(e.terminalEnv),l=Lt(e.client);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{mementoEnv:s},...c!==void 0&&{terminalEnv:c},...l!==void 0&&{client:l}}}function bt(e,t){return vt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function xt(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}const St={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Ct(e){let t=Object.keys(St).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[St[t](n.join(`, `))]});return t.length===0?null:t.join(`
3
- `)}function wt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=D.filter(e=>t[e]!==void 0);return n.every(e=>Et(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function Tt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ht.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 Et(e){return typeof e==`string`&&s.isAbsolute(e)?e:void 0}function Dt(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 Ot=1e4;function kt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>Ot?Ot:t}function At(e){return typeof e==`boolean`?e:void 0}function jt(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var Mt=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Nt(e){return Pt(JSON.stringify(e))}function Pt(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Ft(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 Mt(`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 Mt(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function It(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=Ft(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(Nt(t))})}function Lt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=Et(n);return _t.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function Rt(e,t,n){let r=null;try{r=await Ut(et(),t.connectMs);let i=await It(r,{v:3,...e},t.budgetMs);return Vt(e.kind,i,n)}catch(e){return Ht(e)}finally{r&&r.destroy()}}function zt(e,t){return typeof e==`string`?e:t}function Bt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function Vt(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=zt(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:Bt(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 Ht(e){if(e instanceof Mt||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 Ut(e,t){return new Promise((n,r)=>{let i=C.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 Wt(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 Gt=`1.152.0`,k={connectMs:50,budgetMs:150},Kt={connectMs:50,budgetMs:200};function qt(e){let t=e.output;return typeof t==`string`?t:void 0}function Jt(e){return Vt(`render`,e,qt)}function Yt(e,t,n,r){return Rt({kind:`render`,hookData:e,args:t,cwd:n,...r},k,qt)}function Xt(e,t){return Rt({kind:`pane-session`,socket:e,pane:t},Kt,e=>`paneSession`in e?e.paneSession:void 0)}function Zt(e,t){return Rt({kind:`click`,verb:e,value:t,clientVersion:Gt},Kt,qt)}let A=null;function Qt(e){if(A!==null)return A;p.mkdirSync(s.dirname(e),{recursive:!0});try{A=p.statSync(e).size}catch{A=0}return A}function $t(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,r=`${e}.${t+1}`;try{p.renameSync(n,r)}catch{}}try{p.renameSync(e,`${e}.1`)}catch{}A=0}function j(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=pt(),t=Qt(e);p.appendFileSync(e,n),A=t+Buffer.byteLength(n,`utf8`),A>=5242880&&$t(e)}catch(e){A=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}const en=5e3;function tn(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
+ `)}function wt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=D.filter(e=>t[e]!==void 0);return n.every(e=>Et(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function Tt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ht.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 Et(e){return typeof e==`string`&&s.isAbsolute(e)?e:void 0}function Dt(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 Ot=1e4;function kt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>Ot?Ot:t}function At(e){return typeof e==`boolean`?e:void 0}function jt(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var Mt=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Nt(e){return Pt(JSON.stringify(e))}function Pt(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Ft(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 Mt(`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 Mt(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function It(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=Ft(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(Nt(t))})}function Lt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=Et(n);return _t.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function Rt(e,t,n){let r=null;try{r=await Ut(et(),t.connectMs);let i=await It(r,{v:3,...e},t.budgetMs);return Vt(e.kind,i,n)}catch(e){return Ht(e)}finally{r&&r.destroy()}}function zt(e,t){return typeof e==`string`?e:t}function Bt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function Vt(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=zt(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:Bt(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 Ht(e){if(e instanceof Mt||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 Ut(e,t){return new Promise((n,r)=>{let i=C.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 Wt(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 Gt=`1.152.2`,k={connectMs:50,budgetMs:150},Kt={connectMs:50,budgetMs:200};function qt(e){let t=e.output;return typeof t==`string`?t:void 0}function Jt(e){return Vt(`render`,e,qt)}function Yt(e,t,n,r){return Rt({kind:`render`,hookData:e,args:t,cwd:n,...r},k,qt)}function Xt(e,t){return Rt({kind:`pane-session`,socket:e,pane:t},Kt,e=>`paneSession`in e?e.paneSession:void 0)}function Zt(e,t){return Rt({kind:`click`,verb:e,value:t,clientVersion:Gt},Kt,qt)}let A=null;function Qt(e){if(A!==null)return A;p.mkdirSync(s.dirname(e),{recursive:!0});try{A=p.statSync(e).size}catch{A=0}return A}function $t(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,r=`${e}.${t+1}`;try{p.renameSync(n,r)}catch{}}try{p.renameSync(e,`${e}.1`)}catch{}A=0}function j(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=pt(),t=Qt(e);p.appendFileSync(e,n),A=t+Buffer.byteLength(n,`utf8`),A>=5242880&&$t(e)}catch(e){A=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}const en=5e3;function tn(e){let t=[];for(let n of e){let e=n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
4
4
  `)}const nn=`/usr/bin/footprint`;function rn(e,t){return e===`darwin`?[cn(nn,[`-p`,String(t)]),cn(`/usr/bin/vmmap`,[`--summary`,String(t)])]:e===`linux`?[ln(`/proc/self/smaps_rollup`),ln(`/proc/self/status`)]:[]}function an(e,t){return e===`darwin`?on(t,e=>Ue({bin:nn,args:e,timeoutMs:en,category:`limits.charge`})):async e=>({kind:`charged`,measure:`rss`,bytes:e})}function on(e,t){return async n=>{let r=await t([`-p`,String(e),`--noCategories`,`-f`,`bytes`]);if(!r.ok)return{kind:`stand-in`,bytes:n,unread:`footprint ${r.reason}${r.error===void 0?``:`: ${r.error}`}${un(r.stderr)}`};let i=sn(r.stdout);return i===null?{kind:`stand-in`,bytes:n,unread:`footprint printed no phys_footprint line`}:{kind:`charged`,measure:`phys_footprint`,bytes:i}}}function sn(e){let t=/^\s*phys_footprint:\s+(\d+) B\s*$/m.exec(e);return t===null?null:Number(t[1])}function cn(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=We({bin:e,args:[...t],timeoutMs:en,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}`}${un(n.stderr)}`}}}}function ln(e){return{name:e,read:()=>{try{let t=p.readFileSync(e,`utf8`);return t.trim().length>0?{kind:`text`,text:t}:{kind:`unavailable`,reason:`empty file`}}catch(e){return{kind:`unavailable`,reason:e.message}}}}}function un(e){let t=e.split(`
5
5
  `).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const dn=`CC_CANDYBAR_RSS_LIMIT_MB`;function fn(e){let t=e[dn];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${dn} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function pn(e){return fn(e)*2}const mn=1024*1024,hn=e=>Math.round(e/mn);function gn(e){return fn(e)*mn}const _n={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function vn(e,t){return e>t}function yn(e,t){return e>t*.75}function bn(e,t,n){let{prefix:r,suffix:i}=_n[t];return s.join(e,`${r}${n}${i}`)}function xn(e){for(let t of Object.keys(_n)){let{prefix:n,suffix:r}=_n[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function Sn(e){let t=e.limitBytes??512*mn,n=e.snapshotsKeep??3,r=!1,i={kind:`unmeasured`},a=null;function o(){return a??=s().finally(()=>{a=null}),a}async function s(){if(r)return!0;let{rss:a,heapTotal:o}=e.memoryBytes(),s=await e.memoryCharge(a),c={kind:`measured`,charge:s,rss:a,heapTotal:o};if(i=c,e.log(`info`,`memory ${Tn(c,t)}`),s.bytes<=t)return!1;r=!0,e.log(`warn`,`${Cn(s)} > limit ${hn(t)} MB (rss ${hn(a)} MB, v8 heap ${hn(o)} MB); recording memory then shutting down`);let l=`${new Date(e.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return En(e.log,`memory report`,()=>{let t=bn(e.snapshotDir,`memoryReport`,l);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),En(e.log,`heap snapshot`,()=>{let t=bn(e.snapshotDir,`heapSnapshot`,l);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),En(e.log,`artifact rotation`,()=>{for(let{artifacts:t}of M(e.listArtifacts()).slice(n))for(let n of Object.values(t))En(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0}function c(){return i.kind===`measured`&&yn(i.charge.bytes,t)?`${Cn(i.charge)} approaching limit ${hn(t)} MB (v8 heap ${hn(i.heapTotal)} MB)`:null}function l(){let n;try{n={kind:`ok`,value:M(e.listArtifacts())}}catch(e){n={kind:`failed`,reason:e.message}}return{pid:e.pid,memory:i,limit:t,postMortems:n}}function u(t=6e4){let n,r=!0,i=async()=>{try{if(await o())return}catch(t){e.log(`warn`,`memory check failed: ${t.message}`)}r&&(n=setTimeout(()=>void i(),t),n.unref())};return i(),{disarm:()=>{r=!1,clearTimeout(n)}}}return{check:o,describeNextRestart:c,serving:l,arm:u}}function Cn(e){return e.kind===`charged`?`${e.measure} ${hn(e.bytes)} MB`:`rss ${hn(e.bytes)} MB (standing in: ${e.unread})`}function wn(e){return e.kind===`charged`?e.measure:`rss-stand-in`}function Tn({charge:e,rss:t,heapTotal:n},r){let i=e.kind===`stand-in`?` unread=${JSON.stringify(e.unread)}`:``;return`measure=${wn(e)} charge=${hn(e.bytes)}MB rss=${hn(t)}MB heap=${hn(n)}MB limit=${hn(r)}MB${i}`}function En(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function M(e){let t=new Map;for(let n of e){let e=s.basename(n),r=xn(e);if(r===null)continue;let{prefix:i,suffix:a}=_n[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(_n);return[...t].sort(([e],[t])=>vn(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=$e();return{now:()=>Date.now(),pid:process.pid,snapshotDir:r,log:j,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},memoryCharge:an(process.platform,process.pid),captureMemoryReport:()=>tn(rn(process.platform,process.pid)),writeMemoryReport:(e,t)=>p.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>w.writeHeapSnapshot(e),listArtifacts:()=>{let e;try{e=p.readdirSync(r)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>xn(e)!==null).map(e=>s.join(r,e))},removeFile:e=>p.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function On(e={}){if(Wn()!==null)return;let n=e.spawn??Gn,r=Vn();if(r.kind===`contended`){let e=An();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),kn(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),kn(n);return}try{kn(n)}finally{Un()}}function kn(e){Ln()&&jn(e)}function An(){try{let e=p.statSync(lt());return Date.now()-e.mtimeMs}catch{return null}}function jn(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
6
6
  `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function Mn(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function Nn(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function Pn(e){try{let t=p.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function Fn(e,n){try{p.mkdirSync(s.dirname(e),{recursive:!0}),p.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function In(){try{p.unlinkSync(dt())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function Ln(){let e=ut(),n=dt(),r=Pn(n),i=Mn(Rn(e),Nn(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`),zn(e),Fn(n,Math.min(r+1,5)),!0)}function Rn(e){try{return Date.now()-p.statSync(e).mtimeMs}catch{return null}}function zn(e){try{p.mkdirSync(s.dirname(e),{recursive:!0}),p.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 Bn=null;function Vn(){let e=lt();for(let n=0;n<2;n++){try{let n=p.openSync(e,`wx`,384);try{p.writeSync(n,JSON.stringify({pid:t.pid,ts:Date.now()}))}catch{}return Bn={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(!Hn(e))return{kind:`contended`};try{p.unlinkSync(e)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function Hn(e){try{let t=p.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function Un(){if(!Bn)return;let{fd:e,path:t}=Bn;Bn=null;try{p.closeSync(e)}catch{}try{p.unlinkSync(t)}catch{}}function Wn(){try{return p.mkdirSync($e(),{recursive:!0}),null}catch(e){return`mkdir ${$e()}: ${e.message}`}}function Gn(){let e=t.execPath,n=t.argv[1];return n?Ge({bin:e,args:[`--max-old-space-size=${pn(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const Kn=`cc-candybar`,qn=`dispatch`,Jn=`set-state`,Yn=`step-state`,Xn=`copy`,Zn=`open-vscode`,Qn=`toolbar-toggle`,$n=`show-config-error`,er=`show-config-warning`,tr=`set-config`,nr=`step-config`,rr=`save`,ir=`save-preset`,ar=`save-theme-default`,or=`delete-preset`,sr=`reset-config`,cr=`apply-layout-op`,lr=`undo`,ur=`redo`,dr=`back`,fr=`rewind`,pr=`apply-update`,mr=`doctor-run`,hr=`doctor-fix`,gr=`doctor-mark`,_r=`doctor-probe`,vr=`ceiling`,yr=`slash`;function br(e){return e.map(encodeURIComponent).join(`/`)}function xr(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function Sr(e){return`${Kn}://${qn}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${br(e.args)}`)}`).join(`&`)}`}function Cr(e){return new r(e).getAll(`e`).map(Dr)}const wr=new Set([Jn,sr]);function Tr(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&Er(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function Er(e,t){if(e.verb!==t.verb||!wr.has(e.verb))return;let[n,r]=[Dr(e.value),Dr(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function Dr(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const Or=`closed`,kr=`🍫`;function Ar(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 jr(e,t,n,r){let i=Ar(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 Nr(e,t,n,r,i){return{kind:`segment`,name:e,opens:{ref:t,body:n,placement:r},...i!==void 0&&{when:i}}}function Pr(e,...t){return`{{ and ${[e,...t].map(Fr).join(` `)} }}`}function Fr(e){return`(eq .${e.variable} "${Mr(e.member)}")`}function Ir(e,t,n){return`{{ ${Lr(e,Rr(t),Rr(n))} }}`}function Lr(e,t,n){return`action "${e}" ${t} ${n}`}function Rr(e){return`"${Mr(e)}"`}function zr(e,t){return{kind:`state`,key:e,default:t}}function Br(e,t){return{set:e,cycle:[Or,t]}}const Vr=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Hr(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Ur(e){return Vr.test(e)?e:Hr(e)}var Wr=Ee(((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]/})),Gr=Ee(((e,t)=>{let n=Wr();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)}}})),Kr=Ee(((e,t)=>{let n=Gr(),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(),ie[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=ee[p]();if(e)return e}}function y(){if(r[o])return String.fromCodePoint(r.codePointAt(o))}function b(){let e=y();return e===`
@@ -57,7 +57,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
57
57
  `)}function Vv(e,t,n,r){if(t===null)return e;let i=Wv(r),a=Uv(t,i),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[Kv(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
58
58
  `);return e?`${l}\n${e}`:l}function Hv(e,t){return Uv(e,Wv(t)).join(`
59
59
  `)}function Uv(e,t){return e.channels.flatMap(e=>Gv(e,t))}function Wv(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,colorCompatibility:e.colorCompatibility}}function Gv(e,t){let n=new H({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=Mo(Math.max(2,t.width-1)),i=(e,t)=>new G(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>jv([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=>Lo(e,r)).map(e=>i(e,t))})],t).split(`
60
- `))}function Kv(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:o,failedConfigFile:s}=t,c=new H({bgcolor:i.bg,color:i.fg}),l=(e,t)=>new G(e,{style:t,end:``,overflow:`ignore`}),u=n>0?[l(`${n} more rows · `,c),o.kind===`file`?l(`open full text`,c.withLink(a(o.path).href)):l(`full text unavailable: ${Q_(o.reason)}`,c)]:[],d=s===null?[]:[l(`${u.length>0?` · `:``}open `,c),l(Q_(s),c.withLink(a(s).href))],f=[l(`↳ `,c),...u,...d.slice(0,-1)],p=f.reduce((e,t)=>e+t.cellLength,0),m=d.slice(-1).map(e=>e.truncate(Math.max(1,r.width-p),{mode:`middle`})),h=G.fromFragments([...f,...m]).truncate(r.width);return h.overflow=`ignore`,jv([h],r)}const qv=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Jv(e,t){return t.isSymbolicLink()?Buffer.from(p.readlinkSync(e)):p.readFileSync(e)}function Yv(e,t,n=qv){return p.readdirSync(t).filter(n).sort().flatMap(n=>{let r=s.join(t,n),i=p.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Yv(e,r):[[s.relative(e,r).split(s.sep).join(`/`),Jv(r,i)]]})}function Xv(e){let t=ue.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Zv(e){return Xv(Yv(e,e))}const Qv=[`Cargo.toml`,`Cargo.lock`,`src`];function $v(e){return Xv(Yv(e,e,e=>Qv.includes(e)))}const ey=e=>e.slice(0,7);function ty(e){let t=s.dirname(s.dirname(e));return p.existsSync(s.join(t,`src`))?t:null}function ny(){let e=ry();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:Gt,digest:e}}function ry(){return`918356c079174da2fce879239ea9698accaa5566af4666a8f4300f0365fe614b`}function iy(e){let t=JSON.parse(p.readFileSync(s.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${s.join(e,`package.json`)} has no version string`);return n}function ay(e,t){try{let n=ty(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Zv(s.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:iy(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}var J=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const oy=new Map;function sy(e){let t=ly(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 cy(e,t){return e===`bar`?t:sy(e)}function ly(e){let t=oy.get(e);if(t!==void 0)return t;let n=qc(e);return n===null?null:(oy.set(e,n),n)}function uy(e,t){return dy(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>al(e,t))}const dy=Zp();function fy(e){let t=ly(e);return t===null?null:{kind:`decided`,name:e,value:t}}function py(e,t,n){let r=fy(e);return r===null?(n(Eh(t,`palette`,`"${e}" names no installed theme${ch(e)}`)),hy()):r}function my(e,t,n){return vh(e,t,n,hy(),fy)}function hy(){return{kind:`decided`,name:lh,value:sy(lh)}}const gy=/^[A-Za-z_][A-Za-z0-9_]*$/;function _y(e){return`#${e+1}`}const vy={rows:{}};function yy(e){return`rows`in e}function by(e){return Object.fromEntries(e.map((e,t)=>[_y(t),e]))}function xy(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:by(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:by([n])}}function Sy(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function Cy(e){return yy(e)?Sy(e):e}function*wy(e,t){if(!yy(e)){yield*eg(e,t);return}yield[Sy(e),t];for(let[n,r]of Object.entries(e.rows))yield*eg(r,`${t}.rows.${n}`)}function Ty(e,t){return yy(e)?{...t,...e,rows:{...t.rows,...e.rows}}:xy(e)}function Ey(e){if(!yy(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const Dy=`default`,Oy={};function ky(e){return[...new Set([Dy,...Object.keys(e)])]}function Ay(e,t,n){return hh(void 0,e,t,Dy,n)}function jy(e,t){let n={[Dy]:Oy,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${Dy}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function My(e,t){let n=jy(e.presets,t).root??vy;return{node:Sy(Ty(n,e.root)),path:Ey(n)?`presets.${t}.root`:`root`}}function Ny(e,t){return{...e.globals,...jy(e.presets,t).globals}}const Py=new Map;function Fy(e,t,n){Py.set(e,{permanent:!0,resolve:t,paletteOf:n})}Fy(`themes`,()=>dh(),e=>sy(e));const Iy=`placementThemes`;Fy(Iy,fh,(e,t)=>cy(e,t.palette));for(let{name:e,members:t}of F_)Fy(e,()=>t);function Ly(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>uy(n.basePalette,e.styles[t])}],[`presets`,{members:ky(e.presets)}]])}function Ry(e){return[...new Set([...Py.keys(),...e.keys()])]}function zy(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=Py.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(Vy(e,t))}const By=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function Vy(e,t){let n=By.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${Ry(t).join(`, `)})`}const Hy=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*Uy(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 Wy=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,Gy=RegExp(`^(?:(\\$)(?:\\.(${Wy}))?|\\.(${Wy})?)(?=[\\s)]|$)`);function Ky(e,t,n){let r=Gy.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 qy=/^(\w+)\b\s*([\s\S]*)$/;function*Jy(e,t){let n=[t];for(let r of Uy(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=qy.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:Ky(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(Ky(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const Yy=/(?<![.$])\btemplate\s+$/;function*Xy(e,t,n){let r=0;for(let i of[...e.matchAll(Hy)]){let a=i.index+i[0].length;Yy.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:Ky(e.slice(a),t,n)}),r=a}}function*Zy(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...Jy(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...Xy(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 Qy=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${Wy})`,`g`);function*$y({code:e,dot:t,root:n}){let r=e.replace(Hy,``);for(let e of[...r.matchAll(Qy)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function eb(e,t){let n=new Map;for(let r of Zy(e,t))for(let e of $y(r))n.has(e)||n.set(e,r.via);return n}const tb=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,nb={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*rb(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(Hy)]){let o=e.slice(t,a.index),s=tb.exec(o);if(s!==null)n=nb[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 ib(e,t){let n=new Map;for(let{code:r,via:i}of Zy(e,t))for(let{name:e,site:t}of rb(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function ab(e,t){return new Set([...ob(e,t)].filter(e=>Object.hasOwn(t,e)))}function ob(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of Zy(e,t))for(let{name:e}of Xy(r,i,a))n.add(e);return n}function sb(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 cb(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),lb(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 lb(e){return e.kind===`dropped`||(e.kind===`shell`||e.kind===`file`)&&ng(e.parse)===`json`}function ub(e){let t=s.basename(e),n=s.dirname(e);for(;;){let r=db(n);if(r!==null)return{dir:r,name:t,leaf:n===s.dirname(e)};t=s.basename(n),n=s.dirname(n)}}function db(e){try{return p.statSync(e).isDirectory()?p.realpathSync(e):null}catch{return null}}var fb=Ee((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()===Ht}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){Rt(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 zt.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=Ut,n=Ut){let r=new Kt(e);return t!==Ut&&(r.onBOL=new Set([t])),n!==Ut&&(r.onBUOL=new Set([n])),r}function _(e,t){return jt(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||nt(e)?e:Array.isArray(e)?cn.array(e,{name:n}):o(e)?cn.object(e,void 0,{name:n}):u(e)?cn.map(e,{name:n}):d(e)?cn.set(e,{name:n}):typeof e!=`function`||Ge(e)||$e(e)?e:s(e)?Kn(e):Rn(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:ee,u:x}}function ee(e,t,n,r){var i;return(i=this.i)!=null&&i.bound?this.u(e,t,n,!1)===null?0:1:r===e.h?this.u(e,t,n,!1)===null?0:2:Ge(n.value)?1:(Rt(r,t,te(e,this,t,n,!1)),2)}function x(e,t,n,r){let i=te(e,this,t,n);return e.l(t,i,r)}function S(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return be(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return Ge(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(Ge(n)||(n=c(n)),(l=s.i)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),n):void t(43,s.t,String(a),i);var l}function te(e,t,n,r,i=M.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:be(t.i?.name??n.toString(),c,(o=t.i?.autoAction)!=null&&o,(s=t.i)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function ne(e,t){return{t:e,i:t,o:re,u:ie}}function re(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)||!$e(e.h[t]))&&this.u(e,t,n,!1)===null?0:$e(n.value)?1:(Rt(r,t,oe(e,0,0,n,!1,!1)),2)}function ie(e,t,n,r){let i=oe(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function ae(e,t,n){var r;let{name:i,addInitializer:a}=n;return $e(t)||(t=Kn(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 oe(e,t,n,r,i,a=M.safeDescriptors){let{value:o}=r;return $e(o)||(o=Kn(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function C(e,t){return{t:e,i:t,o:w,u:se}}function w(e,t,n){return this.u(e,t,n,!1)===null?0:1}function se(e,t,n,r){return e.m(t,It({},this.i,{get:n.get,set:n.set}),r)}function T(e,t,n){function r(e){let n=It({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new bn(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=wt(this)[k],n=this,i=e.j.get(a);i instanceof bn&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[k],n=e.j.get(a);if(n instanceof bn&&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 ce(e,t){return{t:e,i:t,o:le,u:ue}}function le(e,t,n){return this.u(e,t,n,!1)===null?0:1}function ue(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function de(e,t,n){function r(e,t){let n=wt(e)[k];return(n.V??=new Map).set(o,()=>new vn(t,i.i?.A??v,`ObservableObject.${o.toString()}`,!1)),n}let i=e,{kind:a,name:o}=n;if(a===`accessor`)return{get(){return(this[k]??r(this,t.get.call(this)))._(o)},set(e){return(this[k]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function fe(e){return{t:Xt,i:e,o:pe,u:me}}function pe(e,t,n,r){var i,a,o;if(n.get)return fn.o(e,t,n,r);if(n.set){let i=Ge(n.set)?n.set:be(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!M.safeDescriptors||e.p,set:i})===null?0:2:(Rt(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?qn:Kn).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?Bn:Rn).o(e,t,n,r);let c=!1===this.i?.deep?rn:cn;return typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function me(e,t,n,r){var i;return n.get?fn.u(e,t,n,r):n.set?e.l(t,{configurable:!M.safeDescriptors||e.p,set:be(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.i?.deep?rn:cn).u(e,t,n,r))}function he(e,t){return It(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function ge(e){return e||Qt}function _e(e){return he(e,de)}function ve(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 ye(e){return he(e,T)}function be(e,t,n=!1,r){function i(){return xe(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),gn&&(_n.value=e,Rt(i,`name`,_n)),i}function xe(e,t,n,r,i){let a=Se(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{Ce(a)}}function Se(e,t){let n=M.trackingDerivation,r=!t||!n;Fe();let i=M.allowStateChanges;r&&ke();let a={R:r,k:n,C:i,I:M.allowStateReads,P:!1,T:0,B:hn++,D:mn};return mn=a.B,a}function Ce(e){mn!==e.B&&t(30),mn=e.D,e.N!==void 0&&(M.suppressReactionErrors=!0),Ie(),e.R&&Ae(e.k),M.suppressReactionErrors=!1}function we(e,t){let n=function(e){let t=M.allowStateChanges;return M.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){M.allowStateChanges=e})(n)}}function Te(e){return e instanceof Sn}function Ee(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=ke(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(xn(r)){if(M.disableErrorBoundaries)r.get();else try{r.get()}catch{return Ae(t),!0}if(e.K===2)return Ae(t),!0}}return je(e),Ae(t),!1}}}function De(e,t,n){je(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++M.runId;let r=M.trackingDerivation,i;if(M.trackingDerivation=e,M.inBatch++,!0===M.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new Sn(e)}return M.inBatch--,M.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&&Ne(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,Me(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function Oe(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Ne(t[n],e);e.K=-1}function E(e){let t=ke();try{return e()}finally{Ae(t)}}function ke(){let e=M.trackingDerivation;return M.trackingDerivation=null,e}function Ae(e){M.trackingDerivation=e}function je(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function Me(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Ne(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&Pe(e))}function Pe(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,M.pendingUnobservations.push(e))}function Fe(){M.inBatch++}function Ie(){--M.inBatch===0&&(Be(),!M.isRunningUnobservations&&M.pendingUnobservations.length>0&&function(){M.isRunningUnobservations=!0;try{let e=M.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 bn&&n.G())}M.pendingUnobservations=[]}finally{M.isRunningUnobservations=!1}}())}function Le(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Le))}function Re(e){let t=M.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&M.inBatch>0&&Pe(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&M.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function ze(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 Be(){M.inBatch>0||M.isRunningReactions||kn(Ve)}function Ve(){M.isRunningReactions=!0;let e=M.pendingReactions,t=0;for(;e.length>0;){++t===On&&(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()}M.isRunningReactions=!1}function He(e){return he(e,S)}function Ue(e){return function(t,n){return n&&typeof n.kind==`string`?S(e?Fn:Nn,t,n):r(t)?be(t.name||`<unnamed action>`,t,e):r(n)?be(t,n,e):i(t)?He(b(e?Mn:jn,{name:t,autoAction:e})):void 0}}function We(e){return xe(0,!1,e,this,void 0)}function Ge(e){return r(e)&&!0===e.isMobxAction}function Ke(e,t=Vt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=qe(t),r=!1;a=new Dn(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new Dn(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 qe(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Vn}function Je(e,t,n,i){let a=typeof i==`function`?Dt(t,n):Dt(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 Ye(e,t,n,r){let i=Gt(t);return At(()=>{let t=wt(e,r)[k];Wt(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function Xe(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(Xe)),t}function Ze(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),Ze)),t}function Qe(e){r(e.cancel)&&e.cancel()}function $e(e){return!0===e?.isMobXFlow}function et(e,t){var n;if(t===void 0)return xn(e);if(!1===Et(e))return!1;let r=e[k];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?xn(Dt(e,t)):!1}function tt(e,t){if(!e)return!1;if(t!==void 0){if(Et(e)){var n,r;let i=e[k];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return Et(e)||!!e[k]||qt(e)||An(e)||xn(e)}function nt(e){return tt(e)}function rt(e){return Et(e)?e[k].nt():ar(e)||cr(e)?Array.from(e.keys()):xt(e)?e.map((e,t)=>t):void t(5)}function it(e,n){return Et(e)?e[k].et(n):ar(e)||cr(e)?e.has(n):xt(e)?n>=0&&n<e.length:void t(10)}function at(e){if(Et(e))return e[k].it();t(38)}function ot(e,t,n){if(xn(e)){let r,i=!0;return Ke(()=>{let a=e.get();if(!i||n){let n=ke();t({observableKind:`computed`,debugObjectName:e.tt,type:Zn,object:e,newValue:a,oldValue:r}),Ae(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Zn,newValue:e.rt,oldValue:void 0}),ht(e,t)}function st(e,t,n){return e.set(t,n),n}function ct(e,t){if(typeof e!=`object`||!e||e instanceof Date||!nt(e))return e;if(yn(e)||xn(e))return ct(e.get(),t);if(t.has(e))return t.get(e);if(xt(e)){let n=st(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=ct(e,t)}),n}if(cr(e)){let n=st(t,e,new Set);return e.forEach(e=>{n.add(ct(e,t))}),n}if(ar(e)){let n=st(t,e,new Map);return e.forEach((e,r)=>{n.set(r,ct(e,t))}),n}{let n=st(t,e,{});return at(e).forEach(r=>{zt.propertyIsEnumerable.call(e,r)&&(n[r]=ct(e[r],t))}),n}}function lt(e,t){Fe();try{return e.apply(t)}finally{Ie()}}function ut(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[k].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=be(`When-effect`,t);var a=Ke(t=>{we(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function dt(e){return e[k]}function ft(e){return e.st!==void 0&&e.st.length>0}function pt(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 D(e,n){let r=ke();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{Ae(r)}}function mt(e){return e.ot!==void 0&&e.ot.length>0}function ht(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 gt(e,t){let n=ke(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ae(n)}}function _t(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!==zt;){let t=Lt(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 O(e,t){typeof Array.prototype[e]==`function`&&(er[e]=t(e))}function vt(e){return function(){let t=this[k];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function yt(e){return function(t,n){let r=this[k];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function bt(e){return function(){let t=this[k];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 xt(e){return a(e)&&tr(e[k])}function St(e){return e[Symbol.toStringTag]=`MapIterator`,Pt(e)}function Ct(e){return e[Symbol.toStringTag]=`SetIterator`,Pt(e)}function wt(e,t){if(p(e,k))return e;let n=t?.name??`ObservableObject`;return c(e,k,new dr(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 A[r]??(A[r]=fe({deep:t,autoBind:n}))}(e):void 0}(t))),e}function Tt(e){return lr[e]||(lr[e]={get(){return this[k]._(e)},set(t){return this[k].M(e,t)}})}function Et(e){return!!a(e)&&fr(e[k])}function Dt(e,n){if(typeof e==`object`&&e){if(xt(e))return n!==void 0&&t(23),e[k].ct;if(cr(e))return e.ct;if(ar(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,kt(e)),r}if(Et(e)){if(!n)return t(26);let r=e[k],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,kt(e)),i}if(qt(e)||xn(e)||An(e))return e}else if(r(e)&&An(e[k]))return e[k];t(28)}function Ot(e,n){return e||t(29),n===void 0?qt(e)||xn(e)||An(e)||ar(e)||cr(e)?e:e[k]?e[k]:void t(24,e):Ot(Dt(e,n))}function kt(e,t){let n;if(t!==void 0)n=Dt(e,t);else{if(Ge(e))return e.name;n=Et(e)||ar(e)||cr(e)?Ot(e):Dt(e)}return n.tt}function At(e){let t=ke();Fe();try{return e()}finally{Ie(),Ae(t)}}function jt(e,t,n=-1){return Mt(e,t,n)}function Mt(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=pr.call(e);if(s!==pr.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=Nt(e),t=Nt(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(!Mt(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)||!Mt(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function Nt(e){return xt(e)?e.slice():u(e)||ar(e)||d(e)||cr(e)?Array.from(e.entries()):e}function Pt(e){return e[Symbol.iterator]=Ft,It(Object.create(mr),e)}function Ft(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let It=Object.assign,Lt=Object.getOwnPropertyDescriptor,Rt=Object.defineProperty,zt=Object.prototype,Bt=[];Object.freeze(Bt);let Vt={};Object.freeze(Vt);let Ht=Object.toString(),Ut=()=>{},Wt=Reflect.ownKeys,Gt=Object.getOwnPropertyDescriptors,k=Symbol(`mobx administration`);var Kt=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 Re(this)}reportChanged(){Fe(),ze(this),Ie()}toString(){return this.tt}};let qt=l(`Atom`,Kt),Jt=Object.is,Yt={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},Xt=`true`,Zt=fe(),A=[Zt],Qt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Qt);let $t=ce(`observable`),j=ce(`observable.ref`,{A:y}),en=ce(`observable.shallow`,{A:function(e,t,n){return e==null||Et(e)||xt(e)||ar(e)||cr(e)?e:Array.isArray(e)?cn.array(e,{name:n,deep:!1}):o(e)?cn.object(e,void 0,{name:n,deep:!1}):u(e)?cn.map(e,{name:n,deep:!1}):d(e)?cn.set(e,{name:n,deep:!1}):void 0}}),tn=ce(`observable.struct`,{A:function(e,t){return jt(e,t)?t:e}}),nn={box(e,t){let n=ge(t);return new vn(e,ve(n),n.name,!0,n.equals)},array(e,t){let n=ge(t);return function(e,t,n=`ObservableArray`,r=!1){return At(()=>{let i=new $n(n,t,r);Rt(i.j,k,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Qn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,ve(n),n.name)},map(e,t){let n=ge(t);return new ir(e,ve(n),n.name)},set(e,t){let n=ge(t);return new sr(e,ve(n),n.name)},object:(e,t,n)=>At(()=>Ye(function(e,t){var n;return(n=(e=wt(e,t))[k]).v??(n.v=new Proxy(e,Jn))}({},n),e,t))},rn=_e(j),an=_e(en),on=_e($t),sn=_e(tn);var cn=It(function(e,t,n){return t&&typeof t.kind==`string`?de($t,e,t):nt(e)?e:o(e)?cn.object(e,t,n):Array.isArray(e)?cn.array(e,t):u(e)?cn.map(e,t):d(e)?cn.set(e,t):typeof e==`object`&&e?e:cn.box(e,t)},$t,nn);let ln=`computed`,un=C(ln),dn=ye(C(`computed.struct`,{equals:_})),fn=function(e,t){if(t&&typeof t.kind==`string`)return T(un,e,t);if(o(e))return ye(C(ln,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new bn(n)};var pn;It(fn,un);let mn=0,hn=1,gn=(pn=Lt(()=>{},`name`)?.configurable)!=null&&pn,_n={value:`action`,configurable:!0,writable:!1,enumerable:!1};var vn=class extends Kt{constructor(e,t,n=`ObservableValue`,r=!0,i=Jt){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))!==M.UNCHANGED&&this.Ot(e)}jt(e){if(ft(this)){let t=D(this,{object:this,type:Zn,newValue:e});if(!t)return M.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?M.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),mt(this)&&gt(this,{type:Zn,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.rt)}raw(){return this.rt}toJSON(){return this.get()}toString(){return`${this.tt}[${this.rt}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let yn=l(`ObservableValue`,vn);var bn=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 Sn(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=be(`ComputedValue-setter`,e.set)),this.xt=e.equals||Jt,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),M.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Re(this),Ee(this)){let e=M.trackingContext;e||!this.Mt&&!this.isBeingObserved||(M.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),M.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Le)}else Ee(this)&&(this.Nt(),Fe(),this.rt=this.Rt(!1),Ie());let e=this.rt;if(Te(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||Te(e)||Te(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=De(this,this.derivation,this.At);else if(!0===M.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new Sn(e)}return this.isComputing=!1,t}G(){this.Mt||(Oe(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let xn=l(`ComputedValue`,bn);var Sn=class{constructor(e){this.cause=void 0,this.cause=e}};let Cn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var wn=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 Tn=!0,En=!1,M=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Tn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Tn=!1),Tn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new wn):(setTimeout(()=>{En||t(35)},1),new wn)}();var Dn=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,M.pendingReactions.push(this),Be())}X(){if(!this.isDisposed){Fe(),this.isScheduled=!1;let e=M.trackingContext;if(M.trackingContext=this,Ee(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}M.trackingContext=e,Ie()}}track(e){if(this.isDisposed)return;Fe(),this.isRunning=!0;let t=M.trackingContext;M.trackingContext=this;let n=De(this,e,void 0);M.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Oe(this),Te(n)&&this.Pt(n.cause),Ie()}Pt(e){if(this.kt)this.kt(e,this);else{if(M.disableErrorBoundaries)throw e;M.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),M.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(Fe(),Oe(this),Ie()))}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[k]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let On=100,kn=e=>e(),An=l(`Reaction`,Dn),jn=`action`,Mn=`autoAction`,Nn=b(jn),Pn=b(`action.bound`,{bound:!0}),Fn=b(Mn,{autoAction:!0}),In=b(`autoAction.bound`,{autoAction:!0,bound:!0}),Ln=Ue(!1);It(Ln,Nn);let Rn=Ue(!0);It(Rn,Fn);let zn=He(Pn),Bn=He(In),Vn=e=>e(),Hn=`always`;var Un=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Wn=ne(`flow`),Gn=ne(`flow.bound`,{bound:!0}),Kn=It(function(e,t){if(t&&typeof t.kind==`string`)return ae(Wn,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=Ln(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=Ln(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=Ln(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=Ln(i,function(){try{o&&Qe(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Ut,Ut),Qe(n),a(new Un)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Wn),qn=he(Gn,ae),Jn={has:(e,t)=>dt(e).et(t),get:(e,t)=>dt(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=dt(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=dt(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=dt(e).l(t,n))==null||r},ownKeys:e=>dt(e).it(),preventExtensions(e){t(13)}},Yn=Symbol(`mobx-keys`),Xn=`splice`,Zn=`update`,Qn={get(e,t){let n=e[k];return t===k?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p(er,t)?er[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[k];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var $n=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 Kt(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=Bt),ft(this)){let r=D(this,{object:this.v,type:Xn,index:e,removedCount:t,added:n});if(!r)return Bt;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=mt(this),i=r?{observableKind:`array`,object:this.v,type:Zn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&gt(this,i)}Ft(e,t,n){let r=mt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:Xn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&gt(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(ft(this)){let n=D(this,{type:Zn,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)}}},er={clear(){return this.splice(0)},replace(e){let t=this[k];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[k];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[k].wt(e,t,n)},push(...e){let t=this[k];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[k].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[k];return t.wt(0,0,e),t.j.length},reverse(){return M.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){M.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[k],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};O(`at`,vt),O(`concat`,vt),O(`flat`,vt),O(`includes`,vt),O(`indexOf`,vt),O(`join`,vt),O(`lastIndexOf`,vt),O(`slice`,vt),O(`toString`,vt),O(`toLocaleString`,vt),O(`toSorted`,vt),O(`toSpliced`,vt),O(`with`,vt),O(`every`,yt),O(`filter`,yt),O(`find`,yt),O(`findIndex`,yt),O(`findLast`,yt),O(`findLastIndex`,yt),O(`flatMap`,yt),O(`forEach`,yt),O(`map`,yt),O(`some`,yt),O(`toReversed`,yt),O(`reduce`,bt),O(`reduceRight`,bt);let tr=l(`ObservableArrayAdministration`,$n),nr={},rr=`delete`;var ir=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[k]=nr,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,At(()=>{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(!M.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new vn(this.et(e),y,`ObservableMap.key?`,!1);this.dt.set(e,n),n.onBUOL=new Set([()=>this.dt.delete(e)])}return t.get()}set(e,t){let n=this.et(e);if(ft(this)){let r=D(this,{type:n?Zn:`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(ft(this)&&!D(this,{type:rr,object:this,name:e}))return!1;if(this.et(e)){let t=mt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:rr,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return lt(()=>{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&&gt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==M.UNCHANGED){let r=mt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Zn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&gt(this,i)}}Jt(e,t){lt(()=>{var n;let r=new vn(t,this.A,`ObservableMap.key`,!1);this.ft.set(e,r),t=r.rt,(n=this.dt.get(e))==null||n.Ot(!0),this.lt.reportChanged()});let n=mt(this);n&&gt(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 St({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 St({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 ar(e)&&(e=new Map(e)),lt(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>zt.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(){lt(()=>{E(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return lt(()=>{let n=function(e){if(u(e)||ar(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`}},ar=l(`ObservableMap`,ir);let or={};var sr=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[k]=or,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),At(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){lt(()=>{E(()=>{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(ft(this)){let t=D(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){lt(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=mt(this);t&&gt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(ft(this)&&!D(this,{type:rr,object:this,oldValue:e}))return!1;if(this.has(e)){let t=mt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:rr,object:this,oldValue:e}:null;return lt(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&gt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return Ct({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 Ct({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 cr(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?lt(()=>{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`}},cr=l(`ObservableSet`,sr);let lr=Object.create(null),ur=`remove`;var dr=class{constructor(e,t=new Map,n,r=Zt){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 Kt(`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 bn)return n.set(t),!0;if(ft(this)){let n=D(this,{type:Zn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==M.UNCHANGED){let r=mt(this),i=r?{type:Zn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&gt(this,i)}return!0}Tt(e){return M.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(!M.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new vn(e in this.h,y,`ObservableObject.key?`,!1),this.Qt.set(e,t)),t.get()}u(e,t,n,r=!1){return!0===n&&(n=this.ut),!1===n?this.l(e,t,r):n.u(this,e,t,r)}l(e,t,n=!1){try{Fe();let r=this.Dt(e);if(!r)return r;if(ft(this)){let n=D(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=It({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else Rt(this.h,e,t);this.Yt(e,t.value)}finally{Ie()}return!0}S(e,t,n,r=!1){try{Fe();let i=this.Dt(e);if(!i)return i;if(ft(this)){let n=D(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=Tt(e),o={configurable:!M.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else Rt(this.h,e,o);let s=new vn(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Ie()}return!0}m(e,t,n=!1){try{Fe();let r=this.Dt(e);if(!r)return r;if(ft(this)&&!D(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=Tt(e),a={configurable:!M.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else Rt(this.h,e,a);this.j.set(e,new bn(t)),this.Yt(e,void 0)}finally{Ie()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(ft(this)&&!D(this,{object:this.v||this.h,name:e,type:ur}))return null;try{var n;Fe();let r=mt(this),i=this.j.get(e),a;if(i||!r||(a=Lt(this.h,e)?.value),t){if(!Reflect.deleteProperty(this.h,e))return!1}else delete this.h[e];i&&(this.j.delete(e),i instanceof vn&&(a=i.rt),ze(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&gt(this,{type:ur,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Ie()}return!0}Yt(e,t){var n;let r=mt(this);r&&r&&gt(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(),Wt(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let fr=l(`ObservableObjectAdministration`,dr),pr=zt.toString,mr=globalThis.Iterator?.prototype||{};e.$mobx=k,e.FlowCancellationError=Un,e.ObservableMap=ir,e.ObservableSet=sr,e.Reaction=Dn,e._allowStateChanges=we,e._allowStateChangesInsideComputed=We,e._allowStateReadsEnd=function(e){M.allowStateReads=e},e._allowStateReadsStart=function(e){let t=M.allowStateReads;return M.allowStateReads=e,t},e._autoAction=Rn,e._autoActionBound=Bn,e._endAction=Ce,e._getAdministration=Ot,e._getGlobalState=function(){return M},e._interceptReads=function(e,t,n){let r;return ar(e)||xt(e)||yn(e)?r=Ot(e):Et(e)&&(r=Ot(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return M.trackingDerivation!==null},e._resetGlobalState=function(){let e=new wn;for(let t in e)Cn.indexOf(t)===-1&&(M[t]=e[t]);M.allowStateChanges=!M.enforceActions},e._startAction=Se,e.action=Ln,e.actionBound=zn,e.autorun=Ke,e.compareDefault=Jt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return jt(e,t,1)},e.compareStructural=_,e.computed=fn,e.computedStruct=dn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((M.pendingReactions.length||M.inBatch||M.isRunningReactions)&&t(36),En=!0,Tn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),M=new wn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===Hn?Hn:n===`observed`;M.enforceActions=e,M.allowStateChanges=!0!==e&&e!==Hn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(M[t]=!!e[t])}),M.allowStateReads=!M.observableRequiresReaction,e.reactionScheduler&&function(e){let t=kn;kn=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(Et(e))return e[k].l(n,r);t(39)},e.entries=function(e){return Et(e)?rt(e).map(t=>[t,e[t]]):ar(e)?rt(e).map(t=>[t,e.get(t)]):cr(e)?Array.from(e.entries()):xt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ye,e.flow=Kn,e.flowBound=qn,e.flowResult=function(e){return e},e.get=function(e,n){if(it(e,n))return Et(e)?e[k].Tt(n):ar(e)?e.get(n):xt(e)?e[n]:void t(11)},e.getAtom=Dt,e.getDebugName=kt,e.getDependencyTree=function(e,t){return Xe(Dt(e,t))},e.getObserverTree=function(e,t){return Ze(Dt(e,t))},e.has=it,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return pt(Ot(e,t),n)}(e,t,n):function(e,t){return pt(Ot(e),t)}(e,t)},e.isAction=Ge,e.isBoxedObservable=yn,e.isComputed=function(e){return et(e)},e.isComputedProp=function(e,t){return et(e,t)},e.isFlow=$e,e.isFlowCancellationError=function(e){return e instanceof Un},e.isObservable=nt,e.isObservableArray=xt,e.isObservableMap=ar,e.isObservableObject=Et,e.isObservableProp=function(e,t){return tt(e,t)},e.isObservableSet=cr,e.keys=rt,e.makeAutoObservable=function(e,t,n){return o(e)?Ye(e,e,t,n):(At(()=>{let r=wt(e,n)[k];if(!e[Yn]){let t=Object.getPrototypeOf(e),n=new Set([...Wt(e),...Wt(t)]);n.delete(`constructor`),n.delete(k),c(t,Yn,n)}e[Yn].forEach(e=>_t(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return At(()=>{let r=wt(e,n)[k];Wt(t).forEach(e=>_t(r,e,t[e]))}),e},e.observable=cn,e.observableDeep=on,e.observableRef=rn,e.observableShallow=an,e.observableStruct=sn,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return ot(Ot(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Ot(e);if(xt(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(!ar(e)&&!cr(e)&&!Et(e))return ot(r,t,n);return ht(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return Je(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return Je(`onBUO`,e,t,n)},e.onReactionError=function(e){return M.globalReactionErrorHandlers.push(e),()=>{let t=M.globalReactionErrorHandlers.indexOf(e);t>=0&&M.globalReactionErrorHandlers.splice(t,1)}},e.override=Yt,e.ownKeys=at,e.reaction=function(e,t,n=Vt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=we(!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=Ln(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=qe(n),d,f=!0,p=!1,m=n.equals||Jt,h=new Dn(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){Et(e)?e[k].Dt(n):ar(e)||cr(e)?e.delete(n):xt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=We,e.set=function e(n,r,i){if(arguments.length===2&&!cr(n)){Fe();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Ie()}return}Et(n)?n[k].Bt(r,i):ar(n)?n.set(r,i):cr(n)?n.add(r):xt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),Fe(),r>=n.length&&(n.length=r+1),n[r]=i,Ie()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return ct(e,new Map)},e.transaction=lt,e.untracked=E,e.values=function(e){return Et(e)?rt(e).map(t=>e[t]):ar(e)?rt(e).map(t=>e.get(t)):cr(e)?Array.from(e.values()):xt(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 It(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=ut(e,n,It({},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):ut(e,t,n||{})}})),pb=Ee((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++A.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=ae(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===l}function _(e){let t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function v(e,t,n){a(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function y(e,t,n){a(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function b(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return h(e)&&e[n]===!0}}function ee(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function x(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function S(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function te(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let ne=Reflect.ownKeys;function re(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ie(e){return e===null?null:typeof e==`object`?``+e:e}function ae(e,t){return o.hasOwnProperty.call(e,t)}let oe=Object.getOwnPropertyDescriptors;function C(e,t){return!!(e&t)}function w(e,t,n){return n?e|=t:e&=~t,e}function se(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let T=Symbol(`mobx administration`);var ce=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 C(this.flags_,1)}set isBeingObserved(e){this.flags_=w(this.flags_,1,e)}get isPendingUnobservation(){return C(this.flags_,2)}set isPendingUnobservation(e){this.flags_=w(this.flags_,2,e)}get diffValue(){return+!!C(this.flags_,4)}set diffValue(e){this.flags_=w(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return un(this)}reportChanged(){on(),dn(this),sn()}toString(){return this.name_}};let le=b(`Atom`,ce);function ue(e,t=f,n=f){let r=new ce(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function de(e,t){return e===t}function fe(e,t){return P(e,t)}function pe(e,t){return P(e,t,1)}let me=Object.is;function he(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||Sr(e)?e:Array.isArray(e)?D.array(e,{name:n}):g(e)?D.object(e,void 0,{name:n}):ee(e)?D.map(e,{name:n}):S(e)?D.set(e,{name:n}):typeof e==`function`&&!Bn(e)&&!pr(e)?_(e)?lr(e):In(n,e):e}function ge(e,t,r){if(e==null||Ai(e)||pi(e)||_i(e)||Si(e))return e;if(Array.isArray(e))return D.array(e,{name:r,deep:!1});if(g(e))return D.object(e,void 0,{name:r,deep:!1});if(ee(e))return D.map(e,{name:r,deep:!1});if(S(e))return D.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function _e(e){return e}function ve(e,t){return Sr(e)&&n(`observable.struct should not be used with observable values`),P(e,t)?t:e}let ye=`override`,be={annotationType_:ye,make_:Se,extend_:Ce};function xe(e){return e.annotationType_===ye}function Se(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),ae(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function Ce(e,t,r,i){n(44,this.annotationType_)}function we(e,t){return{annotationType_:e,options_:t,make_:Te,extend_:Ee}}function Te(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:Bn(n.value)?1:(a(r,t,E(e,this,t,n,!1)),2)}function Ee(e,t,n,r){let i=E(e,this,t,n);return e.defineProperty_(t,i,r)}function De(e,t,r){se(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>St(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return Bn(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return Bn(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 Oe(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 E(e,t,n,r,i=A.safeDescriptors){var a,o;Oe(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:St(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 ke(e,t){return{annotationType_:e,options_:t,make_:Ae,extend_:je}}function Ae(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&&(!ae(e.target_,t)||!pr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:pr(n.value)?1:(a(r,t,Pe(e,this,t,n,!1,!1)),2)}function je(e,t,n,r){let i=Pe(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function Me(e,t,n){var r;se(n,[`method`]);let{name:i,addInitializer:a}=n;return pr(t)||(t=lr(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 Ne(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 Pe(e,t,n,r,i,a=A.safeDescriptors){Ne(e,t,n,r);let{value:o}=r;return pr(o)||(o=lr(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function Fe(e,t){return{annotationType_:e,options_:t,make_:Ie,extend_:Le}}function Ie(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Le(e,t,n,i){return ze(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Re(e,t,n){se(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 jt(o)}return o(function(){let e=Di(this)[T],n=this,r=e.values_.get(a);r instanceof jt&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[T],n=e.values_.get(a);if(n instanceof jt&&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 ze(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 Be(e,t){return{annotationType_:e,options_:t,make_:Ve,extend_:He}}function Ve(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function He(e,t,n,r){return We(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??he,r)}function Ue(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);se(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=Di(e)[T];return(n.lazyObservableKeys_??=new Map).set(o,()=>new kt(t,i.options_?.enhancer_??he,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[T]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[T]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function We(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 Ge=Ke();function Ke(e){return{annotationType_:`true`,options_:e,make_:Ye,extend_:Xe}}let qe=[Ge];function Je(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return qe[r]??(qe[r]=Ke({deep:t,autoBind:n}))}function Ye(e,t,n,r){var i;if(n.get)return O.make_(e,t,n,r);if(n.set){let i=Bn(n.set)?n.set:St(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:A.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?ur:lr).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Rn:In).make_(e,t,n,r)}let c=this.options_?.deep===!1?ut:D;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 Xe(e,t,n,r){var i;return n.get?O.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:A.safeDescriptors?e.isPlainObject_:!0,set:St(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?ut:D).extend_(e,t,n,r))}function Ze(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 Qe={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Qe);function $e(e){return e||Qe}let et=Be(`observable`),tt=Be(`observable.ref`,{enhancer_:_e}),nt=Be(`observable.shallow`,{enhancer_:ge}),rt=Be(`observable.struct`,{enhancer_:ve});function it(e){return Ze(e,Ue)}function at(e){return e.deep===!0?he:e.deep===!1?_e:st(e.defaultDecorator)}function ot(e){return e?e.defaultDecorator??Je(e):void 0}function st(e){return e?e.options_?.enhancer_??he:he}function ct(e,t,n){return t&&typeof t.kind==`string`?Ue(et,e,t):Sr(e)?e:g(e)?D.object(e,t,n):Array.isArray(e)?D.array(e,t):ee(e)?D.map(e,t):S(e)?D.set(e,t):typeof e==`object`&&e?e:D.box(e,t)}let lt={box(e,t){let n=$e(t);return new kt(e,at(n),n.name,!0,n.equals)},array(e,t){let n=$e(t);return si(e,at(n),n.name)},map(e,t){let n=$e(t);return new gi(e,at(n),n.name)},set(e,t){let n=$e(t);return new xi(e,at(n),n.name)},object(e,t,n){return Ii(()=>Zn(Kr({},n),e,t))}},ut=it(tt),dt=it(nt),ft=it(et),pt=it(rt);var D=r(ct,et,lt);let mt=`computed`;function ht(e){return Ze(e,Re)}let gt=Fe(mt),_t=ht(Fe(`computed.struct`,{equals:fe})),O=function(e,t){if(t&&typeof t.kind==`string`)return Re(gt,e,t);if(g(e))return ht(Fe(mt,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 jt(r)};r(O,gt);let vt=0,yt=1,bt=i(()=>{},`name`)?.configurable??!1,xt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function St(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 Ct(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),bt&&(xt.value=e,a(o,`name`,xt)),o}function Ct(e,t,n,r,i){let a=wt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{Tt(a)}}function wt(e,t,n,r){let i=xn()&&!!e,a=0;i&&(a=Date.now(),Cn({type:M,name:e,object:n,arguments:r?Array.from(r):s}));let o=A.trackingDerivation,c=!t||!o;on();let l=A.allowStateChanges;c&&(Wt(),l=Dt(!0));let u=A.allowStateReads;k(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:yt++,parentActionId_:vt};return vt=d.actionId_,d}function Tt(e){vt!==e.actionId_&&n(30),vt=e.parentActionId_,e.error_!==void 0&&(A.suppressReactionErrors=!0),Ot(e.prevAllowStateChanges_),Kt(e.prevAllowStateReads_),sn(),e.runAsAction_&&Gt(e.prevDerivation_),e.notifySpy_&&Tn({time:Date.now()-e.startTime_}),A.suppressReactionErrors=!1}function Et(e,t){let n=Dt(e);try{return t()}finally{Ot(n)}}function Dt(e){let t=A.allowStateChanges;return A.allowStateChanges=e,t}function Ot(e){A.allowStateChanges=e}var kt=class extends ce{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=me){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&&xn()&&Sn({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!==A.UNCHANGED){let n=xn();n&&Cn({type:ii,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Tn()}}prepareNewValue_(e){if(Lt(this),qr(this)){let t=Yr(this,{object:this,type:ii,newValue:e});if(!t)return A.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?A.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),Xr(this)&&Qr(this,{type:ii,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 ie(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let At=b(`ObservableValue`,kt);var jt=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 Nt(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_=St(this.name_+`-setter`,e.set)),this.equals_=e.equals||me,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){pn(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return C(this.flags_,1)}set isComputing(e){this.flags_=w(this.flags_,1,e)}get isRunningSetter(){return C(this.flags_,2)}set isRunningSetter(e){this.flags_=w(this.flags_,2,e)}get isBeingObserved(){return C(this.flags_,4)}set isBeingObserved(e){this.flags_=w(this.flags_,4,e)}get isPendingUnobservation(){return C(this.flags_,8)}set isPendingUnobservation(e){this.flags_=w(this.flags_,8,e)}get diffValue(){return+!!C(this.flags_,16)}set diffValue(e){this.flags_=w(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),A.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Ft(this)&&(this.warnAboutUntrackedRead_(),on(),this.value_=this.computeValue_(!1),sn());else{let e=this.isBeingObserved;if(un(this),Ft(this)){let e=A.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(A.trackingContext=this),this.trackAndCompute()&&fn(this),A.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(ln)}let e=this.value_;if(Pt(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||Pt(e)||Pt(n)||!this.equals_(e,n);return r&&(this.value_=n,xn()&&Sn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=Dt(!1),n;if(e)n=zt(this,this.derivation,this.scope_);else if(A.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new Nt(e)}return Ot(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(Ht(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:A.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 ie(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Mt=b(`ComputedValue`,jt);var Nt=class{constructor(e){this.cause=void 0,this.cause=e}};function Pt(e){return e instanceof Nt}function Ft(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=k(!0),n=Wt(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(Mt(i)){if(A.disableErrorBoundaries)i.get();else try{i.get()}catch{return Gt(n),Kt(t),!0}if(e.dependenciesState_===2)return Gt(n),Kt(t),!0}}return qt(e),Gt(n),Kt(t),!1}}}function It(){return A.trackingDerivation!==null}function Lt(e){let t=!!e.observers_&&e.observers_.size>0;!A.allowStateChanges&&(t||A.enforceActions===`always`)&&console.warn(`[MobX] `+(A.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 Rt(e){!A.allowStateReads&&A.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function zt(e,t,n){let r=k(!0);qt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++A.runId;let i=A.trackingDerivation;A.trackingDerivation=e,A.inBatch++;let a;if(A.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new Nt(e)}return A.inBatch--,A.trackingDerivation=i,Vt(e),Bt(e),Kt(r),a}function Bt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:A.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function Vt(e){let t=e.observing_,n=e.observing_=e.newObserving_,r=0,i=0,a=e.unboundDepsCount_;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.dependenciesState_>r&&(r=t.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&rn(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,nn(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function Ht(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)rn(t[n],e);e.dependenciesState_=-1}function Ut(e){let t=Wt();try{return e()}finally{Gt(t)}}function Wt(){let e=A.trackingDerivation;return A.trackingDerivation=null,e}function Gt(e){A.trackingDerivation=e}function k(e){let t=A.allowStateReads;return A.allowStateReads=e,t}function Kt(e){A.allowStateReads=e}function qt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Jt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Yt=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 Xt=!0,Zt=!1,A=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Xt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Xt=!1),Xt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Yt):(setTimeout(()=>{Zt||n(35)},1),new Yt)}();function Qt(){if((A.pendingReactions.length||A.inBatch||A.isRunningReactions)&&n(36),Zt=!0,Xt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),A=new Yt}}function $t(){return A}function j(){let e=new Yt;for(let t in e)Jt.indexOf(t)===-1&&(A[t]=e[t]);A.allowStateChanges=!A.enforceActions}function en(e){return!!e.observers_&&e.observers_.size>0}function tn(e){return e.observers_??new Set}function nn(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function rn(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&an(e))}function an(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,A.pendingUnobservations.push(e))}function on(){A.inBatch++}function sn(){--A.inBatch===0&&(_n(),!A.isRunningUnobservations&&A.pendingUnobservations.length>0&&cn())}function cn(){A.isRunningUnobservations=!0;try{let e=A.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 jt&&n.suspend_())}A.pendingUnobservations=[]}finally{A.isRunningUnobservations=!1}}function ln(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(ln))}function un(e){Rt(e);let t=A.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&A.inBatch>0&&an(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&A.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function dn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&e.onBecomeStale_(),e.dependenciesState_=2}))}function fn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(t=>{t.dependenciesState_===1?t.dependenciesState_=2:t.dependenciesState_===0&&(e.lowestObserverState_=0)}))}function pn(e){var t;e.lowestObserverState_===0&&(e.lowestObserverState_=1,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&(e.dependenciesState_=1,e.onBecomeStale_())}))}var mn=class{constructor(e=`Reaction@`+u(),t,n,r){this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=-1,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.removeAbortListener_=void 0,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}get isDisposed(){return C(this.flags_,1)}set isDisposed(e){this.flags_=w(this.flags_,1,e)}get isScheduled(){return C(this.flags_,2)}set isScheduled(e){this.flags_=w(this.flags_,2,e)}get isTrackPending(){return C(this.flags_,4)}set isTrackPending(e){this.flags_=w(this.flags_,4,e)}get isRunning(){return C(this.flags_,8)}set isRunning(e){this.flags_=w(this.flags_,8,e)}get diffValue(){return+!!C(this.flags_,16)}set diffValue(e){this.flags_=w(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,A.pendingReactions.push(this),_n())}runReaction_(){if(!this.isDisposed){on(),this.isScheduled=!1;let e=A.trackingContext;if(A.trackingContext=this,Ft(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&xn()&&Sn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}A.trackingContext=e,sn()}}track(e){if(this.isDisposed)return;on();let t=xn(),n;t&&(n=Date.now(),Cn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=A.trackingContext;A.trackingContext=this;let i=zt(this,e,void 0);A.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Ht(this),Pt(i)&&this.reportExceptionInDerivation_(i.cause),t&&Tn({time:Date.now()-n}),sn()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(A.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;A.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),xn()&&Sn({type:`error`,name:this.name_,message:t,error:``+e}),A.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(on(),Ht(this),sn())}}getDisposer_(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.removeAbortListener_=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[T]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function hn(e){return A.globalReactionErrorHandlers.push(e),()=>{let t=A.globalReactionErrorHandlers.indexOf(e);t>=0&&A.globalReactionErrorHandlers.splice(t,1)}}let gn=e=>e();function _n(){A.inBatch>0||A.isRunningReactions||gn(vn)}function vn(){A.isRunningReactions=!0;let e=A.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_()}A.isRunningReactions=!1}let yn=b(`Reaction`,mn);function bn(e){let t=gn;gn=n=>e(()=>t(n))}function xn(){return!!A.spyListeners.length}function Sn(e){if(!A.spyListeners.length)return;let t=A.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function Cn(e){Sn(r({},e,{spyReportStart:!0}))}let wn={type:`report-end`,spyReportEnd:!0};function Tn(e){Sn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):wn)}function En(e){return A.spyListeners.push(e),d(()=>{A.spyListeners=A.spyListeners.filter(t=>t!==e)})}let M=`action`,Dn=`autoAction`,On=`<unnamed action>`,kn=we(M),An=we(`action.bound`,{bound:!0}),jn=we(Dn,{autoAction:!0}),Mn=we(`autoAction.bound`,{autoAction:!0,bound:!0});function Nn(e){return Ze(e,De)}function Pn(e){return function(t,r){if(r&&typeof r.kind==`string`)return De(e?jn:kn,t,r);if(p(t))return St(t.name||On,t,e);if(p(r))return St(t,r,e);if(m(t))return Nn(we(e?Dn:M,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Fn=Pn(!1);r(Fn,kn);let In=Pn(!0);r(In,jn);let Ln=Nn(An),Rn=Nn(Mn);function zn(e){return Ct(e.name||On,!1,e,this,void 0)}function Bn(e){return p(e)&&e.isMobxAction===!0}function Vn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),Bn(e)&&n(`Autorun does not accept actions since actions are untrackable`);let i=t?.name??(e.name||`Autorun@`+u()),a=!t.scheduler&&!t.delay,o;if(a)o=new mn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Un(t),n=!1;o=new mn(i,()=>{n||(n=!0,e(()=>{n=!1,o.isDisposed||o.track(s)}))},t.onError,t.requiresObservable)}function s(){e(o)}return t!=null&&(r=t.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}let Hn=e=>e();function Un(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Hn}function Wn(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=Fn(a,r.onError?Gn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Un(r),d=!0,f=!1,m,h=r.equals||me,_=new mn(a,()=>{d||s?v():f||(f=!0,l(v))},r.onError,r.requiresObservable);function v(){if(f=!1,_.isDisposed)return;let t=!1,n=m;_.track(()=>{let n=Et(!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 Gn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Kn(e,t,n){return Jn(`onBO`,e,t,n)}function qn(e,t,n){return Jn(`onBUO`,e,t,n)}function Jn(e,t,n,r){let i=typeof r==`function`?Ni(t,n):Ni(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 Yn=`always`;function Xn(e){e.isolateGlobalState===!0&&Qt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Yn?Yn:t===`observed`;A.enforceActions=e,A.allowStateChanges=!(e===!0||e===Yn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(A[t]=!!e[t])}),A.allowStateReads=!A.observableRequiresReaction,A.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&bn(e.reactionScheduler)}function Zn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),_i(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(Sr(t)||Sr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=oe(t);return Ii(()=>{let t=Di(e,i)[T];ne(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Qn(e,t){return $n(Ni(e,t))}function $n(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=nr(e.observing_).map($n)),t}function er(e,t){return tr(Ni(e,t))}function tr(e){let t={name:e.name_};return en(e)&&(t.observers=Array.from(tn(e),tr)),t}function nr(e){return Array.from(new Set(e))}let rr=0;var ir=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function ar(e){return e instanceof ir}function or(e){return Ze(e,Me)}let sr=ke(`flow`),cr=ke(`flow.bound`,{bound:!0}),lr=r(function(e,t){if(t&&typeof t.kind==`string`)return Me(sr,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=++rr,a=Fn(`${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=Fn(`${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=Fn(`${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=Fn(`${i} - runid: ${n} - cancel`,function(){try{s&&dr(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),dr(t),o(new ir)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},sr),ur=or(cr);function dr(e){p(e.cancel)&&e.cancel()}function fr(e){return e}function pr(e){return e?.isMobXFlow===!0}function mr(e,t,r){let i;if(_i(e)||pi(e)||At(e))i=Pi(e);else if(Ai(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=Pi(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 hr(e,t,n){return p(n)?_r(e,t,n):gr(e,t)}function gr(e,t){return Jr(Pi(e),t)}function _r(e,t,n){return Jr(Pi(e,t),n)}function vr(e,t){var n;if(t===void 0)return Mt(e);if(Ai(e)===!1)return!1;let r=e[T];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?Mt(Ni(e,t)):!1}function yr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):vr(e)}function br(e,t){return m(t)?vr(e,t):n(`isComputed expected a property name as second argument`)}function xr(e,t){if(!e)return!1;if(t!==void 0){if(_i(e)||pi(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(Ai(e)){var r,i;let n=e[T];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return Ai(e)||!!e[T]||le(e)||yn(e)||Mt(e)}function Sr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),xr(e)}function Cr(e,t){return m(t)?xr(e,t):n(`expected a property name as second argument`)}function wr(e){if(Ai(e))return e[T].keys_();if(_i(e)||Si(e))return Array.from(e.keys());if(pi(e))return e.map((e,t)=>t);n(5)}function Tr(e){if(Ai(e))return wr(e).map(t=>e[t]);if(_i(e))return wr(e).map(t=>e.get(t));if(Si(e))return Array.from(e.values());if(pi(e))return e.slice();n(6)}function Er(e){if(Ai(e))return wr(e).map(t=>[t,e[t]]);if(_i(e))return wr(e).map(t=>[t,e.get(t)]);if(Si(e))return Array.from(e.entries());if(pi(e))return e.map((e,t)=>[t,e]);n(7)}function Dr(e,t,r){if(arguments.length===2&&!Si(e)){on();let n=t;try{for(let t in n)Dr(e,t,n[t])}finally{sn()}return}Ai(e)?e[T].set_(t,r):_i(e)?e.set(t,r):Si(e)?e.add(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),on(),t>=e.length&&(e.length=t+1),e[t]=r,sn()):n(8)}function Or(e,t){Ai(e)?e[T].delete_(t):_i(e)||Si(e)?e.delete(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function kr(e,t){if(Ai(e))return e[T].has_(t);if(_i(e)||Si(e))return e.has(t);if(pi(e))return t>=0&&t<e.length;n(10)}function Ar(e,t){if(kr(e,t)){if(Ai(e))return e[T].get_(t);if(_i(e))return e.get(t);if(pi(e))return e[t];n(11)}}function jr(e,t,r){if(Ai(e))return e[T].defineProperty_(t,r);n(39)}function Mr(e){if(Ai(e))return e[T].ownKeys_();n(38)}function Nr(e,t,n,r){return p(n)?Fr(e,t,n,r):Pr(e,t,n)}function Pr(e,t,r){let i=Pi(e);if(pi(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(_i(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(Si(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(Ai(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Ir(i,t,r);return Zr(i,t)}function Fr(e,t,n,r){return Ir(Pi(e,t),n,r)}function Ir(e,t,n){if(Mt(e)){let r=!0,i;return Vn(()=>{let a=e.get();if(!r||n){let n=Wt();t({observableKind:`computed`,debugObjectName:e.name_,type:ii,object:e,newValue:a,oldValue:i}),Gt(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ii,newValue:e.value_,oldValue:void 0}),Zr(e,t)}function Lr(e,t,n){return e.set(t,n),n}function Rr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!Sr(e))return e;if(At(e)||Mt(e))return Rr(e.get(),t);if(t.has(e))return t.get(e);if(pi(e)){let n=Lr(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Rr(e,t)}),n}if(Si(e)){let n=Lr(t,e,new Set);return e.forEach(e=>{n.add(Rr(e,t))}),n}if(_i(e)){let n=Lr(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Rr(e,t))}),n}else{let n=Lr(t,e,{});return Mr(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Rr(e[r],t))}),n}}function zr(e,t){return t&&n(`toJS no longer supports options`),Rr(e,new Map)}function Br(e,t=void 0){on();try{return e.apply(t)}finally{sn()}}function Vr(e,t,n){return arguments.length===1||t&&typeof t==`object`?Ur(e,t):Hr(e,t,n||{})}function Hr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[T].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=St(n.name+`-effect`,t);var a=Vn(t=>{Et(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function Ur(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=Hr(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 Wr(e){return e[T]}let Gr={has(e,t){return Wr(e).has_(t)},get(e,t){return Wr(e).get_(t)},set(e,t,n){return m(t)?Wr(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Wr(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Wr(e).defineProperty_(t,n)??!0},ownKeys(e){return Wr(e).ownKeys_()},preventExtensions(e){n(13)}};function Kr(e,t){var n;return e=Di(e,t),(n=e[T]).proxy_??(n.proxy_=new Proxy(e,Gr))}function qr(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function Jr(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 Yr(e,t){let r=Wt();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{Gt(r)}}function Xr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Zr(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 Qr(e,t){let n=Wt(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Gt(n)}}function $r(e,t,n){return Ii(()=>{let r=Di(e,n)[T];ne(t).forEach(e=>ni(r,e,t[e]))}),e}let ei=Symbol(`mobx-keys`);function ti(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),Ai(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Zn(e,e,t,r):(Ii(()=>{let n=Di(e,r)[T];if(!e[ei]){let t=Object.getPrototypeOf(e),n=new Set([...ne(e),...ne(t)]);n.delete(`constructor`),n.delete(T),v(t,ei,n)}e[ei].forEach(e=>ni(n,e,t&&e in t?t[e]:!0))}),e)}function ni(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;Mi(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)}ji(e,r,t)}let ri=`splice`,ii=`update`,ai={get(e,t){let n=e[T];return t===T?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):ae(ci,t)?ci[t]:e[t]},set(e,t,n){let r=e[T];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var oi=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 ce(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){Lt(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),qr(this)){let r=Yr(this,{object:this.proxy_,type:ri,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_&&xn(),i=Xr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ii,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&Cn(a),this.atom_.reportChanged(),i&&Qr(this,a),r&&Tn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&xn(),i=Xr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:ri,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Cn(a),this.atom_.reportChanged(),i&&Qr(this,a),r&&Tn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Lt(this.atom_);let r=n[e];if(qr(this)){let n=Yr(this,{type:ii,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 si(e,t,n=`ObservableArray@`+u(),r=!1){return Ii(()=>{let i=new oi(n,t,r);y(i.values_,T,i);let a=new Proxy(i.values_,ai);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var ci={clear(){return this.splice(0)},replace(e){let t=this[T];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[T];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[T].spliceWithArray_(e,t,n)},push(...e){let t=this[T];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[T].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[T];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return A.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){A.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[T],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};N(`at`,li),N(`concat`,li),N(`flat`,li),N(`includes`,li),N(`indexOf`,li),N(`join`,li),N(`lastIndexOf`,li),N(`slice`,li),N(`toString`,li),N(`toLocaleString`,li),N(`toSorted`,li),N(`toSpliced`,li),N(`with`,li),N(`every`,ui),N(`filter`,ui),N(`find`,ui),N(`findIndex`,ui),N(`findLast`,ui),N(`findLastIndex`,ui),N(`flatMap`,ui),N(`forEach`,ui),N(`map`,ui),N(`some`,ui),N(`toReversed`,ui),N(`reduce`,di),N(`reduceRight`,di);function N(e,t){typeof Array.prototype[e]==`function`&&(ci[e]=t(e))}function li(e){return function(){let t=this[T];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function ui(e){return function(t,n){let r=this[T];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function di(e){return function(){let t=this[T];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 fi=b(`ObservableArrayAdministration`,oi);function pi(e){return h(e)&&fi(e[T])}let mi={},hi=`delete`;var gi=class{constructor(e,t=he,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[T]=mi,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,Ii(()=>{this.keysAtom_=ue(`${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(!A.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new kt(this.has_(e),_e,`${this.name_}.${re(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(qr(this)){let r=Yr(this,{type:n?ii:`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(Lt(this.keysAtom_),qr(this)&&!Yr(this,{type:hi,object:this,name:e}))return!1;if(this.has_(e)){let t=xn(),n=Xr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:hi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&Cn(r),Br(()=>{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&&Qr(this,r),t&&Tn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==A.UNCHANGED){let r=xn(),i=Xr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ii,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&Cn(a),n.setNewValue_(t),i&&Qr(this,a),r&&Tn()}}addValue_(e,t){Lt(this.keysAtom_),Br(()=>{var n;let r=new kt(t,this.enhancer_,`${this.name_}.${re(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=xn(),r=Xr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&Cn(i),r&&Qr(this,i),n&&Tn()}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 vi({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 vi({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 _i(e)&&(e=new Map(e)),Br(()=>{g(e)?te(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):ee(e)?(x(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){Br(()=>{Ut(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return Br(()=>{let t=yi(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`}},_i=b(`ObservableMap`,gi);function vi(e){return e[Symbol.toStringTag]=`MapIterator`,zi(e)}function yi(e){if(ee(e)||_i(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 bi={};var xi=class{constructor(e,t=he,n=`ObservableSet@`+u()){this.name_=void 0,this[T]=bi,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),Ii(()=>{this.atom_=ue(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){Br(()=>{Ut(()=>{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(Lt(this.atom_),qr(this)){let t=Yr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){Br(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=xn(),n=Xr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&Cn(r),n&&Qr(this,r),t&&Tn()}return this}delete(e){if(qr(this)&&!Yr(this,{type:hi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=xn(),n=Xr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:hi,object:this,oldValue:e}:null;return t&&Cn(r),Br(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Qr(this,r),t&&Tn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return Ci({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 Ci({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 Si(e)&&(e=new Set(e)),Array.isArray(e)||S(e)?Br(()=>{let t=S(e)?e:new Set(e);if(t.size===0){this.clear();return}if(this.data_.size===0){t.forEach(e=>this.add(e));return}for(let e of this.data_.values())t.has(this.dehanceValue_(e))||this.delete(e);t.forEach(e=>this.add(e))}):e!=null&&n(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},Si=b(`ObservableSet`,xi);function Ci(e){return e[Symbol.toStringTag]=`SetIterator`,zi(e)}let wi=Object.create(null),Ti=`remove`;var Ei=class{constructor(e,t=new Map,r,i=Ge){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 ce(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Vi(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 jt)return n.set(t),!0;if(qr(this)){let n=Yr(this,{type:ii,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==A.UNCHANGED){let r=Xr(this),i=xn(),a=r||i?{type:ii,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&Cn(a),n.setNewValue_(t),r&&Qr(this,a),i&&Tn()}return!0}get_(e){return A.trackingDerivation&&!ae(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return ae(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(!A.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new kt(e in this.target_,_e,`${this.name_}.${re(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);Mi(this,n,e);let i=n.extend_(this,e,t,r);return i&&ji(this,n,e),i}defineProperty_(e,t,n=!1){Lt(this.keysAtom_);try{on();let i=this.delete_(e);if(!i)return i;if(qr(this)){let n=Yr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:i}=n;t.value!==i&&(t=r({},t,{value:i}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else a(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{sn()}return!0}defineObservableProperty_(e,t,n,r=!1){Lt(this.keysAtom_);try{on();let i=this.delete_(e);if(!i)return i;if(qr(this)){let n=Yr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=ki(e),s={configurable:A.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 kt(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{sn()}return!0}defineComputedProperty_(e,t,n=!1){Lt(this.keysAtom_);try{on();let r=this.delete_(e);if(!r)return r;if(qr(this)&&!Yr(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=ki(e),o={configurable:A.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 jt(t)),this.notifyPropertyAddition_(e,void 0)}finally{sn()}return!0}delete_(e,t=!1){if(Lt(this.keysAtom_),!ae(this.target_,e))return!0;if(qr(this)&&!Yr(this,{object:this.proxy_||this.target_,name:e,type:Ti}))return null;try{var n;on();let r=Xr(this),a=xn(),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 kt&&(s=o.value_),dn(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Ti,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&Cn(t),r&&Qr(this,t),a&&Tn()}}finally{sn()}return!0}notifyPropertyAddition_(e,t){var n;let r=Xr(this),i=xn();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&&Cn(n),r&&Qr(this,n),i&&Tn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),ne(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function Di(e,t){if(t&&Ai(e)&&n(`Options can't be provided for already observable objects.`),ae(e,T))return Pi(e)instanceof Ei||n(`Cannot convert '${Fi(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,T,new Ei(e,new Map,String(r),ot(t))),e}let Oi=b(`ObservableObjectAdministration`,Ei);function ki(e){return wi[e]||(wi[e]={get(){return this[T].getObservablePropValue_(e)},set(t){return this[T].setObservablePropValue_(e,t)}})}function Ai(e){return h(e)?Oi(e[T]):!1}function ji(e,t,n){e.appliedAnnotations_[n]=t}function Mi(e,t,r){if(Vi(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!xe(t)&&ae(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 Ni(e,t){if(typeof e==`object`&&e){if(pi(e))return t!==void 0&&n(23),e[T].atom_;if(Si(e))return e.atom_;if(_i(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,Fi(e)),r}if(Ai(e)){if(!t)return n(26);let r=e[T],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,Fi(e)),i}if(le(e)||Mt(e)||yn(e))return e}else if(p(e)&&yn(e[T]))return e[T];n(28)}function Pi(e,t){if(e||n(29),t!==void 0)return Pi(Ni(e,t));if(le(e)||Mt(e)||yn(e)||_i(e)||Si(e))return e;if(e[T])return e[T];n(24,e)}function Fi(e,t){let n;if(t!==void 0)n=Ni(e,t);else if(Bn(e))return e.name;else n=Ai(e)||_i(e)||Si(e)?Pi(e):Ni(e);return n.name_}function Ii(e){let t=Wt(),n=Dt(!0);on();try{return e()}finally{sn(),Ot(n),Gt(t)}}let Li=o.toString;function P(e,t,n=-1){return F(e,t,n)}function F(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=Li.call(e);if(o!==Li.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=I(e),t=I(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(!F(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(!(ae(t,o)&&F(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function I(e){return pi(e)?e.slice():ee(e)||_i(e)||S(e)||Si(e)?Array.from(e.entries()):e}let Ri=globalThis.Iterator?.prototype||{};function zi(e){return e[Symbol.iterator]=Bi,r(Object.create(Ri),e)}function Bi(){return this}function Vi(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:En,extras:{getDebugName:Fi},$mobx:T}),e.$mobx=T,e.FlowCancellationError=ir,e.ObservableMap=gi,e.ObservableSet=xi,e.Reaction=mn,e._allowStateChanges=Et,e._allowStateChangesInsideComputed=zn,e._allowStateReadsEnd=Kt,e._allowStateReadsStart=k,e._autoAction=In,e._autoActionBound=Rn,e._endAction=Tt,e._getAdministration=Pi,e._getGlobalState=$t,e._interceptReads=mr,e._isComputingDerivation=It,e._resetGlobalState=j,e._startAction=wt,e.action=Fn,e.actionBound=Ln,e.autorun=Vn,e.compareDefault=me,e.compareIdentity=de,e.compareShallow=pe,e.compareStructural=fe,e.computed=O,e.computedStruct=_t,e.configure=Xn,e.createAtom=ue,e.defineProperty=jr,e.entries=Er,e.extendObservable=Zn,e.flow=lr,e.flowBound=ur,e.flowResult=fr,e.get=Ar,e.getAtom=Ni,e.getDebugName=Fi,e.getDependencyTree=Qn,e.getObserverTree=er,e.has=kr,e.intercept=hr,e.isAction=Bn,e.isBoxedObservable=At,e.isComputed=yr,e.isComputedProp=br,e.isFlow=pr,e.isFlowCancellationError=ar,e.isObservable=Sr,e.isObservableArray=pi,e.isObservableMap=_i,e.isObservableObject=Ai,e.isObservableProp=Cr,e.isObservableSet=Si,e.keys=wr,e.makeAutoObservable=ti,e.makeObservable=$r,e.observable=D,e.observableDeep=ft,e.observableRef=ut,e.observableShallow=dt,e.observableStruct=pt,e.observe=Nr,e.onBecomeObserved=Kn,e.onBecomeUnobserved=qn,e.onReactionError=hn,e.override=be,e.ownKeys=Mr,e.reaction=Wn,e.remove=Or,e.runInAction=zn,e.set=Dr,e.spy=En,e.toJS=zr,e.transaction=Br,e.untracked=Ut,e.values=Tr,e.when=Vr})),mb=Ee(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=fb():t.exports=pb()}))();function hb(e){if(Array.isArray(e))return Object.freeze(e.map(hb));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]=hb(r);return Object.freeze(t)}return e}function gb(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 _b(e){return typeof e==`string`?e:String(e)}function vb(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 yb(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 bb=class extends Error{constructor(e,t){super(t),this.variable=e}};function xb(e){return e instanceof bb||e instanceof Error&&e.cause!==void 0&&xb(e.cause)}var Sb=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?jb(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}},Cb=class extends Sb{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},wb=class extends Sb{name=`EvalError`;kind=`EvalError`},Tb=class extends wb{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=Mb(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}},Eb=class extends wb{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}},Db=class extends wb{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}},Ob=class extends Db{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)}`}},kb=class extends wb{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},Ab=class extends wb{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function jb(e,t){let n=e.split(`
60
+ `))}function Kv(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:o,failedConfigFile:s}=t,c=new H({bgcolor:i.bg,color:i.fg}),l=(e,t)=>new G(e,{style:t,end:``,overflow:`ignore`}),u=n>0?[l(`${n} more rows · `,c),o.kind===`file`?l(`open full text`,c.withLink(a(o.path).href)):l(`full text unavailable: ${Q_(o.reason)}`,c)]:[],d=s===null?[]:[l(`${u.length>0?` · `:``}open `,c),l(Q_(s),c.withLink(a(s).href))],f=[l(`↳ `,c),...u,...d.slice(0,-1)],p=f.reduce((e,t)=>e+t.cellLength,0),m=d.slice(-1).map(e=>e.truncate(Math.max(1,r.width-p),{mode:`middle`})),h=G.fromFragments([...f,...m]).truncate(r.width);return h.overflow=`ignore`,jv([h],r)}const qv=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Jv(e,t){return t.isSymbolicLink()?Buffer.from(p.readlinkSync(e)):p.readFileSync(e)}function Yv(e,t,n=qv){return p.readdirSync(t).filter(n).sort().flatMap(n=>{let r=s.join(t,n),i=p.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Yv(e,r):[[s.relative(e,r).split(s.sep).join(`/`),Jv(r,i)]]})}function Xv(e){let t=ue.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Zv(e){return Xv(Yv(e,e))}const Qv=[`Cargo.toml`,`Cargo.lock`,`src`];function $v(e){return Xv(Yv(e,e,e=>Qv.includes(e)))}const ey=e=>e.slice(0,7);function ty(e){let t=s.dirname(s.dirname(e));return p.existsSync(s.join(t,`src`))?t:null}function ny(){let e=ry();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:Gt,digest:e}}function ry(){return`ea163077897b23a2078a06f43950db572d5abf4105165aec23a7043cbd73c765`}function iy(e){let t=JSON.parse(p.readFileSync(s.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${s.join(e,`package.json`)} has no version string`);return n}function ay(e,t){try{let n=ty(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Zv(s.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:iy(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}var J=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const oy=new Map;function sy(e){let t=ly(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 cy(e,t){return e===`bar`?t:sy(e)}function ly(e){let t=oy.get(e);if(t!==void 0)return t;let n=qc(e);return n===null?null:(oy.set(e,n),n)}function uy(e,t){return dy(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>al(e,t))}const dy=Zp();function fy(e){let t=ly(e);return t===null?null:{kind:`decided`,name:e,value:t}}function py(e,t,n){let r=fy(e);return r===null?(n(Eh(t,`palette`,`"${e}" names no installed theme${ch(e)}`)),hy()):r}function my(e,t,n){return vh(e,t,n,hy(),fy)}function hy(){return{kind:`decided`,name:lh,value:sy(lh)}}const gy=/^[A-Za-z_][A-Za-z0-9_]*$/;function _y(e){return`#${e+1}`}const vy={rows:{}};function yy(e){return`rows`in e}function by(e){return Object.fromEntries(e.map((e,t)=>[_y(t),e]))}function xy(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:by(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:by([n])}}function Sy(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function Cy(e){return yy(e)?Sy(e):e}function*wy(e,t){if(!yy(e)){yield*eg(e,t);return}yield[Sy(e),t];for(let[n,r]of Object.entries(e.rows))yield*eg(r,`${t}.rows.${n}`)}function Ty(e,t){return yy(e)?{...t,...e,rows:{...t.rows,...e.rows}}:xy(e)}function Ey(e){if(!yy(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const Dy=`default`,Oy={};function ky(e){return[...new Set([Dy,...Object.keys(e)])]}function Ay(e,t,n){return hh(void 0,e,t,Dy,n)}function jy(e,t){let n={[Dy]:Oy,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${Dy}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function My(e,t){let n=jy(e.presets,t).root??vy;return{node:Sy(Ty(n,e.root)),path:Ey(n)?`presets.${t}.root`:`root`}}function Ny(e,t){return{...e.globals,...jy(e.presets,t).globals}}const Py=new Map;function Fy(e,t,n){Py.set(e,{permanent:!0,resolve:t,paletteOf:n})}Fy(`themes`,()=>dh(),e=>sy(e));const Iy=`placementThemes`;Fy(Iy,fh,(e,t)=>cy(e,t.palette));for(let{name:e,members:t}of F_)Fy(e,()=>t);function Ly(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>uy(n.basePalette,e.styles[t])}],[`presets`,{members:ky(e.presets)}]])}function Ry(e){return[...new Set([...Py.keys(),...e.keys()])]}function zy(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=Py.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(Vy(e,t))}const By=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function Vy(e,t){let n=By.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${Ry(t).join(`, `)})`}const Hy=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*Uy(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 Wy=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,Gy=RegExp(`^(?:(\\$)(?:\\.(${Wy}))?|\\.(${Wy})?)(?=[\\s)]|$)`);function Ky(e,t,n){let r=Gy.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 qy=/^(\w+)\b\s*([\s\S]*)$/;function*Jy(e,t){let n=[t];for(let r of Uy(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=qy.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:Ky(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(Ky(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const Yy=/(?<![.$])\btemplate\s+$/;function*Xy(e,t,n){let r=0;for(let i of[...e.matchAll(Hy)]){let a=i.index+i[0].length;Yy.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:Ky(e.slice(a),t,n)}),r=a}}function*Zy(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...Jy(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...Xy(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 Qy=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${Wy})`,`g`);function*$y({code:e,dot:t,root:n}){let r=e.replace(Hy,``);for(let e of[...r.matchAll(Qy)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function eb(e,t){let n=new Map;for(let r of Zy(e,t))for(let e of $y(r))n.has(e)||n.set(e,r.via);return n}const tb=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,nb={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*rb(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(Hy)]){let o=e.slice(t,a.index),s=tb.exec(o);if(s!==null)n=nb[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 ib(e,t){let n=new Map;for(let{code:r,via:i}of Zy(e,t))for(let{name:e,site:t}of rb(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function ab(e,t){return new Set([...ob(e,t)].filter(e=>Object.hasOwn(t,e)))}function ob(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of Zy(e,t))for(let{name:e}of Xy(r,i,a))n.add(e);return n}function sb(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 cb(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),lb(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 lb(e){return e.kind===`dropped`||(e.kind===`shell`||e.kind===`file`)&&ng(e.parse)===`json`}function ub(e){let t=s.basename(e),n=s.dirname(e);for(;;){let r=db(n);if(r!==null)return{dir:r,name:t,leaf:n===s.dirname(e)};t=s.basename(n),n=s.dirname(n)}}function db(e){try{return p.statSync(e).isDirectory()?p.realpathSync(e):null}catch{return null}}var fb=Ee((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()===Ht}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){Rt(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 zt.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=Ut,n=Ut){let r=new Kt(e);return t!==Ut&&(r.onBOL=new Set([t])),n!==Ut&&(r.onBUOL=new Set([n])),r}function _(e,t){return jt(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||nt(e)?e:Array.isArray(e)?cn.array(e,{name:n}):o(e)?cn.object(e,void 0,{name:n}):u(e)?cn.map(e,{name:n}):d(e)?cn.set(e,{name:n}):typeof e!=`function`||Ge(e)||$e(e)?e:s(e)?Kn(e):Rn(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:ee,u:x}}function ee(e,t,n,r){var i;return(i=this.i)!=null&&i.bound?this.u(e,t,n,!1)===null?0:1:r===e.h?this.u(e,t,n,!1)===null?0:2:Ge(n.value)?1:(Rt(r,t,te(e,this,t,n,!1)),2)}function x(e,t,n,r){let i=te(e,this,t,n);return e.l(t,i,r)}function S(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return be(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return Ge(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(Ge(n)||(n=c(n)),(l=s.i)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),n):void t(43,s.t,String(a),i);var l}function te(e,t,n,r,i=M.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:be(t.i?.name??n.toString(),c,(o=t.i?.autoAction)!=null&&o,(s=t.i)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function ne(e,t){return{t:e,i:t,o:re,u:ie}}function re(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)||!$e(e.h[t]))&&this.u(e,t,n,!1)===null?0:$e(n.value)?1:(Rt(r,t,oe(e,0,0,n,!1,!1)),2)}function ie(e,t,n,r){let i=oe(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function ae(e,t,n){var r;let{name:i,addInitializer:a}=n;return $e(t)||(t=Kn(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 oe(e,t,n,r,i,a=M.safeDescriptors){let{value:o}=r;return $e(o)||(o=Kn(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function C(e,t){return{t:e,i:t,o:w,u:se}}function w(e,t,n){return this.u(e,t,n,!1)===null?0:1}function se(e,t,n,r){return e.m(t,It({},this.i,{get:n.get,set:n.set}),r)}function T(e,t,n){function r(e){let n=It({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new bn(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=wt(this)[k],n=this,i=e.j.get(a);i instanceof bn&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[k],n=e.j.get(a);if(n instanceof bn&&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 ce(e,t){return{t:e,i:t,o:le,u:ue}}function le(e,t,n){return this.u(e,t,n,!1)===null?0:1}function ue(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function de(e,t,n){function r(e,t){let n=wt(e)[k];return(n.V??=new Map).set(o,()=>new vn(t,i.i?.A??v,`ObservableObject.${o.toString()}`,!1)),n}let i=e,{kind:a,name:o}=n;if(a===`accessor`)return{get(){return(this[k]??r(this,t.get.call(this)))._(o)},set(e){return(this[k]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function fe(e){return{t:Xt,i:e,o:pe,u:me}}function pe(e,t,n,r){var i,a,o;if(n.get)return fn.o(e,t,n,r);if(n.set){let i=Ge(n.set)?n.set:be(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!M.safeDescriptors||e.p,set:i})===null?0:2:(Rt(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?qn:Kn).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?Bn:Rn).o(e,t,n,r);let c=!1===this.i?.deep?rn:cn;return typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function me(e,t,n,r){var i;return n.get?fn.u(e,t,n,r):n.set?e.l(t,{configurable:!M.safeDescriptors||e.p,set:be(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.i?.deep?rn:cn).u(e,t,n,r))}function he(e,t){return It(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function ge(e){return e||Qt}function _e(e){return he(e,de)}function ve(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 ye(e){return he(e,T)}function be(e,t,n=!1,r){function i(){return xe(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),gn&&(_n.value=e,Rt(i,`name`,_n)),i}function xe(e,t,n,r,i){let a=Se(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{Ce(a)}}function Se(e,t){let n=M.trackingDerivation,r=!t||!n;Fe();let i=M.allowStateChanges;r&&ke();let a={R:r,k:n,C:i,I:M.allowStateReads,P:!1,T:0,B:hn++,D:mn};return mn=a.B,a}function Ce(e){mn!==e.B&&t(30),mn=e.D,e.N!==void 0&&(M.suppressReactionErrors=!0),Ie(),e.R&&Ae(e.k),M.suppressReactionErrors=!1}function we(e,t){let n=function(e){let t=M.allowStateChanges;return M.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){M.allowStateChanges=e})(n)}}function Te(e){return e instanceof Sn}function Ee(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=ke(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(xn(r)){if(M.disableErrorBoundaries)r.get();else try{r.get()}catch{return Ae(t),!0}if(e.K===2)return Ae(t),!0}}return je(e),Ae(t),!1}}}function De(e,t,n){je(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++M.runId;let r=M.trackingDerivation,i;if(M.trackingDerivation=e,M.inBatch++,!0===M.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new Sn(e)}return M.inBatch--,M.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&&Ne(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,Me(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function Oe(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Ne(t[n],e);e.K=-1}function E(e){let t=ke();try{return e()}finally{Ae(t)}}function ke(){let e=M.trackingDerivation;return M.trackingDerivation=null,e}function Ae(e){M.trackingDerivation=e}function je(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function Me(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Ne(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&Pe(e))}function Pe(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,M.pendingUnobservations.push(e))}function Fe(){M.inBatch++}function Ie(){--M.inBatch===0&&(Be(),!M.isRunningUnobservations&&M.pendingUnobservations.length>0&&function(){M.isRunningUnobservations=!0;try{let e=M.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 bn&&n.G())}M.pendingUnobservations=[]}finally{M.isRunningUnobservations=!1}}())}function Le(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Le))}function Re(e){let t=M.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&M.inBatch>0&&Pe(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&M.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function ze(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 Be(){M.inBatch>0||M.isRunningReactions||kn(Ve)}function Ve(){M.isRunningReactions=!0;let e=M.pendingReactions,t=0;for(;e.length>0;){++t===On&&(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()}M.isRunningReactions=!1}function He(e){return he(e,S)}function Ue(e){return function(t,n){return n&&typeof n.kind==`string`?S(e?Fn:Nn,t,n):r(t)?be(t.name||`<unnamed action>`,t,e):r(n)?be(t,n,e):i(t)?He(b(e?Mn:jn,{name:t,autoAction:e})):void 0}}function We(e){return xe(0,!1,e,this,void 0)}function Ge(e){return r(e)&&!0===e.isMobxAction}function Ke(e,t=Vt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=qe(t),r=!1;a=new Dn(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new Dn(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 qe(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Vn}function Je(e,t,n,i){let a=typeof i==`function`?Dt(t,n):Dt(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 Ye(e,t,n,r){let i=Gt(t);return At(()=>{let t=wt(e,r)[k];Wt(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function Xe(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(Xe)),t}function Ze(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),Ze)),t}function Qe(e){r(e.cancel)&&e.cancel()}function $e(e){return!0===e?.isMobXFlow}function et(e,t){var n;if(t===void 0)return xn(e);if(!1===Et(e))return!1;let r=e[k];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?xn(Dt(e,t)):!1}function tt(e,t){if(!e)return!1;if(t!==void 0){if(Et(e)){var n,r;let i=e[k];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return Et(e)||!!e[k]||qt(e)||An(e)||xn(e)}function nt(e){return tt(e)}function rt(e){return Et(e)?e[k].nt():ar(e)||cr(e)?Array.from(e.keys()):xt(e)?e.map((e,t)=>t):void t(5)}function it(e,n){return Et(e)?e[k].et(n):ar(e)||cr(e)?e.has(n):xt(e)?n>=0&&n<e.length:void t(10)}function at(e){if(Et(e))return e[k].it();t(38)}function ot(e,t,n){if(xn(e)){let r,i=!0;return Ke(()=>{let a=e.get();if(!i||n){let n=ke();t({observableKind:`computed`,debugObjectName:e.tt,type:Zn,object:e,newValue:a,oldValue:r}),Ae(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Zn,newValue:e.rt,oldValue:void 0}),ht(e,t)}function st(e,t,n){return e.set(t,n),n}function ct(e,t){if(typeof e!=`object`||!e||e instanceof Date||!nt(e))return e;if(yn(e)||xn(e))return ct(e.get(),t);if(t.has(e))return t.get(e);if(xt(e)){let n=st(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=ct(e,t)}),n}if(cr(e)){let n=st(t,e,new Set);return e.forEach(e=>{n.add(ct(e,t))}),n}if(ar(e)){let n=st(t,e,new Map);return e.forEach((e,r)=>{n.set(r,ct(e,t))}),n}{let n=st(t,e,{});return at(e).forEach(r=>{zt.propertyIsEnumerable.call(e,r)&&(n[r]=ct(e[r],t))}),n}}function lt(e,t){Fe();try{return e.apply(t)}finally{Ie()}}function ut(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[k].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=be(`When-effect`,t);var a=Ke(t=>{we(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function dt(e){return e[k]}function ft(e){return e.st!==void 0&&e.st.length>0}function pt(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 D(e,n){let r=ke();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{Ae(r)}}function mt(e){return e.ot!==void 0&&e.ot.length>0}function ht(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 gt(e,t){let n=ke(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ae(n)}}function _t(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!==zt;){let t=Lt(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 O(e,t){typeof Array.prototype[e]==`function`&&(er[e]=t(e))}function vt(e){return function(){let t=this[k];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function yt(e){return function(t,n){let r=this[k];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function bt(e){return function(){let t=this[k];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 xt(e){return a(e)&&tr(e[k])}function St(e){return e[Symbol.toStringTag]=`MapIterator`,Pt(e)}function Ct(e){return e[Symbol.toStringTag]=`SetIterator`,Pt(e)}function wt(e,t){if(p(e,k))return e;let n=t?.name??`ObservableObject`;return c(e,k,new dr(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 A[r]??(A[r]=fe({deep:t,autoBind:n}))}(e):void 0}(t))),e}function Tt(e){return lr[e]||(lr[e]={get(){return this[k]._(e)},set(t){return this[k].M(e,t)}})}function Et(e){return!!a(e)&&fr(e[k])}function Dt(e,n){if(typeof e==`object`&&e){if(xt(e))return n!==void 0&&t(23),e[k].ct;if(cr(e))return e.ct;if(ar(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,kt(e)),r}if(Et(e)){if(!n)return t(26);let r=e[k],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,kt(e)),i}if(qt(e)||xn(e)||An(e))return e}else if(r(e)&&An(e[k]))return e[k];t(28)}function Ot(e,n){return e||t(29),n===void 0?qt(e)||xn(e)||An(e)||ar(e)||cr(e)?e:e[k]?e[k]:void t(24,e):Ot(Dt(e,n))}function kt(e,t){let n;if(t!==void 0)n=Dt(e,t);else{if(Ge(e))return e.name;n=Et(e)||ar(e)||cr(e)?Ot(e):Dt(e)}return n.tt}function At(e){let t=ke();Fe();try{return e()}finally{Ie(),Ae(t)}}function jt(e,t,n=-1){return Mt(e,t,n)}function Mt(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=pr.call(e);if(s!==pr.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=Nt(e),t=Nt(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(!Mt(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)||!Mt(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function Nt(e){return xt(e)?e.slice():u(e)||ar(e)||d(e)||cr(e)?Array.from(e.entries()):e}function Pt(e){return e[Symbol.iterator]=Ft,It(Object.create(mr),e)}function Ft(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let It=Object.assign,Lt=Object.getOwnPropertyDescriptor,Rt=Object.defineProperty,zt=Object.prototype,Bt=[];Object.freeze(Bt);let Vt={};Object.freeze(Vt);let Ht=Object.toString(),Ut=()=>{},Wt=Reflect.ownKeys,Gt=Object.getOwnPropertyDescriptors,k=Symbol(`mobx administration`);var Kt=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 Re(this)}reportChanged(){Fe(),ze(this),Ie()}toString(){return this.tt}};let qt=l(`Atom`,Kt),Jt=Object.is,Yt={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},Xt=`true`,Zt=fe(),A=[Zt],Qt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Qt);let $t=ce(`observable`),j=ce(`observable.ref`,{A:y}),en=ce(`observable.shallow`,{A:function(e,t,n){return e==null||Et(e)||xt(e)||ar(e)||cr(e)?e:Array.isArray(e)?cn.array(e,{name:n,deep:!1}):o(e)?cn.object(e,void 0,{name:n,deep:!1}):u(e)?cn.map(e,{name:n,deep:!1}):d(e)?cn.set(e,{name:n,deep:!1}):void 0}}),tn=ce(`observable.struct`,{A:function(e,t){return jt(e,t)?t:e}}),nn={box(e,t){let n=ge(t);return new vn(e,ve(n),n.name,!0,n.equals)},array(e,t){let n=ge(t);return function(e,t,n=`ObservableArray`,r=!1){return At(()=>{let i=new $n(n,t,r);Rt(i.j,k,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Qn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,ve(n),n.name)},map(e,t){let n=ge(t);return new ir(e,ve(n),n.name)},set(e,t){let n=ge(t);return new sr(e,ve(n),n.name)},object:(e,t,n)=>At(()=>Ye(function(e,t){var n;return(n=(e=wt(e,t))[k]).v??(n.v=new Proxy(e,Jn))}({},n),e,t))},rn=_e(j),an=_e(en),on=_e($t),sn=_e(tn);var cn=It(function(e,t,n){return t&&typeof t.kind==`string`?de($t,e,t):nt(e)?e:o(e)?cn.object(e,t,n):Array.isArray(e)?cn.array(e,t):u(e)?cn.map(e,t):d(e)?cn.set(e,t):typeof e==`object`&&e?e:cn.box(e,t)},$t,nn);let ln=`computed`,un=C(ln),dn=ye(C(`computed.struct`,{equals:_})),fn=function(e,t){if(t&&typeof t.kind==`string`)return T(un,e,t);if(o(e))return ye(C(ln,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new bn(n)};var pn;It(fn,un);let mn=0,hn=1,gn=(pn=Lt(()=>{},`name`)?.configurable)!=null&&pn,_n={value:`action`,configurable:!0,writable:!1,enumerable:!1};var vn=class extends Kt{constructor(e,t,n=`ObservableValue`,r=!0,i=Jt){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))!==M.UNCHANGED&&this.Ot(e)}jt(e){if(ft(this)){let t=D(this,{object:this,type:Zn,newValue:e});if(!t)return M.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?M.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),mt(this)&&gt(this,{type:Zn,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.rt)}raw(){return this.rt}toJSON(){return this.get()}toString(){return`${this.tt}[${this.rt}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let yn=l(`ObservableValue`,vn);var bn=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 Sn(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=be(`ComputedValue-setter`,e.set)),this.xt=e.equals||Jt,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),M.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Re(this),Ee(this)){let e=M.trackingContext;e||!this.Mt&&!this.isBeingObserved||(M.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),M.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Le)}else Ee(this)&&(this.Nt(),Fe(),this.rt=this.Rt(!1),Ie());let e=this.rt;if(Te(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||Te(e)||Te(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=De(this,this.derivation,this.At);else if(!0===M.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new Sn(e)}return this.isComputing=!1,t}G(){this.Mt||(Oe(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let xn=l(`ComputedValue`,bn);var Sn=class{constructor(e){this.cause=void 0,this.cause=e}};let Cn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var wn=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 Tn=!0,En=!1,M=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Tn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Tn=!1),Tn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new wn):(setTimeout(()=>{En||t(35)},1),new wn)}();var Dn=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,M.pendingReactions.push(this),Be())}X(){if(!this.isDisposed){Fe(),this.isScheduled=!1;let e=M.trackingContext;if(M.trackingContext=this,Ee(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}M.trackingContext=e,Ie()}}track(e){if(this.isDisposed)return;Fe(),this.isRunning=!0;let t=M.trackingContext;M.trackingContext=this;let n=De(this,e,void 0);M.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Oe(this),Te(n)&&this.Pt(n.cause),Ie()}Pt(e){if(this.kt)this.kt(e,this);else{if(M.disableErrorBoundaries)throw e;M.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),M.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(Fe(),Oe(this),Ie()))}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[k]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let On=100,kn=e=>e(),An=l(`Reaction`,Dn),jn=`action`,Mn=`autoAction`,Nn=b(jn),Pn=b(`action.bound`,{bound:!0}),Fn=b(Mn,{autoAction:!0}),In=b(`autoAction.bound`,{autoAction:!0,bound:!0}),Ln=Ue(!1);It(Ln,Nn);let Rn=Ue(!0);It(Rn,Fn);let zn=He(Pn),Bn=He(In),Vn=e=>e(),Hn=`always`;var Un=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Wn=ne(`flow`),Gn=ne(`flow.bound`,{bound:!0}),Kn=It(function(e,t){if(t&&typeof t.kind==`string`)return ae(Wn,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=Ln(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=Ln(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=Ln(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=Ln(i,function(){try{o&&Qe(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Ut,Ut),Qe(n),a(new Un)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Wn),qn=he(Gn,ae),Jn={has:(e,t)=>dt(e).et(t),get:(e,t)=>dt(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=dt(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=dt(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=dt(e).l(t,n))==null||r},ownKeys:e=>dt(e).it(),preventExtensions(e){t(13)}},Yn=Symbol(`mobx-keys`),Xn=`splice`,Zn=`update`,Qn={get(e,t){let n=e[k];return t===k?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p(er,t)?er[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[k];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var $n=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 Kt(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=Bt),ft(this)){let r=D(this,{object:this.v,type:Xn,index:e,removedCount:t,added:n});if(!r)return Bt;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=mt(this),i=r?{observableKind:`array`,object:this.v,type:Zn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&gt(this,i)}Ft(e,t,n){let r=mt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:Xn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&gt(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(ft(this)){let n=D(this,{type:Zn,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)}}},er={clear(){return this.splice(0)},replace(e){let t=this[k];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[k];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[k].wt(e,t,n)},push(...e){let t=this[k];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[k].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[k];return t.wt(0,0,e),t.j.length},reverse(){return M.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){M.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[k],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};O(`at`,vt),O(`concat`,vt),O(`flat`,vt),O(`includes`,vt),O(`indexOf`,vt),O(`join`,vt),O(`lastIndexOf`,vt),O(`slice`,vt),O(`toString`,vt),O(`toLocaleString`,vt),O(`toSorted`,vt),O(`toSpliced`,vt),O(`with`,vt),O(`every`,yt),O(`filter`,yt),O(`find`,yt),O(`findIndex`,yt),O(`findLast`,yt),O(`findLastIndex`,yt),O(`flatMap`,yt),O(`forEach`,yt),O(`map`,yt),O(`some`,yt),O(`toReversed`,yt),O(`reduce`,bt),O(`reduceRight`,bt);let tr=l(`ObservableArrayAdministration`,$n),nr={},rr=`delete`;var ir=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[k]=nr,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,At(()=>{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(!M.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new vn(this.et(e),y,`ObservableMap.key?`,!1);this.dt.set(e,n),n.onBUOL=new Set([()=>this.dt.delete(e)])}return t.get()}set(e,t){let n=this.et(e);if(ft(this)){let r=D(this,{type:n?Zn:`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(ft(this)&&!D(this,{type:rr,object:this,name:e}))return!1;if(this.et(e)){let t=mt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:rr,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return lt(()=>{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&&gt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==M.UNCHANGED){let r=mt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Zn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&gt(this,i)}}Jt(e,t){lt(()=>{var n;let r=new vn(t,this.A,`ObservableMap.key`,!1);this.ft.set(e,r),t=r.rt,(n=this.dt.get(e))==null||n.Ot(!0),this.lt.reportChanged()});let n=mt(this);n&&gt(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 St({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 St({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 ar(e)&&(e=new Map(e)),lt(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>zt.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(){lt(()=>{E(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return lt(()=>{let n=function(e){if(u(e)||ar(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`}},ar=l(`ObservableMap`,ir);let or={};var sr=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[k]=or,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),At(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){lt(()=>{E(()=>{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(ft(this)){let t=D(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){lt(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=mt(this);t&&gt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(ft(this)&&!D(this,{type:rr,object:this,oldValue:e}))return!1;if(this.has(e)){let t=mt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:rr,object:this,oldValue:e}:null;return lt(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&gt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return Ct({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 Ct({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 cr(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?lt(()=>{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`}},cr=l(`ObservableSet`,sr);let lr=Object.create(null),ur=`remove`;var dr=class{constructor(e,t=new Map,n,r=Zt){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 Kt(`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 bn)return n.set(t),!0;if(ft(this)){let n=D(this,{type:Zn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==M.UNCHANGED){let r=mt(this),i=r?{type:Zn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&gt(this,i)}return!0}Tt(e){return M.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(!M.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new vn(e in this.h,y,`ObservableObject.key?`,!1),this.Qt.set(e,t)),t.get()}u(e,t,n,r=!1){return!0===n&&(n=this.ut),!1===n?this.l(e,t,r):n.u(this,e,t,r)}l(e,t,n=!1){try{Fe();let r=this.Dt(e);if(!r)return r;if(ft(this)){let n=D(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=It({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else Rt(this.h,e,t);this.Yt(e,t.value)}finally{Ie()}return!0}S(e,t,n,r=!1){try{Fe();let i=this.Dt(e);if(!i)return i;if(ft(this)){let n=D(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=Tt(e),o={configurable:!M.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else Rt(this.h,e,o);let s=new vn(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Ie()}return!0}m(e,t,n=!1){try{Fe();let r=this.Dt(e);if(!r)return r;if(ft(this)&&!D(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=Tt(e),a={configurable:!M.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else Rt(this.h,e,a);this.j.set(e,new bn(t)),this.Yt(e,void 0)}finally{Ie()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(ft(this)&&!D(this,{object:this.v||this.h,name:e,type:ur}))return null;try{var n;Fe();let r=mt(this),i=this.j.get(e),a;if(i||!r||(a=Lt(this.h,e)?.value),t){if(!Reflect.deleteProperty(this.h,e))return!1}else delete this.h[e];i&&(this.j.delete(e),i instanceof vn&&(a=i.rt),ze(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&gt(this,{type:ur,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Ie()}return!0}Yt(e,t){var n;let r=mt(this);r&&r&&gt(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(),Wt(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let fr=l(`ObservableObjectAdministration`,dr),pr=zt.toString,mr=globalThis.Iterator?.prototype||{};e.$mobx=k,e.FlowCancellationError=Un,e.ObservableMap=ir,e.ObservableSet=sr,e.Reaction=Dn,e._allowStateChanges=we,e._allowStateChangesInsideComputed=We,e._allowStateReadsEnd=function(e){M.allowStateReads=e},e._allowStateReadsStart=function(e){let t=M.allowStateReads;return M.allowStateReads=e,t},e._autoAction=Rn,e._autoActionBound=Bn,e._endAction=Ce,e._getAdministration=Ot,e._getGlobalState=function(){return M},e._interceptReads=function(e,t,n){let r;return ar(e)||xt(e)||yn(e)?r=Ot(e):Et(e)&&(r=Ot(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return M.trackingDerivation!==null},e._resetGlobalState=function(){let e=new wn;for(let t in e)Cn.indexOf(t)===-1&&(M[t]=e[t]);M.allowStateChanges=!M.enforceActions},e._startAction=Se,e.action=Ln,e.actionBound=zn,e.autorun=Ke,e.compareDefault=Jt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return jt(e,t,1)},e.compareStructural=_,e.computed=fn,e.computedStruct=dn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((M.pendingReactions.length||M.inBatch||M.isRunningReactions)&&t(36),En=!0,Tn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),M=new wn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===Hn?Hn:n===`observed`;M.enforceActions=e,M.allowStateChanges=!0!==e&&e!==Hn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(M[t]=!!e[t])}),M.allowStateReads=!M.observableRequiresReaction,e.reactionScheduler&&function(e){let t=kn;kn=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(Et(e))return e[k].l(n,r);t(39)},e.entries=function(e){return Et(e)?rt(e).map(t=>[t,e[t]]):ar(e)?rt(e).map(t=>[t,e.get(t)]):cr(e)?Array.from(e.entries()):xt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ye,e.flow=Kn,e.flowBound=qn,e.flowResult=function(e){return e},e.get=function(e,n){if(it(e,n))return Et(e)?e[k].Tt(n):ar(e)?e.get(n):xt(e)?e[n]:void t(11)},e.getAtom=Dt,e.getDebugName=kt,e.getDependencyTree=function(e,t){return Xe(Dt(e,t))},e.getObserverTree=function(e,t){return Ze(Dt(e,t))},e.has=it,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return pt(Ot(e,t),n)}(e,t,n):function(e,t){return pt(Ot(e),t)}(e,t)},e.isAction=Ge,e.isBoxedObservable=yn,e.isComputed=function(e){return et(e)},e.isComputedProp=function(e,t){return et(e,t)},e.isFlow=$e,e.isFlowCancellationError=function(e){return e instanceof Un},e.isObservable=nt,e.isObservableArray=xt,e.isObservableMap=ar,e.isObservableObject=Et,e.isObservableProp=function(e,t){return tt(e,t)},e.isObservableSet=cr,e.keys=rt,e.makeAutoObservable=function(e,t,n){return o(e)?Ye(e,e,t,n):(At(()=>{let r=wt(e,n)[k];if(!e[Yn]){let t=Object.getPrototypeOf(e),n=new Set([...Wt(e),...Wt(t)]);n.delete(`constructor`),n.delete(k),c(t,Yn,n)}e[Yn].forEach(e=>_t(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return At(()=>{let r=wt(e,n)[k];Wt(t).forEach(e=>_t(r,e,t[e]))}),e},e.observable=cn,e.observableDeep=on,e.observableRef=rn,e.observableShallow=an,e.observableStruct=sn,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return ot(Ot(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Ot(e);if(xt(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(!ar(e)&&!cr(e)&&!Et(e))return ot(r,t,n);return ht(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return Je(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return Je(`onBUO`,e,t,n)},e.onReactionError=function(e){return M.globalReactionErrorHandlers.push(e),()=>{let t=M.globalReactionErrorHandlers.indexOf(e);t>=0&&M.globalReactionErrorHandlers.splice(t,1)}},e.override=Yt,e.ownKeys=at,e.reaction=function(e,t,n=Vt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=we(!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=Ln(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=qe(n),d,f=!0,p=!1,m=n.equals||Jt,h=new Dn(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){Et(e)?e[k].Dt(n):ar(e)||cr(e)?e.delete(n):xt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=We,e.set=function e(n,r,i){if(arguments.length===2&&!cr(n)){Fe();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Ie()}return}Et(n)?n[k].Bt(r,i):ar(n)?n.set(r,i):cr(n)?n.add(r):xt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),Fe(),r>=n.length&&(n.length=r+1),n[r]=i,Ie()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return ct(e,new Map)},e.transaction=lt,e.untracked=E,e.values=function(e){return Et(e)?rt(e).map(t=>e[t]):ar(e)?rt(e).map(t=>e.get(t)):cr(e)?Array.from(e.values()):xt(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 It(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=ut(e,n,It({},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):ut(e,t,n||{})}})),pb=Ee((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++A.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=ae(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===l}function _(e){let t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function v(e,t,n){a(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function y(e,t,n){a(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function b(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return h(e)&&e[n]===!0}}function ee(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function x(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function S(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function te(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let ne=Reflect.ownKeys;function re(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ie(e){return e===null?null:typeof e==`object`?``+e:e}function ae(e,t){return o.hasOwnProperty.call(e,t)}let oe=Object.getOwnPropertyDescriptors;function C(e,t){return!!(e&t)}function w(e,t,n){return n?e|=t:e&=~t,e}function se(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let T=Symbol(`mobx administration`);var ce=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 C(this.flags_,1)}set isBeingObserved(e){this.flags_=w(this.flags_,1,e)}get isPendingUnobservation(){return C(this.flags_,2)}set isPendingUnobservation(e){this.flags_=w(this.flags_,2,e)}get diffValue(){return+!!C(this.flags_,4)}set diffValue(e){this.flags_=w(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return un(this)}reportChanged(){on(),dn(this),sn()}toString(){return this.name_}};let le=b(`Atom`,ce);function ue(e,t=f,n=f){let r=new ce(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function de(e,t){return e===t}function fe(e,t){return P(e,t)}function pe(e,t){return P(e,t,1)}let me=Object.is;function he(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||Sr(e)?e:Array.isArray(e)?D.array(e,{name:n}):g(e)?D.object(e,void 0,{name:n}):ee(e)?D.map(e,{name:n}):S(e)?D.set(e,{name:n}):typeof e==`function`&&!Bn(e)&&!pr(e)?_(e)?lr(e):In(n,e):e}function ge(e,t,r){if(e==null||Ai(e)||pi(e)||_i(e)||Si(e))return e;if(Array.isArray(e))return D.array(e,{name:r,deep:!1});if(g(e))return D.object(e,void 0,{name:r,deep:!1});if(ee(e))return D.map(e,{name:r,deep:!1});if(S(e))return D.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function _e(e){return e}function ve(e,t){return Sr(e)&&n(`observable.struct should not be used with observable values`),P(e,t)?t:e}let ye=`override`,be={annotationType_:ye,make_:Se,extend_:Ce};function xe(e){return e.annotationType_===ye}function Se(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),ae(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function Ce(e,t,r,i){n(44,this.annotationType_)}function we(e,t){return{annotationType_:e,options_:t,make_:Te,extend_:Ee}}function Te(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:Bn(n.value)?1:(a(r,t,E(e,this,t,n,!1)),2)}function Ee(e,t,n,r){let i=E(e,this,t,n);return e.defineProperty_(t,i,r)}function De(e,t,r){se(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>St(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return Bn(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return Bn(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 Oe(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 E(e,t,n,r,i=A.safeDescriptors){var a,o;Oe(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:St(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 ke(e,t){return{annotationType_:e,options_:t,make_:Ae,extend_:je}}function Ae(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&&(!ae(e.target_,t)||!pr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:pr(n.value)?1:(a(r,t,Pe(e,this,t,n,!1,!1)),2)}function je(e,t,n,r){let i=Pe(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function Me(e,t,n){var r;se(n,[`method`]);let{name:i,addInitializer:a}=n;return pr(t)||(t=lr(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 Ne(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 Pe(e,t,n,r,i,a=A.safeDescriptors){Ne(e,t,n,r);let{value:o}=r;return pr(o)||(o=lr(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function Fe(e,t){return{annotationType_:e,options_:t,make_:Ie,extend_:Le}}function Ie(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Le(e,t,n,i){return ze(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Re(e,t,n){se(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 jt(o)}return o(function(){let e=Di(this)[T],n=this,r=e.values_.get(a);r instanceof jt&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[T],n=e.values_.get(a);if(n instanceof jt&&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 ze(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 Be(e,t){return{annotationType_:e,options_:t,make_:Ve,extend_:He}}function Ve(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function He(e,t,n,r){return We(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??he,r)}function Ue(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);se(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=Di(e)[T];return(n.lazyObservableKeys_??=new Map).set(o,()=>new kt(t,i.options_?.enhancer_??he,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[T]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[T]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function We(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 Ge=Ke();function Ke(e){return{annotationType_:`true`,options_:e,make_:Ye,extend_:Xe}}let qe=[Ge];function Je(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return qe[r]??(qe[r]=Ke({deep:t,autoBind:n}))}function Ye(e,t,n,r){var i;if(n.get)return O.make_(e,t,n,r);if(n.set){let i=Bn(n.set)?n.set:St(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:A.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?ur:lr).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Rn:In).make_(e,t,n,r)}let c=this.options_?.deep===!1?ut:D;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 Xe(e,t,n,r){var i;return n.get?O.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:A.safeDescriptors?e.isPlainObject_:!0,set:St(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?ut:D).extend_(e,t,n,r))}function Ze(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 Qe={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Qe);function $e(e){return e||Qe}let et=Be(`observable`),tt=Be(`observable.ref`,{enhancer_:_e}),nt=Be(`observable.shallow`,{enhancer_:ge}),rt=Be(`observable.struct`,{enhancer_:ve});function it(e){return Ze(e,Ue)}function at(e){return e.deep===!0?he:e.deep===!1?_e:st(e.defaultDecorator)}function ot(e){return e?e.defaultDecorator??Je(e):void 0}function st(e){return e?e.options_?.enhancer_??he:he}function ct(e,t,n){return t&&typeof t.kind==`string`?Ue(et,e,t):Sr(e)?e:g(e)?D.object(e,t,n):Array.isArray(e)?D.array(e,t):ee(e)?D.map(e,t):S(e)?D.set(e,t):typeof e==`object`&&e?e:D.box(e,t)}let lt={box(e,t){let n=$e(t);return new kt(e,at(n),n.name,!0,n.equals)},array(e,t){let n=$e(t);return si(e,at(n),n.name)},map(e,t){let n=$e(t);return new gi(e,at(n),n.name)},set(e,t){let n=$e(t);return new xi(e,at(n),n.name)},object(e,t,n){return Ii(()=>Zn(Kr({},n),e,t))}},ut=it(tt),dt=it(nt),ft=it(et),pt=it(rt);var D=r(ct,et,lt);let mt=`computed`;function ht(e){return Ze(e,Re)}let gt=Fe(mt),_t=ht(Fe(`computed.struct`,{equals:fe})),O=function(e,t){if(t&&typeof t.kind==`string`)return Re(gt,e,t);if(g(e))return ht(Fe(mt,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 jt(r)};r(O,gt);let vt=0,yt=1,bt=i(()=>{},`name`)?.configurable??!1,xt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function St(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 Ct(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),bt&&(xt.value=e,a(o,`name`,xt)),o}function Ct(e,t,n,r,i){let a=wt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{Tt(a)}}function wt(e,t,n,r){let i=xn()&&!!e,a=0;i&&(a=Date.now(),Cn({type:M,name:e,object:n,arguments:r?Array.from(r):s}));let o=A.trackingDerivation,c=!t||!o;on();let l=A.allowStateChanges;c&&(Wt(),l=Dt(!0));let u=A.allowStateReads;k(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:yt++,parentActionId_:vt};return vt=d.actionId_,d}function Tt(e){vt!==e.actionId_&&n(30),vt=e.parentActionId_,e.error_!==void 0&&(A.suppressReactionErrors=!0),Ot(e.prevAllowStateChanges_),Kt(e.prevAllowStateReads_),sn(),e.runAsAction_&&Gt(e.prevDerivation_),e.notifySpy_&&Tn({time:Date.now()-e.startTime_}),A.suppressReactionErrors=!1}function Et(e,t){let n=Dt(e);try{return t()}finally{Ot(n)}}function Dt(e){let t=A.allowStateChanges;return A.allowStateChanges=e,t}function Ot(e){A.allowStateChanges=e}var kt=class extends ce{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=me){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&&xn()&&Sn({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!==A.UNCHANGED){let n=xn();n&&Cn({type:ii,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Tn()}}prepareNewValue_(e){if(Lt(this),qr(this)){let t=Yr(this,{object:this,type:ii,newValue:e});if(!t)return A.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?A.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),Xr(this)&&Qr(this,{type:ii,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 ie(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let At=b(`ObservableValue`,kt);var jt=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 Nt(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_=St(this.name_+`-setter`,e.set)),this.equals_=e.equals||me,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){pn(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return C(this.flags_,1)}set isComputing(e){this.flags_=w(this.flags_,1,e)}get isRunningSetter(){return C(this.flags_,2)}set isRunningSetter(e){this.flags_=w(this.flags_,2,e)}get isBeingObserved(){return C(this.flags_,4)}set isBeingObserved(e){this.flags_=w(this.flags_,4,e)}get isPendingUnobservation(){return C(this.flags_,8)}set isPendingUnobservation(e){this.flags_=w(this.flags_,8,e)}get diffValue(){return+!!C(this.flags_,16)}set diffValue(e){this.flags_=w(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),A.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Ft(this)&&(this.warnAboutUntrackedRead_(),on(),this.value_=this.computeValue_(!1),sn());else{let e=this.isBeingObserved;if(un(this),Ft(this)){let e=A.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(A.trackingContext=this),this.trackAndCompute()&&fn(this),A.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(ln)}let e=this.value_;if(Pt(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||Pt(e)||Pt(n)||!this.equals_(e,n);return r&&(this.value_=n,xn()&&Sn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=Dt(!1),n;if(e)n=zt(this,this.derivation,this.scope_);else if(A.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new Nt(e)}return Ot(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(Ht(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:A.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 ie(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Mt=b(`ComputedValue`,jt);var Nt=class{constructor(e){this.cause=void 0,this.cause=e}};function Pt(e){return e instanceof Nt}function Ft(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=k(!0),n=Wt(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(Mt(i)){if(A.disableErrorBoundaries)i.get();else try{i.get()}catch{return Gt(n),Kt(t),!0}if(e.dependenciesState_===2)return Gt(n),Kt(t),!0}}return qt(e),Gt(n),Kt(t),!1}}}function It(){return A.trackingDerivation!==null}function Lt(e){let t=!!e.observers_&&e.observers_.size>0;!A.allowStateChanges&&(t||A.enforceActions===`always`)&&console.warn(`[MobX] `+(A.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 Rt(e){!A.allowStateReads&&A.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function zt(e,t,n){let r=k(!0);qt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++A.runId;let i=A.trackingDerivation;A.trackingDerivation=e,A.inBatch++;let a;if(A.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new Nt(e)}return A.inBatch--,A.trackingDerivation=i,Vt(e),Bt(e),Kt(r),a}function Bt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:A.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function Vt(e){let t=e.observing_,n=e.observing_=e.newObserving_,r=0,i=0,a=e.unboundDepsCount_;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.dependenciesState_>r&&(r=t.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&rn(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,nn(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function Ht(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)rn(t[n],e);e.dependenciesState_=-1}function Ut(e){let t=Wt();try{return e()}finally{Gt(t)}}function Wt(){let e=A.trackingDerivation;return A.trackingDerivation=null,e}function Gt(e){A.trackingDerivation=e}function k(e){let t=A.allowStateReads;return A.allowStateReads=e,t}function Kt(e){A.allowStateReads=e}function qt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Jt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Yt=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 Xt=!0,Zt=!1,A=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Xt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Xt=!1),Xt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Yt):(setTimeout(()=>{Zt||n(35)},1),new Yt)}();function Qt(){if((A.pendingReactions.length||A.inBatch||A.isRunningReactions)&&n(36),Zt=!0,Xt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),A=new Yt}}function $t(){return A}function j(){let e=new Yt;for(let t in e)Jt.indexOf(t)===-1&&(A[t]=e[t]);A.allowStateChanges=!A.enforceActions}function en(e){return!!e.observers_&&e.observers_.size>0}function tn(e){return e.observers_??new Set}function nn(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function rn(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&an(e))}function an(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,A.pendingUnobservations.push(e))}function on(){A.inBatch++}function sn(){--A.inBatch===0&&(_n(),!A.isRunningUnobservations&&A.pendingUnobservations.length>0&&cn())}function cn(){A.isRunningUnobservations=!0;try{let e=A.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 jt&&n.suspend_())}A.pendingUnobservations=[]}finally{A.isRunningUnobservations=!1}}function ln(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(ln))}function un(e){Rt(e);let t=A.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&A.inBatch>0&&an(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&A.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function dn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&e.onBecomeStale_(),e.dependenciesState_=2}))}function fn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(t=>{t.dependenciesState_===1?t.dependenciesState_=2:t.dependenciesState_===0&&(e.lowestObserverState_=0)}))}function pn(e){var t;e.lowestObserverState_===0&&(e.lowestObserverState_=1,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&(e.dependenciesState_=1,e.onBecomeStale_())}))}var mn=class{constructor(e=`Reaction@`+u(),t,n,r){this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=-1,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.removeAbortListener_=void 0,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}get isDisposed(){return C(this.flags_,1)}set isDisposed(e){this.flags_=w(this.flags_,1,e)}get isScheduled(){return C(this.flags_,2)}set isScheduled(e){this.flags_=w(this.flags_,2,e)}get isTrackPending(){return C(this.flags_,4)}set isTrackPending(e){this.flags_=w(this.flags_,4,e)}get isRunning(){return C(this.flags_,8)}set isRunning(e){this.flags_=w(this.flags_,8,e)}get diffValue(){return+!!C(this.flags_,16)}set diffValue(e){this.flags_=w(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,A.pendingReactions.push(this),_n())}runReaction_(){if(!this.isDisposed){on(),this.isScheduled=!1;let e=A.trackingContext;if(A.trackingContext=this,Ft(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&xn()&&Sn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}A.trackingContext=e,sn()}}track(e){if(this.isDisposed)return;on();let t=xn(),n;t&&(n=Date.now(),Cn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=A.trackingContext;A.trackingContext=this;let i=zt(this,e,void 0);A.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Ht(this),Pt(i)&&this.reportExceptionInDerivation_(i.cause),t&&Tn({time:Date.now()-n}),sn()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(A.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;A.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),xn()&&Sn({type:`error`,name:this.name_,message:t,error:``+e}),A.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(on(),Ht(this),sn())}}getDisposer_(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.removeAbortListener_=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[T]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function hn(e){return A.globalReactionErrorHandlers.push(e),()=>{let t=A.globalReactionErrorHandlers.indexOf(e);t>=0&&A.globalReactionErrorHandlers.splice(t,1)}}let gn=e=>e();function _n(){A.inBatch>0||A.isRunningReactions||gn(vn)}function vn(){A.isRunningReactions=!0;let e=A.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_()}A.isRunningReactions=!1}let yn=b(`Reaction`,mn);function bn(e){let t=gn;gn=n=>e(()=>t(n))}function xn(){return!!A.spyListeners.length}function Sn(e){if(!A.spyListeners.length)return;let t=A.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function Cn(e){Sn(r({},e,{spyReportStart:!0}))}let wn={type:`report-end`,spyReportEnd:!0};function Tn(e){Sn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):wn)}function En(e){return A.spyListeners.push(e),d(()=>{A.spyListeners=A.spyListeners.filter(t=>t!==e)})}let M=`action`,Dn=`autoAction`,On=`<unnamed action>`,kn=we(M),An=we(`action.bound`,{bound:!0}),jn=we(Dn,{autoAction:!0}),Mn=we(`autoAction.bound`,{autoAction:!0,bound:!0});function Nn(e){return Ze(e,De)}function Pn(e){return function(t,r){if(r&&typeof r.kind==`string`)return De(e?jn:kn,t,r);if(p(t))return St(t.name||On,t,e);if(p(r))return St(t,r,e);if(m(t))return Nn(we(e?Dn:M,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Fn=Pn(!1);r(Fn,kn);let In=Pn(!0);r(In,jn);let Ln=Nn(An),Rn=Nn(Mn);function zn(e){return Ct(e.name||On,!1,e,this,void 0)}function Bn(e){return p(e)&&e.isMobxAction===!0}function Vn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),Bn(e)&&n(`Autorun does not accept actions since actions are untrackable`);let i=t?.name??(e.name||`Autorun@`+u()),a=!t.scheduler&&!t.delay,o;if(a)o=new mn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Un(t),n=!1;o=new mn(i,()=>{n||(n=!0,e(()=>{n=!1,o.isDisposed||o.track(s)}))},t.onError,t.requiresObservable)}function s(){e(o)}return t!=null&&(r=t.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}let Hn=e=>e();function Un(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Hn}function Wn(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=Fn(a,r.onError?Gn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Un(r),d=!0,f=!1,m,h=r.equals||me,_=new mn(a,()=>{d||s?v():f||(f=!0,l(v))},r.onError,r.requiresObservable);function v(){if(f=!1,_.isDisposed)return;let t=!1,n=m;_.track(()=>{let n=Et(!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 Gn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Kn(e,t,n){return Jn(`onBO`,e,t,n)}function qn(e,t,n){return Jn(`onBUO`,e,t,n)}function Jn(e,t,n,r){let i=typeof r==`function`?Ni(t,n):Ni(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 Yn=`always`;function Xn(e){e.isolateGlobalState===!0&&Qt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Yn?Yn:t===`observed`;A.enforceActions=e,A.allowStateChanges=!(e===!0||e===Yn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(A[t]=!!e[t])}),A.allowStateReads=!A.observableRequiresReaction,A.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&bn(e.reactionScheduler)}function Zn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),_i(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(Sr(t)||Sr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=oe(t);return Ii(()=>{let t=Di(e,i)[T];ne(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Qn(e,t){return $n(Ni(e,t))}function $n(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=nr(e.observing_).map($n)),t}function er(e,t){return tr(Ni(e,t))}function tr(e){let t={name:e.name_};return en(e)&&(t.observers=Array.from(tn(e),tr)),t}function nr(e){return Array.from(new Set(e))}let rr=0;var ir=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function ar(e){return e instanceof ir}function or(e){return Ze(e,Me)}let sr=ke(`flow`),cr=ke(`flow.bound`,{bound:!0}),lr=r(function(e,t){if(t&&typeof t.kind==`string`)return Me(sr,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=++rr,a=Fn(`${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=Fn(`${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=Fn(`${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=Fn(`${i} - runid: ${n} - cancel`,function(){try{s&&dr(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),dr(t),o(new ir)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},sr),ur=or(cr);function dr(e){p(e.cancel)&&e.cancel()}function fr(e){return e}function pr(e){return e?.isMobXFlow===!0}function mr(e,t,r){let i;if(_i(e)||pi(e)||At(e))i=Pi(e);else if(Ai(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=Pi(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 hr(e,t,n){return p(n)?_r(e,t,n):gr(e,t)}function gr(e,t){return Jr(Pi(e),t)}function _r(e,t,n){return Jr(Pi(e,t),n)}function vr(e,t){var n;if(t===void 0)return Mt(e);if(Ai(e)===!1)return!1;let r=e[T];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?Mt(Ni(e,t)):!1}function yr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):vr(e)}function br(e,t){return m(t)?vr(e,t):n(`isComputed expected a property name as second argument`)}function xr(e,t){if(!e)return!1;if(t!==void 0){if(_i(e)||pi(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(Ai(e)){var r,i;let n=e[T];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return Ai(e)||!!e[T]||le(e)||yn(e)||Mt(e)}function Sr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),xr(e)}function Cr(e,t){return m(t)?xr(e,t):n(`expected a property name as second argument`)}function wr(e){if(Ai(e))return e[T].keys_();if(_i(e)||Si(e))return Array.from(e.keys());if(pi(e))return e.map((e,t)=>t);n(5)}function Tr(e){if(Ai(e))return wr(e).map(t=>e[t]);if(_i(e))return wr(e).map(t=>e.get(t));if(Si(e))return Array.from(e.values());if(pi(e))return e.slice();n(6)}function Er(e){if(Ai(e))return wr(e).map(t=>[t,e[t]]);if(_i(e))return wr(e).map(t=>[t,e.get(t)]);if(Si(e))return Array.from(e.entries());if(pi(e))return e.map((e,t)=>[t,e]);n(7)}function Dr(e,t,r){if(arguments.length===2&&!Si(e)){on();let n=t;try{for(let t in n)Dr(e,t,n[t])}finally{sn()}return}Ai(e)?e[T].set_(t,r):_i(e)?e.set(t,r):Si(e)?e.add(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),on(),t>=e.length&&(e.length=t+1),e[t]=r,sn()):n(8)}function Or(e,t){Ai(e)?e[T].delete_(t):_i(e)||Si(e)?e.delete(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function kr(e,t){if(Ai(e))return e[T].has_(t);if(_i(e)||Si(e))return e.has(t);if(pi(e))return t>=0&&t<e.length;n(10)}function Ar(e,t){if(kr(e,t)){if(Ai(e))return e[T].get_(t);if(_i(e))return e.get(t);if(pi(e))return e[t];n(11)}}function jr(e,t,r){if(Ai(e))return e[T].defineProperty_(t,r);n(39)}function Mr(e){if(Ai(e))return e[T].ownKeys_();n(38)}function Nr(e,t,n,r){return p(n)?Fr(e,t,n,r):Pr(e,t,n)}function Pr(e,t,r){let i=Pi(e);if(pi(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(_i(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(Si(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(Ai(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Ir(i,t,r);return Zr(i,t)}function Fr(e,t,n,r){return Ir(Pi(e,t),n,r)}function Ir(e,t,n){if(Mt(e)){let r=!0,i;return Vn(()=>{let a=e.get();if(!r||n){let n=Wt();t({observableKind:`computed`,debugObjectName:e.name_,type:ii,object:e,newValue:a,oldValue:i}),Gt(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ii,newValue:e.value_,oldValue:void 0}),Zr(e,t)}function Lr(e,t,n){return e.set(t,n),n}function Rr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!Sr(e))return e;if(At(e)||Mt(e))return Rr(e.get(),t);if(t.has(e))return t.get(e);if(pi(e)){let n=Lr(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Rr(e,t)}),n}if(Si(e)){let n=Lr(t,e,new Set);return e.forEach(e=>{n.add(Rr(e,t))}),n}if(_i(e)){let n=Lr(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Rr(e,t))}),n}else{let n=Lr(t,e,{});return Mr(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Rr(e[r],t))}),n}}function zr(e,t){return t&&n(`toJS no longer supports options`),Rr(e,new Map)}function Br(e,t=void 0){on();try{return e.apply(t)}finally{sn()}}function Vr(e,t,n){return arguments.length===1||t&&typeof t==`object`?Ur(e,t):Hr(e,t,n||{})}function Hr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[T].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=St(n.name+`-effect`,t);var a=Vn(t=>{Et(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function Ur(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=Hr(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 Wr(e){return e[T]}let Gr={has(e,t){return Wr(e).has_(t)},get(e,t){return Wr(e).get_(t)},set(e,t,n){return m(t)?Wr(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Wr(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Wr(e).defineProperty_(t,n)??!0},ownKeys(e){return Wr(e).ownKeys_()},preventExtensions(e){n(13)}};function Kr(e,t){var n;return e=Di(e,t),(n=e[T]).proxy_??(n.proxy_=new Proxy(e,Gr))}function qr(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function Jr(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 Yr(e,t){let r=Wt();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{Gt(r)}}function Xr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Zr(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 Qr(e,t){let n=Wt(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Gt(n)}}function $r(e,t,n){return Ii(()=>{let r=Di(e,n)[T];ne(t).forEach(e=>ni(r,e,t[e]))}),e}let ei=Symbol(`mobx-keys`);function ti(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),Ai(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Zn(e,e,t,r):(Ii(()=>{let n=Di(e,r)[T];if(!e[ei]){let t=Object.getPrototypeOf(e),n=new Set([...ne(e),...ne(t)]);n.delete(`constructor`),n.delete(T),v(t,ei,n)}e[ei].forEach(e=>ni(n,e,t&&e in t?t[e]:!0))}),e)}function ni(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;Mi(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)}ji(e,r,t)}let ri=`splice`,ii=`update`,ai={get(e,t){let n=e[T];return t===T?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):ae(ci,t)?ci[t]:e[t]},set(e,t,n){let r=e[T];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var oi=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 ce(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){Lt(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),qr(this)){let r=Yr(this,{object:this.proxy_,type:ri,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_&&xn(),i=Xr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ii,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&Cn(a),this.atom_.reportChanged(),i&&Qr(this,a),r&&Tn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&xn(),i=Xr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:ri,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Cn(a),this.atom_.reportChanged(),i&&Qr(this,a),r&&Tn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Lt(this.atom_);let r=n[e];if(qr(this)){let n=Yr(this,{type:ii,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 si(e,t,n=`ObservableArray@`+u(),r=!1){return Ii(()=>{let i=new oi(n,t,r);y(i.values_,T,i);let a=new Proxy(i.values_,ai);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var ci={clear(){return this.splice(0)},replace(e){let t=this[T];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[T];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[T].spliceWithArray_(e,t,n)},push(...e){let t=this[T];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[T].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[T];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return A.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){A.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[T],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};N(`at`,li),N(`concat`,li),N(`flat`,li),N(`includes`,li),N(`indexOf`,li),N(`join`,li),N(`lastIndexOf`,li),N(`slice`,li),N(`toString`,li),N(`toLocaleString`,li),N(`toSorted`,li),N(`toSpliced`,li),N(`with`,li),N(`every`,ui),N(`filter`,ui),N(`find`,ui),N(`findIndex`,ui),N(`findLast`,ui),N(`findLastIndex`,ui),N(`flatMap`,ui),N(`forEach`,ui),N(`map`,ui),N(`some`,ui),N(`toReversed`,ui),N(`reduce`,di),N(`reduceRight`,di);function N(e,t){typeof Array.prototype[e]==`function`&&(ci[e]=t(e))}function li(e){return function(){let t=this[T];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function ui(e){return function(t,n){let r=this[T];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function di(e){return function(){let t=this[T];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 fi=b(`ObservableArrayAdministration`,oi);function pi(e){return h(e)&&fi(e[T])}let mi={},hi=`delete`;var gi=class{constructor(e,t=he,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[T]=mi,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,Ii(()=>{this.keysAtom_=ue(`${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(!A.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new kt(this.has_(e),_e,`${this.name_}.${re(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(qr(this)){let r=Yr(this,{type:n?ii:`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(Lt(this.keysAtom_),qr(this)&&!Yr(this,{type:hi,object:this,name:e}))return!1;if(this.has_(e)){let t=xn(),n=Xr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:hi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&Cn(r),Br(()=>{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&&Qr(this,r),t&&Tn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==A.UNCHANGED){let r=xn(),i=Xr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ii,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&Cn(a),n.setNewValue_(t),i&&Qr(this,a),r&&Tn()}}addValue_(e,t){Lt(this.keysAtom_),Br(()=>{var n;let r=new kt(t,this.enhancer_,`${this.name_}.${re(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=xn(),r=Xr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&Cn(i),r&&Qr(this,i),n&&Tn()}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 vi({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 vi({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 _i(e)&&(e=new Map(e)),Br(()=>{g(e)?te(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):ee(e)?(x(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){Br(()=>{Ut(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return Br(()=>{let t=yi(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`}},_i=b(`ObservableMap`,gi);function vi(e){return e[Symbol.toStringTag]=`MapIterator`,zi(e)}function yi(e){if(ee(e)||_i(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 bi={};var xi=class{constructor(e,t=he,n=`ObservableSet@`+u()){this.name_=void 0,this[T]=bi,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),Ii(()=>{this.atom_=ue(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){Br(()=>{Ut(()=>{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(Lt(this.atom_),qr(this)){let t=Yr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){Br(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=xn(),n=Xr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&Cn(r),n&&Qr(this,r),t&&Tn()}return this}delete(e){if(qr(this)&&!Yr(this,{type:hi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=xn(),n=Xr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:hi,object:this,oldValue:e}:null;return t&&Cn(r),Br(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Qr(this,r),t&&Tn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return Ci({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 Ci({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 Si(e)&&(e=new Set(e)),Array.isArray(e)||S(e)?Br(()=>{let t=S(e)?e:new Set(e);if(t.size===0){this.clear();return}if(this.data_.size===0){t.forEach(e=>this.add(e));return}for(let e of this.data_.values())t.has(this.dehanceValue_(e))||this.delete(e);t.forEach(e=>this.add(e))}):e!=null&&n(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},Si=b(`ObservableSet`,xi);function Ci(e){return e[Symbol.toStringTag]=`SetIterator`,zi(e)}let wi=Object.create(null),Ti=`remove`;var Ei=class{constructor(e,t=new Map,r,i=Ge){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 ce(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Vi(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 jt)return n.set(t),!0;if(qr(this)){let n=Yr(this,{type:ii,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==A.UNCHANGED){let r=Xr(this),i=xn(),a=r||i?{type:ii,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&Cn(a),n.setNewValue_(t),r&&Qr(this,a),i&&Tn()}return!0}get_(e){return A.trackingDerivation&&!ae(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return ae(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(!A.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new kt(e in this.target_,_e,`${this.name_}.${re(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);Mi(this,n,e);let i=n.extend_(this,e,t,r);return i&&ji(this,n,e),i}defineProperty_(e,t,n=!1){Lt(this.keysAtom_);try{on();let i=this.delete_(e);if(!i)return i;if(qr(this)){let n=Yr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:i}=n;t.value!==i&&(t=r({},t,{value:i}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else a(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{sn()}return!0}defineObservableProperty_(e,t,n,r=!1){Lt(this.keysAtom_);try{on();let i=this.delete_(e);if(!i)return i;if(qr(this)){let n=Yr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=ki(e),s={configurable:A.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 kt(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{sn()}return!0}defineComputedProperty_(e,t,n=!1){Lt(this.keysAtom_);try{on();let r=this.delete_(e);if(!r)return r;if(qr(this)&&!Yr(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=ki(e),o={configurable:A.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 jt(t)),this.notifyPropertyAddition_(e,void 0)}finally{sn()}return!0}delete_(e,t=!1){if(Lt(this.keysAtom_),!ae(this.target_,e))return!0;if(qr(this)&&!Yr(this,{object:this.proxy_||this.target_,name:e,type:Ti}))return null;try{var n;on();let r=Xr(this),a=xn(),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 kt&&(s=o.value_),dn(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Ti,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&Cn(t),r&&Qr(this,t),a&&Tn()}}finally{sn()}return!0}notifyPropertyAddition_(e,t){var n;let r=Xr(this),i=xn();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&&Cn(n),r&&Qr(this,n),i&&Tn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),ne(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function Di(e,t){if(t&&Ai(e)&&n(`Options can't be provided for already observable objects.`),ae(e,T))return Pi(e)instanceof Ei||n(`Cannot convert '${Fi(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,T,new Ei(e,new Map,String(r),ot(t))),e}let Oi=b(`ObservableObjectAdministration`,Ei);function ki(e){return wi[e]||(wi[e]={get(){return this[T].getObservablePropValue_(e)},set(t){return this[T].setObservablePropValue_(e,t)}})}function Ai(e){return h(e)?Oi(e[T]):!1}function ji(e,t,n){e.appliedAnnotations_[n]=t}function Mi(e,t,r){if(Vi(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!xe(t)&&ae(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 Ni(e,t){if(typeof e==`object`&&e){if(pi(e))return t!==void 0&&n(23),e[T].atom_;if(Si(e))return e.atom_;if(_i(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,Fi(e)),r}if(Ai(e)){if(!t)return n(26);let r=e[T],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,Fi(e)),i}if(le(e)||Mt(e)||yn(e))return e}else if(p(e)&&yn(e[T]))return e[T];n(28)}function Pi(e,t){if(e||n(29),t!==void 0)return Pi(Ni(e,t));if(le(e)||Mt(e)||yn(e)||_i(e)||Si(e))return e;if(e[T])return e[T];n(24,e)}function Fi(e,t){let n;if(t!==void 0)n=Ni(e,t);else if(Bn(e))return e.name;else n=Ai(e)||_i(e)||Si(e)?Pi(e):Ni(e);return n.name_}function Ii(e){let t=Wt(),n=Dt(!0);on();try{return e()}finally{sn(),Ot(n),Gt(t)}}let Li=o.toString;function P(e,t,n=-1){return F(e,t,n)}function F(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=Li.call(e);if(o!==Li.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=I(e),t=I(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(!F(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(!(ae(t,o)&&F(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function I(e){return pi(e)?e.slice():ee(e)||_i(e)||S(e)||Si(e)?Array.from(e.entries()):e}let Ri=globalThis.Iterator?.prototype||{};function zi(e){return e[Symbol.iterator]=Bi,r(Object.create(Ri),e)}function Bi(){return this}function Vi(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:En,extras:{getDebugName:Fi},$mobx:T}),e.$mobx=T,e.FlowCancellationError=ir,e.ObservableMap=gi,e.ObservableSet=xi,e.Reaction=mn,e._allowStateChanges=Et,e._allowStateChangesInsideComputed=zn,e._allowStateReadsEnd=Kt,e._allowStateReadsStart=k,e._autoAction=In,e._autoActionBound=Rn,e._endAction=Tt,e._getAdministration=Pi,e._getGlobalState=$t,e._interceptReads=mr,e._isComputingDerivation=It,e._resetGlobalState=j,e._startAction=wt,e.action=Fn,e.actionBound=Ln,e.autorun=Vn,e.compareDefault=me,e.compareIdentity=de,e.compareShallow=pe,e.compareStructural=fe,e.computed=O,e.computedStruct=_t,e.configure=Xn,e.createAtom=ue,e.defineProperty=jr,e.entries=Er,e.extendObservable=Zn,e.flow=lr,e.flowBound=ur,e.flowResult=fr,e.get=Ar,e.getAtom=Ni,e.getDebugName=Fi,e.getDependencyTree=Qn,e.getObserverTree=er,e.has=kr,e.intercept=hr,e.isAction=Bn,e.isBoxedObservable=At,e.isComputed=yr,e.isComputedProp=br,e.isFlow=pr,e.isFlowCancellationError=ar,e.isObservable=Sr,e.isObservableArray=pi,e.isObservableMap=_i,e.isObservableObject=Ai,e.isObservableProp=Cr,e.isObservableSet=Si,e.keys=wr,e.makeAutoObservable=ti,e.makeObservable=$r,e.observable=D,e.observableDeep=ft,e.observableRef=ut,e.observableShallow=dt,e.observableStruct=pt,e.observe=Nr,e.onBecomeObserved=Kn,e.onBecomeUnobserved=qn,e.onReactionError=hn,e.override=be,e.ownKeys=Mr,e.reaction=Wn,e.remove=Or,e.runInAction=zn,e.set=Dr,e.spy=En,e.toJS=zr,e.transaction=Br,e.untracked=Ut,e.values=Tr,e.when=Vr})),mb=Ee(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=fb():t.exports=pb()}))();function hb(e){if(Array.isArray(e))return Object.freeze(e.map(hb));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]=hb(r);return Object.freeze(t)}return e}function gb(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 _b(e){return typeof e==`string`?e:String(e)}function vb(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 yb(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 bb=class extends Error{constructor(e,t){super(t),this.variable=e}};function xb(e){return e instanceof bb||e instanceof Error&&e.cause!==void 0&&xb(e.cause)}var Sb=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?jb(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}},Cb=class extends Sb{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},wb=class extends Sb{name=`EvalError`;kind=`EvalError`},Tb=class extends wb{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=Mb(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}},Eb=class extends wb{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}},Db=class extends wb{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}},Ob=class extends Db{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)}`}},kb=class extends wb{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},Ab=class extends wb{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function jb(e,t){let n=e.split(`
61
61
  `),r=t.line-1,i=[];if(r-1>=0&&r-1<n.length&&i.push({num:r,text:n[r-1]??``}),r>=0&&r<n.length&&i.push({num:r+1,text:n[r]??``}),r+1<n.length&&i.push({num:r+2,text:n[r+1]??``}),i.length===0)return``;let a=String(i[i.length-1]?.num??1).length,o=[];for(let e of i)if(o.push(` ${String(e.num).padStart(a,` `)} | ${e.text}`),e.num===t.line){let e=` ${` `.repeat(a)} | `,n=` `.repeat(Math.max(0,t.column-1));o.push(`${e}${n}^`)}return o.join(`
62
62
  `)}function Mb(e,t){if(t.length===0)return[];let n=t.map(t=>({name:t,dist:Nb(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 Nb(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 Pb(e){throw Error(`unhandled node kind: ${JSON.stringify(e)}`)}const Fb=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`]]),Ib={left:`{{`,right:`}}`};var Lb=class{src;leftDelim;rightDelim;offset=0;line=1;column=1;mode=`text`;pending;constructor(e,t=Ib){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 Cb(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&&Rb(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);Rb(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);Rb(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(;Rb(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`;Rb(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&&(Bb(e)||zb(e)&&Bb(this.src[this.offset+1]??``)||e===`.`&&Bb(this.src[this.offset+1]??``)))return this.readNumber(t);if(e===`.`)return this.readDotOrField(t);if(e!==void 0&&Gb(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===`
63
63
  `)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===`
@@ -73,7 +73,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
73
73
  `,1)[0]??``}function ED(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?F:P(n)}function DD(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?P(t):F}const OD={github:`gh`,gitlab:`glab`};function kD(e){return!e.ok&&e.reason===`spawn-error`&&/ENOENT/i.test(e.error??``)}const AD=/^[A-Za-z]:[\\/]/;function jD(e){let t=e.trim();if(AD.test(t))return null;let n=t.match(/^(?:[^@/]+@)?(\[[^\]]+\]):(.*)$/)??t.match(/^(?:[^@/:]+@)?([^/:]+):(?!\/\/)(.*)$/),r=n?`ssh://${n[1]}/${n[2].replace(/^\/+/,``)}`:t,i;try{i=new URL(r)}catch{return null}return{scheme:i.protocol.replace(/:$/,``),host:i.hostname.toLowerCase(),port:i.port,path:i.pathname.replace(/^\/+/,``).replace(/\/+$/,``)}}function MD(e){return jD(e)?.host||null}function ND(e){let t=MD(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}const PD=[`config`,`--local`,`--get-regexp`,`^remote\\..*\\.url$`];function FD(e){let t=CD(`git config --get-regexp remote url`,e,1);return t.kind===`failed`?t:{kind:`ok`,value:t.kind===`ok`?ID(t.value):[]}}function ID(e){let t=new Map;for(let n of e.split(`
74
74
  `)){let e=n.match(/^remote\.(.+)\.url\s+(\S.*)$/);if(!e)continue;let r=t.get(e[1])??[];r.push(e[2].trim()),t.set(e[1],r)}return[...t].map(([e,t])=>({name:e,urls:t}))}function LD(e){return e.urls.find(e=>HD(e)!==null)??e.urls[0]??null}function RD(e){return e.find(e=>e.name===`origin`)??e[0]??null}function zD(e){let t=RD(e);return t?LD(t):null}function BD(e){let t=RD(e);return t?t.urls.find(e=>ND(e)!==null)??LD(t):null}function VD(e){let t=(jD(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function HD(e){let t=jD(e);if(!t)return null;let n=t.scheme===`https`?{scheme:`https`,port:t.port}:t.scheme===`http`?{scheme:`http`,port:t.port}:t.scheme===`ssh`||t.scheme===`git`?{scheme:`https`,port:``}:null;if(!n||!t.host)return null;let r=t.path.replace(/\.git$/,``);if(!r)return null;let i=n.port?`${t.host}:${n.port}`:t.host;return`${n.scheme}://${i}/${r}`}function UD(e){let t=zD(e);return t===null?null:HD(t)}function WD(e,t,n,r){return t.ok?r(t.stdout):kD(t)||t.reason===`non-zero`&&n.test(t.stderr)?F:I(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??TD(t.stderr)].filter(Boolean).join(`, `)}`)}function GD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function KD(e){let t=`detached`,n=F,r=F,i=F,a=0,o=0,s=0,c=0;for(let l of e.split(`
75
75
  `)){if(!l)continue;if(l.startsWith(`# `)){let e=l.slice(2);if(e.startsWith(`branch.oid `)){let t=e.slice(11).trim();n=t===`(initial)`?F:P(t)}else if(e.startsWith(`branch.head `)){let n=e.slice(12).trim();t=n===`(detached)`?`detached`:n}else if(e.startsWith(`branch.upstream `))r=P(e.slice(16).trim());else if(e.startsWith(`branch.ab `)){let t=e.slice(10).trim().match(/^\+(\d+)\s+-(\d+)$/);t&&(i=P({ahead:parseInt(t[1],10),behind:parseInt(t[2],10)}))}continue}let e=l[0];if(e===`1`||e===`2`){let e=l.slice(2,4);e[0]!==`.`&&a++,e[1]!==`.`&&o++}else e===`u`?c++:e===`?`&&s++}let l=`clean`;return c>0?l=`conflicts`:(a||o||s)&&(l=`dirty`),{branch:t,status:l,aheadBehind:i,oid:n,upstream:r,workingTree:{staged:a,unstaged:o,untracked:s,conflicts:c}}}function qD(e){let t;try{t=JSON.parse(e)}catch(e){return I(`gh pr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!GD(t))return I(`gh pr view: JSON is not an object`);let{number:n,state:r,url:i,headRefOid:a}=t;if(typeof n!=`number`||typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return I(`gh pr view: missing number/state/url/headRefOid`);let o=SD(`gh pr view`,bD,r);return o.kind===`ok`?P({number:n,state:o.value,url:i,head:a}):o}function JD(e){let t;try{t=JSON.parse(e)}catch(e){return I(`glab mr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!GD(t))return I(`glab mr view: JSON is not an object`);let n=t.iid,r=t.state,i=t.web_url,a=t.sha;if(typeof n!=`number`||typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return I(`glab mr view: missing iid/state/web_url/sha`);let o=SD(`glab mr view`,xD,r);return o.kind===`ok`?P({number:n,state:o.value,url:i,head:a}):o}function YD(e){try{let t=p.statSync(e);return{key:`${t.dev}:${t.ino}`,stamp:`${t.mtimeMs}:${t.size}`}}catch{return null}}var XD=class{isGitRepo(e){return hD(e)}async execGitAsync(e,t){return Ue({bin:`git`,args:[...e],cwd:t.cwd,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:t.timeout,category:`git`})}async resolveEffectiveGitDir(e,t){return this.isWorktree(e)?P(e):t&&this.isGitRepo(t)?P(t):this.isGitRepo(e)?P(e):this.findGitRoot(e)}async findGitRoot(e){let t=gD(e);return t===void 0?F:P(t)}async getGitInfo(e,t={},n){try{return await this.computeGitInfo(e,t,n)}catch(e){return I(`git: ${e instanceof Error?e.message:String(e)}`)}}async computeGitInfo(e,t={},n){let r,i=this.isWorktree(e);if(i)r=e;else if(n&&this.isGitRepo(n))r=n;else if(this.isGitRepo(e))r=e;else{let t=await this.findGitRoot(e);if(t.kind!==`ok`)return t;r=t.value}let a=await this.getCoreAsync(r);if(a.kind!==`ok`)return a;let o={branch:a.value.branch,status:a.value.status,aheadBehind:a.value.aheadBehind,head:a.value.oid};t.showWorkingTree&&(o.workingTree=a.value.workingTree),t.showSha&&(o.sha=ED(a.value.oid,e=>e.slice(0,7))),t.showUpstream&&(o.upstream=a.value.upstream),t.showTag&&(o.tag=await this.getNearestTagAsync(r)),t.showTimeSinceCommit&&(o.committedAt=await this.committedAt(r,a.value.oid)),t.showStashCount&&(o.stashCount=this.getStashCount(r));let s=t.showRepoName||t.showRepoUrl?await this.getRemotesAsync(r):void 0;return s!==void 0&&t.showRepoName&&(o.repoName=ED(s,e=>this.repoNameFrom(e,r)),o.isWorktree=i),s!==void 0&&t.showRepoUrl&&(o.repoUrl=ED(s,UD)),t.showOperation&&(o.operation=this.getOngoingOperation(r)),P(o)}resolveGitDir(e){let t=s.join(e,`.git`);try{if(p.existsSync(t)&&p.statSync(t).isFile()){let n=p.readFileSync(t,`utf-8`).match(/^gitdir:\s*(.+)$/m);if(n?.[1])return s.resolve(e,n[1].trim())}}catch{}return t}getOngoingOperation(e){try{let t=this.resolveGitDir(e);return p.existsSync(s.join(t,`MERGE_HEAD`))?P(`MERGE`):p.existsSync(s.join(t,`CHERRY_PICK_HEAD`))?P(`CHERRY-PICK`):p.existsSync(s.join(t,`REVERT_HEAD`))?P(`REVERT`):p.existsSync(s.join(t,`BISECT_LOG`))?P(`BISECT`):p.existsSync(s.join(t,`rebase-merge`))||p.existsSync(s.join(t,`rebase-apply`))?P(`REBASE`):F}catch(e){return I(`git operation probe: ${e instanceof Error?e.message:String(e)}`)}}async getNearestTagAsync(e){return DD(CD(`git describe --tags`,await this.execGitAsync([`describe`,`--tags`,`--abbrev=0`],{cwd:e,timeout:2e3}),`absent`))}async committedAt(e,t){return t.kind===`ok`?this.commitTimestampMs(e,t.value):t}commitTimes=new Map;async commitTimestampMs(e,t){let n=this.commitTimes.get(t);if(n!==void 0)return this.commitTimes.delete(t),this.commitTimes.set(t,n),n;let r=this.readCommitTimestampMs(e,t);for(this.commitTimes.set(t,r),r.then(e=>{e.kind!==`ok`&&this.commitTimes.get(t)===r&&this.commitTimes.delete(t)},()=>{this.commitTimes.get(t)===r&&this.commitTimes.delete(t)});this.commitTimes.size>256;){let e=this.commitTimes.keys().next().value;if(e===void 0)break;this.commitTimes.delete(e)}return r}async readCommitTimestampMs(e,t){let n=DD(CD(`git log -1`,await this.execGitAsync([`log`,`-1`,`--format=%ct`,t,`--`],{cwd:e,timeout:2e3}),`absent`));if(n.kind!==`ok`)return n;let r=parseInt(n.value,10)*1e3;return Number.isNaN(r)?I(`git log -1: unparseable timestamp "${n.value}"`):P(r)}resolveCommonGitDir(e){let t=this.resolveGitDir(e);try{let e=p.readFileSync(s.join(t,`commondir`),`utf-8`).trim();if(e)return s.resolve(t,e)}catch{}return t}getStashCount(e){let t=s.join(this.resolveCommonGitDir(e),`logs`,`refs`,`stash`),n;try{n=p.readFileSync(t,`utf-8`)}catch(e){return e.code===`ENOENT`?P(0):I(`git stash reflog ${t}: ${e instanceof Error?e.message:String(e)}`)}let r=n.trim();return P(r?r.split(`
76
- `).length:0)}async getRemotesAsync(e){let t=YD(s.join(this.resolveCommonGitDir(e),`config`));if(t===null)return this.readRemotes(e);let{key:n,stamp:r}=t,i=this.remotesByConfig.get(n);if(i!==void 0&&i.stamp===r)return this.remotesByConfig.delete(n),this.remotesByConfig.set(n,i),i.remotes;let a=this.readRemotes(e);for(this.remotesByConfig.set(n,{stamp:r,remotes:a}),a.then(e=>{let t=this.remotesByConfig.get(n);e.kind!==`ok`&&t?.remotes===a&&this.remotesByConfig.delete(n)},()=>{this.remotesByConfig.get(n)?.remotes===a&&this.remotesByConfig.delete(n)});this.remotesByConfig.size>256;){let e=this.remotesByConfig.keys().next().value;if(e===void 0)break;this.remotesByConfig.delete(e)}return a}remotesByConfig=new Map;async readRemotes(e){return FD(await this.execGitAsync(PD,{cwd:e,timeout:2e3}))}repoNameFrom(e,t){let n=zD(e);return(n===null?null:VD(n))??s.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=BD(t.value);return n===null?F:P(n)}async execForgeAsync(e,t,n){return Ue({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=ND(t);return n===`github`?WD(`gh pr view`,await this.execForgeAsync(OD.github,[`pr`,`view`,`--json`,`number,state,url,headRefOid`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,qD):n===`gitlab`?WD(`glab mr view`,await this.execForgeAsync(OD.gitlab,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,JD):F}isWorktree(e){try{let t=s.join(e,`.git`);return!!(p.existsSync(t)&&p.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){E(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=CD(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?P(KD(t.value)):t}};const ZD=(e,t)=>E(t);var QD=class{slots=new Map;maxWatchers;counters;logger;closed=!1;constructor(e={}){this.maxWatchers=e.maxWatchers??128,this.counters=e.counters,this.logger=e.logger??ZD}acquire(e,t,n){if(this.closed)return{release:()=>{}};let r=this.slots.get(e);if(r)return r.refcount++,r.onInvalidate=n,r.lastTouched=Date.now(),this.slots.delete(e),this.slots.set(e,r),this.makeHandle(e);let i={key:e,watchers:[],refcount:1,debounceTimer:null,onInvalidate:n,targets:t,lastTouched:Date.now()};return this.openWatchers(i),this.slots.set(e,i),this.counters&&this.counters.watchersOpened++,this.evictIfNeeded(),this.makeHandle(e)}makeHandle(e){let t=!1;return{release:()=>{if(t)return;t=!0;let n=this.slots.get(e);n&&(n.refcount=Math.max(0,n.refcount-1),n.refcount===0&&(this.closeSlot(n),this.slots.delete(e)))}}}openWatchers(e){let t=()=>{e.debounceTimer||(e.debounceTimer=setTimeout(()=>{e.debounceTimer=null;try{e.onInvalidate()}catch(e){this.logger(`warn`,`watcher invalidate threw: ${e.message}`)}},50),e.debounceTimer.unref())};for(let n of e.targets.files)try{let r=p.watch(n,{persistent:!1},t);r.on(`error`,e=>{this.logger(`warn`,`watcher error ${n}: ${e.message}`)}),e.watchers.push(r)}catch(e){this.logger(`warn`,`watch failed ${n}: ${e.message}`)}for(let n of e.targets.dirs)try{let r=n.filenames?new Set(n.filenames):null,i=p.watch(n.path,{persistent:!1},(e,n)=>{r&&(!n||!r.has(n))||t()});i.on(`error`,e=>{this.logger(`warn`,`watcher error ${n.path}: ${e.message}`)}),e.watchers.push(i)}catch(e){this.logger(`warn`,`watch failed ${n.path}: ${e.message}`)}}closeSlot(e){e.debounceTimer&&=(clearTimeout(e.debounceTimer),null);for(let t of e.watchers)try{t.close()}catch{}e.watchers=[],this.counters&&this.counters.watchersClosed++}evictIfNeeded(){for(;this.slots.size>this.maxWatchers;){let e=this.slots.keys().next().value;if(e===void 0)break;let t=this.slots.get(e);this.closeSlot(t),this.slots.delete(e),this.counters&&this.counters.watchersEvicted++;try{t.onInvalidate()}catch{}this.logger(`info`,`watcher LRU evict ${e}`)}}size(){return this.slots.size}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e);this.slots.clear()}},$D=class{running=new Set;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:(this.running.add(e),{kind:`started`,done:this.loop(e,t)})}async loop(e,t){try{do this.again.delete(e),await t();while(this.again.has(e))}finally{this.running.delete(e),this.again.delete(e)}}clear(){this.running.clear(),this.again.clear()}get size(){return this.running.size}};const eO={showSha:!0,showStashCount:!0};function tO(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function nO(e){let t=t=>{try{return p.statSync(s.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function rO(e,t){return e.head!==t.head||e.index!==t.index}function iO(e){let t=[],n=s.join(e,`refs/heads`);try{p.statSync(n).isDirectory()&&t.push({path:n})}catch{}return{files:[s.join(e,`HEAD`),s.join(e,`index`)],dirs:t}}var aO=class extends XD{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;resolutions=new Map;prCache=new Map;prFetchInFlight=new Map;refreshes=new $D;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new XD,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??ke,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new QD({logger:this.logger}),this.ownsWatchers=!0);let t=e.sanityIntervalMs??3e5;t>0&&(this.sanityTimer=setInterval(()=>this.runSanityCheck(),t),this.sanityTimer.unref())}getWatcherRegistry(){return this.watchers}getStats(){return{size:this.entries.size,hits:this.hits,misses:this.misses,invalidations:this.invalidations,watchers:this.watchers.size()}}resolveEffectiveGitDir(e,t){let n=`${e}|${t??``}`,r=Date.now(),i=this.resolutions.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.resolutions.delete(n),this.resolutions.set(n,i),i.dir;let a=this.inner.resolveEffectiveGitDir(e,t);return this.resolutions.set(n,{dir:a,computedAt:r}),a.catch(()=>{this.resolutions.get(n)?.dir===a&&this.resolutions.delete(n)}),this.evictResolutionsIfNeeded(),a}evictResolutionsIfNeeded(){for(;this.resolutions.size>this.maxEntries;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}}async getGitInfo(e,t={},n){let r=await this.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${tO(t)}`,r=Date.now(),i=this.entries.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.entries.delete(n),this.entries.set(n,i),this.hits++,Promise.resolve(P(i.info));let a=this.fetchInFlight.get(n);if(a)return a;let o=this.doFetch(e,n,t,r).finally(()=>{this.fetchInFlight.delete(n)});return this.fetchInFlight.set(n,o),o}async doFetch(e,t,n,r){this.misses++;let i=this.inner.resolveGitDir(e),a=nO(i),o=await this.inner.getGitInfo(e,n);if(o.kind!==`ok`)return o;let s=o.value;n.showPullRequest&&(s.pullRequest=await this.getPullRequestCached(e,s.branch)),this.dropEntry(t);let c=this.watchers.acquire(`git:${e}`,iO(i),()=>this.invalidateRepo(e));return this.entries.set(t,{info:s,computedAt:r,mtime:a,watcher:c,repoRoot:e}),this.evictIfNeeded(),o}async getPullRequestCached(e,t){let n=await this.inner.getRepoRemoteUrl(e);if(n.kind===`failed`)return n;if(n.kind===`absent`)return F;let r=n.value,i=`${e}|${t}|${r}`,a=Date.now(),o=this.prCache.get(i);if(o){let e=o.pr.kind===`failed`?45e3:3e5;if(a-o.computedAt<e)return this.prCache.delete(i),this.prCache.set(i,o),o.pr}let s=this.prFetchInFlight.get(i);if(s)return s;let c=this.inner.resolvePullRequest(e,r).then(e=>(this.prCache.set(i,{pr:e,computedAt:Date.now()}),this.evictPrIfNeeded(),e)).finally(()=>{this.prFetchInFlight.delete(i)});return this.prFetchInFlight.set(i,c),c}evictPrIfNeeded(){for(;this.prCache.size>this.maxEntries;){let e=this.prCache.keys().next().value;if(e===void 0)break;this.prCache.delete(e)}}deliverable(e,t){return e.kind===`failed`?(this.logger(`warn`,`git fetch failed (${t}): ${e.reason}`),null):e.kind===`ok`?e.value:null}subscribe(e,t){let n=!1,r=null;return{firstDelivery:(async()=>{let i=await this.resolveEffectiveGitDir(e);if(n)return;if(i.kind!==`ok`){i.kind===`failed`&&this.logger(`warn`,`git resolve failed (subscribe ${e}): ${i.reason}`),this.safeInvoke(t,null);return}let a=i.value,o=this.subscribersByRepo.get(a);if(!o){let t=this.inner.resolveGitDir(a),n=this.watchers.acquire(`git:${a}`,iO(t),()=>this.invalidateRepo(a));o={workingDir:e,repoRoot:a,callbacks:new Set,watcher:n},this.subscribersByRepo.set(a,o)}o.callbacks.add(t),r={repoRoot:a,entry:o};let s=await this.getGitInfoForRoot(a,{...eO});n||this.safeInvoke(t,this.deliverable(s,a))})(),unsubscribe:()=>{if(n=!0,!r)return;let{repoRoot:e,entry:i}=r;i.callbacks.delete(t),i.callbacks.size===0&&(i.watcher.release(),this.subscribersByRepo.delete(e))}}}invalidateRepo(e){let t=0;for(let[n,r]of this.entries)r.repoRoot===e&&(r.watcher.release(),this.entries.delete(n),t++);t>0&&(this.invalidations+=t,this.logger(`info`,`gitCache invalidate ${e} dropped=${t}`)),this.refreshSubscribers(e)}refreshSubscribers(e){let t=this.subscribersByRepo.get(e);!t||t.callbacks.size===0||this.refreshes.run(e,()=>this.refreshOnce(e))}async refreshOnce(e){let t=this.subscribersByRepo.get(e);if(!t||t.callbacks.size===0)return;let n=await this.getGitInfoForRoot(e,{...eO}),r=this.deliverable(n,e),i=this.subscribersByRepo.get(e);if(!(!i||i.callbacks.size===0))for(let e of[...i.callbacks])i.callbacks.has(e)&&this.safeInvoke(e,r)}safeInvoke(e,t){try{e(t)}catch(e){this.logger(`warn`,`git subscriber threw: ${e.message??String(e)}`)}}dropEntry(e){let t=this.entries.get(e);t&&(t.watcher.release(),this.entries.delete(e))}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.dropEntry(e),this.logger(`info`,`gitCache evict ${e}`)}}runSanityCheck(){let e=new Map;for(let t of this.entries.values()){let n=e.get(t.repoRoot);n||(n=nO(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),rO(t.mtime,n)&&this.invalidateRepo(t.repoRoot)}}runSanityCheckNow(){this.runSanityCheck()}close(){this.sanityTimer&&=(clearInterval(this.sanityTimer),null);for(let e of this.entries.values())e.watcher.release();this.entries.clear();for(let e of this.subscribersByRepo.values())e.callbacks.clear(),e.watcher.release();this.subscribersByRepo.clear(),this.refreshes.clear(),this.fetchInFlight.clear(),this.prCache.clear(),this.prFetchInFlight.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}};const oO=/\r\n|\r|\n/g,sO=e=>P(e.replace(oO,` `).trim());function cO(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?I(`regex no-match`):P(n.replace(oO,` `))}}const lO=e=>{try{return P(JSON.parse(e))}catch(e){return I(`JSON parse failed: ${e.message}`)}},uO=e=>e.getTime()/1e3,dO=e=>new Date(e*1e3);function fO(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(E(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function pO(e){let t=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/.exec(e);if(!t)throw RangeError(`Invalid duration: "${e}"`);let n=parseFloat(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;default:throw RangeError(`Unexpected duration unit: "${t[2]}"`)}}const mO=`session.id`;function hO(e,t,n){return{where:`output of "${e}" in ${t}`,read:async()=>{let r=await Ue({bin:`/bin/sh`,args:[`-c`,e],cwd:t,category:`user-shell`,signal:n});if(!r.ok&&r.reason===`aborted`)throw n.reason;return r.ok?P(r.stdout):I(`shell "${e}" ${r.exitCode===null?[r.reason,r.error].filter(e=>e!==void 0).join(`: `):`exited with code ${r.exitCode}`} in ${t}`)}}}function gO(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await T(e,{encoding:`utf8`,signal:n});return P(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return I(`file unreadable: ${e}`)}}}}function _O(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?I(`${r.reason} in ${n}`):r}const vO=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],yO=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],bO=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],xO=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function SO(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>vO[e.getMonth()]],[`Monday`,e=>bO[e.getDay()]],[`Jan`,e=>yO[e.getMonth()]],[`Mon`,e=>xO[e.getDay()]],[`15`,e=>String(e.getHours()).padStart(2,`0`)],[`06`,e=>String(e.getFullYear()%100).padStart(2,`0`)],[`01`,e=>String(e.getMonth()+1).padStart(2,`0`)],[`02`,e=>String(e.getDate()).padStart(2,`0`)],[`04`,e=>String(e.getMinutes()).padStart(2,`0`)],[`05`,e=>String(e.getSeconds()).padStart(2,`0`)],[`PM`,e=>e.getHours()<12?`AM`:`PM`],[`pm`,e=>e.getHours()<12?`am`:`pm`],[`1`,e=>String(e.getMonth()+1)],[`2`,e=>String(e.getDate())],[`3`,e=>String(e.getHours()%12||12)],[`4`,e=>String(e.getMinutes())],[`5`,e=>String(e.getSeconds())]],r=``,i=0;for(;i<e.length;){let a=!1;for(let[o,s]of n)if(e.startsWith(o,i)){r+=s(t),i+=o.length,a=!0;break}a||(r+=e[i],i++)}return r}const CO={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function wO(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=CO[t];try{return MO(r,e)}catch{return NO(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return Ri(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return Ri(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return Ri(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return Ri(e.stashCount,0)}}function TO(e){try{return b(e)}catch{return e}}function EO(e){try{return ee(e).isDirectory()}catch{return!1}}function DO(e){let t=TO(e);return EO(t)?{dir:t,name:null,leaf:!0}:ub(t)}const OO=e=>`${e.dir}\0${e.name??``}`;var kO=class{watchers=new Map;subscribe(e,t,n){let r=this.watchers.get(e)??this.arm(e);return r.subscribers.set(t,n),r.watcher===null&&n(r.failure),()=>this.unsubscribe(e,t)}arm(e){let t={watcher:null,failure:``,target:DO(e),subscribers:new Map};return t.watcher=this.open(e,t,t.target),this.watchers.set(e,t),t}rearm(e,t){let n=DO(e);if(t.watcher!==null&&OO(n)===OO(t.target))return;let r=this.open(e,t,n);r!==null&&(t.watcher?.close(),t.watcher=r,t.target=n)}open(e,t,n){let{dir:r,name:i}=n,a=s.basename(r);try{return x(r,(n,r)=>{if(!(r===null||i===null||r===i)&&r!==a)return;let o=t.target.leaf;if(this.rearm(e,t),!(!o&&!t.target.leaf))for(let e of t.subscribers.keys())e()})}catch(n){let i=`watch_file ${e}: cannot watch ${r} — ${n instanceof Error?n.message:String(n)}`;t.failure=i;for(let e of t.subscribers.values())e(i);return null}}unsubscribe(e,t){let n=this.watchers.get(e);n&&(n.subscribers.delete(t),n.subscribers.size===0&&(n.watcher?.close(),this.watchers.delete(e)))}dispose(){for(let{watcher:e}of this.watchers.values())e?.close();this.watchers.clear()}size(){return this.watchers.size}},AO=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:he(()=>{for(let e of t)e()},e),callbacks:t},this.buckets.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.buckets.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(pe(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())pe(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function jO(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function MO(e,t){if(typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Expected string|number|boolean from payload, got ${typeof e}`);return t===`string`?_b(e):t===`number`?vb(e):yb(e)}function NO(e){return e===`number`?0:e===`boolean`?!1:``}var PO=class{inputMetas=new Map;lastErrors=new Map;policyFaults=new Map;watchMgr=new kO;ttlMgr=new AO;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;reads=new $D;abort=new AbortController;drawn=mb.observable.box(z.TRUECOLOR);drawnAt=()=>this.drawn.get();instant=mb.observable.box(null);now=()=>{let e=this.instant.get();if(e===null)throw Error(`the time was read before any render published its instant`);return dO(e)};engine=uD({clock:this.now,drawnAt:this.drawnAt});gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new aO({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,gb(t),t)}declareFailedDocument(e,t){this.store.defineDocument(e,I(t))}declareInput(e,t,n,r){let i=r===void 0?this.defaultFor(n):r;this.store.defineBox(e,n,i),this.inputMetas.set(e,{path:t,varDefault:r})}declareEnv(e,t,n){let r=process.env[t];if(r!==void 0){this.store.defineBox(e,`string`,r);return}let i=n===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:n;this.store.defineBox(e,`string`,i),this.recordError(e,`env var "${t}" is not set`)}declareShell(e,t,n){this.declareSource(e,hO(t,n.cwd,this.abort.signal),fO(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,gO(t,n.readMode??`whole`,this.abort.signal),n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r,t.where),a=()=>this.runSource(e,t,i);a(),this.registerCachePolicy(e,n,a)}publisherFor(e,t,n){switch(t.kind){case`text`:return this.scalarPublisher(e,sO,t.default,n);case`regex`:return this.scalarPublisher(e,cO(t.regex),t.default,n);case`json`:return this.documentPublisher(e,t.default,n)}}scalarPublisher(e,t,n,r){let i=this.stringInitial(n);return this.store.defineBox(e,`string`,i),n=>{let a=_O(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,Ri(a,i))}}documentPublisher(e,t,n){let r=t===void 0?F:P(t);this.store.defineDocument(e,r);let i,a=!1;return this.cleanups.push(()=>clearTimeout(i)),o=>{clearTimeout(i);let s=o.kind===`ok`&&o.value.trim()===``?F:o,c=_O(s,lO,n);this.noteOutcome(e,c);let l=c.kind===`ok`||s.kind===`ok`||t===void 0?c:r,u=a&&s.kind===`ok`&&c.kind!==`ok`,d=()=>{a=c.kind===`ok`,this.store.setDocument(e,l)};u?i=setTimeout(d,250):d()}}runSource(e,t,n){let r=this.reads.run(e,()=>t.read().then(n,e=>{if(e!==this.abort.signal.reason)throw e}));r.kind===`started`&&this.track(e,r.done)}track(e,t){let n=t.finally(()=>{this.inFlight.get(e)===n&&this.inFlight.delete(e)});this.inFlight.set(e,n)}async settled(e){let t=Date.now()+e;for(;this.inFlight.size>0;){let e=t-Date.now();if(e<=0)break;let n,r=await Promise.race([Promise.all(this.inFlight.values()).then(()=>`settled`),new Promise(t=>{n=setTimeout(()=>t(`deadline`),e)})]);if(clearTimeout(n),r===`deadline`)break}return[...this.inFlight.keys()]}declareTemplate(e,t,n={}){let r=this.engine.parse(t);this.declareDerived(e,()=>r.evaluate(dD(this.store)).map(e=>e.plain).join(``),n.varDefault)}declareTime(e,t){this.declareDerived(e,()=>SO(t.format,this.now()),t.varDefault)}declareDerived(e,t,n){this.store.defineComputed(e,`string`,()=>{try{let n=t();return this.lastErrors.delete(e),n}catch(t){let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),n===void 0)throw xb(t)?new bb(e,`variable "${e}": ${r}`):Error(`variable "${e}": ${r}`);return n}})}declareGit(e,t){let n=CO[t.field],r=t.varDefault===void 0?NO(n):MO(t.varDefault,n);this.store.defineBox(e,n,r);let i=this.gitSubscriptions.get(t.cwd);if(!i){let e=new Map,n=this.gitProvider.subscribe(t.cwd,t=>{this.store.runInAction(()=>{for(let[n,r]of e)for(let{name:e,varDefault:i}of r)this.store.setBox(e,wO(t,n,i,this.defaultEmptyValue))})});i={fieldSubs:e,firstDelivery:n.firstDelivery,unsubscribe:n.unsubscribe},this.gitSubscriptions.set(t.cwd,i)}let a=i.fieldSubs.get(t.field);a||(a=[],i.fieldSubs.set(t.field,a)),a.push({name:e,varDefault:t.varDefault}),this.track(e,i.firstDelivery)}declareState(e,t){if(!this.sessionState)throw Error(`declareState("${e}"): SourceRegistry was constructed without a SessionState — state-kind variables require a SessionState (the daemon provides one; tests must supply one)`);let n=this.sessionState,r=t.varDefault??this.stringInitial(void 0);this.store.defineComputed(e,`string`,e=>{let i=e(mO);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}stateRevision(){let e=this.store.has(`session.id`)?this.store.read(mO):``;return this.sessionState!==void 0&&typeof e==`string`&&e!==``?this.sessionState.revision(e):0}applyInput(e){this.store.runInAction(()=>{for(let[t,n]of this.inputMetas){let r=jO(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,MO(r,i)),this.lastErrors.delete(t)}catch(e){this.applyFallback(t,i,n.varDefault,e instanceof Error?e.message:String(e))}else this.applyFallback(t,i,n.varDefault,`input path "${n.path}" not found in payload`)}})}drawAt(e){this.store.runInAction(()=>this.drawn.set(e))}renderAt(e){this.store.runInAction(()=>this.instant.set(e))}getLastError(e){let t=this.lastErrors.get(e),n=this.policyFaults.get(e);return n===void 0?t:t===void 0?n:{timestamp:t.timestamp,message:`${n.message}; ${t.message}`}}cachePolicyFaults(){return this.policyFaults}dispose(){this.abort.abort();for(let e of this.cleanups)e();this.cleanups.length=0;for(let e of this.gitSubscriptions.values())e.unsubscribe();return this.gitSubscriptions.clear(),this.reads.clear(),this.watchMgr.dispose(),this.ttlMgr.dispose(),this.ownsGitProvider&&this.gitProvider.close(),this.store.dispose()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:break;case`ttl`:{let e=this.ttlMgr.subscribe(t.durationMs,n);this.cleanups.push(e);break}case`watch_file`:{let r=this.watchMgr.subscribe(t.path,n,t=>this.notePolicy(e,I(t)));this.cleanups.push(r);break}case`key`:{let r=this.engine.parse(t.template),i=()=>{try{return P(r.evaluate(dD(this.store)).map(e=>e.plain).join(``))}catch(e){return xb(e)?F:I(`cache key: ${e instanceof Error?e.message:String(e)}`)}},a=i();this.notePolicy(e,a);let o=a.kind===`ok`?a.value:void 0,s=(0,mb.reaction)(i,t=>{this.notePolicy(e,t),!(t.kind!==`ok`||t.value===o)&&(o=t.value,n())});this.cleanups.push(s);break}case`depends_on`:{let e=(0,mb.reaction)(()=>t.varNames.map(e=>this.store.changeKey(e)).join(`,`),n);this.cleanups.push(e);break}}}applyFallback(e,t,n,r){if(this.recordError(e,r),n!==void 0){this.store.setBox(e,n);return}try{this.store.setBox(e,MO(this.defaultEmptyValue,t))}catch{this.store.setBox(e,NO(t))}}defaultFor(e){try{return MO(this.defaultEmptyValue,e)}catch{return NO(e)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:Date.now(),message:t})}notePolicy(e,t){t.kind===`failed`?this.policyFaults.set(e,{timestamp:Date.now(),message:t.reason}):this.policyFaults.delete(e)}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};function FO(e,t){let n=A_[e],r=R_(e),i=n.kind===`session`||n.kind===`config`?n.floor:``;return r===`string`?{kind:`input`,path:t,default:``}:{kind:`input`,path:t,type:r,default:i}}const IO=Object.fromEntries([...K_].map(([e,t])=>[t,FO(e,t)])),LO={subscribers:`number`,fps:`number`,shown:`boolean`},RO=Object.keys(LO),zO={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[mO]:{kind:`input`,path:`session_id`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},resume_command:{kind:`input`,path:`resumeCommand`,default:``},config_path:{kind:`input`,path:`configPath`,default:``},...IO,"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},...Object.fromEntries(o_.flatMap(e=>RO.map(t=>[u_(e,t),{kind:`input`,path:u_(e,t),type:LO[t],default:l_[t]}]))),[c_(`by`)]:{kind:`input`,path:c_(`by`),default:s_.by},[c_(`fps`)]:{kind:`input`,path:c_(`fps`),type:`number`,default:0},"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},"tmux.pane":{kind:`input`,path:`tmux.pane`,default:``},"autocompact.window":{kind:`input`,path:`autocompact.window`,type:`number`,default:-1},...Object.fromEntries([`applied`,`lower`,`higher`].map(e=>[`autocompact.${e}`,{kind:`input`,path:`autocompact.${e}`,type:`number`,default:0}])),"autocompact.error":{kind:`input`,path:`autocompact.error`,default:``},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},BO=`ne .tmux.pane ""`;function VO(e,t,n){let r=new Set,i=e=>{for(let t of eb(e??``,n).keys())r.add(t)};for(let t of Object.values(e.segments))i(t.template),i(t.bg),i(t.fg),i(t.when);for(let e of t)for(let t of Zh(e))i(t.when),t.kind===`segment`&&(i(t.lead),i(t.trail));for(let t of Object.values(e.variables))t.kind===`template`&&i(t.template),t.kind===`state`&&r.add(mO);for(let t of Object.values(e.actions)){r.add(mO),`copy`in t&&i(t.copy),`open`in t&&i(t.open);let e=`set`in t?q_.get(t.set):void 0,n=`persist`in t?K_.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function HO(e,t,n){let r=cb({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of VO(e,t,n.helpers)){if(sb(a,r))continue;let e=zO[a];if(e===void 0)throw Error(`synthesized chrome reads ".${a}", which it does not declare and PAYLOAD_INPUTS does not supply`);i[a]=e}return i}function UO(e){return e.replace(/[^A-Za-z0-9]+/g,`_`)}const WO=`groups.`,GO=`menus.`,KO=`edit.`,X=`candybar.`,qO=[WO,GO,KO,X];function JO(e){return qO.some(t=>e.startsWith(t))}function YO(e){let t=UO(e);return qO.find(e=>t.startsWith(UO(e)))}function XO(e,t,n,r){for(let i of[`variables`,`actions`,`segments`])for(let a of Object.keys(t[i]??{}))a.startsWith(n)&&e.issues.push({path:`${i}.${a}`,message:`"${a}" is in the reserved "${n}" namespace (synthesized by ${r}) — rename it`,line:K(e.source,[`root`])})}function ZO(e){return e}function QO(e,t,n){return n===void 0?GO+UO(e)+`.`+UO(t):$O(n)}function $O(e){return GO+UO(e)}function ek(e,t){return e+`.`+t}function tk(e){return e+`.page`}const nk=[`closeOnPick`,`paged`,`key`,`distribution`],rk=e=>nk.includes(e),ik=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${um.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function ak(e){for(let t of Object.keys(e))if(!rk(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${ik}`);let t=(t,n)=>{let r=e[t];if(r===void 0)return n;if(typeof r!=`boolean`)throw Error(`{{ menu }} option "${t}" must be a boolean, got ${JSON.stringify(r)} (e.g. (dict "${t}" ${String(!n)}))`);return r},n=e.key;if(n!==void 0&&typeof n!=`string`)throw Error(`{{ menu }} option "key" must be a string naming the accordion group, got ${JSON.stringify(n)}`);if(n===``)throw Error(`{{ menu }} has an empty accordion key — a shared key must be a non-empty name (or omit "key" for an independent menu)`);let r=e.distribution;if(r!==void 0&&!dm(r))throw Error(`{{ menu }} option "distribution" must be one of: ${um.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:pm(r)}}const ok=e=>`from`in e?e.from:e.themes;function sk(e,t,n){return e===`bool`?Uh(t)!==null:`min`in e?Wh(t,e)!==null:zy(ok(e),n).members.includes(t)}function ck(e,t){if(e===`bool`)return Vh.join(` or `);if(!(`min`in e)){let n=ok(e),{members:r}=zy(n,t),i=r.map(e=>JSON.stringify(e));if(r.length<=8)return`one of ${i.join(`, `)}`;let a=typeof n==`string`?` "${n}"`:``;return`one of the ${r.length}${a} names, such as ${i.slice(0,3).join(`, `)}`}return`an integer from ${e.min} to ${e.max}`}function lk(e){return{label:e.label,domain:uk(e.domain)}}function uk(e){return e===`theme`?{themes:Iy}:e===`bool`||`min`in e?e:{from:e}}function dk(e,t,n,r,i){let a=Mr(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...Vh]}},variables:{}};if(`from`in o)return fk(t,r,i,o.from,e=>({template:`{{ "${a}" }} {{ carousel "${e.apply}" 0 "${e.open}" }}`,rows:[`{{ picker "${e.apply}" "${e.page}" false true true }}`]}));if(`themes`in o)return fk(t,r,i,o.themes,e=>({template:`{{ action "${e.open}" "${a}" .${n} }} {{ action "${e.open}" (swatch "${e.apply}") }}`,rows:[`{{ swatches "${e.apply}" "${e.page}" }}`,`{{ themePreview "${e.apply}" }}`]}));let s=e=>({set:t,min:o.min,max:o.max,by:e});return{kind:`inline`,template:`{{ action "${r}.down" "◀" }} {{ "${a}" }} {{ .${n} }} {{ action "${r}.up" "▶" }}`,actions:{[`${r}.down`]:s(-o.step),[`${r}.up`]:s(o.step)},variables:{}}}function fk(e,t,n,r,i){let a={variable:n,key:n,member:t},o=ek(n,t),s=`${t}.open`,c=tk(n),l=`${c}.current`,{template:u,rows:d}=i({apply:t,open:s,page:c});return{kind:`picker`,template:u,actions:{[t]:{set:e,from:r},[o]:Br(n,t),[c]:{set:c,int:!0},[l]:{set:c,to:`-1`},[s]:{do:[o,l]}},variables:{[n]:zr(n,Or),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,rows:d}}}const pk=Object.fromEntries(Object.entries(A_).map(([e,t])=>[e,t.spec]));function mk(e){return A_[e].domain}function hk(e,t){return{required:!1,json:{not:{},description:`not allowed here — ${e}`},parse:(e,n,r,i)=>{i[r]!==void 0&&e.issues.push({path:`${n}.${r}`,message:t(`${n}.${r}`),line:K(e.source,[...n.split(`.`),r])})}}}function gk(e){return hk(`${e} cannot select a preset`,t=>`${t}: ${e} cannot select a preset. Which preset is active is resolved once, as session pick over globals.preset over "default"; a fragment naming another would be a second authority over that. Set the default arrangement in the top-level globals.preset instead.`)}function _k(e){return hk(`${e} cannot change the settings menu glyph`,t=>`${t}: ${e} cannot change the settings menu glyph — one menu is shared by every preset. Set it in the top-level globals.menuGlyph instead.`)}function vk(e,t,n){return{...e,json:{...e.json,not:{pattern:`\\{\\{`}},parse:(r,i,a,o)=>{let s=o[a];if(typeof s==`string`&&_h(s)){r.issues.push({path:`${i}.${a}`,message:`${i}.${a}: a rule is not allowed here — ${t} ${n}, so it names a value. Write the rule in globals.${a} (or a preset's globals.${a}) instead.`,line:K(r.source,[...i.split(`.`),a])});return}return e.parse(r,i,a,o)}}}const yk={default_bg:"nothing reads it — a segment with no `bg:` wears the decoration tint of its place in the bar. Delete the key, and author `bg:` on the segments that need a fixed colour.",default_fg:"nothing reads it — a segment with no `fg:` wears text chosen for contrast against its background. Delete the key, and author `fg:` on the segments that need a fixed colour.",default_truncate_marker:'nothing reads it — a segment clipped to its `width:` always ends in "…". Delete the key.',look:`it was renamed "style" — write the same name as style: "<name>"`,progression:`it was renamed "variation", and its values with it: accent (was secondary-accent), duo (was primary-secondary), mono (was primary)`,charset:"the bar always draws Nerd Font glyphs. Delete the key; `cc-candybar doctor` names what your terminal's font is missing."},bk={noun:`globals key`,fields:pk,removed:yk},xk={preset:gk(`a preset`),menuGlyph:_k(`a preset`)},Sk={noun:`preset globals key`,fields:{...pk,...xk},removed:yk};function Ck(e){return Nk(e)&&!(e in xk)}const wk=`is decided later than any rule could be settled`,Tk={noun:`editGlobals key`,removed:yk,fields:{...pk,preset:gk(`the editGlobals fragment`),menuGlyph:_k(`the editGlobals fragment`),palette:vk(pk.palette,`the editGlobals fragment`,wk),style:vk(pk.style,`the editGlobals fragment`,wk),effect:vk(pk.effect,`the editGlobals fragment`,wk)}},Ek={noun:`theme default key`,fields:{...Object.fromEntries(P_.map(e=>[e,pk[e]])),style:vk(pk.style,`a theme's default`,`is the look that theme wears by name`)}};function Dk(e,t){if(!Mg(t))return e.issues.push({path:`themeDefaults`,message:`themeDefaults must be an object mapping theme names to { shade, variation, style }, got ${Ng(t)}`,line:K(e.source,[`themeDefaults`])}),{};let n={};for(let[r,i]of Object.entries(t)){let t=`themeDefaults.${r}`;if(!e.allowedPalettes.has(r)){e.issues.push({path:t,message:`${t}: "${r}" is not an installed theme${ch(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:K(e.source,[`themeDefaults`,r])});continue}let a=Pg(e,Ek,t,i);a!==null&&(n[r]=a)}return n}function Ok(e,t,n){return n===void 0?{}:Pg(e,bk,t,n)??{}}function kk(e,t,n){return Pg(e,Sk,t,n)??{}}function Ak(){return t_(Sk)}function jk(e,t,n){return Pg(e,Tk,t,n)??{}}const Mk=new Set(Object.keys(pk));function Nk(e){return Mk.has(e)}function Pk(e){return Object.hasOwn(yk,e)?yk[e]:void 0}function Fk(){return[...Mk]}const Ik=new Map(Object.entries(A_).flatMap(([e,t])=>`floor`in t&&typeof t.floor==`number`?[[e,t.floor]]:[]));function Lk(e){let t=new Map;for(let[n,r]of Ik){let i=e[n];t.set(n,typeof i==`number`?i:r)}return t}const Rk=/^segments\.([^.]+)\.palette$/,zk=/^presets\.(.+)\.root$/,Bk=/^presets\.(.+)\.globals\.([^.]+)$/,Vk=/^themeDefaults\.(.+)\.([^.]+)$/;function Hk(e){return`presets.${e}.root`}function Uk(e,t){return`themeDefaults.${e}.${t}`}const Wk=e=>P_.includes(e);function Gk(e,t){return`presets.${e}.globals.${t}`}function Kk(e){if(Nk(e))return{scope:`globals`,field:e};let t=Rk.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=Bk.exec(e);if(n&&Ck(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=Vk.exec(e);if(r&&Wk(r[2]))return{scope:`theme-default`,theme:r[1],field:r[2]};let i=zk.exec(e);return i?{scope:`preset-root`,preset:i[1]}:null}function qk(e){switch(e.scope){case`globals`:return[`globals`,e.field];case`preset-globals`:return[`presets`,e.preset,`globals`,e.field];case`segment-palette`:return[`segments`,e.segment,`palette`];case`theme-default`:return[`themeDefaults`,e.theme,e.field]}}const Jk=[`location`,`git`,`model-context`,`cost-limits`,`activity`,`session-tools`],Yk=[...Jk,`other`],Xk={location:`location`,git:`git`,"model-context":`model & context`,"cost-limits":`cost & limits`,activity:`activity`,"session-tools":`session tools`,other:`other`},Zk=mS({fromString:e=>e}),Qk=`edit.mode`,$k=`edit.configure`,eA=`edit.toggle`,tA=`edit.unconfigure`,nA=[eA,tA],rA=`arrange`,iA=`${KO}draft.`;function aA(e,t){return`${e}:${t}`}const oA={variable:Qk,key:Qk,member:rA},sA=Pr(oA);function cA(e){try{return Zk.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function lA(e){if(Object.values(e.actions??{}).some(e=>`do`in e&&e.do.includes(`edit.toggle`)))return!0;for(let t of Object.values(e.segments??{}))for(let e of[t.template,t.bg,t.fg])if(typeof e==`string`&&cA(e))return!0;return!1}function uA(e,t){if(XO(e,t,KO,`edit mode`),!lA(t))return;let{variables:n,actions:r}=dA();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function dA(){return{variables:{[Qk]:zr(Qk,Or),[$k]:zr($k,Or)},actions:{[eA]:Br(Qk,rA),[tA]:{set:$k,to:Or}}}}const fA=`open`;function pA(e,t,n,r){let i={variable:e,key:e,member:fA};return r.variables[e]=zr(e,Or),r.actions[e]=Br(e,fA),r.segments[e]={template:Ir(e,`(?)`,`✕`),...mA(n)},Nr(e,i,{kind:`container`,direction:`horizontal`,children:t.map((t,n)=>{let i=`${e}.${n}`;return r.segments[i]={template:t},{kind:`segment`,name:i}})},`drop`)}function mA(e){let[t,...n]=e;return t===void 0?{}:{when:Pr(t,...n)}}const hA=`none`;function gA(e){return mc(e,`background`)}var _A=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function vA(e,t,n,r,i){let{palette:a,tint:o,text:s}=e,c=yA(n,i),l=c!==hA,u=l?c===void 0?o:bA(a,c,`bg`):gA(a);e.bg=u;let d=yA(r,i),f=d===void 0?l?(e=>e.hex===o.hex?s:Fm(a,e,t))(u):void 0:bA(a,d,`fg`);return new H({...l&&{bgcolor:B.fromRgba(u)},...f!==void 0&&{color:B.fromRgba(f)}})}function yA(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function bA(e,t,n){try{return mc(e,t)}catch(e){throw e instanceof pc?new _A(t,n,e.message):e}}const xA=`🔧`,SA={help:[`-h`,`--help`],version:[`-V`,`--version`]},CA=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],wA=Object.fromEntries(CA.map(e=>[e.member,e.label])),TA={gear:{beside:`theme`,trigger:`⚙`},toggles:{beside:`updateNotice`,trigger:`🧪 toggles`}},EA=Object.keys(TA),DA=J_(e=>V_[e].place),OA=e=>Object.hasOwn(TA,e),kA=e=>OA(e)?kA(DA[TA[e].beside]):e,AA=e=>OA(e)?`${AA(DA[TA[e].beside])} › ${TA[e].trigger}`:e===`door`?`first line`:wA[e],jA=e=>AA(DA[e]),MA=e=>`${a_[e].label} is off — turn it on in the settings menu's ${jA(a_[e].setting)}, or set globals.${a_[e].setting}: true`,NA=[...new Set(Object.values(a_).map(e=>jA(e.setting)))].join(` or `),PA=[`✚ inserts`,`✖ removes`,`${xA} configures`,`↺ resets layout`],FA={band:[`animates the bar in the band above the prompt, through a Claude Code mod`,`on: installs the candybar-band mod from this checkout and types /reload-plugins`],statusline:[`animates the statusline itself, through the attach launcher shipped with cc-candybar`,`on: exits this Claude Code and starts it again under that launcher, resuming this session`],pane:[`animates the bar in a tmux pane under this session's`,`on: opens that pane · off: closes it`]},IA=`
76
+ `).length:0)}async getRemotesAsync(e){let t=YD(s.join(this.resolveCommonGitDir(e),`config`));if(t===null)return this.readRemotes(e);let{key:n,stamp:r}=t,i=this.remotesByConfig.get(n);if(i!==void 0&&i.stamp===r)return this.remotesByConfig.delete(n),this.remotesByConfig.set(n,i),i.remotes;let a=this.readRemotes(e);for(this.remotesByConfig.set(n,{stamp:r,remotes:a}),a.then(e=>{let t=this.remotesByConfig.get(n);e.kind!==`ok`&&t?.remotes===a&&this.remotesByConfig.delete(n)},()=>{this.remotesByConfig.get(n)?.remotes===a&&this.remotesByConfig.delete(n)});this.remotesByConfig.size>256;){let e=this.remotesByConfig.keys().next().value;if(e===void 0)break;this.remotesByConfig.delete(e)}return a}remotesByConfig=new Map;async readRemotes(e){return FD(await this.execGitAsync(PD,{cwd:e,timeout:2e3}))}repoNameFrom(e,t){let n=zD(e);return(n===null?null:VD(n))??s.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=BD(t.value);return n===null?F:P(n)}async execForgeAsync(e,t,n){return Ue({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=ND(t);return n===`github`?WD(`gh pr view`,await this.execForgeAsync(OD.github,[`pr`,`view`,`--json`,`number,state,url,headRefOid`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,qD):n===`gitlab`?WD(`glab mr view`,await this.execForgeAsync(OD.gitlab,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,JD):F}isWorktree(e){try{let t=s.join(e,`.git`);return!!(p.existsSync(t)&&p.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){E(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=CD(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?P(KD(t.value)):t}};const ZD=(e,t)=>E(t);var QD=class{slots=new Map;maxWatchers;counters;logger;closed=!1;constructor(e={}){this.maxWatchers=e.maxWatchers??128,this.counters=e.counters,this.logger=e.logger??ZD}acquire(e,t,n){if(this.closed)return{release:()=>{}};let r=this.slots.get(e);if(r)return r.refcount++,r.onInvalidate=n,r.lastTouched=Date.now(),this.slots.delete(e),this.slots.set(e,r),this.makeHandle(e);let i={key:e,watchers:[],refcount:1,debounceTimer:null,onInvalidate:n,targets:t,lastTouched:Date.now()};return this.openWatchers(i),this.slots.set(e,i),this.counters&&this.counters.watchersOpened++,this.evictIfNeeded(),this.makeHandle(e)}makeHandle(e){let t=!1;return{release:()=>{if(t)return;t=!0;let n=this.slots.get(e);n&&(n.refcount=Math.max(0,n.refcount-1),n.refcount===0&&(this.closeSlot(n),this.slots.delete(e)))}}}openWatchers(e){let t=()=>{e.debounceTimer||(e.debounceTimer=setTimeout(()=>{e.debounceTimer=null;try{e.onInvalidate()}catch(e){this.logger(`warn`,`watcher invalidate threw: ${e.message}`)}},50),e.debounceTimer.unref())};for(let n of e.targets.files)try{let r=p.watch(n,{persistent:!1},t);r.on(`error`,e=>{this.logger(`warn`,`watcher error ${n}: ${e.message}`)}),e.watchers.push(r)}catch(e){this.logger(`warn`,`watch failed ${n}: ${e.message}`)}for(let n of e.targets.dirs)try{let r=n.filenames?new Set(n.filenames):null,i=p.watch(n.path,{persistent:!1},(e,n)=>{r&&(!n||!r.has(n))||t()});i.on(`error`,e=>{this.logger(`warn`,`watcher error ${n.path}: ${e.message}`)}),e.watchers.push(i)}catch(e){this.logger(`warn`,`watch failed ${n.path}: ${e.message}`)}}closeSlot(e){e.debounceTimer&&=(clearTimeout(e.debounceTimer),null);for(let t of e.watchers)try{t.close()}catch{}e.watchers=[],this.counters&&this.counters.watchersClosed++}evictIfNeeded(){for(;this.slots.size>this.maxWatchers;){let e=this.slots.keys().next().value;if(e===void 0)break;let t=this.slots.get(e);this.closeSlot(t),this.slots.delete(e),this.counters&&this.counters.watchersEvicted++;try{t.onInvalidate()}catch{}this.logger(`info`,`watcher LRU evict ${e}`)}}size(){return this.slots.size}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e);this.slots.clear()}},$D=class{running=new Set;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:(this.running.add(e),{kind:`started`,done:this.loop(e,t)})}async loop(e,t){try{do this.again.delete(e),await t();while(this.again.has(e))}finally{this.running.delete(e),this.again.delete(e)}}clear(){this.running.clear(),this.again.clear()}get size(){return this.running.size}};const eO={showSha:!0,showStashCount:!0};function tO(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function nO(e){let t=t=>{try{return p.statSync(s.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function rO(e,t){return e.head!==t.head||e.index!==t.index}function iO(e){let t=[],n=s.join(e,`refs/heads`);try{p.statSync(n).isDirectory()&&t.push({path:n})}catch{}return{files:[s.join(e,`HEAD`),s.join(e,`index`)],dirs:t}}var aO=class extends XD{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;resolutions=new Map;prCache=new Map;prFetchInFlight=new Map;refreshes=new $D;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new XD,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??ke,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new QD({logger:this.logger}),this.ownsWatchers=!0);let t=e.sanityIntervalMs??3e5;t>0&&(this.sanityTimer=setInterval(()=>this.runSanityCheck(),t),this.sanityTimer.unref())}getWatcherRegistry(){return this.watchers}getStats(){return{size:this.entries.size,hits:this.hits,misses:this.misses,invalidations:this.invalidations,watchers:this.watchers.size()}}resolveEffectiveGitDir(e,t){let n=`${e}|${t??``}`,r=Date.now(),i=this.resolutions.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.resolutions.delete(n),this.resolutions.set(n,i),i.dir;let a=this.inner.resolveEffectiveGitDir(e,t);return this.resolutions.set(n,{dir:a,computedAt:r}),a.catch(()=>{this.resolutions.get(n)?.dir===a&&this.resolutions.delete(n)}),this.evictResolutionsIfNeeded(),a}evictResolutionsIfNeeded(){for(;this.resolutions.size>this.maxEntries;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}}async getGitInfo(e,t={},n){let r=await this.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${tO(t)}`,r=Date.now(),i=this.entries.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.entries.delete(n),this.entries.set(n,i),this.hits++,Promise.resolve(P(i.info));let a=this.fetchInFlight.get(n);if(a)return a;let o=this.doFetch(e,n,t,r).finally(()=>{this.fetchInFlight.delete(n)});return this.fetchInFlight.set(n,o),o}async doFetch(e,t,n,r){this.misses++;let i=this.inner.resolveGitDir(e),a=nO(i),o=await this.inner.getGitInfo(e,n);if(o.kind!==`ok`)return o;let s=o.value;n.showPullRequest&&(s.pullRequest=await this.getPullRequestCached(e,s.branch)),this.dropEntry(t);let c=this.watchers.acquire(`git:${e}`,iO(i),()=>this.invalidateRepo(e));return this.entries.set(t,{info:s,computedAt:r,mtime:a,watcher:c,repoRoot:e}),this.evictIfNeeded(),o}async getPullRequestCached(e,t){let n=await this.inner.getRepoRemoteUrl(e);if(n.kind===`failed`)return n;if(n.kind===`absent`)return F;let r=n.value,i=`${e}|${t}|${r}`,a=Date.now(),o=this.prCache.get(i);if(o){let e=o.pr.kind===`failed`?45e3:3e5;if(a-o.computedAt<e)return this.prCache.delete(i),this.prCache.set(i,o),o.pr}let s=this.prFetchInFlight.get(i);if(s)return s;let c=this.inner.resolvePullRequest(e,r).then(e=>(this.prCache.set(i,{pr:e,computedAt:Date.now()}),this.evictPrIfNeeded(),e)).finally(()=>{this.prFetchInFlight.delete(i)});return this.prFetchInFlight.set(i,c),c}evictPrIfNeeded(){for(;this.prCache.size>this.maxEntries;){let e=this.prCache.keys().next().value;if(e===void 0)break;this.prCache.delete(e)}}deliverable(e,t){return e.kind===`failed`?(this.logger(`warn`,`git fetch failed (${t}): ${e.reason}`),null):e.kind===`ok`?e.value:null}subscribe(e,t){let n=!1,r=null;return{firstDelivery:(async()=>{let i=await this.resolveEffectiveGitDir(e);if(n)return;if(i.kind!==`ok`){i.kind===`failed`&&this.logger(`warn`,`git resolve failed (subscribe ${e}): ${i.reason}`),this.safeInvoke(t,null);return}let a=i.value,o=this.subscribersByRepo.get(a);if(!o){let t=this.inner.resolveGitDir(a),n=this.watchers.acquire(`git:${a}`,iO(t),()=>this.invalidateRepo(a));o={workingDir:e,repoRoot:a,callbacks:new Set,watcher:n},this.subscribersByRepo.set(a,o)}o.callbacks.add(t),r={repoRoot:a,entry:o};let s=await this.getGitInfoForRoot(a,{...eO});n||this.safeInvoke(t,this.deliverable(s,a))})(),unsubscribe:()=>{if(n=!0,!r)return;let{repoRoot:e,entry:i}=r;i.callbacks.delete(t),i.callbacks.size===0&&(i.watcher.release(),this.subscribersByRepo.delete(e))}}}invalidateRepo(e){let t=0;for(let[n,r]of this.entries)r.repoRoot===e&&(r.watcher.release(),this.entries.delete(n),t++);t>0&&(this.invalidations+=t,this.logger(`info`,`gitCache invalidate ${e} dropped=${t}`)),this.refreshSubscribers(e)}refreshSubscribers(e){let t=this.subscribersByRepo.get(e);!t||t.callbacks.size===0||this.refreshes.run(e,()=>this.refreshOnce(e))}async refreshOnce(e){let t=this.subscribersByRepo.get(e);if(!t||t.callbacks.size===0)return;let n=await this.getGitInfoForRoot(e,{...eO}),r=this.deliverable(n,e),i=this.subscribersByRepo.get(e);if(!(!i||i.callbacks.size===0))for(let e of[...i.callbacks])i.callbacks.has(e)&&this.safeInvoke(e,r)}safeInvoke(e,t){try{e(t)}catch(e){this.logger(`warn`,`git subscriber threw: ${e.message??String(e)}`)}}dropEntry(e){let t=this.entries.get(e);t&&(t.watcher.release(),this.entries.delete(e))}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.dropEntry(e),this.logger(`info`,`gitCache evict ${e}`)}}runSanityCheck(){let e=new Map;for(let t of this.entries.values()){let n=e.get(t.repoRoot);n||(n=nO(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),rO(t.mtime,n)&&this.invalidateRepo(t.repoRoot)}}runSanityCheckNow(){this.runSanityCheck()}close(){this.sanityTimer&&=(clearInterval(this.sanityTimer),null);for(let e of this.entries.values())e.watcher.release();this.entries.clear();for(let e of this.subscribersByRepo.values())e.callbacks.clear(),e.watcher.release();this.subscribersByRepo.clear(),this.refreshes.clear(),this.fetchInFlight.clear(),this.prCache.clear(),this.prFetchInFlight.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}};const oO=/\r\n|\r|\n/g,sO=e=>P(e.replace(oO,` `).trim());function cO(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?I(`regex no-match`):P(n.replace(oO,` `))}}const lO=e=>{try{return P(JSON.parse(e))}catch(e){return I(`JSON parse failed: ${e.message}`)}},uO=e=>e.getTime()/1e3,dO=e=>new Date(e*1e3);function fO(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(E(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function pO(e){let t=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/.exec(e);if(!t)throw RangeError(`Invalid duration: "${e}"`);let n=parseFloat(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;default:throw RangeError(`Unexpected duration unit: "${t[2]}"`)}}const mO=`session.id`;function hO(e,t,n){return{where:`output of "${e}" in ${t}`,read:async()=>{let r=await Ue({bin:`/bin/sh`,args:[`-c`,e],cwd:t,category:`user-shell`,signal:n});if(!r.ok&&r.reason===`aborted`)throw n.reason;return r.ok?P(r.stdout):I(`shell "${e}" ${r.exitCode===null?[r.reason,r.error].filter(e=>e!==void 0).join(`: `):`exited with code ${r.exitCode}`} in ${t}`)}}}function gO(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await T(e,{encoding:`utf8`,signal:n});return P(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return I(`file unreadable: ${e}`)}}}}function _O(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?I(`${r.reason} in ${n}`):r}const vO=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],yO=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],bO=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],xO=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function SO(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>vO[e.getMonth()]],[`Monday`,e=>bO[e.getDay()]],[`Jan`,e=>yO[e.getMonth()]],[`Mon`,e=>xO[e.getDay()]],[`15`,e=>String(e.getHours()).padStart(2,`0`)],[`06`,e=>String(e.getFullYear()%100).padStart(2,`0`)],[`01`,e=>String(e.getMonth()+1).padStart(2,`0`)],[`02`,e=>String(e.getDate()).padStart(2,`0`)],[`04`,e=>String(e.getMinutes()).padStart(2,`0`)],[`05`,e=>String(e.getSeconds()).padStart(2,`0`)],[`PM`,e=>e.getHours()<12?`AM`:`PM`],[`pm`,e=>e.getHours()<12?`am`:`pm`],[`1`,e=>String(e.getMonth()+1)],[`2`,e=>String(e.getDate())],[`3`,e=>String(e.getHours()%12||12)],[`4`,e=>String(e.getMinutes())],[`5`,e=>String(e.getSeconds())]],r=``,i=0;for(;i<e.length;){let a=!1;for(let[o,s]of n)if(e.startsWith(o,i)){r+=s(t),i+=o.length,a=!0;break}a||(r+=e[i],i++)}return r}const CO={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function wO(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=CO[t];try{return MO(r,e)}catch{return NO(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return Ri(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return Ri(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return Ri(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return Ri(e.stashCount,0)}}function TO(e){try{return b(e)}catch{return e}}function EO(e){try{return ee(e).isDirectory()}catch{return!1}}function DO(e){let t=TO(e);return EO(t)?{dir:t,name:null,leaf:!0}:ub(t)}const OO=e=>`${e.dir}\0${e.name??``}`;var kO=class{watchers=new Map;subscribe(e,t,n){let r=this.watchers.get(e)??this.arm(e);return r.subscribers.set(t,n),r.watcher===null&&n(r.failure),()=>this.unsubscribe(e,t)}arm(e){let t={watcher:null,failure:``,target:DO(e),subscribers:new Map};return t.watcher=this.open(e,t,t.target),this.watchers.set(e,t),t}rearm(e,t){let n=DO(e);if(t.watcher!==null&&OO(n)===OO(t.target))return;let r=this.open(e,t,n);r!==null&&(t.watcher?.close(),t.watcher=r,t.target=n)}open(e,t,n){let{dir:r,name:i}=n,a=s.basename(r);try{return x(r,(n,r)=>{if(!(r===null||i===null||r===i)&&r!==a)return;let o=t.target.leaf;if(this.rearm(e,t),!(!o&&!t.target.leaf))for(let e of t.subscribers.keys())e()})}catch(n){let i=`watch_file ${e}: cannot watch ${r} — ${n instanceof Error?n.message:String(n)}`;t.failure=i;for(let e of t.subscribers.values())e(i);return null}}unsubscribe(e,t){let n=this.watchers.get(e);n&&(n.subscribers.delete(t),n.subscribers.size===0&&(n.watcher?.close(),this.watchers.delete(e)))}dispose(){for(let{watcher:e}of this.watchers.values())e?.close();this.watchers.clear()}size(){return this.watchers.size}},AO=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:he(()=>{for(let e of t)e()},e),callbacks:t},this.buckets.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.buckets.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(pe(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())pe(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function jO(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function MO(e,t){if(typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Expected string|number|boolean from payload, got ${typeof e}`);return t===`string`?_b(e):t===`number`?vb(e):yb(e)}function NO(e){return e===`number`?0:e===`boolean`?!1:``}var PO=class{inputMetas=new Map;lastErrors=new Map;policyFaults=new Map;watchMgr=new kO;ttlMgr=new AO;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;reads=new $D;abort=new AbortController;drawn=mb.observable.box(z.TRUECOLOR);drawnAt=()=>this.drawn.get();instant=mb.observable.box(null);now=()=>{let e=this.instant.get();if(e===null)throw Error(`the time was read before any render published its instant`);return dO(e)};engine=uD({clock:this.now,drawnAt:this.drawnAt});gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new aO({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,gb(t),t)}declareFailedDocument(e,t){this.store.defineDocument(e,I(t))}declareInput(e,t,n,r){let i=r===void 0?this.defaultFor(n):r;this.store.defineBox(e,n,i),this.inputMetas.set(e,{path:t,varDefault:r})}declareEnv(e,t,n){let r=process.env[t];if(r!==void 0){this.store.defineBox(e,`string`,r);return}let i=n===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:n;this.store.defineBox(e,`string`,i),this.recordError(e,`env var "${t}" is not set`)}declareShell(e,t,n){this.declareSource(e,hO(t,n.cwd,this.abort.signal),fO(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,gO(t,n.readMode??`whole`,this.abort.signal),n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r,t.where),a=()=>this.runSource(e,t,i);a(),this.registerCachePolicy(e,n,a)}publisherFor(e,t,n){switch(t.kind){case`text`:return this.scalarPublisher(e,sO,t.default,n);case`regex`:return this.scalarPublisher(e,cO(t.regex),t.default,n);case`json`:return this.documentPublisher(e,t.default,n)}}scalarPublisher(e,t,n,r){let i=this.stringInitial(n);return this.store.defineBox(e,`string`,i),n=>{let a=_O(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,Ri(a,i))}}documentPublisher(e,t,n){let r=t===void 0?F:P(t);this.store.defineDocument(e,r);let i,a=!1;return this.cleanups.push(()=>clearTimeout(i)),o=>{clearTimeout(i);let s=o.kind===`ok`&&o.value.trim()===``?F:o,c=_O(s,lO,n);this.noteOutcome(e,c);let l=c.kind===`ok`||s.kind===`ok`||t===void 0?c:r,u=a&&s.kind===`ok`&&c.kind!==`ok`,d=()=>{a=c.kind===`ok`,this.store.setDocument(e,l)};u?i=setTimeout(d,250):d()}}runSource(e,t,n){let r=this.reads.run(e,()=>t.read().then(n,e=>{if(e!==this.abort.signal.reason)throw e}));r.kind===`started`&&this.track(e,r.done)}track(e,t){let n=t.finally(()=>{this.inFlight.get(e)===n&&this.inFlight.delete(e)});this.inFlight.set(e,n)}async settled(e){let t=Date.now()+e;for(;this.inFlight.size>0;){let e=t-Date.now();if(e<=0)break;let n,r=await Promise.race([Promise.all(this.inFlight.values()).then(()=>`settled`),new Promise(t=>{n=setTimeout(()=>t(`deadline`),e)})]);if(clearTimeout(n),r===`deadline`)break}return[...this.inFlight.keys()]}declareTemplate(e,t,n={}){let r=this.engine.parse(t);this.declareDerived(e,()=>r.evaluate(dD(this.store)).map(e=>e.plain).join(``),n.varDefault)}declareTime(e,t){this.declareDerived(e,()=>SO(t.format,this.now()),t.varDefault)}declareDerived(e,t,n){this.store.defineComputed(e,`string`,()=>{try{let n=t();return this.lastErrors.delete(e),n}catch(t){let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),n===void 0)throw xb(t)?new bb(e,`variable "${e}": ${r}`):Error(`variable "${e}": ${r}`);return n}})}declareGit(e,t){let n=CO[t.field],r=t.varDefault===void 0?NO(n):MO(t.varDefault,n);this.store.defineBox(e,n,r);let i=this.gitSubscriptions.get(t.cwd);if(!i){let e=new Map,n=this.gitProvider.subscribe(t.cwd,t=>{this.store.runInAction(()=>{for(let[n,r]of e)for(let{name:e,varDefault:i}of r)this.store.setBox(e,wO(t,n,i,this.defaultEmptyValue))})});i={fieldSubs:e,firstDelivery:n.firstDelivery,unsubscribe:n.unsubscribe},this.gitSubscriptions.set(t.cwd,i)}let a=i.fieldSubs.get(t.field);a||(a=[],i.fieldSubs.set(t.field,a)),a.push({name:e,varDefault:t.varDefault}),this.track(e,i.firstDelivery)}declareState(e,t){if(!this.sessionState)throw Error(`declareState("${e}"): SourceRegistry was constructed without a SessionState — state-kind variables require a SessionState (the daemon provides one; tests must supply one)`);let n=this.sessionState,r=t.varDefault??this.stringInitial(void 0);this.store.defineComputed(e,`string`,e=>{let i=e(mO);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}stateRevision(){let e=this.store.has(`session.id`)?this.store.read(mO):``;return this.sessionState!==void 0&&typeof e==`string`&&e!==``?this.sessionState.revision(e):0}applyInput(e){this.store.runInAction(()=>{for(let[t,n]of this.inputMetas){let r=jO(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,MO(r,i)),this.lastErrors.delete(t)}catch(e){this.applyFallback(t,i,n.varDefault,e instanceof Error?e.message:String(e))}else this.applyFallback(t,i,n.varDefault,`input path "${n.path}" not found in payload`)}})}drawAt(e){this.store.runInAction(()=>this.drawn.set(e))}renderAt(e){this.store.runInAction(()=>this.instant.set(e))}getLastError(e){let t=this.lastErrors.get(e),n=this.policyFaults.get(e);return n===void 0?t:t===void 0?n:{timestamp:t.timestamp,message:`${n.message}; ${t.message}`}}cachePolicyFaults(){return this.policyFaults}dispose(){this.abort.abort();for(let e of this.cleanups)e();this.cleanups.length=0;for(let e of this.gitSubscriptions.values())e.unsubscribe();return this.gitSubscriptions.clear(),this.reads.clear(),this.watchMgr.dispose(),this.ttlMgr.dispose(),this.ownsGitProvider&&this.gitProvider.close(),this.store.dispose()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:break;case`ttl`:{let e=this.ttlMgr.subscribe(t.durationMs,n);this.cleanups.push(e);break}case`watch_file`:{let r=this.watchMgr.subscribe(t.path,n,t=>this.notePolicy(e,I(t)));this.cleanups.push(r);break}case`key`:{let r=this.engine.parse(t.template),i=()=>{try{return P(r.evaluate(dD(this.store)).map(e=>e.plain).join(``))}catch(e){return xb(e)?F:I(`cache key: ${e instanceof Error?e.message:String(e)}`)}},a=i();this.notePolicy(e,a);let o=a.kind===`ok`?a.value:void 0,s=(0,mb.reaction)(i,t=>{this.notePolicy(e,t),!(t.kind!==`ok`||t.value===o)&&(o=t.value,n())});this.cleanups.push(s);break}case`depends_on`:{let e=(0,mb.reaction)(()=>t.varNames.map(e=>this.store.changeKey(e)).join(`,`),n);this.cleanups.push(e);break}}}applyFallback(e,t,n,r){if(this.recordError(e,r),n!==void 0){this.store.setBox(e,n);return}try{this.store.setBox(e,MO(this.defaultEmptyValue,t))}catch{this.store.setBox(e,NO(t))}}defaultFor(e){try{return MO(this.defaultEmptyValue,e)}catch{return NO(e)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:Date.now(),message:t})}notePolicy(e,t){t.kind===`failed`?this.policyFaults.set(e,{timestamp:Date.now(),message:t.reason}):this.policyFaults.delete(e)}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};function FO(e,t){let n=A_[e],r=R_(e),i=n.kind===`session`||n.kind===`config`?n.floor:``;return r===`string`?{kind:`input`,path:t,default:``}:{kind:`input`,path:t,type:r,default:i}}const IO=Object.fromEntries([...K_].map(([e,t])=>[t,FO(e,t)])),LO={subscribers:`number`,fps:`number`,shown:`boolean`},RO=Object.keys(LO),zO={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[mO]:{kind:`input`,path:`session_id`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},resume_command:{kind:`input`,path:`resumeCommand`,default:``},config_path:{kind:`input`,path:`configPath`,default:``},...IO,"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},...Object.fromEntries(o_.flatMap(e=>RO.map(t=>[u_(e,t),{kind:`input`,path:u_(e,t),type:LO[t],default:l_[t]}]))),[c_(`by`)]:{kind:`input`,path:c_(`by`),default:s_.by},[c_(`fps`)]:{kind:`input`,path:c_(`fps`),type:`number`,default:0},"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},"tmux.pane":{kind:`input`,path:`tmux.pane`,default:``},"autocompact.window":{kind:`input`,path:`autocompact.window`,type:`number`,default:-1},...Object.fromEntries([`applied`,`lower`,`higher`].map(e=>[`autocompact.${e}`,{kind:`input`,path:`autocompact.${e}`,type:`number`,default:0}])),"autocompact.error":{kind:`input`,path:`autocompact.error`,default:``},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},BO=`ne .tmux.pane ""`;function VO(e,t,n){let r=new Set,i=e=>{for(let t of eb(e??``,n).keys())r.add(t)};for(let t of Object.values(e.segments))i(t.template),i(t.bg),i(t.fg),i(t.when);for(let e of t)for(let t of Zh(e))i(t.when),t.kind===`segment`&&(i(t.lead),i(t.trail));for(let t of Object.values(e.variables))t.kind===`template`&&i(t.template),t.kind===`state`&&r.add(mO);for(let t of Object.values(e.actions)){r.add(mO),`copy`in t&&i(t.copy),`open`in t&&i(t.open);let e=`set`in t?q_.get(t.set):void 0,n=`persist`in t?K_.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function HO(e,t,n){let r=cb({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of VO(e,t,n.helpers)){if(sb(a,r))continue;let e=zO[a];if(e===void 0)throw Error(`synthesized chrome reads ".${a}", which it does not declare and PAYLOAD_INPUTS does not supply`);i[a]=e}return i}function UO(e){return e.replace(/[^A-Za-z0-9]+/g,`_`)}const WO=`groups.`,GO=`menus.`,KO=`edit.`,X=`candybar.`,qO=[WO,GO,KO,X];function JO(e){return qO.some(t=>e.startsWith(t))}function YO(e){let t=UO(e);return qO.find(e=>t.startsWith(UO(e)))}function XO(e,t,n,r){for(let i of[`variables`,`actions`,`segments`])for(let a of Object.keys(t[i]??{}))a.startsWith(n)&&e.issues.push({path:`${i}.${a}`,message:`"${a}" is in the reserved "${n}" namespace (synthesized by ${r}) — rename it`,line:K(e.source,[`root`])})}function ZO(e){return e}function QO(e,t,n){return n===void 0?GO+UO(e)+`.`+UO(t):$O(n)}function $O(e){return GO+UO(e)}function ek(e,t){return e+`.`+t}function tk(e){return e+`.page`}const nk=[`closeOnPick`,`paged`,`key`,`distribution`],rk=e=>nk.includes(e),ik=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${um.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function ak(e){for(let t of Object.keys(e))if(!rk(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${ik}`);let t=(t,n)=>{let r=e[t];if(r===void 0)return n;if(typeof r!=`boolean`)throw Error(`{{ menu }} option "${t}" must be a boolean, got ${JSON.stringify(r)} (e.g. (dict "${t}" ${String(!n)}))`);return r},n=e.key;if(n!==void 0&&typeof n!=`string`)throw Error(`{{ menu }} option "key" must be a string naming the accordion group, got ${JSON.stringify(n)}`);if(n===``)throw Error(`{{ menu }} has an empty accordion key — a shared key must be a non-empty name (or omit "key" for an independent menu)`);let r=e.distribution;if(r!==void 0&&!dm(r))throw Error(`{{ menu }} option "distribution" must be one of: ${um.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:pm(r)}}const ok=e=>`from`in e?e.from:e.themes;function sk(e,t,n){return e===`bool`?Uh(t)!==null:`min`in e?Wh(t,e)!==null:zy(ok(e),n).members.includes(t)}function ck(e,t){if(e===`bool`)return Vh.join(` or `);if(!(`min`in e)){let n=ok(e),{members:r}=zy(n,t),i=r.map(e=>JSON.stringify(e));if(r.length<=8)return`one of ${i.join(`, `)}`;let a=typeof n==`string`?` "${n}"`:``;return`one of the ${r.length}${a} names, such as ${i.slice(0,3).join(`, `)}`}return`an integer from ${e.min} to ${e.max}`}function lk(e){return{label:e.label,domain:uk(e.domain)}}function uk(e){return e===`theme`?{themes:Iy}:e===`bool`||`min`in e?e:{from:e}}function dk(e,t,n,r,i){let a=Mr(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...Vh]}},variables:{}};if(`from`in o)return fk(t,r,i,o.from,e=>({template:`{{ "${a}" }} {{ carousel "${e.apply}" 0 "${e.open}" }}`,rows:[`{{ picker "${e.apply}" "${e.page}" false true true }}`]}));if(`themes`in o)return fk(t,r,i,o.themes,e=>({template:`{{ action "${e.open}" "${a}" .${n} }} {{ action "${e.open}" (swatch "${e.apply}") }}`,rows:[`{{ swatches "${e.apply}" "${e.page}" }}`,`{{ themePreview "${e.apply}" }}`]}));let s=e=>({set:t,min:o.min,max:o.max,by:e});return{kind:`inline`,template:`{{ action "${r}.down" "◀" }} {{ "${a}" }} {{ .${n} }} {{ action "${r}.up" "▶" }}`,actions:{[`${r}.down`]:s(-o.step),[`${r}.up`]:s(o.step)},variables:{}}}function fk(e,t,n,r,i){let a={variable:n,key:n,member:t},o=ek(n,t),s=`${t}.open`,c=tk(n),l=`${c}.current`,{template:u,rows:d}=i({apply:t,open:s,page:c});return{kind:`picker`,template:u,actions:{[t]:{set:e,from:r},[o]:Br(n,t),[c]:{set:c,int:!0},[l]:{set:c,to:`-1`},[s]:{do:[o,l]}},variables:{[n]:zr(n,Or),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,rows:d}}}const pk=Object.fromEntries(Object.entries(A_).map(([e,t])=>[e,t.spec]));function mk(e){return A_[e].domain}function hk(e,t){return{required:!1,json:{not:{},description:`not allowed here — ${e}`},parse:(e,n,r,i)=>{i[r]!==void 0&&e.issues.push({path:`${n}.${r}`,message:t(`${n}.${r}`),line:K(e.source,[...n.split(`.`),r])})}}}function gk(e){return hk(`${e} cannot select a preset`,t=>`${t}: ${e} cannot select a preset. Which preset is active is resolved once, as session pick over globals.preset over "default"; a fragment naming another would be a second authority over that. Set the default arrangement in the top-level globals.preset instead.`)}function _k(e){return hk(`${e} cannot change the settings menu glyph`,t=>`${t}: ${e} cannot change the settings menu glyph — one menu is shared by every preset. Set it in the top-level globals.menuGlyph instead.`)}function vk(e,t,n){return{...e,json:{...e.json,not:{pattern:`\\{\\{`}},parse:(r,i,a,o)=>{let s=o[a];if(typeof s==`string`&&_h(s)){r.issues.push({path:`${i}.${a}`,message:`${i}.${a}: a rule is not allowed here — ${t} ${n}, so it names a value. Write the rule in globals.${a} (or a preset's globals.${a}) instead.`,line:K(r.source,[...i.split(`.`),a])});return}return e.parse(r,i,a,o)}}}const yk={default_bg:"nothing reads it — a segment with no `bg:` wears the decoration tint of its place in the bar. Delete the key, and author `bg:` on the segments that need a fixed colour.",default_fg:"nothing reads it — a segment with no `fg:` wears text chosen for contrast against its background. Delete the key, and author `fg:` on the segments that need a fixed colour.",default_truncate_marker:'nothing reads it — a segment clipped to its `width:` always ends in "…". Delete the key.',look:`it was renamed "style" — write the same name as style: "<name>"`,progression:`it was renamed "variation", and its values with it: accent (was secondary-accent), duo (was primary-secondary), mono (was primary)`,charset:"the bar always draws Nerd Font glyphs. Delete the key; `cc-candybar doctor` names what your terminal's font is missing."},bk={noun:`globals key`,fields:pk,removed:yk},xk={preset:gk(`a preset`),menuGlyph:_k(`a preset`)},Sk={noun:`preset globals key`,fields:{...pk,...xk},removed:yk};function Ck(e){return Nk(e)&&!(e in xk)}const wk=`is decided later than any rule could be settled`,Tk={noun:`editGlobals key`,removed:yk,fields:{...pk,preset:gk(`the editGlobals fragment`),menuGlyph:_k(`the editGlobals fragment`),palette:vk(pk.palette,`the editGlobals fragment`,wk),style:vk(pk.style,`the editGlobals fragment`,wk),effect:vk(pk.effect,`the editGlobals fragment`,wk)}},Ek={noun:`theme default key`,fields:{...Object.fromEntries(P_.map(e=>[e,pk[e]])),style:vk(pk.style,`a theme's default`,`is the look that theme wears by name`)}};function Dk(e,t){if(!Mg(t))return e.issues.push({path:`themeDefaults`,message:`themeDefaults must be an object mapping theme names to { shade, variation, style }, got ${Ng(t)}`,line:K(e.source,[`themeDefaults`])}),{};let n={};for(let[r,i]of Object.entries(t)){let t=`themeDefaults.${r}`;if(!e.allowedPalettes.has(r)){e.issues.push({path:t,message:`${t}: "${r}" is not an installed theme${ch(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:K(e.source,[`themeDefaults`,r])});continue}let a=Pg(e,Ek,t,i);a!==null&&(n[r]=a)}return n}function Ok(e,t,n){return n===void 0?{}:Pg(e,bk,t,n)??{}}function kk(e,t,n){return Pg(e,Sk,t,n)??{}}function Ak(){return t_(Sk)}function jk(e,t,n){return Pg(e,Tk,t,n)??{}}const Mk=new Set(Object.keys(pk));function Nk(e){return Mk.has(e)}function Pk(e){return Object.hasOwn(yk,e)?yk[e]:void 0}function Fk(){return[...Mk]}const Ik=new Map(Object.entries(A_).flatMap(([e,t])=>`floor`in t&&typeof t.floor==`number`?[[e,t.floor]]:[]));function Lk(e){let t=new Map;for(let[n,r]of Ik){let i=e[n];t.set(n,typeof i==`number`?i:r)}return t}const Rk=/^segments\.([^.]+)\.palette$/,zk=/^presets\.(.+)\.root$/,Bk=/^presets\.(.+)\.globals\.([^.]+)$/,Vk=/^themeDefaults\.(.+)\.([^.]+)$/;function Hk(e){return`presets.${e}.root`}function Uk(e,t){return`themeDefaults.${e}.${t}`}const Wk=e=>P_.includes(e);function Gk(e,t){return`presets.${e}.globals.${t}`}function Kk(e){if(Nk(e))return{scope:`globals`,field:e};let t=Rk.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=Bk.exec(e);if(n&&Ck(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=Vk.exec(e);if(r&&Wk(r[2]))return{scope:`theme-default`,theme:r[1],field:r[2]};let i=zk.exec(e);return i?{scope:`preset-root`,preset:i[1]}:null}function qk(e){switch(e.scope){case`globals`:return[`globals`,e.field];case`preset-globals`:return[`presets`,e.preset,`globals`,e.field];case`segment-palette`:return[`segments`,e.segment,`palette`];case`theme-default`:return[`themeDefaults`,e.theme,e.field]}}const Jk=[`location`,`git`,`model-context`,`cost-limits`,`activity`,`session-tools`],Yk=[...Jk,`other`],Xk={location:`location`,git:`git`,"model-context":`model & context`,"cost-limits":`cost & limits`,activity:`activity`,"session-tools":`session tools`,other:`other`},Zk=mS({fromString:e=>e}),Qk=`edit.mode`,$k=`edit.configure`,eA=`edit.toggle`,tA=`edit.unconfigure`,nA=[eA,tA],rA=`arrange`,iA=`${KO}draft.`;function aA(e,t){return`${e}:${t}`}const oA={variable:Qk,key:Qk,member:rA},sA=Pr(oA);function cA(e){try{return Zk.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function lA(e){if(Object.values(e.actions??{}).some(e=>`do`in e&&e.do.includes(`edit.toggle`)))return!0;for(let t of Object.values(e.segments??{}))for(let e of[t.template,t.bg,t.fg])if(typeof e==`string`&&cA(e))return!0;return!1}function uA(e,t){if(XO(e,t,KO,`edit mode`),!lA(t))return;let{variables:n,actions:r}=dA();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function dA(){return{variables:{[Qk]:zr(Qk,Or),[$k]:zr($k,Or)},actions:{[eA]:Br(Qk,rA),[tA]:{set:$k,to:Or}}}}const fA=`open`;function pA(e,t,n,r){let i={variable:e,key:e,member:fA};return r.variables[e]=zr(e,Or),r.actions[e]=Br(e,fA),r.segments[e]={template:Ir(e,`(?)`,`✕`),...mA(n)},Nr(e,i,{kind:`container`,direction:`horizontal`,children:t.map((t,n)=>{let i=`${e}.${n}`;return r.segments[i]={template:t},{kind:`segment`,name:i}})},`drop`)}function mA(e){let[t,...n]=e;return t===void 0?{}:{when:Pr(t,...n)}}const hA=`none`;function gA(e){return mc(e,`background`)}var _A=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function vA(e,t,n,r,i){let{palette:a,tint:o,text:s}=e,c=yA(n,i),l=c!==hA,u=l?c===void 0?o:bA(a,c,`bg`):gA(a);e.bg=u;let d=yA(r,i),f=d===void 0?l?(e=>e.hex===o.hex?s:Fm(a,e,t))(u):void 0:bA(a,d,`fg`);return new H({...l&&{bgcolor:B.fromRgba(u)},...f!==void 0&&{color:B.fromRgba(f)}})}function yA(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function bA(e,t,n){try{return mc(e,t)}catch(e){throw e instanceof pc?new _A(t,n,e.message):e}}const xA=`🔧`,SA={help:[`-h`,`--help`],version:[`-V`,`--version`]},CA=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],wA=Object.fromEntries(CA.map(e=>[e.member,e.label])),TA={gear:{beside:`theme`,trigger:`⚙`},toggles:{beside:`updateNotice`,trigger:`🧪 toggles`}},EA=Object.keys(TA),DA=J_(e=>V_[e].place),OA=e=>Object.hasOwn(TA,e),kA=e=>OA(e)?kA(DA[TA[e].beside]):e,AA=e=>OA(e)?`${AA(DA[TA[e].beside])} › ${TA[e].trigger}`:e===`door`?`first line`:wA[e],jA=e=>AA(DA[e]),MA=e=>`${a_[e].label} is off — turn it on in the settings menu's ${jA(a_[e].setting)}, or set globals.${a_[e].setting}: true`,NA=[...new Set(Object.values(a_).map(e=>jA(e.setting)))].join(` or `),PA=[`✚ inserts`,`✖ removes`,`${xA} configures`,`↺ resets layout`],FA={band:[`animates the bar in the band above the prompt, through a Claude Code mod`,`on: installs the candybar-band mod from this checkout and types /reload-plugins`],statusline:[`animates the statusline itself, through the attach launcher shipped with cc-candybar`,`on: exits this Claude Code and starts it again under that launcher, on this session`],pane:[`animates the bar in a tmux pane under this session's`,`on: opens that pane · off: closes it`]},IA=`
77
77
  cc-candybar - Beautiful powerline statusline for Claude Code
78
78
 
79
79
  Usage: cc-candybar [options]
@@ -175,8 +175,8 @@ Config tooling:
175
175
  `,LA=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`,RA={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function zA(e){let t=e[RA.socket]??``,n=e[RA.pane]??``;if(t===``||n===``)return null;let r=e[RA.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const BA=[`moves`,`can-move`,`still`];function VA(e,t,n){return t<n+60?{kind:`unseen`,over:Math.max(0,Math.floor(t-n))}:{kind:`seen`,seconds:e.filter(e=>e>=n&&e<n+60).length}}const HA=e=>e.kind===`seen`&&e.seconds>=45,UA=e=>e.kind===`unseen`?[1,e.over]:[HA(e)?2:0,e.seconds],WA=(e,t)=>{let[n,r]=[UA(e),UA(t)];return n[0]-r[0]||n[1]-r[1]},GA=e=>e.reduce((e,t)=>WA(t.redraws,e.redraws)<0?t:e);function KA(e){let t=e.context_window?.current_usage;return t===null?`no`:t===void 0?`unknown`:`yes`}const qA=[`carried`,`missing`,`unanswered`];function JA(e){let t=e.rate_limits;return t?.five_hour!=null||t?.seven_day!=null?`carried`:KA(e)===`no`?`unanswered`:`missing`}function YA(e){return{path:e.transcript_path,answered:KA(e)===`yes`}}const XA=[...BA,`failed`,`drawing`],ZA=[`statusline`,`frames`],QA=e=>e?.kind===`frames`?`frames`:`statusline`;var $A=class{seen=new Map;see(e,t,n,r){let i=QA(t.client),a=JSON.stringify([e,i]),o=this.seen.get(a);if(o!==void 0&&o.order>r)return;let s=Math.floor(n),c=new Set([...o?.redrawn??[],s].filter(e=>e>s-60));this.seen.delete(a),this.seen.set(a,{sessionId:e,said:{...t,role:i},at:n,order:r,since:o?.since??n,redrawn:c}),this.seen.size>64&&this.seen.delete(this.seen.keys().next().value)}list(e){return[...this.seen.values()].map(({sessionId:t,said:n,at:r,since:i,redrawn:a})=>({...n,sessionId:t,ago:e-r,since:e-i,redrawn:[...a].map(t=>Math.floor(e)-t)}))}ofSession(e,t){return this.list(t).filter(t=>t.sessionId===e)}};const ej={kitty:{label:`kitty`,xtversion:`kitty`,program:null,programVersion:!0,term:`xterm-kitty`,links:{since:`0.19.0`},glyphs:{kind:`bundled`,since:`0.36.0`}},wezterm:{label:`WezTerm`,xtversion:`WezTerm`,program:`WezTerm`,programVersion:!0,term:`wezterm`,links:{since:null},glyphs:{kind:`bundled`,since:`20230712`}},ghostty:{label:`Ghostty`,xtversion:`ghostty`,program:`ghostty`,programVersion:!0,term:`xterm-ghostty`,links:{since:null},glyphs:{kind:`bundled`,since:null}},iterm2:{label:`iTerm2`,xtversion:`iTerm2`,program:`iTerm.app`,programVersion:!0,term:null,links:{since:`3.1`},glyphs:{kind:`configured`}},alacritty:{label:`Alacritty`,xtversion:`alacritty`,program:null,programVersion:!0,term:`alacritty`,links:{since:`0.11.0`},glyphs:{kind:`configured`}},"apple-terminal":{label:`Terminal`,xtversion:null,program:`Apple_Terminal`,programVersion:!0,term:null,links:null,glyphs:{kind:`unread`}},vscode:{label:`VS Code`,xtversion:null,program:`vscode`,programVersion:!1,term:null,links:{since:`1.72`},glyphs:{kind:`unread`}}},tj=e=>ej[e];function nj(e){return tj(e).glyphs.kind===`bundled`}function rj(e){return tj(e).glyphs.kind===`configured`}const ij=e=>tj(e).label,aj=[{since:`3.5.0`,from:57504,to:57507},{since:`3.5.0`,from:57520,to:57554},{since:`3.5.0`,from:57556,to:57556},{since:`3.5.6`,from:57558,to:57559}];function oj(e,t){let n=t.codePointAt(0);return aj.some(({since:t,from:r,to:i})=>r<=n&&n<=i&&e!==null&&lj(e,t)===!0)}const sj=Object.keys(ej);function cj(e){let t=/^\d+(?:\.\d+)*/.exec(e);return t===null?null:t[0].split(`.`).map(Number)}function lj(e,t){let n=cj(e),r=cj(t);if(n===null)return null;for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]??0,i=r[e]??0;if(t!==i)return t>i}return!0}function uj(e){for(let t of sj){let n=tj(t).xtversion;if(n!==null&&e.toLowerCase().startsWith(n.toLowerCase())){let r=e.slice(n.length).replace(/^[\s(]+/,``);return{name:t,version:/^[^\s)]+/.exec(r)?.[0]??null}}}return null}function dj(e){let t=sj.find(t=>tj(t).term===e);return t===void 0?null:{name:t,version:null}}function fj(e){let t=uj(e.termtype)??dj(e.termname);if(t!==null)return{kind:`known`,terminal:t};let n=/^[^\s(]*/.exec(e.termtype)[0];return n===``?{kind:`unnamed`,term:e.termname}:{kind:`unknown`,called:n}}function pj(e){let t=e.TERM_PROGRAM,n=sj.find(e=>tj(e).program===t),r=n===void 0?dj(e.TERM):{name:n,version:tj(n).programVersion?e.TERM_PROGRAM_VERSION??null:null};return r===null?t===void 0||t===`tmux`?{kind:`unnamed`,term:e.TERM??``}:{kind:`unknown`,called:t}:{kind:`known`,terminal:r}}function mj(e){switch(e.kind){case`known`:return ij(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||null}}function hj(e){switch(e.kind){case`known`:return ij(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||`this terminal`}}function gj({name:e,version:t}){let n=tj(e).links;if(n===null)return{kind:`none`};if(n.since===null)return{kind:`draws`};if(t===null)return{kind:`unsaid`,since:n.since};let r=lj(t,n.since);return r===null?{kind:`unsaid`,since:n.since}:r?{kind:`draws`}:{kind:`older`,since:n.since,version:t}}const _j=sj.filter(e=>tj(e).links!==null).map(ij).join(`, `);function vj(e){if(e.kind===`failed`)return{kind:`unread`,reason:e.reason};let t=e.value.flatMap(({scope:e,path:t,settings:n})=>`statusLine`in n?[{from:{scope:e,path:t},line:n.statusLine}]:[]),n=t[0];if(n===void 0)return{kind:`absent`,read:e.value.map(e=>e.path)};if(!ha(n.line))return{kind:`not-an-object`,value:n.line,from:n.from};for(let{from:e,line:r}of t){if(e.scope!==n.from.scope||!ha(r))break;if(`refreshInterval`in r)return{kind:`present`,refreshInterval:r.refreshInterval,from:e}}return{kind:`present`,refreshInterval:void 0,from:n.from}}function yj(e,t){if(e.kind===`failed`)return e;let n=e.value.find(e=>Object.hasOwn(e.env,t));return{kind:`ok`,value:n===void 0?{kind:`unset`}:{kind:`set`,value:n.env[t],from:{scope:n.scope,path:n.path}}}}const bj=[`managed`,`project`],xj=e=>!bj.includes(e.scope),Sj={managed:()=>null,"project-local":e=>({scope:`project-local`,path:e}),project:(e,t)=>({scope:`project-local`,path:fa(t.projectDir)}),user:e=>({scope:`user`,path:e})},Cj=[`drawn`,`boxes`],wj=1024*1024,Tj=e=>e.kind===`session`?`session ${e.sessionId}'s statusline client`:`this command's terminal`;function Ej(e){switch(e.kind){case`claude-settings`:return`${e.kind} ${e.path.join(`.`)}=${JSON.stringify(e.value)} file=${JSON.stringify(e.file.path)} scope=${e.file.scope}`;case`post-mortems-read`:return`${e.kind} through=${e.through}`}}function Dj(e){let[t,...n]=e;return t===void 0?{ok:!0}:{ok:!1,reason:t,more:n}}const Oj=RA.truecolor;function kj(e,t){switch(e.kind){case`unreported`:return{ok:!1,reason:"the client reported no tmux facts — re-run `cc-candybar install` to stage a current client"};case`outside`:return{ok:!0};case`inside`:return e.client.kind===`failed`?{ok:!1,reason:`tmux could not be asked: ${e.client.reason}`}:e.client.value===null?{ok:!0}:t(e.client.value,e.hint)}}const Aj={name:`tmuxTruecolor`,label:`tmux truecolor`,takesMark:!1,probe:({tmux:e,claudeSettings:{origin:t}})=>kj(e,(e,n)=>{if(!e.features.includes(`RGB`)||n.truecolor!==null)return{ok:!0};let r=yj(t.sources,Oj);if(r.kind===`failed`)return{ok:!1,reason:r.reason};let i=r.value;if(i.kind===`set`&&typeof i.value==`string`&&i.value!==``)return{ok:!1,reason:`${Oj} is set in ${i.from.path} — restart Claude Code to apply`};let a=`Claude Code renders the bar in 256 colours inside tmux`,o=e=>({ok:!1,reason:a,fix:{kind:`claude-settings`,file:e,path:[`env`,Oj],value:`1`}});if(i.kind===`unset`)return o({scope:`user`,path:t.at.userFile});let s=Sj[i.from.scope](i.from.path,t.at);return s===null?{ok:!1,reason:`${a} — the value that counts is in managed settings, ${i.from.path}: set ${Oj} to "1" there`}:o(s)})},jj={name:`utf8`,label:`UTF-8`,takesMark:!1,probe:({tmux:e})=>kj(e,e=>e.utf8?{ok:!0}:{ok:!1,reason:"tmux draws this terminal without UTF-8, so every glyph on the bar arrives as `_` — attach with `tmux -u`, or set a UTF-8 LC_ALL/LC_CTYPE/LANG in the shell that runs tmux"})},Mj={name:`termWidth`,label:`terminal width`,takesMark:!1,probe:({width:e})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.columns===null?{ok:!1,reason:`${Tj(e.value.of)} measured no width (no COLUMNS, and no terminal to ask — or the daemon refused the width sent, which the bar's red strip names), so the bar is laid out as if the terminal were 120 columns wide`}:{ok:!0,note:`${e.value.columns} columns, as ${Tj(e.value.of)} measured`}},Nj={variable:`is never read`,action:`is never clicked`,helper:`is never called`,segment:`is in no preset`},Pj={name:`config`,label:`config`,takesMark:!1,probe:({config:e})=>{switch(e.kind){case`failed`:{let[t=`the config failed to load`,...n]=[...e.error.split(`
176
176
  `).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return Dj([...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${Nj[e]}`)])}}},Fj="re-run `cc-candybar install`";function Ij(e){if(e.kind===`failed`)return[`Launch Services could not be asked which app opens cc-candybar:// — ${e.reason}`];if(e.value===null)return[`no app is registered for cc-candybar:// — ${Fj}`];let{app:t,missing:n}=e.value;return n.kind===`failed`?[`${t} opens cc-candybar://, but ${n.reason} — ${Fj}`]:n.value.map(e=>`${e} is missing, and ${t} runs it — ${Fj}`)}const Lj={name:`urlHandler`,label:`URL handler`,takesMark:!1,probe:({urlHandler:e})=>{switch(e.kind){case`unsupported`:return{ok:!0};case`unprobed`:return{ok:!1,reason:e.reason};case`arrived`:return e.handler===e.bar?{ok:!0}:{ok:!1,reason:e.handler===null?`the URL handler does not report its version, so it is older than the bar (${e.bar}) — ${Fj}`:`the URL handler runs cc-candybar ${e.handler}; the bar runs ${e.bar} — ${Fj}`};case`lost`:return Dj([...Ij(e.opener),e.unopened===null?`a cc-candybar:// link was opened and did not arrive at the daemon`:`a cc-candybar:// link could not be opened — ${e.unopened}`])}}};function Rj({bundle:e,checkout:t},n){return{bundle:n.bundle.kind===`failed`?{kind:`unresolved`,reason:n.bundle.reason}:n.bundle.value===e?{kind:`same`}:{kind:`other`,path:n.bundle.value},source:n.client!==`native`||t===null?{kind:`uncompared`}:t.rustSource.kind===`failed`?{kind:`unreadable`,root:t.root,reason:t.rustSource.reason}:n.source===null?{kind:`unstamped`}:n.source===t.rustSource.value?{kind:`same`}:{kind:`other`,root:t.root}}}function zj(e,t){return t===`frames`?`run \`node ${e.bundle} frames --lane <band|statusline|pane>\``:e.checkout===null?Fj:`run \`just install-rust\` and point the statusLine command at ${e.checkout.root}/bin/cc-candybar-native`}function Bj(e,t,n){let{checkout:r}=e;if(n.kind===`unreported`)return[`the bar is drawn by a statusline client too old to say what it is — ${zj(e,`native`)}`];let{bundle:i,source:a}=Rj(e,n);switch(i.kind){case`unresolved`:return[`the statusline client's bundle cannot be resolved: ${i.reason}`];case`other`:return[`the statusline client runs ${i.path}, not the daemon's ${e.bundle} — ${zj(e,n.client)}`];case`same`:break}if(n.client===`node`&&(t||r!==null))return[`the bar is drawn by the Node fallback, which starts node on every render — ${zj(e,`native`)}`];switch(a.kind){case`uncompared`:case`same`:return[];case`unreadable`:return[`${a.root}/rust-client could not be read: ${a.reason}`];case`unstamped`:return["the native client carries no source stamp, so which source it was built from is unknown — run `just install-rust`"];case`other`:return[`the native client was built from other source than ${a.root}/rust-client holds — run \`just install-rust\``]}}const Vj=e=>{let t=`restarted since the bar was drawn, or has served 64 newer sessions`;return e.kind===`clicked`?`this daemon holds no render of this bar (it ${t})`:`this daemon holds no render of session ${e.sessionId}'s bar (its statusLine does not run cc-candybar — a \`claude -p\` session draws none — or the daemon ${t}; unset CLAUDE_CODE_SESSION_ID to judge every bar drawn recently)`},Hj={name:`install`,label:`install`,takesMark:!1,probe:({install:e,sighted:t})=>{if(e.kind===`failed`)return{ok:!1,reason:`the daemon could not be asked which clients draw the bar: ${e.reason}`};let{daemon:n,nativeShipped:r,clients:i}=e.value;return i.length===0?{ok:!1,reason:t.kind===`recent`?`no statusline client has drawn a bar for this daemon in the last ${300/60} minutes — run the doctor again once the bar has redrawn; if it never does, the statusLine command does not run cc-candybar`:`${Vj(t)}, so which client draws it is unknown — run the doctor again once the bar has redrawn`}:Dj([...new Set(i.flatMap(e=>Bj(n,r,e)))])}};function Uj({postMortems:e},t){return e.kind===`ok`&&t.kind===`ok`?e.value.filter(e=>t.value.through===null||vn(e.identity,t.value.through)):[]}function Wj(e,t){return e.kind===`failed`?t:t.filter(t=>t.pid!==e.value.pid)}const Gj={name:`daemon`,label:`daemon`,takesMark:!1,probe:({daemon:{serving:e,processes:t,read:n}})=>{let r=t.kind===`failed`?[`the process table could not be read: ${t.reason}`]:[],i=t.kind===`ok`?Wj(e,t.value):[];if(e.kind===`failed`){let t=i.length>0?` — daemon ${i.map(e=>e.pid).join(`, `)} running`:``;return Dj([`${e.reason}${t}`,...r])}let{pid:a,memory:o,limit:s,postMortems:c}=e.value,l=Uj(e.value,n),u=Dj([...l.map(e=>`the daemon ran out of memory and restarted (${e.identity}) — post-mortem: ${Object.values(e.artifacts).join(`, `)}`),...c.kind===`failed`?[`the daemon's post-mortems could not be listed: ${c.reason}`]:[],...n.kind===`failed`&&!(c.kind===`ok`&&c.value.length===0)?[`which post-mortems were read could not be read: ${n.reason}`]:[],...r,...i.map(e=>`daemon ${e.pid} (started ${e.started}, rss ${hn(e.rss)} MB${e.ppid===1?``:`, child of ${e.ppid}`}) runs beside the one serving the bar (${a}) — \`kill ${e.pid}\``),...o.kind===`measured`&&o.charge.kind===`stand-in`?[`the daemon could not read what macOS charges it (${o.charge.unread}), so its memory limit judges RSS, which counts pages macOS has reclaimed`]:[],...o.kind===`measured`&&yn(o.charge.bytes,s)?[`the daemon holds ${Cn(o.charge)} of its ${hn(s)} MB limit — at the limit it records a post-mortem and restarts`]:[]]);if(u.ok&&o.kind===`unmeasured`)return{ok:!0,note:`the daemon has not measured its memory yet`};let d=l[0];return u.ok||d===void 0?u:{...u,fix:{kind:`post-mortems-read`,through:d.identity}}}},Kj=`click 🩺 doctor in the bar's settings menu: if it runs, links work`;function qj(e,t){let n=mj(e);return t.kind===`ok`&&n!==null&&t.value.includes(n)?{kind:`draws`}:e.kind===`known`?gj(e.terminal):{kind:`unknown`}}function Jj({identified:e,tmuxClient:t},n){let r=hj(e),i=qj(e,n),a=mj(e)===null?Kj:`${Kj}, and the doctor remembers it for this terminal`,o=(()=>{switch(i.kind){case`draws`:return[];case`none`:return[`${r} draws no links (OSC 8), so nothing on the bar can be clicked — run Claude Code in a terminal that draws them: ${_j}`];case`older`:return[`${r} ${i.version} draws no links (OSC 8 came in ${i.since}) — update ${r}`];case`unsaid`:return[`${r} draws links (OSC 8) since ${i.since}, and did not say which release this is — ${a}`];case`unknown`:return[`the doctor does not know whether ${r} draws links (OSC 8) — ${a}`]}})(),s=n.kind===`failed`&&i.kind!==`draws`?[`the terminals a doctor click came back from could not be read: ${n.reason}`]:[],c=i.kind===`none`||t===null||t.features.includes(`hyperlinks`)?[]:[`tmux does not pass links through to ${r} — add \`set -as terminal-features ",${t.termname}:hyperlinks"\` to tmux.conf, then detach and reattach (tmux 3.4 or later)`];return[...o,...s,...c]}const Yj={name:`links`,label:`links`,takesMark:!1,probe:({sighted:e,terminal:t,clicked:n})=>{if(e.kind===`clicked`)return{ok:!0};switch(t.kind){case`unreported`:return{ok:!1,reason:"the client reported no terminal — re-run `cc-candybar install` to stage a current client"};case`unasked`:return{ok:!1,reason:`tmux could not be asked which terminal is attached: ${t.reason}`};case`seen`:return Dj(Jj(t,n))}}},Xj=e=>e.filter(e=>e.role===`statusline`),Zj={name:`effectRefresh`,label:`effect refresh`,takesMark:!1,probe:({frames:e,claudeSettings:{origin:t,elsewhere:n},sighted:r})=>{if(e.kind===`failed`)return{ok:!1,reason:e.reason};let i=[t,...n],[a,...o]=i.flatMap(({sources:e,bars:t})=>{let[n,...r]=Xj(t).filter(e=>e.frame===`moves`||e.frame===`can-move`);if(n===void 0)return[];let i=GA([n,...r]);return[{redraws:i.redraws,verdict:Qj(e,i)}]}).sort((e,t)=>WA(e.redraws,t.redraws));if(a===void 0){let e=i.flatMap(e=>e.bars),t=Xj(e);return t.some(e=>e.frame===`still`)?{ok:!0}:{ok:!1,reason:`${t.length>0?t.some(e=>e.frame===`drawing`)?`the bar's latest render has not finished`:`the bar's recent renders failed`:e.length>0?"only a `cc-candybar frames` display has drawn this bar, not Claude Code's statusline":r.kind===`recent`?`no session has drawn a statusline for this daemon in the last ${300/60} minutes`:Vj(r)}, so whether it moves is unknown — run the doctor again once the bar has redrawn`}}let[s,...c]=[a,...o].flatMap(({verdict:e})=>e.ok?[]:[e]);if(s===void 0)return a.verdict;let l=[...new Set(c.map(e=>e.reason))].filter(e=>e!==s.reason);return l.length===0?s:{...s,more:l}}};function Qj(e,t){let n=t.frame===`moves`?`the bar moves (an effect, a fade, or an animated segment)`:`the bar can start moving (a globals.effect rule, placements that fade in and out, or a placement with an effect of its own that is not drawn now)`,r=vj(e);if(r.kind===`present`&&r.refreshInterval!==1){let{from:e,refreshInterval:t}=r,i=t===void 0?`its statusLine sets no refreshInterval, so Claude Code redraws it only on events`:typeof t==`number`&&t>1?`its statusLine redraws it only every ${t} s`:`its statusLine.refreshInterval is ${JSON.stringify(t)}, not a number of seconds Claude Code accepts (its minimum is 1)`;return xj(e)?{ok:!1,reason:`${n}, but ${i} (statusLine from ${e.path})`,fix:{kind:`claude-settings`,file:e,path:[`statusLine`,`refreshInterval`],value:1}}:{ok:!1,reason:`${n}, but ${i} — its statusLine is in ${e.scope===`managed`?`managed settings`:`the project's shared settings`}, ${e.path}: set "refreshInterval": 1 there`}}let{redraws:i}=t;if(i.kind===`unseen`)return{ok:!1,reason:`${n}, and this daemon has watched Claude Code redraw it for only ${i.over} of the 60 seconds its redraw rate is judged over, so whether it is redrawn every second is unknown — run the doctor again once the bar has been on screen for a minute`};if(HA(i))return{ok:!0,note:`Claude Code redrew the bar in ${i.seconds} of the last 60 seconds`};let a=`${n}, but Claude Code redrew it in only ${i.seconds} of the last 60 seconds`,o=`a statusLine from --settings, MDM or server-managed settings, which the doctor cannot read, runs the bar; set "refreshInterval": 1 beside its command there`;switch(r.kind){case`unread`:return{ok:!1,reason:`${a}, and Claude Code's settings could not be read: ${r.reason}`};case`absent`:return{ok:!1,reason:`${a}, and no settings file Claude Code reads here sets a statusLine (read: ${r.read.join(`, `)||`none`}) — ${o}`};case`not-an-object`:return{ok:!1,reason:`${a}, and ${r.from.path} sets statusLine to ${JSON.stringify(r.value)}, not a statusLine object — ${r.from.scope===`user`?"re-run `cc-candybar install` to write one":`replace it there with the statusLine object that runs cc-candybar`}`};case`present`:return{ok:!1,reason:`${a}, though ${r.from.path} sets statusLine.refreshInterval to 1 — set within the last minute, it shows once Claude Code has redrawn the bar for one (restart Claude Code if it does not); otherwise ${o}`}}}const $j=e=>[...e].map(e=>`U+${e.codePointAt(0).toString(16).toUpperCase()}`).join(` `);function eM(e){switch(e.kind){case`unreported`:case`unasked`:return`this terminal`;case`unknown`:case`unnamed`:return hj(e);case`bundling`:case`unread`:case`configured`:return[ij(e.name),e.version].filter(e=>e!==null).join(` `)}}function tM(e){switch(e.kind){case`unreported`:case`unasked`:return null;case`unknown`:case`unnamed`:return mj(e);case`bundling`:case`unread`:return ij(e.name);case`configured`:{let t=ij(e.name);return e.font.kind===`ok`?`${t} with ${e.font.value.font} (${e.font.value.from})`:`${t}, its font unread: ${e.font.reason}`}}}function nM(e){let t=tM(e.terminal);return t===null?void 0:{glyphs:e.glyphs,id:`${t}|${$j(e.glyphs)}`}}const rM={name:`nerdFont`,label:`Nerd Font`,takesMark:!0,probe:({nerdFont:e,marks:t})=>{if(e.kind===`none`)return{ok:!0};let n=nM(e),r=e=>t.kind===`failed`&&n!==void 0?{ok:!1,reason:e,more:[`the mark book could not be read: ${t.reason}`]}:{ok:!1,reason:e,...n!==void 0&&{sighting:n}},i=e.terminal,a=eM(i);switch(n===void 0||t.kind===`failed`?null:t.value.nerdFont?.[n.id]??null){case`drawn`:return{ok:!0};case`boxes`:return r(`${a} draws ${$j(e.glyphs)} as boxes — set a Nerd Font as its font`);case null:break}switch(i.kind){case`unreported`:return r("the client reported no terminal — re-run `cc-candybar install` to stage a current client");case`unasked`:return r(`tmux could not be asked which terminal is attached: ${i.reason}`);case`unknown`:case`unnamed`:case`unread`:return r(`the doctor cannot read ${a}'s font`);case`bundling`:{let e=ej[i.name].glyphs.since;if(e===null)return{ok:!0};let t=i.version===null?null:lj(i.version,e);if(t===!0)return{ok:!0};let n=ij(i.name);return r(t===null?`${n} ships Nerd Font symbols since ${e}, and did not say which release this is`:`${a} ships no Nerd Font symbols (they came in ${e}) — update ${n}, or set a Nerd Font as its font`)}case`configured`:{if(i.font.kind===`failed`)return r(`the doctor cannot read ${a}'s font: ${i.font.reason}`);let{font:e,from:t,lacks:n}=i.font.value;return n===null?r(`${a} is set to ${e} (${t}), which is not installed — install it or set a Nerd Font`):n.length===0?{ok:!0}:r(`${a} draws with ${e} (${t}), which has no ${$j(n)} — set a Nerd Font as its font`)}}}};function iM(e){return e.join(`, `)}function aM(e){return`or set missingData: "ignore" on ${iM(e)}`}function oM(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;if(n.kind===`failed`)return[`${iM(t)}: whether the forge CLI is ready could not be asked: ${n.reason}`];if(n.value===null)return[];let{cli:r,host:i,status:a}=n.value;return a===`ready`?[]:a===`missing`?[`${iM(t)}: ${r} is not installed, so no pull request is ever shown — install it, ${aM(t)}`]:[`${iM(t)}: ${r} is not logged in to ${i} (${a.loggedOut}) — run \`${r} auth login --hostname ${i}\`, ${aM(t)}`]}function sM(e,t){if(e.kind===`unneeded`)return[];let{segments:n,fact:r}=e;return r.kind===`failed`?[`${iM(n)}: ${r.reason}`]:r.value.length===0?[t.kind===`recent`?`${iM(n)}: no session of this Claude Code has drawn a bar for this daemon in the last ${300/60} minutes, so whether it sends rate_limits is unseen — run the doctor again once the bar has redrawn`:`${iM(n)}: ${Vj(t)}, so whether Claude Code sends rate_limits is unseen — run the doctor again once the bar has redrawn`]:r.value.includes(`missing`)&&!r.value.includes(`carried`)?[`${iM(n)}: Claude Code sent no rate_limits — it sends them only to Claude.ai subscription sessions; on any other account, set missingData: "ignore" on ${iM(n)}`]:[]}function cM(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;switch(n.located.kind){case`ok`:return[];case`absent`:return[`${iM(t)}: memento is not installed (or is disabled) for ${n.claudeConfigDir} — install the memento plugin, ${aM(t)}`];case`failed`:return[`${iM(t)}: whether memento is installed could not be read: ${n.located.reason}`]}}const lM={name:`segmentData`,label:`segment data`,takesMark:!1,probe:({data:e,sighted:t})=>Dj([...oM(e.pullRequests),...sM(e.rateLimits,t),...cM(e.memento)])};function uM({path:e,answered:t,read:n}){switch(n.kind){case`absent`:return t?[`the transcript ${e} does not exist, though Claude Code has answered in its session — the bar's session cost, metrics and activity read nothing`]:[];case`failed`:return[`the transcript ${e} cannot be read: ${n.reason}`];case`ok`:{let{lines:t,unparsed:r,whole:i}=n.value;return r===0?[]:[`${r} of the ${t} lines ${i?`in`:`in the last ${wj/1024/1024} MiB of`} the transcript ${e} are not JSON objects — the bar skips them, so what it counts from them is missing`]}}}const dM=[Pj,Hj,Gj,Lj,Yj,Aj,jj,Mj,Zj,rM,lM,{name:`sessionData`,label:`session data`,takesMark:!1,probe:({transcripts:e,sighted:t})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.length===0?{ok:!1,reason:t.kind===`recent`?`no session has drawn a bar for this daemon in the last ${300/60} minutes, so no transcript was named — run the doctor again once the bar has redrawn`:`${Vj(t)}, so which transcript it reads is unknown — run the doctor again once the bar has redrawn`}:Dj(e.value.flatMap(uM))}],fM=dM.filter(e=>e.takesMark);function pM(e){return dM.map(t=>({check:t,verdict:t.probe(e)}))}function mM(e){return dM.find(t=>t.name===e)}const hM=/^[^\s"=\\]+$/,gM=e=>hM.test(e)?e:JSON.stringify(e),_M=`${X}doctor.`;function vM(e){let t=`${_M}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`,sighting:`${t}sighting`}}function yM(e,t){let n=e.kind===`seen`?e.tmuxClient:null,r=e.kind===`seen`?mj(e.identified):null,i=t.kind===`failed`?`unread`:r===null?`-`:t.value.includes(r)?`yes`:`no`;return`tmuxLinks=${n===null?`-`:n.features.includes(`hyperlinks`)?`yes`:`no`} clicked=${i}`}function bM(e,t){let n=e.kind===`seen`?e.tmuxClient:null;return`cols=${t.kind===`failed`?`failed widthOf=-`:`${t.value.columns??`-`} widthOf=${t.value.of.kind}`} clientUtf8=${n===null?`-`:n.utf8?`yes`:`no`}`}function xM(e){if(e.kind===`failed`)return`clients=unasked`;let{daemon:t,clients:n}=e.value;return`clients=${n.map(e=>{if(e.kind===`unreported`)return`unreported/-/-`;let{bundle:n,source:r}=Rj(t,e);return`${e.client}/${n.kind}/${r.kind===`uncompared`?`-`:r.kind}`}).join(`,`)||`-`}`}function SM({serving:e,processes:t,read:n}){let r=t.kind===`failed`?`daemons=unread others=-`:`daemons=${t.value.length} others=${Wj(e,t.value).map(e=>e.pid).join(`,`)||`-`}`;if(e.kind===`failed`)return`${r} memory=unasked postMortems=unasked`;let{memory:i,limit:a,postMortems:o}=e.value,s=o.kind===`failed`||n.kind===`failed`?`unread`:`${Uj(e.value,n).length}/${o.value.length}`;return`${r} memory=${i.kind===`unmeasured`?`unmeasured`:`${wn(i.charge)}:${hn(i.charge.bytes)}`}/${hn(a)} postMortems=${s}`}function CM(e){let t=()=>{if(e.pullRequests.kind===`unneeded`)return`-`;let t=e.pullRequests.fact;if(t.kind===`failed`)return`failed`;if(t.value===null)return`no-forge`;let{status:n}=t.value;return typeof n==`string`?n:`logged-out`},n=()=>{if(e.rateLimits.kind===`unneeded`)return`-`;let t=e.rateLimits.fact;if(t.kind===`failed`)return`failed`;let n=e=>t.value.filter(t=>t===e).length;return`${n(`carried`)}/${n(`missing`)}/${n(`unanswered`)}`},r=e.memento.kind===`unneeded`?`-`:e.memento.fact.located.kind===`ok`?`located`:e.memento.fact.located.kind;return`data=pr:${t()},rateLimits:${n()},memento:${r}`}function wM(e,{origin:t,elsewhere:n}){let r=[t,...n],i=r.map(({sources:e})=>TM(e)).join(`,`);if(e.kind===`failed`)return`frames=failed redrawn=failed chains=${gM(i)}`;let a=Xj(r.flatMap(e=>e.bars)),o=e=>a.filter(t=>t.frame===e).length,s=a.map(({redraws:e})=>e.kind===`seen`?`${e.seconds}`:`unseen(${e.over})`);return`frames=${XA.map(o).join(`/`)} redrawn=${s.join(`,`)||`-`} chains=${gM(i)}`}function TM(e){let t=vj(e);switch(t.kind){case`unread`:return`failed`;case`absent`:case`not-an-object`:return t.kind;case`present`:return`${t.from.scope}:${t.refreshInterval===void 0?`-`:JSON.stringify(t.refreshInterval)}`}}function EM(e){let t=yj(e,Oj);return t.kind===`failed`?`truecolorEnv=failed`:t.value.kind===`unset`?`truecolorEnv=unset`:`truecolorEnv=${gM(`${t.value.from.scope}:${JSON.stringify(t.value.value)}`)}`}function DM(e){if(e.kind===`failed`)return`transcripts=failed`;let t=t=>e.value.filter(e=>e.read.kind===t).length,n=e.value.reduce((e,t)=>e+(t.read.kind===`ok`?t.read.value.unparsed:0),0);return`transcripts=${t(`ok`)}/${t(`absent`)}/${t(`failed`)} unparsed=${n}`}function OM(e,t){if(e.kind===`none`)return`glyphs=- terminal=- font=- mark=-`;let{glyphs:n,terminal:r}=e,i=[...n].map(e=>e.codePointAt(0).toString(16)),a=(()=>{switch(r.kind){case`unreported`:case`unasked`:return r.kind;case`unknown`:return`unknown:${JSON.stringify(r.called)}`;case`unnamed`:return`unnamed:${JSON.stringify(r.term)}`;case`bundling`:case`unread`:case`configured`:return`${r.name}@${r.version??`-`}`}})(),o=(()=>{if(r.kind!==`configured`)return`-`;if(r.font.kind===`failed`)return`failed`;let{font:e,lacks:t}=r.font.value;return`${JSON.stringify(e)}:${t===null?`not-installed`:`lacks${t.length}`}`})(),s=nM(e),c=t.kind===`failed`?`unread`:s===void 0?`-`:t.value.nerdFont?.[s.id]??`-`;return`glyphs=${i.join(`,`)} terminal=${a} font=${o} mark=${c}`}function kM(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function AM(e){return e.flatMap(({check:e,verdict:t})=>{let n=vM(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:t.note??``},{key:n.fixable,value:Bh},{key:n.sighting,value:``}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:kM(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?Bh:zh},{key:n.sighting,value:t.sighting?.glyphs??``}]})}const jM={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function MM(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }}{{ if ne .resume_command "" }} {{ action "${t(`copyResume`)}" "⎘ resume" }}{{ end }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}{{ if ne .config_path "" }} {{ action "${t(`openConfig`)}" "↗ config" }}{{ end }}`,actions:Object.fromEntries(Object.entries(jM).map(([t,n])=>[`${e}${t}`,n]))}}const NM=`armed`,PM=`disarmed`,FM=`.armed`,IM=e=>e.endsWith(FM);function LM(e,t,n){let r=`${e}${FM}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${NM}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:NM},[a]:{set:r,to:PM},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:PM}},disarm:a}}const RM=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function zM(e){return typeof e==`string`&&RM.test(e)?{kind:`line`,line:e}:{kind:`refused`,reason:`a slash command is "/" then its name, e.g. "/compact" or "/model opus", on one line with no control characters, got ${JSON.stringify(e)}`}}function BM(e){let t=zM(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const VM=[`/compact`,`/model`],HM=`/clear`;function UM(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=LM(`${e}clear`,{arm:HM,confirm:`${HM} ✓ confirm`},[n]);return{template:VM.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${BO} }}`,actions:{...Object.fromEntries(VM.map(e=>[t(e),{slash:BM(e)}])),...r.actions,[n]:{slash:BM(HM)}},variables:r.variables,disarm:r.disarm}}const WM=Array.from({length:10},(e,t)=>(t+1)*1e5),GM=WM[0],KM=WM[WM.length-1];function qM(e){let t;try{t=la(e)}catch(e){return I(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?P(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=GM&&n<=KM?P(n):I(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${GM}–${KM} tokens)`)}function JM(e,t){let n=Math.min(t??KM,KM),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:WM.filter(e=>e<r).at(-1)??0,higher:WM.find(e=>e>r&&e<=n)??0}}function YM(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${BO} }}{{ if gt .autocompact.lower 0 }} {{ action (printf "${e}%d" .autocompact.lower) "−" }}{{ end }}{{ if gt .autocompact.higher 0 }} {{ action (printf "${e}%d" .autocompact.higher) "+" }}{{ end }}{{ if gt .autocompact.window 0 }} {{ action "${e}auto" "↺" }}{{ end }}{{ end }}{{ end }}`,bg:`{{ if ne .autocompact.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .autocompact.window 0) (ne .autocompact.error "") }}`,actions:{[`${e}auto`]:{slash:BM(`/autocompact auto`)},...Object.fromEntries(WM.map(t=>[`${e}${t}`,{slash:BM(`/autocompact ${t}`)}]))}}}const XM=e=>`{{ if ge ${e} 1000000 }}{{ printf "%.1f" (divf ${e} 1000000) }}M{{ else if ge ${e} 1000 }}{{ printf "%.1f" (divf ${e} 1000) }}K{{ else }}{{ ${e} }}{{ end }}`,ZM=`${X}menu`,QM=`open`,$M=`${X}edit`,eN=`${X}toolbar`,tN=MM(X),nN=`${X}commands`,rN=UM(`${nN}.`),iN=`${X}autocompact`,aN=YM(`${iN}.`,XM),oN=e=>({kind:`segment`,name:e}),sN=`${X}tab`,cN=e=>`${sN}.${e}`,lN=e=>`${cN(e)}.toggle`,uN=e=>({variable:sN,key:sN,member:e}),dN=`${X}save`,fN=`${X}preset.save`,pN=`${X}preset.delete`,mN=e=>`${X}${e}`,hN=e=>`${X}apply.${e}`,gN=e=>`${X}reset.${e}`,_N=`${X}themeDefault.save`,vN=`${X}themeDefault.differs`,yN=`${X}themeDefault.theme`,bN={when:`{{ .${vN} }}`,template:`{{ action "${_N}" (printf "⤓ default for %s" .${yN}) }} {{ swatch "${hN(`theme`)}" .${yN} }}`},xN=`${X}resetAll`,SN=`${ZM}.toggle`,CN={variable:ZM,key:ZM,member:QM},wN=`${X}undo`,TN=`${X}back`,EN=`${TN}.step`,DN=`${X}navigation.back`,ON=TN,kN={template:`{{ if gt .${DN} 0 }}{{ action "${TN}" "◁" }}{{ else }}{{ fg (${LA}) "◁" }}{{ end }}`},AN=`${X}redo`,jN=`${X}doctor`,MN=`${jN}.run`,NN=e=>`${jN}.fix.${e}`,PN=(e,t)=>`${jN}.mark.${e}.${t}`,FN=e=>`${jN}.${e}`,IN={drawn:`[✓ shapes]`,boxes:`[✗ boxes]`},LN=$O(`${X}pickers`),RN=e=>`${X}${e}`,zN=e=>`${RN(e)}.toggle`,BN=e=>OA(e)?$O(`${X}${e}Pickers`):LN,VN=e=>{let t=BN(DA[TA[e].beside]);return{variable:t,key:t,member:e}},HN={layout:{template:`{{ layoutPreview }}`},palette:{template:`{{ themePreview }}`},presetDelete:{when:`{{ not .preset.bundled }}`,template:`{{ action "${pN}" (printf "🚮 delete %s" .${V_.preset.effectiveVar}) }}`}},UN=(e,t)=>`${X}list.${e}.${t}`,WN=e=>`${X}resettable.${e}`,GN=e=>e.length===0?`false`:`(or ${e.map(e=>`.${WN(e)}`).join(` `)})`,KN=o_.map(e=>[a_[e].setting,e]),qN={variables:{},actions:{},segments:{}},JN=Object.fromEntries(KN.map(([e,t])=>[e,pA(`${X}help.${e}`,FA[t],[],qN)])),YN=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],XN=e=>{let t=t=>`.${u_(e,t)}`,n=YN.map(e=>`${1/30} "${e}"`).join(` `);return`{{ if .${V_[a_[e].setting].effectiveVar} }} {{ if ${t(`subscribers`)} }}{{ frames ${n} }} {{ ${t(`fps`)} }} fps{{ if not ${t(`shown`)} }} · off screen{{ end }}{{ else }}no subscriber{{ end }}{{ end }}`},ZN=`{{ if eq .${c_(`by`)} "feed" }} {{ printf "%2d" (int .${c_(`fps`)}) }} fps{{ end }}`,QN=Object.fromEntries(KN.map(([e,t])=>[e,XN(t)])),$N=Object.keys(V_).map(e=>{let t=V_[e],n=mk(t.configKey),r=dk({label:t.label,domain:n},t.sessionKey,t.effectiveVar,hN(e),BN(DA[e]));return{...t,name:e,control:r,beneath:t.previews.map(e=>HN[e])}}),eP=e=>$N.filter(t=>DA[t.name]===e),tP=e=>$N.filter(t=>kA(DA[t.name])===e),nP=e=>EA.filter(t=>TA[t].beside===e),rP=e=>eP(e).flatMap(e=>[hP(e),...[JN[e.name]].filter(e=>e!==void 0),...nP(e.name).map(e=>Nr(RN(e),VN(e),{kind:`container`,direction:`horizontal`,children:rP(e)},`drop`))]);new Set($N.flatMap(e=>[e.sessionKey,e.configKey]));const iP=LM(xN,{arm:`⟲`,confirm:`⟲ reset all?`},$N.map(e=>gN(e.name))),aP=[`unsaved`,`history.undo`,`history.redo`],oP=e=>`${X}${e}`,sP=oP(`unsaved`),cP=(e,t)=>({body:t,shown:`(gt .${oP(e)} 0)`}),lP=[cP(`unsaved`,`{{ action "${dN}" (printf "💾 save %d" .${sP}) }}`),cP(`history.undo`,`{{ action "${wN}" "↶" }}`),cP(`history.redo`,`{{ action "${AN}" "↷" }}`),{body:iP.template,shown:`(or ${GN($N.map(e=>e.name))} ${iP.armed})`}],uP={when:`{{ or ${lP.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+lP.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},dP=[{step:iP,place:`door`},{step:rN,place:`session`}],fP=e=>e.map(e=>e.step.disarm),pP=fP(dP),mP=fP(dP.filter(e=>e.place!==`door`));function hP(e){let t=mN(e.name);return e.control.kind===`inline`?oN(t):Nr(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[...e.control.list.rows,...e.beneath].map((t,n)=>oN(UN(e.name,n)))},`drop`)}function gP(e){return e===ZM}function _P(e){let t=oN(ZM);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[_P(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function vP(e){return yP(e)>0?e:_P(e)}function yP(e){let t=0;for(let n of Zh(e))n.kind===`segment`&&gP(n.name)&&(t+=1);return t}function bP(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&gP(e.name)||e.opens!==void 0&&bP(e.opens.body,!0):e.children.some(e=>bP(e,n))}const xP={session:{direction:`vertical`,content:[oN(eN),{kind:`container`,direction:`horizontal`,children:[oN(nN),oN(iN)]}],after:[]},look:{direction:`horizontal`,content:[],after:[oN(_N)]},layout:{direction:`horizontal`,content:[oN(fN),oN($M)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[oN(jN),...dM.map(e=>oN(FN(e.name)))],after:[]}},SP=e=>({kind:`container`,direction:xP[e].direction,children:[...xP[e].content,...rP(e),...xP[e].after]});function CP(e){return e.kind===`segment`?gP(e.name)?Nr(e.name,CN,TP,`above`):e:DP(e)}function wP(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[oN(ON),...rP(`door`),oN(dN)]},{kind:`container`,direction:`horizontal`,children:CA.map(({member:e})=>Nr(cN(e),uN(e),SP(e),`drop`))}]}}const TP=wP();function EP(e){let t=new Map;for(let e of Zh(TP))e.kind===`segment`&&e.opens!==void 0&&t.set(e.opens.ref.key,e.opens.ref.variable);return[...t].map(([t,n])=>{let r=e.variables[n];if(r?.kind!==`state`||r.default===void 0)throw Error(`settings menu: the door folds "${t}", but "${n}" is not a state variable the menu declares with a default`);let i=`${ZM}.fold.${UO(t)}`;return e.actions[i]={set:t,to:r.default},i})}function DP(e){return{...e,children:e.children.map(e=>CP(e))}}function OP(e){let t={variables:{[ZM]:zr(ZM,Or)},actions:{[SN]:Br(ZM,QM),[MN]:{doctor:`run`},[$M]:{do:[...nA]},...tN.actions,...rN.actions,...aN.actions,[dN]:{save:!0},[wN]:{undo:!0},[EN]:{back:!0},[TN]:{do:[EN,...pP]},[AN]:{redo:!0},[fN]:{preset:`save`},[_N]:{themeDefault:`save`},[pN]:{preset:`delete`,name:`{{ .${V_.preset.effectiveVar} }}`}},segments:{[ZM]:{template:`{{ $door := ${Lr(ZM,Rr(e),Rr(`✖`))} }}{{ if ${Fr(CN)} }}{{ fg (keptOn (color "error") (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`+ZN},[eN]:{template:tN.template},[nN]:{template:rN.template,when:rN.when},[iN]:{template:aN.template,bg:aN.bg,when:aN.when},[ON]:kN,[dN]:uP,[_N]:bN,[fN]:{template:`{{ action "${fN}" "+ preset" }}`},[jN]:{template:`{{ action "${MN}" "🩺 doctor" }}`},[$M]:{template:`{{ action "${$M}" "✎ arrange" "✎ done" }}`}}};t.variables[vN]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[yN]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[DN]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of aP)t.variables[oP(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[sN]=zr(sN,`session`);for(let{member:e,label:n}of CA){t.actions[lN(e)]=Br(sN,e),t.actions[cN(e)]={do:[lN(e),...mP]};let r=GN(tP(e).map(e=>e.name)),i=`(ternary ${Rr(` •`)} "" ${r})`,a=e=>`(print ${Rr(e)} ${i})`;t.segments[cN(e)]={template:`{{ ${Lr(cN(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,rN.variables,iP.variables),AP(t),kP(t),t.actions[ZM]={do:[SN,...pP,...EP(t)]},t}function kP(e){for(let t of dM){let n=vM(t.name),r=NN(t.name);for(let t of Object.values(n))e.variables[t]={kind:`state`,key:t,default:``};e.actions[r]={doctor:`fix`,check:t.name};let i=t.takesMark?Cj:[];for(let n of i)e.actions[PN(t.name,n)]={doctor:`mark`,check:t.name,mark:n};let a=i.map(e=>` {{ action "${PN(t.name,e)}" "${IN[e]}" }}`).join(``);e.segments[FN(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ if ne .${n.reason} "" }} — {{ .${n.reason} }}{{ end }}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${zh}" }} {{ action "${r}" "[fix]" }}{{ end }}`+(a===``?``:`{{ if ne .${n.sighting} "" }} {{ .${n.sighting} }}${a}{{ end }}`)+`{{ end }}`}}}function AP(e){for(let t of $N){Object.assign(e.actions,t.control.actions);let n=gN(t.name);e.actions[n]={reset:t.configKey},e.variables[WN(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${WN(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[mN(t.name)]={template:`${t.control.template}${QN[t.name]??``}${r}`},t.control.kind===`picker`&&[...t.control.list.rows.map(e=>({template:e})),...t.beneath].forEach((n,r)=>{e.segments[UN(t.name,r)]=n})}Object.assign(e.actions,iP.actions),Object.assign(e.variables,qN.variables),Object.assign(e.actions,qN.actions),Object.assign(e.segments,qN.segments);for(let t of EA){let n=VN(t);e.actions[zN(t)]=Br(n.key,n.member),e.segments[RN(t)]={template:`{{ action "${zN(t)}" ${Rr(TA[t].trigger)} }}`}}}function jP(e){let{variables:t,actions:n}=dA();Object.assign(e.variables,t),Object.assign(e.actions,n)}function MP(e){let t=OP(e.globals.menuGlyph??`🍫`);jP(t);let n={...e.presets},r=[];for(let t of ky(e.presets)){let{node:i}=My(e,t),a=CP(vP(i));r.push(a),n[t]={...jy(e.presets,t),root:a}}let i=HO(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const NP=`${KO}live`,PP=[`☐ live`,`☑ live`],FP=`${KO}done`,IP=`${KO}cancel`,LP=`${KO}rewind`,RP=`${KO}changes`,zP=`(gt .${RP} 0)`,BP=`(or ${zP} (gt .${sP} 0))`,VP={variable:NP,key:NP,member:`open`};function HP(e){return`${KO}configuring.p${e}`}function UP(e){return`and ${Fr(oA)} (not ${Fr(VP)}) (ne .${HP(e)} "true")`}function WP(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${$k} "${Mr(e)}")`).join(` `)} false }}`}}function GP(e,t,n){return`{{ if ${UP(e)} }}${t}{{ else }}${n}{{ end }}`}const KP=`{{ and ${Fr(oA)} .preset.customized }}`,qP=JO;function JP(e){return new Map([...Ly(e),...XP(e)])}const YP=`${KO}addable`;function XP(e){return new Map([[YP,{members:Object.keys(e.segments).filter(e=>!qP(e)),library:{groups:Yk.map(e=>({id:e,label:Xk[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function ZP(e,t,n){return n.segments[e]={template:t,when:sA,bg:hA},{kind:`segment`,name:e}}function QP(e,t,n){let r=`${KO}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${Pm}`}) (action "${r}" "✖") }}`}function $P(e){return`{{ if ${Fr(oA)} }}${e}{{ end }}`}function eF(e,t){return e.reduce((e,t)=>`{{ if and ${Fr(oA)} ${Fr(t)} }}true{{ else }}${e}{{ end }}`,t)}function tF(e){return e.flatMap(e=>[...Zh(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function nF(e,t,n){return`${iA}${e}.${t}.${n}`}function rF(e,t,n,r){let i=qh(n),a=`${KO}${e.presetIdent}`,o=aA(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=$O(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:Or},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:$k,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=nF(e.presetIdent,i,r),l=`${iA}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:gg(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=dk(lk(o),s,l,d,c);if(Object.assign(e.artifacts.actions,f.actions),Object.assign(e.artifacts.variables,f.variables),f.kind===`inline`)return e.artifacts.segments[d]={template:f.template},{kind:`segment`,name:d};e.artifacts.segments[d]={template:f.template};let p=f.list.rows.map((t,n)=>{let r=`${d}.list.${n}`;return e.artifacts.segments[r]={template:t},{kind:`segment`,name:r}});return Nr(d,f.list.ref,{kind:`container`,direction:`vertical`,children:p},`drop`)});return{term:`{{ action "${s}" "${xA}" }}`,ref:{variable:$k,key:$k,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const iF=`${KO}label:`;function aF(e){if(e.startsWith(iF)){let t=e.slice(iF.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function oF(e,t,n,r){let{artifacts:i}=n,a=qh(e),o=`${iF}${a}:${e.name}`;i.segments[o]={template:`{{ "${Mr(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=Object.fromEntries(dg.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...Nr(o,r.ref,r.body,`drop`,eF([r.ref],`{{ ${UP(n.presetIdent)} }}`)),...Object.keys(s).length>0&&{settings:s},drafts:Object.fromEntries(dg.map(e=>[e,r.drafts[e]]))}}function sF(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${KO}${i}.insert.${t}`,s=`${KO}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:YP,anchor:n,relation:r};let c=ZO(o),l=QO(s,o,void 0),u=tk(l),d=ek(l,c);return a.variables[l]=zr(l,Or),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=Br(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${Fr({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${Pm}`}) $m }}{{ end }}`}}function cF(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!qP(e.name)),i=e=>cF(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=Xh(o,i);if(qP(o.name)){n.push(s);continue}let c=qh(o),l=a===r?[sF(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=sF(t,u,c,`after`),f=QP(t,u,c),p=t.segments[o.name],m=rF(t,u,o,fg(p)),h=$P(f),g=$P(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>ZP(e.host,e.template,t.artifacts)),{...oF(o,p,t,m),lead:h,trail:g},{...s,when:GP(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},ZP(d.host,d.template,t.artifacts)]};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[_]}:_)}return{...e,children:n,...e.when!==void 0&&{when:eF(tF(n),GP(t.presetIdent,`true`,e.when))}}}function lF(e,t,n,r,i,a,o){let s=`${KO}${t}.resetLayout`,c=`${KO}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:KP},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},uF(e,o)]}}function uF(e,t){if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[e,t]};let n=e.children.at(-1);return e.direction===`vertical`&&n!==void 0&&(n.kind===`segment`||n.when===void 0)?{...e,children:[...e.children.slice(0,-1),uF(n,t)]}:{...e,children:[...e.children,t]}}function dF(e,t,n,r,i,a){let{node:o}=My(e,t),s={presetIdent:UO(t),rootKey:Hk(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=cF(o,s);return n.variables[HP(s.presetIdent)]=WP(s.configured),lF(c,s.presetIdent,s.rootKey,n,r,i,a)}function fF(e){let t={variables:{},actions:{},segments:{}},n=pA(`${KO}help`,PA,[oA],t);t.variables[NP]=zr(NP,Or),t.actions[NP]=Br(NP,VP.member),t.segments[NP]={template:Ir(NP,...PP),when:sA};let r={kind:`segment`,name:NP},i=n;t.variables[RP]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[FP]={do:[dN,...nA]},t.segments[FP]={template:`{{ if ${BP} }}{{ action "${FP}" "✓ save" }}{{ else }}{{ action "${FP}" "✓ done" }}{{ end }}`,when:sA},t.actions[LP]={rewind:!0},t.actions[IP]={do:[LP,...nA]},t.segments[IP]={template:`{{ action "${IP}" "↩ cancel" }}`,when:`{{ and ${Fr(oA)} ${zP} }}`};let a=[{kind:`segment`,name:FP},{kind:`segment`,name:IP}],o={...e.presets},s=[];for(let n of ky(e.presets)){let c=dF(e,n,t,a,r,i);s.push(c),o[n]={...jy(e.presets,n),root:c}}let c=HO(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}function pF(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function mF(e){let t=e.split(`:`);return t[0]===`remove`&&t.length===2&&t[1]?{op:`remove`,target:t[1]}:t[0]===`insert`&&t.length===4&&t[1]&&t[2]&&(t[3]===`before`||t[3]===`after`)?{op:`insert`,segment:t[1],anchor:t[2],relation:t[3]}:null}function hF(e,t,n){let r=Yh(e,new Set(n.map(Jh).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const gF=/^-?\d+$/;function _F(e,t,n=`set-state`){let r=e.filter(e=>e.includes(`/`));if(r.length>0)throw Error(`makeAllowListValidator(${t}): values contain "/" — the ${n} wire shape splits values on "/" so slash-bearing options cannot be addressed. Offending values: ${r.join(`, `)}`);if(e.includes(``))throw Error(`makeAllowListValidator(${t}): empty string is not a writable option — the validator rejects empty input before the allow-list check, so an "" in the allowed list could be rendered but never delivered. Remove "" from the allowed list.`);let i=new Set(e),a=[...e];return e=>e?i.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown ${t} "${e}" (have: ${a.join(`, `)})`}:{ok:!1,reason:`${t} value is required`}}function vF(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!gF.test(t))return{ok:!1,reason:`${e} must be an integer, got "${t}"`};let n=t[0]===`-`,r=(n?t.slice(1):t).replace(/^0+/,``);return r===``?{ok:!0,value:`0`}:{ok:!0,value:n?`-${r}`:r}}}function yF(e,t,n){return r=>r?gF.test(r)?{ok:!0,value:String(Math.max(e,Math.min(t,parseInt(r,10))))}:{ok:!1,reason:`${n} must be an integer, got "${r}"`}:{ok:!1,reason:`${n} value is required`}}function bF(e,t,n=`state`){let r=t.filter(e=>e.kind===`range`),i=t.some(e=>e.kind===`int`),a=t.flatMap(e=>e.kind===`allow-list`?e.allowed:[]);if(r.length===0&&!i)return{kind:`allow-list`,allowed:[...new Set(a)]};let o=a.filter(e=>!gF.test(e));if(o.length>0)throw Error(`${n} action table: key "${e}" is an integer spec (a paged cursor or a bounded value) but a click writes non-integer value(s) to it (${o.join(`, `)}). A ${n} key has one key shape — point that click at a distinct key, or write an integer.`);if(i&&r.length>0)throw Error(`${n} action table: key "${e}" is declared as both a paged cursor (int) and a bounded value (range) — a ${n} key has one key shape. Use distinct keys.`);if(r.length>0){let t=Math.min(...r.map(e=>e.min)),i=Math.max(...r.map(e=>e.max)),o=a.filter(e=>{let n=parseInt(e,10);return n<t||n>i});if(o.length>0)throw Error(`${n} action table: key "${e}" is a bounded range [${t},${i}] but a click writes out-of-range value(s) to it (${o.join(`, `)}). The range gate would clamp them, storing a different value than the click renders — write an in-range integer, or point that click at a distinct key.`);return{kind:`range`,min:t,max:i}}return{kind:`int`}}function xF(e){return e===`config`?`set-config`:`set-state`}function SF(e,t,n){return t.kind===`int`?vF(`menu page "${e}"`):t.kind===`range`?yF(t.min,t.max,`${n} stepper "${e}"`):_F(t.allowed,`${n} "${e}"`,xF(n))}function CF(e,t=`state`){let n=new Map;for(let{key:t,spec:r}of e){let e=n.get(t);e?e.push(r):n.set(t,[r])}return[...n].map(([e,n])=>({key:e,spec:bF(e,n,t)}))}function wF(e,t,n,r){let i=new Map(Object.entries(e)),a=new Map,o=new Set(t.map(e=>e.key));for(let{key:e,spec:t}of n)if(o.has(e)&&t.kind!==`allow-list`)throw Error(`${r} gate: key "${e}" is written by the daemon's own links as one of a list of values, and cannot be declared as ${t.kind===`int`?`a paged cursor (int)`:`a bounded value (range)`}. Use a distinct key.`);let s=[...t.map(({key:e,allowed:t})=>({key:e,spec:{kind:`allow-list`,allowed:t}})),...n];for(let{key:t,spec:n}of CF(s,r)){if(!t)throw Error(`${r} gate: key is required`);if(t.includes(`/`))throw Error(`${r} gate: key "${t}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);if(Object.hasOwn(e,t))throw Error(`${r} gate: key "${t}" is a built-in ${r} key and cannot be re-claimed (built-in keys: ${Object.keys(e).join(`, `)})`);i.set(t,SF(t,n,r)),n.kind===`range`&&a.set(t,{min:n.min,max:n.max})}return{validate(e,t){let n=i.get(e);return n?n(t):{ok:!1,reason:`unknown ${r} key "${e}" (have: ${[...i.keys()].join(`, `)})`}},listKeys:()=>[...i.keys()],rangeParamsFor:e=>a.get(e)??null}}function TF(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};wF(e,[o],[],t),r.push(o),i++;let s=!0;return()=>{s&&(s=!1,r.splice(r.indexOf(o),1),i++)}},gateFor(o){let s=a.get(o);if(s?.epoch===i)return s.gate;let c=wF(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const EF=TF({},`config`,NF);function DF(e,t){return EF.register(e,t)}function OF(e){return EF.gateFor(e)}function kF(e,t){return`persist`in e?`to`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:zy(e.from,t).members}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[pF({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[pF({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:zy(e.insertSegmentFrom,t).members.map(t=>pF({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function AF(e,t){let n=Lk(e).get(t);return n===void 0?null:String(n)}function jF(e){let t=new Set;for(let n of Object.values(e.actions)){`reset`in n&&t.add(n.reset);let e=`persist`in n?Kk(n.persist):null;e?.scope===`preset-root`&&t.add(Hk(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function MF(e){let t=JP(e);return[...jF(e),...Object.values(e.actions).flatMap(e=>kF(e,t))]}function NF(e){return CF(MF(e),`config`)}function PF(e,t){return{globals:{...t.globals,...e.globals??{}},variables:{...t.variables,...e.variables??{}},segments:LF(t.segments,FF(t.segments,e.segments??{})),root:Ty(e.root??vy,t.root),actions:{...t.actions,...e.actions??{}},styles:{...t.styles,...e.styles??{}},presets:LF(t.presets,IF(t.presets,e.presets??{})),themeDefaults:LF(t.themeDefaults,e.themeDefaults??{}),editGlobals:{...t.editGlobals,...e.editGlobals??{}},helpers:{...t.helpers,...e.helpers??{}}}}function FF(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.settings===void 0?n:{...n,settings:{...e[t]?.settings,...n.settings}}]))}function IF(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.globals===void 0?n:{...n,globals:{...e[t]?.globals,...n.globals}}]))}function LF(e,t){return{...e,...Object.fromEntries(Object.entries(t).map(([t,n])=>[t,{...e[t],...n}]))}}function RF(e,t,n,r){return n.cache===void 0?(e.issues.push({path:`${t}.cache`,message:`${r} variables must declare a cache policy (one of: ${rg.join(`, `)})`,line:K(e.source,t.split(`.`))}),null):VF(e,`${t}.cache`,n.cache)}function zF(e){return{required:!0,json:HF(),parse:(t,n,r,i)=>RF(t,n,i,e)??void 0}}const BF={noun:`cache`,arms:{ttl:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&WF(n)?{ttl:n}:zg(e,t,`cache.ttl must be a duration string like "5s", "100ms", "2m", "1h"; got ${q(n)}`)},watch_file:{json:{type:`string`,pattern:`^/`},parse:(e,t,n)=>{if(typeof n!=`string`)return zg(e,t,`cache.watch_file must be a path string, got ${q(n)}`);let r=Zg(`cache.watch_file`,n);return r===null?{watch_file:n}:zg(e,t,r)}},depends_on:{json:{type:`array`,items:{type:`string`}},parse:(e,t,n)=>Array.isArray(n)&&n.every(e=>typeof e==`string`)?{depends_on:n}:zg(e,t,`cache.depends_on must be an array of variable-name strings, got ${q(n)}`)},key:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&n!==``?{key:n}:zg(e,t,`cache.key must be a non-empty template string, got ${q(n)}`)},never:{json:{const:!0},parse:(e,t,n)=>n===!0?{never:!0}:zg(e,t,`cache.never must be the literal boolean true, got ${q(n)}`)}}};function VF(e,t,n){return Bg(e,BF,t,n)}function HF(){return i_(BF)}const UF=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/;function WF(e){return UF.test(e)}function GF(e,t,n){if(n===void 0)return{};if(!Mg(n))return e.issues.push({path:t,message:`${t} must be an object, got ${Ng(n)}`,line:K(e.source,t.split(`.`))}),{};let r={};for(let[i,a]of Object.entries(n)){let n=Vg(e,_I,`${t}.${i}`,a);n!==null&&(r[i]=n)}return r}function KF(){return{required:!0,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.value;if(typeof i!=`string`&&typeof i!=`number`&&typeof i!=`boolean`){e.issues.push({path:`${t}.value`,message:`literal value must be string|number|boolean, got ${Ng(i)}`,line:K(e.source,t.split(`.`))});return}return i}}}function qF(){return{required:!0,json:{enum:[...ag]},parse:(e,t,n,r)=>{let i=r.field;if(typeof i!=`string`||!ag.includes(i)){e.issues.push({path:`${t}.field`,message:`git field must be one of: ${ag.join(`, `)}, got ${JSON.stringify(i)}`,line:K(e.source,[...t.split(`.`),`field`])});return}return i}}}function JF(){return{required:!1,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.type;return Og(e,t,r,i===`number`||i===`boolean`||i===`string`?i:`string`)}}}const YF={noun:`parse`,arms:{text:{json:{const:!0},parse:(e,t,n)=>n===!0?{text:!0}:zg(e,t,`parse.text must be the literal boolean true, got ${q(n)}`)},regex:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`?XF(e,t,n):zg(e,t,`parse.regex must be a pattern string, got ${q(n)}`)},json:{json:{const:!0},parse:(e,t,n)=>n===!0?{json:!0}:zg(e,t,`parse.json must be the literal boolean true, got ${q(n)}`)}}};function XF(e,t,n){let r;try{new RegExp(n),r=RegExp(`${n}|`).exec(``).length-1}catch(n){return zg(e,t,`parse.regex is not a valid regular expression: ${n.message}`)}return r>=1?{regex:n}:zg(e,t,`parse.regex must contain a capture group — its group 1 is the value; got ${JSON.stringify(n)}`)}function ZF(){return{required:!1,json:i_(YF),parse:(e,t,n,r)=>(r.regex!==void 0&&e.issues.push({path:`${t}.regex`,message:`${t}.regex was retired; the regex is the parse step's regex arm now: parse: { regex: ${JSON.stringify(r.regex)} }`,line:K(e.source,[...t.split(`.`),`regex`])}),r.parse===void 0?void 0:Bg(e,YF,`${t}.parse`,r.parse)??void 0)}}function QF(){return{required:!1,json:{type:[`string`,`number`,`boolean`,`array`,`object`],description:`The value published when the source fails: a string under the text/regex parse arms, any non-null JSON value under the json arm`},parse:(e,t,n,r)=>Mg(r.parse)&&`json`in r.parse?$F(e,t,r.default):kg(e,t,r,`default`)}}function $F(e,t,n){if(n!==void 0)return eI(n)?n:zg(e,`${t}.default`,`${t}.default must be a JSON value (a json-parsed source's document), got ${q(n)}`)??void 0}function eI(e){return e!==null&&tI(e)}function tI(e){if(e===null)return!0;switch(typeof e){case`string`:case`boolean`:return!0;case`number`:return Number.isFinite(e);case`object`:{if(Array.isArray(e))return e.every(tI);let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&Object.values(e).every(tI)}default:return!1}}const nI={value:KF(),default:Gg()},rI={path:Xg(),type:$g([`string`,`number`,`boolean`]),default:JF()},iI={name:Xg(),default:Gg()},aI={path:Qg(),readMode:$g([`whole`,`first-line`]),parse:ZF(),cache:zF(`file`),default:QF()},oI={command:Xg(),parse:ZF(),cache:zF(`shell`),default:QF()};function sI(e){return{cache:`${e}, so it takes no cache policy — delete the key`}}const cI={template:Xg(),default:Gg()},lI=sI(`a template variable recomputes whenever a variable it reads changes`),uI={layout:Xg(),default:Gg()},dI=sI(`a time variable reads the instant its render is drawn at`),fI={field:qF(),default:Gg()},pI=sI(`a git variable is refreshed by the daemon's own watch on the repository`),mI={key:Xg(),default:Gg()},hI=`kind`;function gI(e,t,n={}){return{...Hg(hI,e,t),parse:(r,i,a)=>{Fg(r,n,i,a);let o=Ig(r,t,i,a);return o===null?null:{kind:e,...o}}}}const _I={tag:hI,noun:`source kind`,memberNoun:`variable`,arms:{literal:gI(`literal`,nI),input:gI(`input`,rI),env:gI(`env`,iI),file:gI(`file`,aI),shell:gI(`shell`,oI),template:gI(`template`,cI,lI),time:gI(`time`,uI,dI),git:gI(`git`,fI,pI),state:gI(`state`,mI)}};function vI(){return r_(_I)}function yI(){return{type:`object`,additionalProperties:vI()}}const bI=new Map([[`gitTaculous`,{kind:`built-in`,to:`gitaculous`}],[`git`,{kind:`built-in`,to:`gitaculous`}],[`settings.menu`,{kind:`built-in`,to:`candybar.menu`}],[`ticket`,{kind:`plugin`,to:`plugins.lit.ticket`,source:`promptctl/links-issue-tracker`}]]);function xI(e){let t=bI.get(e);if(t===void 0)return``;switch(t.kind){case`built-in`:return` (the built-in segment "${e}" was renamed to "${t.to}" — update this reference)`;case`plugin`:return` (the built-in segment "${e}" became "${t.to}", a segment of the plugin \`cc-candybar plugin install ${t.source}\` installs — update this reference)`}}const SI=/^[A-Za-z_][A-Za-z0-9_]*$/,CI={pattern:SI.source},wI={anyOf:[{type:`boolean`},{type:`string`},{type:`integer`}]},TI={type:`object`,additionalProperties:!1,required:[`label`,`domain`,`default`],properties:{label:{type:`string`,pattern:`^[^\\n\\r]+$`},domain:{anyOf:[{const:`bool`},{type:`array`,items:{type:`string`,pattern:`^[^/\\n\\r]+$`},minItems:1,uniqueItems:!0},{type:`object`,additionalProperties:!1,required:[`min`,`max`],properties:{min:{type:`integer`},max:{type:`integer`},step:{type:`integer`,minimum:1},atLeast:{type:`string`,...CI}}}]},default:wI}},EI=[`label`,`domain`,`default`],DI=[`min`,`max`,`step`,`atLeast`];function OI(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))})}function kI(e,t,n){if(n===`bool`)return`bool`;if(Array.isArray(n)){let r=n.filter(e=>typeof e==`string`);if(n.length===0||r.length!==n.length)return OI(e,t,`a list domain must be a non-empty list of words, got ${JSON.stringify(n)}`);if(new Set(r).size!==r.length)return OI(e,t,`a list domain names each word once, got ${JSON.stringify(n)}`);let i=r.filter(e=>e===``||e.includes(`/`)||/[\n\r]/.test(e));return i.length>0?OI(e,t,`a list domain's words must be non-empty, slash-free, and newline-free — configure mode writes each on the set-state wire — got ${JSON.stringify(i)}`):r}if(Mg(n)){let{min:r,max:i,step:a=1,atLeast:o}=n;return Object.keys(n).filter(e=>!DI.includes(e)).length===0&&Number.isInteger(r)&&Number.isInteger(i)&&r<=i&&Number.isInteger(a)&&a>=1&&(o===void 0||typeof o==`string`)?{min:r,max:i,step:a,...o!==void 0&&{atLeast:o}}:OI(e,t,`a range domain is { min, max, step?, atLeast? } with integers min ≤ max, a whole step ≥ 1, and atLeast naming another range setting, got ${JSON.stringify(n)}`)}return OI(e,t,`domain must be "bool", a list of words, or { min, max }, got ${q(n)}`)}function AI(e,t,n){if(!Mg(n))return OI(e,t,`${t} must be { label, domain, default }, got ${Ng(n)}`);for(let r of Object.keys(n))EI.includes(r)||OI(e,`${t}.${r}`,`Unknown setting key "${r}". Expected one of: ${EI.join(`, `)}`);let{label:r}=n,i=typeof r==`string`&&r.length>0&&!/[\n\r]/.test(r);i||OI(e,`${t}.label`,`a setting needs a one-line, non-empty "label" — the name its control shows, spliced into a synthesized template string — got ${q(r)}`);let a=kI(e,`${t}.domain`,n.domain);if(!i||a===void 0)return;let o={label:r,domain:a,default:n.default};return!jI(n.default)||!hg(o,n.default)?OI(e,`${t}.default`,`default must be ${yg(o)}, got ${q(n.default)}`):o}function jI(e){return typeof e==`boolean`||typeof e==`string`||typeof e==`number`}const MI={theme:`its default for this segment is segments.<name>.palette, and a placement sets its own with settings: { ${lg}: "<theme>" }`,effect:`a placement follows the bar's effect, or sets its own with settings: { effect: "<effect>" }`};function NI(e){return dg.includes(e)}function PI(){return{required:!1,json:{type:`object`,propertyNames:{...CI,not:{enum:[...dg]}},additionalProperties:TI},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!Mg(i))return OI(e,a,`${a} must be an object of name → { label, domain, default }, got ${Ng(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i)){if(!SI.test(t)){OI(e,`${a}.${t}`,`setting name "${t}" is read as .settings.${t} in a template, so it must be an identifier (letters, digits, _; not starting with a digit)`);continue}if(NI(t)){OI(e,`${a}.${t}`,`setting "${t}" is one every placement already has — ${MI[t]}`);continue}let r=AI(e,`${a}.${t}`,n);r!==void 0&&(o[t]=r)}return o}}}const FI=qO.map(e=>e.replace(/\./g,`\\.`)).join(`|`);function II(){return{required:!1,json:{type:`string`,minLength:1,pattern:`^(?!${FI})[^:/]+$`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return typeof i==`string`&&i.length>0&&!/[:/]/.test(i)&&!JO(i)?i:OI(e,`${t}.${n}`,`a placement "id" must be a non-empty string without "/" or ":", outside the reserved ${qO.map(e=>`"${e}"`).join(`, `)} namespaces, got ${q(i)}`)}}}function LI(){return{required:!1,json:{type:`object`,propertyNames:CI,additionalProperties:wI},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!Mg(i))return OI(e,a,`a placement's "settings" must be an object of setting name → value, got ${Ng(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i))jI(n)?o[t]=n:OI(e,`${a}.${t}`,`setting "${t}" must be a boolean, a word, or a number, got ${Ng(n)}`);return o}}}function RI(e){return new Set(Object.keys(e.segments).filter(e=>!JO(e)))}function zI(e,t,n){if(t===void 0)return{};if(!Mg(t))return e.issues.push({path:`segments`,message:`segments must be an object, got ${Ng(t)}`,line:K(e.source,[`segments`])}),{};let r={};for(let[i,a]of Object.entries(t)){let t=Pg(e,n.has(i)?GI:WI,`segments.${i}`,a);t!==null&&(r[i]=t)}return r}function BI(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>r[n]===void 0?zg(e,`${t}.${n}`,`${t} declares no template — only a segment the bundled default declares may omit it (inheriting the bundled template); a segment of your own needs its own${xI(t.slice(9))}`)??void 0:Dg(e,t,r,n)??void 0}}function VI(){return{required:!1,json:{anyOf:[{const:`auto`},{const:`fill`},{type:`integer`,minimum:1}]},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(i===`auto`)return`auto`;if(i===`fill`)return`fill`;if(typeof i==`number`&&Number.isInteger(i)&&i>0)return i;e.issues.push({path:`${t}.${n}`,message:`width must be "auto", "fill", or a positive integer, got ${q(i)}`,line:K(e.source,[...t.split(`.`),n])})}}}}function HI(){return{required:!1,json:yI(),parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return GF(e,`${t}.${n}`,i)}}}const UI={template:BI(),description:Gg(),group:$g(Jk),width:VI(),justify:$g(bg),truncate:$g(xg),bg:Gg(),fg:Gg(),when:Gg(),palette:Yg(),vars:HI(),settings:PI(),missingData:$g(og)},WI={noun:`segment key`,fields:UI},GI={noun:`segment key`,fields:{...UI,template:Gg()}},KI=`#/definitions/LayoutNode`,qI={kind:`container`,direction:`vertical`,children:[]};function JI(e){return{required:!0,json:{const:e},parse:()=>e}}function YI(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a segment node must have a non-empty "name" (a segment name), got ${q(i)}`,line:K(e.source,[`root`])}),``)}}}function XI(){return{required:!0,json:{enum:[...Gh]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&Gh.includes(i)?i:(e.issues.push({path:`${t}.${n}`,message:`a container "direction" must be one of: ${Gh.join(`, `)} (got ${JSON.stringify(i)})`,line:K(e.source,[`root`])}),`vertical`)}}}function ZI(e){return{required:!0,json:{type:`array`,items:{$ref:KI}},parse:(t,n,r,i)=>{let a=i[r];return Array.isArray(a)?a.map((i,a)=>e(t,`${n}.${r}[${a}]`,i)):(t.issues.push({path:`${n}.${r}`,message:`a container must have a "children" array of layout nodes, got ${Ng(a)}`,line:K(t.source,[`root`])}),[])}}}const QI={noun:`layout-node key`,fields:{kind:JI(`segment`),name:YI(),when:Gg(),id:II(),settings:LI()}},$I=()=>$g(um),eL={noun:`layout-node key`,fields:{kind:JI(`container`),direction:XI(),children:ZI(Ug(()=>aL)),when:Gg(),distribution:$I()}};function tL(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a "seg" node must have a non-empty segment name, got ${q(i)}`,line:K(e.source,[`root`])}),``)}}}const nL={noun:`layout-node key`,fields:{seg:tL(),when:Gg(),id:II(),settings:LI()}},rL={noun:`layout-node key`,fields:{h:ZI(Ug(()=>aL)),when:Gg(),distribution:$I()}},iL={noun:`layout-node key`,fields:{v:ZI(Ug(()=>aL)),when:Gg(),distribution:$I()}},aL=(e,t,n)=>{if(typeof n==`string`)return n.length===0?(e.issues.push({path:t,message:`a bare-string layout node must be a non-empty segment name`,line:K(e.source,[`root`])}),qI):{kind:`segment`,name:n};if(!Mg(n))return e.issues.push({path:t,message:`a layout node must be a string (segment name) or an object with "kind" / "seg" / "h" / "v", got ${Ng(n)}`,line:K(e.source,[`root`])}),qI;if(n.kind===`container`)return Pg(e,eL,t,n)??qI;if(n.kind===`segment`)return Pg(e,QI,t,n)??qI;if(n.kind===`cells`)return e.issues.push({path:t,message:`kind: "cells" is no longer supported — use the h-arm spelling instead:
177
177
  Old: { kind: "cells", segments: ["seg1", "seg2"] }
178
- New: { h: ["seg1", "seg2"] }`,line:K(e.source,[`root`])}),qI;if(n.kind===`group`){let r=Pg(e,fL,t,n);return r===null?qI:(e.groups.push({name:r.name,label:r.label,...r.open!==void 0&&{open:r.open},...r.direction!==void 0&&{direction:r.direction},...r.key!==void 0&&{key:r.key},...r.bg!==void 0&&{bg:r.bg},...r.fg!==void 0&&{fg:r.fg},...r.when!==void 0&&{when:r.when},path:t}),mL(r))}let r=`h`in n,i=`v`in n,a=`seg`in n;if(+!!r+ +!!i+ +!!a>1){let r=[`seg`,`h`,`v`].filter(e=>e in n);return e.issues.push({path:t,message:`a layout node may have exactly one of "seg", "h", or "v" — got ${r.map(e=>`"${e}"`).join(` and `)} together`,line:K(e.source,[`root`])}),qI}if(a){let r=Pg(e,nL,t,n);return r===null?qI:{kind:`segment`,name:r.seg,...r.when!==void 0&&{when:r.when},...r.id!==void 0&&{id:r.id},...r.settings!==void 0&&{settings:r.settings}}}if(r){let r=Pg(e,rL,t,n);return r===null?qI:{kind:`container`,direction:`horizontal`,children:r.h,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}if(i){let r=Pg(e,iL,t,n);return r===null?qI:{kind:`container`,direction:`vertical`,children:r.v,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}return e.issues.push({path:`${t}.kind`,message:`a layout node "kind" must be "container", "segment", or "group", or use the terse A-grammar: a bare string, or an object with "seg", "h", or "v" (got ${JSON.stringify(n.kind)})`,line:K(e.source,[`root`])}),qI};function oL(){return{required:!0,json:{type:`object`,propertyNames:{pattern:gy.source},additionalProperties:{$ref:KI}},parse:(e,t,n,r)=>{let i=r[n];if(!Mg(i))return e.issues.push({path:`${t}.${n}`,message:`"rows" must be an object of row name → layout node, got ${Ng(i)}`,line:K(e.source,[...t.split(`.`),n])}),{};let a={};for(let[r,o]of Object.entries(i)){if(!gy.test(r)){e.issues.push({path:`${t}.${n}.${r}`,message:`row name "${r}" must be an identifier (letters, digits, _; not starting with a digit) — it names the row in the config file and merges by name over the bundled default's rows`,line:K(e.source,[...t.split(`.`),n,r])});continue}a[r]=aL(e,`${t}.${n}.${r}`,o)}return a}}}const sL={noun:`root key`,fields:{rows:oL(),when:Gg(),distribution:$I()}};function cL(e,t,n){return Mg(n)&&`rows`in n?Pg(e,sL,t,n)??{rows:{}}:aL(e,t,n)}function lL(){return{required:!0,json:{type:`string`,pattern:gy.source},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`string`||!gy.test(i)||i===`closed`){e.issues.push({path:`${t}.${n}`,message:`a group "name" must be an identifier (letters, digits, _; not starting with a digit) and not the reserved "${Or}", got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}function uL(){return{required:!1,json:{type:`string`,minLength:1},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`string`||i===``||i.includes(`/`)){e.issues.push({path:`${t}.${n}`,message:`a group "key" must be a non-empty, slash-free SessionState key, got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}}function dL(){return{required:!0,json:{type:`string`,pattern:`^[^\\n\\r]*$`},parse:(e,t,n,r)=>{let i=Dg(e,t,r,n);if(i!==null){if(/[\n\r]/.test(i)){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: group label must not contain newlines`,line:K(e.source,[...t.split(`.`),n])});return}return i}}}}const fL={noun:`layout-node key`,fields:{kind:JI(`group`),name:lL(),label:dL(),open:Kg(),direction:$g(Gh),key:uL(),bg:Gg(),fg:Gg(),when:Gg(),distribution:$I(),children:ZI(Ug(()=>aL))}};function pL(e){return e.key??`groups.`+e.name}function mL(e){let t=WO+e.name;return Nr(t,{variable:t,key:pL(e),member:e.name},{kind:`container`,direction:e.direction??`vertical`,children:e.children,...e.distribution!==void 0&&{distribution:e.distribution}},`drop`,e.when)}function hL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function gL(e,t){XO(e,t,WO,`group nodes`);let n=e.groups;if(n.length===0)return;let r=new Set;for(let t of n)r.has(t.name)&&hL(e,t.path,`duplicate group name "${t.name}" — group names must be unique (they name the synthesized state var, action, and toggle segment)`),r.add(t.name);for(let t of n)for(let r of n)t!==r&&t.path.startsWith(`${r.path}.`)&&pL(t)===pL(r)&&hL(e,t.path,`group "${t.name}" shares key "${pL(t)}" with its ancestor group "${r.name}" — a shared key holds ONE open group, so an ancestor and a descendant cannot share one. Sibling accordions share a key; nested groups use distinct keys.`);let i=new Map;for(let t of n){let n=pL(t);if(i.has(n)||i.set(n,Or),t.open===!0){let r=i.get(n);r!==`closed`&&hL(e,t.path,`groups "${r}" and "${t.name}" share key "${n}" and both declare open: true — a shared key holds one open group; pick one`),i.set(n,t.name)}}let a={},o={},s={};for(let e of n){let t=WO+e.name,r=pL(e),c=n.filter(t=>t!==e&&e.path.startsWith(t.path+`.`)).length,l=` `.repeat(c);a[t]=zr(r,i.get(r)),o[t]=Br(r,e.name),s[t]={template:Ir(t,`${l}${e.label} ▸`,`${l}${e.label} ▾`),...e.bg!==void 0&&{bg:e.bg},...e.fg!==void 0&&{fg:e.fg}}}t.variables={...t.variables??{},...a},t.actions={...t.actions??{},...o},t.segments={...t.segments??{},...s}}const _L=`menu`,vL=`a menu binds its trigger text the way a cycle action binds a display — write {{ menu "applyTheme" "▸" "▾" }} (one per state) or {{ menu "insertHere" "+" }} (one static display for both), with the rare knobs in ONE trailing dict: {{ menu "applyTheme" "▸" "▾" (dict "closeOnPick" true "paged" false "key" "pickers") }} (defaults: closeOnPick false, paged true, no key). The renderer no longer appends ▸/▾ of its own (candybar-settings-ui-aok.4), and the older positional tail ("pageAction" closeOnPick paged "key") was removed — the page cursor is synthesized from the menu's identity`,yL=e=>e.kind===`call`&&e.name===`dict`,bL=e=>e.kind===`literal`&&typeof e.value!=`object`,xL=e=>Ar(``,e,2)===void 0;function SL(e){let t=e=>({kind:`issue`,message:e}),[n,...r]=e.argExprs;if(n===void 0)return t(`with no arguments — it takes an apply-action name and its trigger text (e.g. {{ menu "applyTheme" "▸" "▾" }})`);if(n.kind!==`literal`||typeof n.value!=`string`)return t(`whose apply action is not a string literal — a menu's identity is its apply-action name, which must be a literal so it can be gated at load (e.g. {{ menu "applyTheme" "▸" "▾" }})`);let i=r[r.length-1],a=i!==void 0&&yL(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(yL))return t(`whose options (dict …) is not its last argument — ${vL}`);if(i!==void 0&&a===void 0&&!bL(i)&&xL(o.length-1))return t(`whose last argument is neither a literal nor a literal (dict …) — the renderer tells a display from the options dict by the value it evaluates to, so this call could be read as ${o.length} displays or as ${o.length-1} plus options, and both are legal. Make the options explicit as a trailing (dict …) — {{ menu "${n.value}" (printf "…") (printf "…") (dict) }} binds dynamic displays unambiguously — or bind the trigger text as literals`);let s=Ar(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${vL}`);let c=a===void 0?{}:aw(a);if(c===null)return t(`whose options (dict …) is not fully literal — every option value must be a literal so the menu can be gated at load (a dynamic entry like (dict "key" .x) cannot)`);let l;try{l=ak(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=YO(u);if(e!==void 0)return t(`whose accordion key "${u}" lands in the reserved "${e}" namespace — a key is collapsed to an identifier (${JSON.stringify(u)} becomes "${$O(u)}"), so it would share one open-state key with the synthesized accordion that owns that namespace instead of grouping only your own menus. Name the group without the reserved prefix`)}return{kind:`ok`,apply:n.value,options:l}}function CL(e){let t=mS({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===_L).map(SL)}catch{return`parse-failed`}}function wL(e){let t=mS({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(_L)}catch{return!1}}function TL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function EL(e,t){XO(e,t,GO,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))wL(r)&&e.issues.push({path:`helpers.${n}`,message:`helper "${n}" uses {{ menu }}, but a menu must live directly in a segment template — its identity is derived from the segment it sits in, which a shared helper does not have. Inline the {{ menu }} call into each segment that needs it.`,line:K(e.source,[`helpers`,n])});let n=t.segments??{};for(let[t,r]of Object.entries(n))for(let n of[`bg`,`fg`,`when`]){let i=r[n];typeof i==`string`&&wL(i)&&TL(e,`segments.${t}.${n}`,`segment "${t}" uses {{ menu }} in its "${n}" — a menu is only valid in a segment's "template" (its placement is published only there; "${n}" needs a ${n===`when`?`predicate`:`color`}). Move the {{ menu }} into the template.`)}if(t.root!==void 0)for(let n of Zh(Cy(t.root)))typeof n.when==`string`&&wL(n.when)&&TL(e,`root`,`a layout node's "when" predicate uses {{ menu }} — a menu is only valid in a segment's "template", not a node predicate. Move it into a segment.`);for(let[t,{template:r}]of Object.entries(n)){if(r===void 0||!wL(r))continue;let n=CL(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:DL(r.apply);n!==void 0&&TL(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function DL(e){if(e===``)return`with an empty apply-action name — an empty member aliases the absent-state sentinel ("") so the menu would render open before any click. Name the apply action`;if(ZO(e)===`closed`)return`whose apply action is named "${Or}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function OL(e,t){let n={},r={},i=new Map,a=new Set,o=(e,n)=>{let r=`segments.${e}`;a.has(`${r}\0${n}`)||(a.add(`${r}\0${n}`),t.push({path:r,message:n}))};for(let t of ky(e.presets)){let a=new Map,s=new Map;for(let c of Zh(My(e,t).node)){if(c.kind!==`segment`)continue;let t=e.segments[c.name];if(t===void 0)continue;i.has(c.name)||i.set(c.name,CL(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=qh(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||DL(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=ZO(i),f=QO(u,i,l.key),p=tk(f),m=l.key===void 0?`ind ${u} ${i}`:`key ${l.key}`,h=[f,p].find(e=>{let t=a.get(e);return t!==void 0&&t!==m});if(h!==void 0){o(c.name,`two {{ menu }} disclosures normalize to the same state key ("${h}") but were declared differently — distinct names that differ only by non-alphanumeric characters (e.g. "a-b" vs "a_b") collapse to one key and would silently share open-state. Rename so they don't collide.`);continue}a.set(f,m),a.set(p,m);let g=ek(f,d),_=`${c.name}\0${e}`,v=s.get(g);if(v!==void 0&&v!==_){o(c.name,`two {{ menu }} disclosures resolve to the same identity ("${g}") — ${l.key===void 0?`a segment cannot contain two menus over the same apply action "${i}"`:`menus sharing key "${l.key}" must have distinct apply actions`}.`);continue}s.set(g,_),r[g]=Br(f,d),n[f]=zr(f,Or),n[p]={kind:`state`,key:p,default:`0`},r[p]={set:p,int:!0}}}}return{...e,variables:{...e.variables,...n},actions:{...e.actions,...r}}}const kL=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`ceiling`,`slash`,`do`];function AL(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function jL(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function ML(e,t){if(t===void 0)return{};if(!Mg(t))return Z(e,`actions`,`actions must be an object, got ${Ng(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=NL(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Z(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))})}function NL(e,t,n){if(!Mg(n))return Z(e,t,`${t} must be an action object, got ${Ng(n)}`),null;if(`persistWhen`in n)return Z(e,t,`${t}.persistWhen was removed: declare the \`set\` alone — a session pick is a draft until a \`{ save: true }\` action writes every unsaved setting to the config file`),null;let r=kL.filter(e=>e in n);return r.length===1?PL[r[0]](e,t,n):(Z(e,t,`action must declare exactly one of: ${kL.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const PL={set:(e,t,n)=>mR(e,t,n,`set`,uR),persist:(e,t,n)=>mR(e,t,n,`persist`,dR),copy:FL(`copy`),open:FL(`open`),reset:IL,undo:RL(`undo`),redo:RL(`redo`),back:RL(`back`),rewind:RL(`rewind`),save:RL(`save`),preset:zL,themeDefault:BL,doctor:HL,ceiling:UL,slash:WL,do:GL};function FL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=Dg(t,n,r,e);return i===null?null:{[e]:i}}}function IL(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=KL(e,t,`reset`,n,`reset key must be non-empty (the config globals field to clear)`,e=>`reset key "${e}" contains "/" — keys must be slash-free`);return r===null?null:{reset:r}}const LL={undo:`it steps the session's settings history`,redo:`it steps the session's settings history`,back:`it steps the session's navigation history`,rewind:`it steps the session's settings history back to where edit mode opened`,save:`it saves the session's unsaved settings`};function RL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Z(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${LL[e]}), got ${q(r[e])}`),null)}}function zL(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Z(e,`${t}.preset`,`preset must be "save" or "delete", got ${q(r)}`),null;if(r===`save`)return{preset:`save`};let a=Dg(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function BL(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(Z(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${q(n.themeDefault)}`),null)}const VL={run:[`doctor`],fix:[`doctor`,`check`],mark:[`doctor`,`check`,`mark`]};function HL(e,t,n){let r=n.doctor,i=typeof r==`string`&&Object.hasOwn(VL,r),a=i?VL[r]:[...new Set(Object.values(VL).flat())];for(let r of Object.keys(n))a.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${a.join(`, `)}`);if(!i)return Z(e,`${t}.doctor`,`doctor must be ${Object.keys(VL).map(e=>`"${e}"`).join(`, `)}, got ${q(r)}`),null;if(r===`run`)return{doctor:`run`};let o=n.check,s=r===`mark`?fM:dM;if(typeof o!=`string`||!s.some(e=>e.name===o))return Z(e,`${t}.check`,`doctor ${r} must name a check (have: ${s.map(e=>e.name).join(`, `)}), got ${q(o)}`),null;if(r===`fix`)return{doctor:`fix`,check:o};let c=n.mark;return Cj.includes(c)?{doctor:`mark`,check:o,mark:c}:(Z(e,`${t}.mark`,`doctor mark must be ${Cj.map(e=>`"${e}"`).join(` or `)}, got ${q(c)}`),null)}function UL(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Z(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${q(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Z(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${q(a)}`),null):{ceiling:`set`,to:a}}function WL(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=zM(n.slash);return r.kind===`refused`?(Z(e,`${t}.slash`,r.reason),null):{slash:r.line}}function GL(e,t,n){for(let r of Object.keys(n))r!==`do`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(Z(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${q(r)}`),null):{do:r}}function KL(e,t,n,r,i,a){let o=Dg(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Z(e,s,i),null):o.includes(`/`)?(Z(e,s,a(o)),null):o}const qL={set:`the SessionState key to write`,persist:`the config globals field to write`};function JL(e,t,n,r){let i=qL[r],a=KL(e,t,r,n,`${r} key must be non-empty (${i})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);return a===null?null:{[r]:a}}function YL(e){return e===`set`?`set-state`:`set-config`}const XL={to:hR(`set`)},ZL={to:hR(`persist`)},QL={from:gR(`set`)},$L={from:gR(`persist`)},eR={min:xR(),max:xR(),by:xR()},tR={int:vR()},nR={cycle:_R(`set`)},rR={cycle:_R(`persist`)},iR={removeSegment:yR(`removeSegment`)},aR={insertSegment:yR(`insertSegment`),anchor:yR(`anchor`),relation:bR()},oR={insertSegmentFrom:gR(`persist`),anchor:yR(`anchor`),relation:bR()},sR={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},cR={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function lR(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>Ig(e,t,n,r),c=e_(t);return{detect:a,allowed:[...o,...i],label:i.join(`/`),json:{type:`object`,properties:{...Object.fromEntries(o.map(e=>[e,{type:`string`}])),...c.properties},required:[...o,...c.required??[]],additionalProperties:!1},parse:n.length?Wg(s,...n):s}}const uR=[lR(`set`,XL),lR(`set`,QL),lR(`set`,eR,[sR,cR]),lR(`set`,tR),lR(`set`,nR)],dR=[lR(`persist`,ZL),lR(`persist`,$L),lR(`persist`,eR,[sR,cR]),lR(`persist`,rR),lR(`persist`,iR),lR(`persist`,aR,[],[`insertSegment`]),lR(`persist`,oR,[],[`insertSegmentFrom`])];function fR(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"endcaps"/"styles", or an inline array of literal values)`,`"min"/"max"/"by" (a bounded step)`];return e===`set`&&t.push(`"int" (an unbounded integer cursor)`),t.push(`"cycle" (an enumerated domain stepped in order)`),e===`persist`&&t.push(`"removeSegment" (remove a named segment from the layout)`,`"insertSegment"/"anchor"/"relation" (insert a named segment before/after an existing one)`,`"insertSegmentFrom"/"anchor"/"relation" (insert a segment PICKED from an option domain before/after an existing one)`),t}function pR(e){let t=fR(e),n=t[t.length-1];return`a ${e} action declares exactly one value source: ${t.length===1?n:`${t.slice(0,-1).join(`, `)}, or ${n}`}`}function mR(e,t,n,r,i){let a=JL(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Z(e,t,`${pR(r)}${o.length>1?` — found: ${o.map(e=>e.label).join(`, `)}`:``}`),null;let s=o[0];for(let i of Object.keys(n))s.allowed.includes(i)||Z(e,`${t}.${i}`,`Unknown key "${i}" on this ${r} action. Expected one of: ${s.allowed.join(`, `)}`);let c=s.parse(e,t,n);return a===null||c===null?null:{...a,...c}}function hR(e){let t=YL(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>KL(n,r,i,a,`${e} value must be non-empty — an empty value cannot be delivered on the ${t} wire`,t=>`${e} value "${t}" contains "/" — ${e} values must be slash-free`)??void 0}}function gR(e){let t=YL(e);return{required:!0,json:{anyOf:[{type:`string`,minLength:1},{type:`array`,items:{type:`string`,minLength:1},minItems:1,uniqueItems:!0}]},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(typeof o==`string`){if(o===``){Z(n,s,`${i} must be a non-empty domain name`);return}return o}if(Array.isArray(o)&&o.every(e=>typeof e==`string`)){let r=o;if(r.length===0){Z(n,s,`${i} must name a domain (a non-empty string) or declare an inline domain (a non-empty array of values)`);return}if(r.some(e=>e===``)){Z(n,s,`${i} array members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}let a=r.filter(e=>e.includes(`/`));if(a.length>0){Z(n,s,`${i} array member(s) ${a.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(r).size!==r.length){Z(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Z(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${q(o)}`)}}}function _R(e){let t=YL(e);return{required:!0,json:{type:`array`,items:{type:`string`,minLength:1},minItems:2,uniqueItems:!0},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(!Array.isArray(o)||o.some(e=>typeof e!=`string`)){Z(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${Ng(o)}`);return}let c=o;if(c.length<2){Z(n,s,`cycle needs at least two members (one member has no successor — use a literal "to")`);return}let l=c.some(e=>e===``),u=c.filter(e=>e.includes(`/`));if(l){Z(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Z(n,s,`cycle member(s) ${u.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(c).size!==c.length){Z(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function vR(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Z(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${q(r[n])}`);return}return!0}}}function yR(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Dg(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Z(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Z(t,o,`${e} "${a}" contains "/" or ":" — segment names in a layout op must be free of both (the click wire's own delimiter and layout-ops.ts's op-token delimiter)`);return}return a}}}function bR(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Z(e,`${t}.${n}`,`relation must be "before" or "after", got ${q(i)}`);return}return i}}}function xR(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Z(e,`${t}.${n}`,`${n} must be an integer, got ${q(i)}`);return}return i}}}function SR(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const CR={noun:`style key`,fields:{hueShift:Jg(),chromaScale:Jg({min:0}),lightnessScale:Jg(),lightnessShift:Jg()}};function wR(e,t){if(!Mg(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${Ng(t)}`,line:K(e.source,[`styles`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`styles.${r}`,message:`style name ${JSON.stringify(r)} must be non-empty and slash-free — a style picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:K(e.source,[`styles`,r])});continue}if(Ph(r)){e.issues.push({path:`styles.${r}`,message:SR(`styles.${r}`,r,`globals.endcaps`),line:K(e.source,[`styles`,r])});continue}let t=Pg(e,CR,`styles.${r}`,i);t!==null&&(n[r]={...nc,...t})}return n}const TR={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:cL(e,`${t}.${n}`,r[n])},globals:{required:!1,json:Ak(),parse:(e,t,n,r)=>r[n]===void 0?void 0:kk(e,`${t}.${n}`,r[n])}}};function ER(e,t){if(!Mg(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${Ng(t)}`,line:K(e.source,[`presets`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)||/[\n\r]/.test(r)){e.issues.push({path:`presets.${r}`,message:`preset name ${JSON.stringify(r)} must be non-empty, slash-free, and newline-free — a preset picker writes the name on the set-state wire (which rejects empty values and splits on "/"), and edit mode splices it into a synthesized template string`,line:K(e.source,[`presets`,r])});continue}let t=Pg(e,TR,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function DR(e,t){if(t===void 0)return{};if(!Mg(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${Ng(t)}`,line:K(e.source,[`helpers`])}),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){if(typeof i!=`string`){e.issues.push({path:`helpers.${r}`,message:`helpers.${r} must be a string template body, got ${q(i)}`,line:K(e.source,[`helpers`,r])});continue}n[r]=i}return n}const OR=new Map([[`session.budget.amount`,{segment:`session`,setting:`budget`}],[`session.budget.warningThreshold`,{segment:`session`,setting:`warnAt`}],[`today.budget.amount`,{segment:`today`,setting:`budget`}],[`today.budget.warningThreshold`,{segment:`today`,setting:`warnAt`}],[`block.budget.heatThreshold`,{segment:`block`,setting:`warnAt`}],[`block.budget.warningThreshold`,{segment:`block`,setting:`errorAt`}],[`weekly.budget.heatThreshold`,{segment:`weekly`,setting:`warnAt`}],[`weekly.budget.warningThreshold`,{segment:`weekly`,setting:`errorAt`}],[`burn.eta.errorMinutes`,{segment:`burnrate`,setting:`errorWithin`}],[`burn.eta.warnMinutes`,{segment:`burnrate`,setting:`warnWithin`}]]);function kR(e){return`it became the "${e.setting}" setting of each "${e.segment}" placement — set it on the placement where a row places "${e.segment}" ({ seg: "${e.segment}", settings: { ${e.setting}: <value> } }), or redeclare segments.${e.segment}.settings.${e.setting} with the default every placement should start from`}function AR(e){let t=OR.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${kR(t)}`}function jR(e){let t=OR.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${kR(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function MR(e,t){let n=new Map;for(let e of Object.keys(t)){let t=UO(e),r=n.get(t);r?r.push(e):n.set(t,[e])}for(let[t,r]of n)r.length<2||e.issues.push({path:`presets`,message:`preset names ${r.map(e=>JSON.stringify(e)).join(` and `)} both collapse to the same synthesis identifier "${t}" — edit mode's synthesized reset affordance would silently steal one preset's action for the other. Rename one.`,line:K(e.source,[`presets`])})}function NR(e,t,n){let r=[[[`globals`],t.globals.style,`globals.endcaps`],[[`editGlobals`],t.editGlobals.style,`editGlobals.endcaps`],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style,`presets.${e}.globals.endcaps`]),...Object.entries(t.themeDefaults).map(([e,t])=>[[`themeDefaults`,e],t.style,`globals.endcaps`])];for(let[n,i,a]of r){if(i===void 0||_h(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:Ph(i)?SR(r,i,a):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:K(e.source,[...n,`style`])})}t.globals.preset!==void 0&&!Object.prototype.hasOwnProperty.call(t.presets,t.globals.preset)&&e.issues.push({path:`globals.preset`,message:`globals.preset "${t.globals.preset}" does not match any declared preset (have: ${Object.keys(t.presets).join(`, `)})`,line:K(e.source,[`globals`,`preset`])}),MR(e,t.presets);let i=cb(t);for(let t of i.names)t!==`settings`&&!t.startsWith(IR)||e.issues.push({path:`variables`,message:`variable "${t}" is named under "settings", which a segment's templates read as its placement's own settings (.settings.<name>) — rename it`,line:K(e.source,[`variables`,t])});let a=(t,n,r)=>{yP(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${ZM}" ${yP(t)} times — it may appear at most once per layout (it is one disclosure, and one state key holds one open state). Remove all but the placement you want; removing every placement puts the menu at its default position.`,line:r}),bP(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${ZM}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r}),o(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and shade, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of Zh(t)){if(e.kind!==`segment`)continue;let t=qh(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=Yh(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.length} placements with the id "${t}" — an id names one placement (its settings, its menus' open state, and edit mode all address it), so give each its own: { seg: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function o(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>o(n,t||Kh[e.direction]===`cell`))}let s=(n,r)=>{for(let[a,o]of wy(n,r)){let n=K(e.source,o.split(`.`));if(a.when!==void 0&&(JR(e,`${o}.when`,a.when,i,{line:n}),qR(e,`${o}.when`,a.when,n)),a.kind===`segment`){if(gP(a.name)){(a.id!==void 0||a.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${ZM}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${ZM}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,a.name)||e.issues.push({path:o,message:`${r} entry "${a.name}" does not match any declared segment${xI(a.name)}`,line:n}),WR(e,t,a,o,n)}}};n.root!==void 0&&s(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&s(t.root,`presets.${e}.root`);let c=new Map([[`root`,Sy(t.root)]]);for(let e of ky(t.presets)){let{node:n,path:r}=My(t,e);c.set(r,n)}for(let[t,n]of c)a(n,t,K(e.source,t.split(`.`)));tz(e,t,i,()=>!0)}const PR=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function FR(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=K(e.source,[`actions`,n,r]);if(!ky(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${ky(t.presets).join(`, `)})`,line:c});return}if(r===`reset`)return;let l=`removeSegment`in o,u=`insertSegment`in o,d=`insertSegmentFrom`in o;if(!l&&!u&&!d){e.issues.push({path:s,message:`actions.${n}: "${i}" is a "presets.<name>.root" target and can only be paired with "removeSegment", "insertSegment", or "insertSegmentFrom" (not "to"/"from"/"cycle"/bounded — those have no meaning as a tree op)`,line:c});return}let f=(r,i)=>{Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})${xI(i)}`,line:c})},p=new Set(Jh(My(t,a).node)),m=(r,i)=>{!bI.has(i)||p.has(i)||Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" names no placement${xI(i)}`,line:c})};`removeSegment`in o&&m(`removeSegment`,o.removeSegment),`insertSegment`in o&&f(`insertSegment`,o.insertSegment),(`insertSegment`in o||`insertSegmentFrom`in o)&&m(`anchor`,o.anchor)}const IR=`settings.`;function LR(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>IR+e)])}}function RR(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:K(e.source,[`segments`,t,`settings`,n])})},a=VR(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of mg(n,BR(n)))i(e,`the defaults do not stand together: ${t}`)}function zR(e){return VR(e).length>0||mg(e,BR(e)).length>0}function BR(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function VR(e){let t=t=>pg(HR(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||pg(HR(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${UR(e,n).join(`, `)||`none`})`}];let i=[n];for(let e=r;e!==void 0;e=t(e)){if(e===n)return i.every(e=>n<=e)?[{setting:n,message:`atLeast closes a cycle (${[...i,n].join(` ≥ `)}) — every setting on it could only ever equal the rest`}]:[];if(i.includes(e))return[];i.push(e)}return[]})}function HR(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function UR(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&pg(n)!==void 0).map(([e])=>e)}function WR(e,t,n,r,i){let a=Object.prototype.hasOwnProperty.call(t.segments,n.name)?t.segments[n.name]:void 0;if(a===void 0)return;let o=fg(a),s=`${r}: placement "${qh(n)}" of segment "${n.name}"`;for(let[t,a]of Object.entries(n.settings??{})){let c=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0,l=c===void 0?`sets "${t}", which segment "${n.name}" does not declare (it has: ${Object.keys(o).join(`, `)})`:hg(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?ch(a):``}, but it must be ${yg(c)}`;l!==void 0&&e.issues.push({path:r,message:`${s} ${l}`,line:i})}let c=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,n.settings?.[e]??t.default]));if(!(!Object.entries(c).every(([e,t])=>hg(o[e],t))||zR(o)))for(let{message:t}of mg(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function GR(e,t,n,r,i){n.kind===`template`&&JR(e,`${t}.template`,n.template,r,{segCtx:i}),ig(n)&&`key`in n.cache&&JR(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function KR(e,t,n,r,i){if(!(!ig(n)||!(`depends_on`in n.cache)))for(let a=0;a<n.cache.depends_on.length;a++){let o=n.cache.depends_on[a];if(r.names.has(o))continue;let s=i===void 0?void 0:`${i}.${o}`,c=s!==void 0&&r.names.has(s)?` (segment-local vars are namespaced — write "${s}")`:``;e.issues.push({path:`${t}.cache.depends_on[${a}]`,message:`cache.depends_on references unknown variable "${o}"${c}`,line:K(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function qR(e,t,n,r){try{Zk.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function JR(e,t,n,r,i){for(let[a,o]of eb(n,r.helpers)){if(sb(a,r))continue;if(a.startsWith(IR)){let n=o===null?``:` through helper "${o}"`,r=a.slice(9),s=i?.segCtx===void 0||i.settings===void 0?`Template reads ".${a}"${n}, but only a segment's own templates have settings — call it from a segment that declares "${r}"`:`Template reads ".${a}"${n}, but segment "${i.segCtx}" has no setting "${r}" (it has: ${Object.keys(i.settings).join(`, `)}) — declare it under segments.${i.segCtx}.settings`;e.issues.push({path:t,message:s,line:i?.line??K(e.source,t.split(`.`))});continue}if(o!==null){YR(e,o,`Template references unknown variable ".${a}"${jR(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&sb(n,r)?` (segment-local vars are namespaced — write ".${n}")`:jR(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??K(e.source,t.split(`.`))})}}function YR(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:K(e.source,[`helpers`,t])})}function XR(e,t,n,r,i){let a=n.set,o=mk(V_[r].configKey),s=`${a} takes ${ck(o,i)}`;if(`min`in n&&(o===`bool`||!(`min`in o))){e.issues.push({path:`actions.${t}.min`,message:`actions.${t}: a stepper writes the integers from ${n.min} to ${n.max}, and ${a} is not an integer range; ${s}`,line:K(e.source,[`actions`,t,`min`])});return}let c=$R(n,i);if(c===QR){e.issues.push({path:`actions.${t}.int`,message:`actions.${t}.int: an int cursor writes whatever integer the template binds, and a click outside the ${a} domain would change nothing; ${s}`,line:K(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!sk(o,e.value,i));if(l.length!==0){if(a===V_.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>Ph(e.value)))){let r=V_.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:SR(`actions.${t}.to`,n.to,`set: "${r}", to`),line:K(e.source,[`actions`,t,`to`])}:{path:`actions.${t}.set`,message:`actions.${t}.set: "${a}" here writes only endcaps shapes, not styles — endcaps were renamed from "style" to "endcaps"; write set: "${r}"`,line:K(e.source,[`actions`,t,`set`])});return}for(let n of new Set(l.map(e=>e.field))){let r=l.filter(e=>e.field===n).map(e=>JSON.stringify(e.value)),i=r.length<=ZR?r.join(`, `):`${r.slice(0,ZR).join(`, `)} and ${r.length-ZR} more`,o=`actions.${t}.${n}`;e.issues.push({path:o,message:`${o}: ${i} ${r.length===1?`is`:`are`} outside the ${a} domain — a click would write it and nothing would change; ${s}`,line:K(e.source,[`actions`,t,n])})}}}const ZR=3,QR=Symbol(`any integer`);function $R(e,t){return`to`in e?[{field:`to`,value:e.to}]:`cycle`in e?e.cycle.map(e=>({field:`cycle`,value:e})):`from`in e?zy(e.from,t).members.map(e=>({field:`from`,value:e})):`min`in e?[{field:`min`,value:String(e.min)},{field:`max`,value:String(e.max)}]:QR}function ez(e,t){return Object.entries(e).filter(([e])=>t(e))}function tz(e,t,n,r){let i=JP(t),a=Ry(i);for(let[n,o]of ez(t.actions,r)){let[t,r]=`from`in o?[`from`,o.from]:`insertSegmentFrom`in o?[`insertSegmentFrom`,o.insertSegmentFrom]:[null,null];if(t!==null&&typeof r==`string`&&!a.includes(r)){e.issues.push({path:`actions.${n}.${t}`,message:`actions.${n} ${t}: references ${Vy(r,i)}`,line:K(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;G_.has(o.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${o.set}", which has no session pick — globals.${o.set} is set in the config file only, so a click would change nothing; write it with { persist: "${o.set}", … } instead`,line:K(e.source,[`actions`,n,`set`])});let s=Y_.get(o.set);s!==void 0&&XR(e,n,o,s,i)}for(let[n,i]of ez(t.actions,r))`do`in i&&i.do.forEach((r,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,r)?t.actions[r]:void 0,s=o===void 0?`references unknown action "${r}"`:`do`in o?`"${r}" is itself a do action — list its members here instead`:i.do.indexOf(r)===a?a>0&&jL(o)?`"${r}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${r}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:K(e.source,[`actions`,n,`do`])})});for(let[n,i]of ez(t.actions,r)){let r=`persist`in i?i.persist:`reset`in i?i.reset:null;if(r===null)continue;let a=`persist`in i?`persist`:`reset`,o=Kk(r);if(o===null){let t=Pk(r);e.issues.push({path:`actions.${n}.${a}`,message:t===void 0?`actions.${n}: "${r}" is not a config globals field (have: ${Fk().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, a "themeDefaults.<theme>.<shade|variation|style>" target, or a "presets.<name>.root" target`:`actions.${n}: the globals field "${r}" was removed: ${t}`,line:K(e.source,[`actions`,n,a])});continue}let s=PR.filter(e=>e in i);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){FR(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!ky(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names preset "${o.preset}" which is not declared (have: ${ky(t.presets).join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`theme-default`&&!e.allowedPalettes.has(o.theme)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names theme "${o.theme}" which is not installed${ch(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`segment-palette`){if(!Object.prototype.hasOwnProperty.call(t.segments,o.segment)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${xI(o.segment)}`,line:K(e.source,[`actions`,n,a])});continue}`min`in i&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:K(e.source,[`actions`,n,a])})}}for(let[i,a]of ez(t.variables,r)){GR(e,`variables.${i}`,a,n);let t=AR(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:K(e.source,[`variables`,i])})}for(let[i,a]of ez(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))GR(e,`segments.${i}.vars.${t}`,r,n,i);let r=fg(a);RR(e,i,r);let o=LR(n,r);for(let n of[`template`,`bg`,`fg`,`when`]){let s=a[n];if(typeof s==`string`){JR(e,`segments.${i}.${n}`,s,o,{segCtx:i,settings:r});for(let{name:r,site:a,via:o}of ib(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=a===`options`?` (in a picker, menu, carousel, swatch, swatches or themePreview)`:``;if(o!==null){YR(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${i}.${n}`,message:`${n} references unknown action "${r}"${s}`,line:K(e.source,[`segments`,i,n])})}}}}for(let[i,a]of ez(t.variables,r))KR(e,`variables.${i}`,a,n);for(let[i,a]of ez(t.segments,r))if(a.vars)for(let[t,r]of Object.entries(a.vars))KR(e,`segments.${i}.vars.${t}`,r,n,i)}function nz(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=rz(t),a=new Map,o=[];for(let e of r.keys())a.set(e,0);for(let e of r.keys())if(!(!n(e)||a.get(e)!==0)&&s(e))return;function s(t){a.set(t,1),o.push(t);for(let c of r.get(t)??[]){if(!n(c))continue;let t=a.get(c);if(t===1){let t=o.indexOf(c),n=[...o.slice(t),c],r=n[0],a=i.get(r);return e.issues.push({path:a?.declarationPath??`variables.${r}`,message:`Dependency cycle: ${n.join(` → `)}`,line:K(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function rz(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of eb(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),ig(n)&&(`key`in n.cache&&i(e,n.cache.key),`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}function iz(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?S.homedir()+e.slice(1):e}function az(e,t){return s.resolve(e,iz(t))}function oz(e,t){return typeof t==`string`&&t!==``?az(e,t):void 0}function sz(e){return`plugin ${e.path} was not loaded: ${e.reason}`}const cz=new Set([`data`,`segments`,`helpers`,`actions`]),lz=`plugin.json5`,uz=/^[a-z][a-z0-9_]*$/;function dz(e){let t=s.basename(s.dirname(e));return uz.test(t)?t:void 0}const fz=`plugins.`;function pz(e){return`${fz}${e}.data`}function mz(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,reason:hz(e)}}}function hz(e){return e instanceof Sg?e.issues.map(e=>e.path===``||e.message.includes(e.path)?e.message:`${e.path}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function gz(e,t){return e.map(e=>az(s.dirname(t),e))}function _z(e,t,n,r){let i=new Map;return e.reduce((e,n)=>{let a=dz(n),o=(t,r)=>{let i=new Map(e.rendering);return a!==void 0&&r!==e.config&&i.delete(a),{...e,config:r,rendering:i,dropped:[...e.dropped,{path:n,plugin:a,reason:t}]}};if(s.basename(n)!==`plugin.json5`){let t=`a plugin is a folder holding its ${lz}, and the folder's name is the plugin's: move this file to <dir>/<name>/${lz} and list that`;return o(t,a===void 0?e.config:bz(yz(e.config,a),a,{path:n,plugin:a,reason:t}))}if(a===void 0)return o(`its folder "${s.basename(s.dirname(n))}" is not a plugin name (one matching ${uz}: it prefixes every name the plugin declares)`,e.config);let c=i.get(a);if(c!==void 0)return o(`plugin "${a}" is already listed, from ${c}`,e.config);i.set(a,n);let l=yz(e.config,a),u=mz(()=>{let i=p.readFileSync(n,`utf-8`),o=PF(Ez(n,a,{source:i,json:Jr.default.parse(i)},t),l);return r(o,a,l!==e.config),o});if(u.ok)return{...e,config:u.value,loaded:[...e.loaded,n],rendering:new Map([...e.rendering,[a,n]])};let d={path:n,plugin:a,reason:u.reason};return o(u.reason,bz(l,a,d))},{config:n.config,rendering:n.rendering,loaded:[],dropped:[]})}function vz(e){let t=`${fz}${e}.`;return e=>e.startsWith(t)}function yz(e,t){let n=vz(t),r=e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n(e)));return[e.variables,e.segments,e.helpers,e.actions].some(e=>Object.keys(e).some(n))?{...e,variables:r(e.variables),segments:r(e.segments),helpers:r(e.helpers),actions:r(e.actions)}:e}function bz(e,t,n){return{...e,variables:{...e.variables,[pz(t)]:{kind:`dropped`,reason:sz(n),definition:n.path}}}}function xz(e){return e.startsWith(`plugins.`)?e.slice(8).split(`.`)[0]:void 0}function Sz(e,t){let n=new Set([...Object.keys(e.config.variables),...Object.keys(e.config.segments)].map(xz)),r=[...t,...e.dropped].filter(e=>e.plugin===void 0).map(e=>({definition:e.path,notice:sz(e)}));return t=>{let i=xz(t);if(i===void 0)return[];let a=e.config.variables[pz(i)];return a?.kind===`dropped`?[{definition:a.definition,notice:a.reason}]:n.has(i)?[]:r}}function Cz(e,t){let n=ky(e.presets).flatMap(t=>[...Zh(My(e,t).node)]).flatMap(e=>e.kind===`segment`?[e]:[]),r=[...new Set([...n.map(e=>e.name),...Object.keys(e.segments)])].map(e=>({name:e,cause:t(e)})).filter(({cause:e})=>e.length>0),i=Object.fromEntries(r.map(({name:e,cause:t})=>[e,wz(e,t.map(e=>e.notice),n.filter(t=>t.name===e))])),a=t=>{let n=xz(t),r=n===void 0?void 0:e.variables[pz(n)];return r?.kind===`dropped`?{definition:r.definition,notice:r.reason}:void 0},o=Object.values(e.variables).some(e=>e.kind===`dropped`),s=o?Object.values(e.segments).flatMap(e=>[`template`,`bg`,`fg`,`when`].flatMap(t=>e[t]===void 0?[]:[e[t]])):[],c=o?Object.values(e.actions).flatMap(e=>`do`in e?[...e.do]:[]):[],l=(e,t)=>[...new Set(e)].flatMap(e=>{let n=e in t?void 0:a(e);return n===void 0?[]:[[e,n]]}),u=l([...s.flatMap(t=>ib(t,e.helpers).map(e=>e.name)),...c],e.actions),d=l(s.flatMap(t=>[...ob(t,e.helpers)]),e.helpers),f=new Set([...r.flatMap(({cause:e})=>e.map(e=>e.definition)),...[...u,...d].map(([,e])=>e.definition)]);return{config:{...e,segments:{...e.segments,...i},actions:{...e.actions,...Object.fromEntries(u.map(([e])=>[e,{copy:`{{ .${pz(xz(e)??``)} }}`}]))},helpers:{...e.helpers,...Object.fromEntries(d.map(([e,t])=>[e,`{{ fail ${JSON.stringify(t.notice)} }}`]))}},reached:f}}function wz(e,t,n){let r=`⚠ ${e}: ${t.join(`; `)}`,i=new Map;for(let e of n)for(let[t,n]of Object.entries(e.settings??{})){let e=i.get(t);i.set(t,e===void 0?[n]:[...e,n])}let a=Object.fromEntries([...i].map(([e,t])=>[e,Tz(e,t)]));return{template:`{{ ${JSON.stringify(r)} }}`,bg:`error`,description:`stands in for a segment whose plugin did not load`,settings:a}}function Tz(e,t){let[n]=t,r=t.filter(e=>typeof e==`number`);return typeof n==`boolean`?{label:e,domain:`bool`,default:n}:typeof n==`number`?{label:e,domain:{min:Math.min(...r),max:Math.max(...r),step:1},default:n}:{label:e,domain:[...new Set(t.map(String))],default:n}}function Ez(e,t,{source:n,json:r},{checkout:i}){let a=[],o=()=>{throw new Sg(e,a)};if(!Mg(r))return a.push({path:``,message:`a plugin definition must be an object, got ${Ng(r)}`}),o();for(let e of Object.keys(r))cz.has(e)||a.push({path:e,message:e===`plugin`?`a plugin definition does not name itself: its name is its folder's ("${t}") — remove "plugin"`:`a plugin definition may not declare "${e}". Expected only: ${[...cz].join(`, `)}`});let s=Mz(r.data,e,i,a);if(Mg(r.segments)||a.push({path:`segments`,message:`"segments" must be an object naming the plugin's segments`}),a.length>0||s===void 0)return o();let c={source:n,issues:a,allowedPalettes:new Set(dh()),groups:[]},l=GF(c,`data`,{[pz(t)]:{kind:`file`,path:s,parse:{json:!0},cache:{watch_file:s},default:{}}});for(let[e,t]of Object.entries(r.segments))if(!(!Mg(t)||!Mg(t.vars)))for(let[n,r]of Object.entries(t.vars)){let t=Mg(r)?r.kind:void 0;typeof t!=`string`||t===`state`||a.push({path:`segments.${e}.vars.${n}`,message:`a plugin segment's vars may declare only state variables (kind: "state"), never a source such as ${JSON.stringify(t)}: a plugin's only source is its data file`})}let u={variables:l,segments:Oz(t,Az(t,zI(c,r.segments,new Set))),helpers:Oz(t,DR(c,r.helpers)),actions:Oz(t,jz(t,ML(c,r.actions)))};for(let[e,t]of Dz(u))try{Zk.parse(t)}catch(t){a.push({path:e,message:`Template parse error in ${e}: ${t.message}`})}return a.length>0&&o(),u}function*Dz(e){for(let[t,n]of Object.entries(e.segments??{}))for(let e of[`template`,`bg`,`fg`,`when`]){let r=n[e];r!==void 0&&(yield[`segments.${t}.${e}`,r])}for(let[t,n]of Object.entries(e.helpers??{}))yield[`helpers.${t}`,`{{ define "${t}" }}${n}{{ end }}`];for(let[t,n]of Object.entries(e.actions??{}))`copy`in n&&(yield[`actions.${t}.copy`,n.copy]),`open`in n&&(yield[`actions.${t}.open`,n.open]),`preset`in n&&n.preset===`delete`&&(yield[`actions.${t}.name`,n.name])}function Oz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[`${fz}${e}.${t}`,n]))}function kz(e,t){return`${fz}${e}.${t}`}function Az(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.vars===void 0?n:{...n,vars:Object.fromEntries(Object.entries(n.vars).map(([t,n])=>[t,n.kind===`state`?{...n,key:kz(e,n.key)}:n]))}]))}function jz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,`set`in n?{...n,set:kz(e,n.set)}:n]))}function Mz(e,t,n,r){if(typeof e==`string`&&e!==``)return az(s.dirname(t),e);if(Mg(e)&&Object.keys(e).length===1&&typeof e.checkout==`string`&&e.checkout!==``){let t=e.checkout;if(s.isAbsolute(t)||t.startsWith(`~`)||s.normalize(t).split(s.sep)[0]===`..`){r.push({path:`data.checkout`,message:`data.checkout "${t}" must be a path inside the checkout, relative to its root (like ".lit/statusline.json"): no absolute path, "~" or ".."`});return}if(n===null){r.push({path:`data.checkout`,message:`data is read from the session's checkout, and this load has no session`});return}return s.resolve(n.root,t)}if(Mg(e)&&`project`in e){r.push({path:`data.project`,message:`data: { project } is now data: { checkout }: the same path, relative to the root of the git checkout the session works in (a linked worktree is its own checkout)`});return}r.push({path:`data`,message:`"data" must be the path of the plugin's JSON data file relative to this definition, or { checkout: "<path>" } relative to the root of the session's checkout`})}function Nz(e){let t=[...[...(process.env.XDG_DATA_DIRS||Iz()).split(`:`).filter(e=>e!==``)].reverse().map(e=>s.join(e,`cc-candybar`,`plugins`)),Pz(),...e===null?[]:[s.join(e,Fz)]];return t.filter((e,n)=>t.lastIndexOf(e)===n)}function Pz(){let e=process.env.XDG_DATA_HOME||s.join(S.homedir(),`.local`,`share`);return s.join(e,`cc-candybar`,`plugins`)}const Fz=s.join(`.cc-candybar`,`plugins`);function Iz(){let e=`/usr/local/share:/usr/share`;return process.platform===`darwin`?`${s.join(process.env.HOMEBREW_PREFIX||`/opt/homebrew`,`share`)}:${e}`:e}function Lz(e){let t=Nz(e),n=new Map,r=[],i=[];for(let e of t){let t=Rz(e);if(`error`in t){r.push(t);continue}for(let r of t.folders)n.delete(r),n.set(r,s.join(e,r,lz));for(let n of t.files)i.push({path:s.join(e,n),plugin:void 0,reason:`a plugin is a folder holding its ${lz}: move this file to ${s.join(e,`<name>`,lz)}`})}return{roots:t,definitions:[...n.values()],unchecked:r,strays:i}}function Rz(e){try{let t=p.readdirSync(e,{withFileTypes:!0}).filter(e=>!e.name.startsWith(`.`)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),n=t=>t.isDirectory()||zz(e,t);return{folders:t.filter(n).map(e=>e.name),files:t.filter(e=>!n(e)).map(e=>e.name)}}catch(t){return t.code===`ENOENT`?{folders:[],files:[]}:{path:e,error:t.message}}}function zz(e,t){if(!t.isSymbolicLink())return!1;try{return p.statSync(s.join(e,t.name)).isDirectory()}catch{return!0}}const Bz=[`json5`,`json`];function Vz(e){try{return p.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function Hz(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Bz.map(t=>s.join(e,`.cc-candybar.${t}`)):[],...Bz.map(e=>s.join(r,`.cc-candybar.${e}`)),...Bz.map(e=>`${Uz()}.${e}`)])]}function Uz(){let e=process.env.XDG_CONFIG_HOME??s.join(S.homedir(),`.config`);return s.join(e,`cc-candybar`,`config`)}function Wz(e,t,n){let r=[],i=new Map;for(let a of Hz(e,t,n)){let e=Vz(a);if(e===`absent`)continue;if(e!==`present`){r.push(e);continue}let t=s.join(p.realpathSync(s.dirname(a)),s.basename(a).replace(/\.(json5|json)$/,``));i.has(t)||i.set(t,a)}let a=[...i.values()].reverse();if(n===void 0)return{kind:`chain`,layers:a,home:Gz(a),unchecked:r};let[o]=r,c=n;return a.length>0?{kind:`chain`,layers:a,home:c,unchecked:r}:o===void 0?{kind:`missing`,path:n,home:c}:{kind:`unreadable`,...o,home:c}}function Gz(e){let t=Uz();return e.find(e=>Bz.some(n=>e===`${t}.${n}`))??`${t}.${Bz[0]}`}function Kz(e,t,n){let r=Wz(e,t,n),i=r.kind===`chain`?r.layers:[];return{path:r.home,above:i.filter(e=>e!==r.home),projectDir:e??null,cwd:t??null}}function qz(e){return Jz(e).join(`
179
- `)||null}function Jz(e){switch(e.kind){case`chain`:return e.unchecked.map(e=>`Config location could not be checked: ${e.path} — ${e.error}`);case`missing`:return[`Config file not found: ${e.path} — rendering the bundled default until it appears`];case`unreadable`:return[`Config file could not be read: ${e.path} — ${e.error} — rendering the bundled default until it can be`]}}function Yz(e,t){let n=Hz(e,t).filter(e=>Vz(e)===`present`),r=new Map;for(let e of n){let t=s.dirname(e),n=s.basename(e).replace(/\.(json5|json)$/,``),i=s.join(t,n);r.has(i)||r.set(i,[]),r.get(i).push(e)}let i=[...r.values()].filter(e=>e.length>1);return i.length===0?null:`config-extension collision: ${i.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function Xz(e,t,n,r){return e===null?{...oB,config:PF(oB.raw,t)}:Qz(e,p.readFileSync(e,`utf-8`),t,n,r)}const Zz={projectDir:null,checkout:null,beneath:{dropped:[],rendering:new Map}};function Qz(e,t,n,r,i){let a=lB(e,t,i,(t,a)=>{let o=_z(gz(t,e),r,{config:n,rendering:r.beneath.rendering},(t,n,r)=>iB(t,n,r,e,i)),s=Sz(o,r.beneath.dropped);return{inherited:new Set([...RI(o.config),...a.filter(e=>s(e).length>0)]),layer:{plugins:o,owning:s}}}),{plugins:o,owning:s}=a.layer,c=Cz(PF(a.raw,o.config),s);return{source:t,raw:a.raw,warnings:[...a.warnings,...o.dropped.map(sz)],plugins:{loaded:o.loaded,dropped:o.dropped,reached:c.reached,rendering:o.rendering},config:c.config}}const $z=new WeakMap;function eB(e,t,n,r){let i=JSON.stringify([[...r??[]].sort(),e.map(e=>[e,nB(e)])]),a=$z.get(n)??new Map;$z.set(n,a);let o=JSON.stringify([t.projectDir,t.checkout?.root??null]),s=a.get(o);if(s?.key===i)return s.layer;let c=_z(e,t,{config:n,rendering:new Map},(e,t,n)=>iB(e,t,n,`<installed plugins>`,r));return a.set(o,{key:i,layer:c}),c}function tB(e,t,n){return _z(e,{projectDir:null,checkout:n},{config:t,rendering:new Map},(e,t,n)=>iB(e,t,n,`<plugin install>`,void 0)).dropped}function nB(e){try{let t=p.statSync(e);return`${t.ino}:${t.size}:${t.mtimeMs}`}catch(e){return e.code??`unreadable`}}function rB(e,t,n,r,i=e=>p.readFileSync(e,`utf-8`),a){let o={projectDir:r.projectDir,checkout:r.cwd===null?null:_D(r.cwd)},s=Lz(o.projectDir),c=eB(s.definitions,o,t,a),l={...c,dropped:[...c.dropped,...s.strays]};n.warned(s.unchecked.map(e=>`Plugin folder could not be listed: ${e.path} — ${e.error}`));let u=l.config,d=[];for(let t of e){n.entered(t);let e=d.at(-1)?.plugins,r=Qz(t,i(t),d.at(-1)?.config??u,{...o,beneath:{dropped:[...l.dropped,...d.flatMap(e=>e.plugins.dropped)],rendering:e?.rendering??l.rendering}},a);n.warned(r.warnings),d.push({...r,path:t})}let f=new Set(d.flatMap(e=>[...e.plugins.reached])),m=e=>f.has(e.path),h=l.dropped.filter(m),g=l.dropped.filter(e=>!m(e));n.warned(h.map(sz));let _={checkout:o.checkout,roots:s.roots,loaded:l.loaded,dropped:h,unreached:g,reached:f,rendering:d.at(-1)?.plugins.rendering??l.rendering},v=d.at(-1);if(v===void 0)return{layers:d,base:u,installed:_,config:sB(Xz(null,u,Zz),`<default>`,a)};try{return{layers:d,base:u,installed:_,config:sB(v,v.path,a)}}catch(e){for(let e of d.slice(0,-1))n.entered(e.path),sB(e,e.path,a);throw n.entered(v.path),e}}function iB(e,t,n,r,i){if(n){sB(aB(e),r,i);return}let a=vz(t),o=[],s={source:``,issues:o,allowedPalettes:new Set,groups:[]};if(tz(s,e,cb(e),a),nz(s,e,a),o.length>0)throw new Sg(r,o)}function aB(e){return{config:e,raw:{root:e.root,presets:e.presets},source:``}}const oB={raw:{},source:``,warnings:[],plugins:{loaded:[],dropped:[],reached:new Set,rendering:new Map}};function sB({config:e,raw:t,source:n},r=`<config>`,i=new Set(dh())){let a=[],o={source:n,issues:a,allowedPalettes:i,groups:[]};if(NR(o,e,t),nz(o,e),a.length>0)throw new Sg(r,a);let s=OL(e,a);if(a.length>0)throw new Sg(r,a);return fF(MP(s))}function cB(e,t,n=new Set(dh()),r=uB){return lB(e,t,n,()=>({inherited:r,layer:null})).raw}function lB(e,t,n,r){let i=dB(e,t),a=Tg(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(dh()),groups:[]};if(!Mg(i))throw new Sg(e,[{path:``,message:`Config root must be an object, got ${Ng(i)}`}],o);let{inherited:l,layer:u}=r(i.plugins===void 0?[]:mB({...c,issues:[]},i.plugins)??[],Mg(i.segments)?Object.keys(i.segments):[]),d=fB(c,i,l);if(s.length>0)throw new Sg(e,s,o);return{raw:d,warnings:o,layer:u}}const uB=new Set;function dB(e,t){try{return Jr.default.parse(t)}catch(t){let n=t;throw new Sg(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function fB(e,t,n){for(let n of Object.keys(t))pB.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...pB].join(`, `)}`,line:K(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=Ok(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=GF(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=zI(e,t.segments,n)),t.layout!==void 0&&e.issues.push({path:`layout`,message:`"layout" is no longer supported — use "root" with the A-grammar instead.
178
+ New: { h: ["seg1", "seg2"] }`,line:K(e.source,[`root`])}),qI;if(n.kind===`group`){let r=Pg(e,fL,t,n);return r===null?qI:(e.groups.push({name:r.name,label:r.label,...r.open!==void 0&&{open:r.open},...r.direction!==void 0&&{direction:r.direction},...r.key!==void 0&&{key:r.key},...r.bg!==void 0&&{bg:r.bg},...r.fg!==void 0&&{fg:r.fg},...r.when!==void 0&&{when:r.when},path:t}),mL(r))}let r=`h`in n,i=`v`in n,a=`seg`in n;if(+!!r+ +!!i+ +!!a>1){let r=[`seg`,`h`,`v`].filter(e=>e in n);return e.issues.push({path:t,message:`a layout node may have exactly one of "seg", "h", or "v" — got ${r.map(e=>`"${e}"`).join(` and `)} together`,line:K(e.source,[`root`])}),qI}if(a){let r=Pg(e,nL,t,n);return r===null?qI:{kind:`segment`,name:r.seg,...r.when!==void 0&&{when:r.when},...r.id!==void 0&&{id:r.id},...r.settings!==void 0&&{settings:r.settings}}}if(r){let r=Pg(e,rL,t,n);return r===null?qI:{kind:`container`,direction:`horizontal`,children:r.h,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}if(i){let r=Pg(e,iL,t,n);return r===null?qI:{kind:`container`,direction:`vertical`,children:r.v,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}return e.issues.push({path:`${t}.kind`,message:`a layout node "kind" must be "container", "segment", or "group", or use the terse A-grammar: a bare string, or an object with "seg", "h", or "v" (got ${JSON.stringify(n.kind)})`,line:K(e.source,[`root`])}),qI};function oL(){return{required:!0,json:{type:`object`,propertyNames:{pattern:gy.source},additionalProperties:{$ref:KI}},parse:(e,t,n,r)=>{let i=r[n];if(!Mg(i))return e.issues.push({path:`${t}.${n}`,message:`"rows" must be an object of row name → layout node, got ${Ng(i)}`,line:K(e.source,[...t.split(`.`),n])}),{};let a={};for(let[r,o]of Object.entries(i)){if(!gy.test(r)){e.issues.push({path:`${t}.${n}.${r}`,message:`row name "${r}" must be an identifier (letters, digits, _; not starting with a digit) — it names the row in the config file and merges by name over the bundled default's rows`,line:K(e.source,[...t.split(`.`),n,r])});continue}a[r]=aL(e,`${t}.${n}.${r}`,o)}return a}}}const sL={noun:`root key`,fields:{rows:oL(),when:Gg(),distribution:$I()}};function cL(e,t,n){return Mg(n)&&`rows`in n?Pg(e,sL,t,n)??{rows:{}}:aL(e,t,n)}function lL(){return{required:!0,json:{type:`string`,pattern:gy.source},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`string`||!gy.test(i)||i===`closed`){e.issues.push({path:`${t}.${n}`,message:`a group "name" must be an identifier (letters, digits, _; not starting with a digit) and not the reserved "${Or}", got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}function uL(){return{required:!1,json:{type:`string`,minLength:1},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`string`||i===``||i.includes(`/`)){e.issues.push({path:`${t}.${n}`,message:`a group "key" must be a non-empty, slash-free SessionState key, got ${q(i)}`,line:K(e.source,[`root`])});return}return i}}}}function dL(){return{required:!0,json:{type:`string`,pattern:`^[^\\n\\r]*$`},parse:(e,t,n,r)=>{let i=Dg(e,t,r,n);if(i!==null){if(/[\n\r]/.test(i)){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: group label must not contain newlines`,line:K(e.source,[...t.split(`.`),n])});return}return i}}}}const fL={noun:`layout-node key`,fields:{kind:JI(`group`),name:lL(),label:dL(),open:Kg(),direction:$g(Gh),key:uL(),bg:Gg(),fg:Gg(),when:Gg(),distribution:$I(),children:ZI(Ug(()=>aL))}};function pL(e){return e.key??`groups.`+e.name}function mL(e){let t=WO+e.name;return Nr(t,{variable:t,key:pL(e),member:e.name},{kind:`container`,direction:e.direction??`vertical`,children:e.children,...e.distribution!==void 0&&{distribution:e.distribution}},`drop`,e.when)}function hL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function gL(e,t){XO(e,t,WO,`group nodes`);let n=e.groups;if(n.length===0)return;let r=new Set;for(let t of n)r.has(t.name)&&hL(e,t.path,`duplicate group name "${t.name}" — group names must be unique (they name the synthesized state var, action, and toggle segment)`),r.add(t.name);for(let t of n)for(let r of n)t!==r&&t.path.startsWith(`${r.path}.`)&&pL(t)===pL(r)&&hL(e,t.path,`group "${t.name}" shares key "${pL(t)}" with its ancestor group "${r.name}" — a shared key holds ONE open group, so an ancestor and a descendant cannot share one. Sibling accordions share a key; nested groups use distinct keys.`);let i=new Map;for(let t of n){let n=pL(t);if(i.has(n)||i.set(n,Or),t.open===!0){let r=i.get(n);r!==`closed`&&hL(e,t.path,`groups "${r}" and "${t.name}" share key "${n}" and both declare open: true — a shared key holds one open group; pick one`),i.set(n,t.name)}}let a={},o={},s={};for(let e of n){let t=WO+e.name,r=pL(e),c=n.filter(t=>t!==e&&e.path.startsWith(t.path+`.`)).length,l=` `.repeat(c);a[t]=zr(r,i.get(r)),o[t]=Br(r,e.name),s[t]={template:Ir(t,`${l}${e.label} ▸`,`${l}${e.label} ▾`),...e.bg!==void 0&&{bg:e.bg},...e.fg!==void 0&&{fg:e.fg}}}t.variables={...t.variables??{},...a},t.actions={...t.actions??{},...o},t.segments={...t.segments??{},...s}}const _L=`menu`,vL=`a menu binds its trigger text the way a cycle action binds a display — write {{ menu "applyTheme" "▸" "▾" }} (one per state) or {{ menu "insertHere" "+" }} (one static display for both), with the rare knobs in ONE trailing dict: {{ menu "applyTheme" "▸" "▾" (dict "closeOnPick" true "paged" false "key" "pickers") }} (defaults: closeOnPick false, paged true, no key). The renderer no longer appends ▸/▾ of its own (candybar-settings-ui-aok.4), and the older positional tail ("pageAction" closeOnPick paged "key") was removed — the page cursor is synthesized from the menu's identity`,yL=e=>e.kind===`call`&&e.name===`dict`,bL=e=>e.kind===`literal`&&typeof e.value!=`object`,xL=e=>Ar(``,e,2)===void 0;function SL(e){let t=e=>({kind:`issue`,message:e}),[n,...r]=e.argExprs;if(n===void 0)return t(`with no arguments — it takes an apply-action name and its trigger text (e.g. {{ menu "applyTheme" "▸" "▾" }})`);if(n.kind!==`literal`||typeof n.value!=`string`)return t(`whose apply action is not a string literal — a menu's identity is its apply-action name, which must be a literal so it can be gated at load (e.g. {{ menu "applyTheme" "▸" "▾" }})`);let i=r[r.length-1],a=i!==void 0&&yL(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(yL))return t(`whose options (dict …) is not its last argument — ${vL}`);if(i!==void 0&&a===void 0&&!bL(i)&&xL(o.length-1))return t(`whose last argument is neither a literal nor a literal (dict …) — the renderer tells a display from the options dict by the value it evaluates to, so this call could be read as ${o.length} displays or as ${o.length-1} plus options, and both are legal. Make the options explicit as a trailing (dict …) — {{ menu "${n.value}" (printf "…") (printf "…") (dict) }} binds dynamic displays unambiguously — or bind the trigger text as literals`);let s=Ar(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${vL}`);let c=a===void 0?{}:aw(a);if(c===null)return t(`whose options (dict …) is not fully literal — every option value must be a literal so the menu can be gated at load (a dynamic entry like (dict "key" .x) cannot)`);let l;try{l=ak(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=YO(u);if(e!==void 0)return t(`whose accordion key "${u}" lands in the reserved "${e}" namespace — a key is collapsed to an identifier (${JSON.stringify(u)} becomes "${$O(u)}"), so it would share one open-state key with the synthesized accordion that owns that namespace instead of grouping only your own menus. Name the group without the reserved prefix`)}return{kind:`ok`,apply:n.value,options:l}}function CL(e){let t=mS({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===_L).map(SL)}catch{return`parse-failed`}}function wL(e){let t=mS({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(_L)}catch{return!1}}function TL(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,[`root`])})}function EL(e,t){XO(e,t,GO,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))wL(r)&&e.issues.push({path:`helpers.${n}`,message:`helper "${n}" uses {{ menu }}, but a menu must live directly in a segment template — its identity is derived from the segment it sits in, which a shared helper does not have. Inline the {{ menu }} call into each segment that needs it.`,line:K(e.source,[`helpers`,n])});let n=t.segments??{};for(let[t,r]of Object.entries(n))for(let n of[`bg`,`fg`,`when`]){let i=r[n];typeof i==`string`&&wL(i)&&TL(e,`segments.${t}.${n}`,`segment "${t}" uses {{ menu }} in its "${n}" — a menu is only valid in a segment's "template" (its placement is published only there; "${n}" needs a ${n===`when`?`predicate`:`color`}). Move the {{ menu }} into the template.`)}if(t.root!==void 0)for(let n of Zh(Cy(t.root)))typeof n.when==`string`&&wL(n.when)&&TL(e,`root`,`a layout node's "when" predicate uses {{ menu }} — a menu is only valid in a segment's "template", not a node predicate. Move it into a segment.`);for(let[t,{template:r}]of Object.entries(n)){if(r===void 0||!wL(r))continue;let n=CL(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:DL(r.apply);n!==void 0&&TL(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function DL(e){if(e===``)return`with an empty apply-action name — an empty member aliases the absent-state sentinel ("") so the menu would render open before any click. Name the apply action`;if(ZO(e)===`closed`)return`whose apply action is named "${Or}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function OL(e,t){let n={},r={},i=new Map,a=new Set,o=(e,n)=>{let r=`segments.${e}`;a.has(`${r}\0${n}`)||(a.add(`${r}\0${n}`),t.push({path:r,message:n}))};for(let t of ky(e.presets)){let a=new Map,s=new Map;for(let c of Zh(My(e,t).node)){if(c.kind!==`segment`)continue;let t=e.segments[c.name];if(t===void 0)continue;i.has(c.name)||i.set(c.name,CL(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=qh(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||DL(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=ZO(i),f=QO(u,i,l.key),p=tk(f),m=l.key===void 0?`ind ${u} ${i}`:`key ${l.key}`,h=[f,p].find(e=>{let t=a.get(e);return t!==void 0&&t!==m});if(h!==void 0){o(c.name,`two {{ menu }} disclosures normalize to the same state key ("${h}") but were declared differently — distinct names that differ only by non-alphanumeric characters (e.g. "a-b" vs "a_b") collapse to one key and would silently share open-state. Rename so they don't collide.`);continue}a.set(f,m),a.set(p,m);let g=ek(f,d),_=`${c.name}\0${e}`,v=s.get(g);if(v!==void 0&&v!==_){o(c.name,`two {{ menu }} disclosures resolve to the same identity ("${g}") — ${l.key===void 0?`a segment cannot contain two menus over the same apply action "${i}"`:`menus sharing key "${l.key}" must have distinct apply actions`}.`);continue}s.set(g,_),r[g]=Br(f,d),n[f]=zr(f,Or),n[p]={kind:`state`,key:p,default:`0`},r[p]={set:p,int:!0}}}}return{...e,variables:{...e.variables,...n},actions:{...e.actions,...r}}}const kL=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`ceiling`,`slash`,`do`];function AL(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function jL(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function ML(e,t){if(t===void 0)return{};if(!Mg(t))return Z(e,`actions`,`actions must be an object, got ${Ng(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=NL(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Z(e,t,n){e.issues.push({path:t,message:n,line:K(e.source,t.split(`.`))})}function NL(e,t,n){if(!Mg(n))return Z(e,t,`${t} must be an action object, got ${Ng(n)}`),null;if(`persistWhen`in n)return Z(e,t,`${t}.persistWhen was removed: declare the \`set\` alone — a session pick is a draft until a \`{ save: true }\` action writes every unsaved setting to the config file`),null;let r=kL.filter(e=>e in n);return r.length===1?PL[r[0]](e,t,n):(Z(e,t,`action must declare exactly one of: ${kL.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const PL={set:(e,t,n)=>mR(e,t,n,`set`,uR),persist:(e,t,n)=>mR(e,t,n,`persist`,dR),copy:FL(`copy`),open:FL(`open`),reset:IL,undo:RL(`undo`),redo:RL(`redo`),back:RL(`back`),rewind:RL(`rewind`),save:RL(`save`),preset:zL,themeDefault:BL,doctor:HL,ceiling:UL,slash:WL,do:GL};function FL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=Dg(t,n,r,e);return i===null?null:{[e]:i}}}function IL(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=KL(e,t,`reset`,n,`reset key must be non-empty (the config globals field to clear)`,e=>`reset key "${e}" contains "/" — keys must be slash-free`);return r===null?null:{reset:r}}const LL={undo:`it steps the session's settings history`,redo:`it steps the session's settings history`,back:`it steps the session's navigation history`,rewind:`it steps the session's settings history back to where edit mode opened`,save:`it saves the session's unsaved settings`};function RL(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Z(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Z(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${LL[e]}), got ${q(r[e])}`),null)}}function zL(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Z(e,`${t}.preset`,`preset must be "save" or "delete", got ${q(r)}`),null;if(r===`save`)return{preset:`save`};let a=Dg(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function BL(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(Z(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${q(n.themeDefault)}`),null)}const VL={run:[`doctor`],fix:[`doctor`,`check`],mark:[`doctor`,`check`,`mark`]};function HL(e,t,n){let r=n.doctor,i=typeof r==`string`&&Object.hasOwn(VL,r),a=i?VL[r]:[...new Set(Object.values(VL).flat())];for(let r of Object.keys(n))a.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${a.join(`, `)}`);if(!i)return Z(e,`${t}.doctor`,`doctor must be ${Object.keys(VL).map(e=>`"${e}"`).join(`, `)}, got ${q(r)}`),null;if(r===`run`)return{doctor:`run`};let o=n.check,s=r===`mark`?fM:dM;if(typeof o!=`string`||!s.some(e=>e.name===o))return Z(e,`${t}.check`,`doctor ${r} must name a check (have: ${s.map(e=>e.name).join(`, `)}), got ${q(o)}`),null;if(r===`fix`)return{doctor:`fix`,check:o};let c=n.mark;return Cj.includes(c)?{doctor:`mark`,check:o,mark:c}:(Z(e,`${t}.mark`,`doctor mark must be ${Cj.map(e=>`"${e}"`).join(` or `)}, got ${q(c)}`),null)}function UL(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Z(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Z(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${q(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Z(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${q(a)}`),null):{ceiling:`set`,to:a}}function WL(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=zM(n.slash);return r.kind===`refused`?(Z(e,`${t}.slash`,r.reason),null):{slash:r.line}}function GL(e,t,n){for(let r of Object.keys(n))r!==`do`&&Z(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(Z(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${q(r)}`),null):{do:r}}function KL(e,t,n,r,i,a){let o=Dg(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Z(e,s,i),null):o.includes(`/`)?(Z(e,s,a(o)),null):o}const qL={set:`the SessionState key to write`,persist:`the config globals field to write`};function JL(e,t,n,r){let i=qL[r],a=KL(e,t,r,n,`${r} key must be non-empty (${i})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);return a===null?null:{[r]:a}}function YL(e){return e===`set`?`set-state`:`set-config`}const XL={to:hR(`set`)},ZL={to:hR(`persist`)},QL={from:gR(`set`)},$L={from:gR(`persist`)},eR={min:xR(),max:xR(),by:xR()},tR={int:vR()},nR={cycle:_R(`set`)},rR={cycle:_R(`persist`)},iR={removeSegment:yR(`removeSegment`)},aR={insertSegment:yR(`insertSegment`),anchor:yR(`anchor`),relation:bR()},oR={insertSegmentFrom:gR(`persist`),anchor:yR(`anchor`),relation:bR()},sR={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},cR={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function lR(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>Ig(e,t,n,r),c=e_(t);return{detect:a,allowed:[...o,...i],label:i.join(`/`),json:{type:`object`,properties:{...Object.fromEntries(o.map(e=>[e,{type:`string`}])),...c.properties},required:[...o,...c.required??[]],additionalProperties:!1},parse:n.length?Wg(s,...n):s}}const uR=[lR(`set`,XL),lR(`set`,QL),lR(`set`,eR,[sR,cR]),lR(`set`,tR),lR(`set`,nR)],dR=[lR(`persist`,ZL),lR(`persist`,$L),lR(`persist`,eR,[sR,cR]),lR(`persist`,rR),lR(`persist`,iR),lR(`persist`,aR,[],[`insertSegment`]),lR(`persist`,oR,[],[`insertSegmentFrom`])];function fR(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"endcaps"/"styles", or an inline array of literal values)`,`"min"/"max"/"by" (a bounded step)`];return e===`set`&&t.push(`"int" (an unbounded integer cursor)`),t.push(`"cycle" (an enumerated domain stepped in order)`),e===`persist`&&t.push(`"removeSegment" (remove a named segment from the layout)`,`"insertSegment"/"anchor"/"relation" (insert a named segment before/after an existing one)`,`"insertSegmentFrom"/"anchor"/"relation" (insert a segment PICKED from an option domain before/after an existing one)`),t}function pR(e){let t=fR(e),n=t[t.length-1];return`a ${e} action declares exactly one value source: ${t.length===1?n:`${t.slice(0,-1).join(`, `)}, or ${n}`}`}function mR(e,t,n,r,i){let a=JL(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Z(e,t,`${pR(r)}${o.length>1?` — found: ${o.map(e=>e.label).join(`, `)}`:``}`),null;let s=o[0];for(let i of Object.keys(n))s.allowed.includes(i)||Z(e,`${t}.${i}`,`Unknown key "${i}" on this ${r} action. Expected one of: ${s.allowed.join(`, `)}`);let c=s.parse(e,t,n);return a===null||c===null?null:{...a,...c}}function hR(e){let t=YL(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>KL(n,r,i,a,`${e} value must be non-empty — an empty value cannot be delivered on the ${t} wire`,t=>`${e} value "${t}" contains "/" — ${e} values must be slash-free`)??void 0}}function gR(e){let t=YL(e);return{required:!0,json:{anyOf:[{type:`string`,minLength:1},{type:`array`,items:{type:`string`,minLength:1},minItems:1,uniqueItems:!0}]},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(typeof o==`string`){if(o===``){Z(n,s,`${i} must be a non-empty domain name`);return}return o}if(Array.isArray(o)&&o.every(e=>typeof e==`string`)){let r=o;if(r.length===0){Z(n,s,`${i} must name a domain (a non-empty string) or declare an inline domain (a non-empty array of values)`);return}if(r.some(e=>e===``)){Z(n,s,`${i} array members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}let a=r.filter(e=>e.includes(`/`));if(a.length>0){Z(n,s,`${i} array member(s) ${a.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(r).size!==r.length){Z(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Z(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${q(o)}`)}}}function _R(e){let t=YL(e);return{required:!0,json:{type:`array`,items:{type:`string`,minLength:1},minItems:2,uniqueItems:!0},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(!Array.isArray(o)||o.some(e=>typeof e!=`string`)){Z(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${Ng(o)}`);return}let c=o;if(c.length<2){Z(n,s,`cycle needs at least two members (one member has no successor — use a literal "to")`);return}let l=c.some(e=>e===``),u=c.filter(e=>e.includes(`/`));if(l){Z(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Z(n,s,`cycle member(s) ${u.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(c).size!==c.length){Z(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function vR(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Z(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${q(r[n])}`);return}return!0}}}function yR(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Dg(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Z(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Z(t,o,`${e} "${a}" contains "/" or ":" — segment names in a layout op must be free of both (the click wire's own delimiter and layout-ops.ts's op-token delimiter)`);return}return a}}}function bR(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Z(e,`${t}.${n}`,`relation must be "before" or "after", got ${q(i)}`);return}return i}}}function xR(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Z(e,`${t}.${n}`,`${n} must be an integer, got ${q(i)}`);return}return i}}}function SR(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const CR={noun:`style key`,fields:{hueShift:Jg(),chromaScale:Jg({min:0}),lightnessScale:Jg(),lightnessShift:Jg()}};function wR(e,t){if(!Mg(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${Ng(t)}`,line:K(e.source,[`styles`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`styles.${r}`,message:`style name ${JSON.stringify(r)} must be non-empty and slash-free — a style picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:K(e.source,[`styles`,r])});continue}if(Ph(r)){e.issues.push({path:`styles.${r}`,message:SR(`styles.${r}`,r,`globals.endcaps`),line:K(e.source,[`styles`,r])});continue}let t=Pg(e,CR,`styles.${r}`,i);t!==null&&(n[r]={...nc,...t})}return n}const TR={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:cL(e,`${t}.${n}`,r[n])},globals:{required:!1,json:Ak(),parse:(e,t,n,r)=>r[n]===void 0?void 0:kk(e,`${t}.${n}`,r[n])}}};function ER(e,t){if(!Mg(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${Ng(t)}`,line:K(e.source,[`presets`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)||/[\n\r]/.test(r)){e.issues.push({path:`presets.${r}`,message:`preset name ${JSON.stringify(r)} must be non-empty, slash-free, and newline-free — a preset picker writes the name on the set-state wire (which rejects empty values and splits on "/"), and edit mode splices it into a synthesized template string`,line:K(e.source,[`presets`,r])});continue}let t=Pg(e,TR,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function DR(e,t){if(t===void 0)return{};if(!Mg(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${Ng(t)}`,line:K(e.source,[`helpers`])}),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){if(typeof i!=`string`){e.issues.push({path:`helpers.${r}`,message:`helpers.${r} must be a string template body, got ${q(i)}`,line:K(e.source,[`helpers`,r])});continue}n[r]=i}return n}const OR=new Map([[`session.budget.amount`,{segment:`session`,setting:`budget`}],[`session.budget.warningThreshold`,{segment:`session`,setting:`warnAt`}],[`today.budget.amount`,{segment:`today`,setting:`budget`}],[`today.budget.warningThreshold`,{segment:`today`,setting:`warnAt`}],[`block.budget.heatThreshold`,{segment:`block`,setting:`warnAt`}],[`block.budget.warningThreshold`,{segment:`block`,setting:`errorAt`}],[`weekly.budget.heatThreshold`,{segment:`weekly`,setting:`warnAt`}],[`weekly.budget.warningThreshold`,{segment:`weekly`,setting:`errorAt`}],[`burn.eta.errorMinutes`,{segment:`burnrate`,setting:`errorWithin`}],[`burn.eta.warnMinutes`,{segment:`burnrate`,setting:`warnWithin`}]]);function kR(e){return`it became the "${e.setting}" setting of each "${e.segment}" placement — set it on the placement where a row places "${e.segment}" ({ seg: "${e.segment}", settings: { ${e.setting}: <value> } }), or redeclare segments.${e.segment}.settings.${e.setting} with the default every placement should start from`}function AR(e){let t=OR.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${kR(t)}`}function jR(e){let t=OR.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${kR(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function MR(e,t){let n=new Map;for(let e of Object.keys(t)){let t=UO(e),r=n.get(t);r?r.push(e):n.set(t,[e])}for(let[t,r]of n)r.length<2||e.issues.push({path:`presets`,message:`preset names ${r.map(e=>JSON.stringify(e)).join(` and `)} both collapse to the same synthesis identifier "${t}" — edit mode's synthesized reset affordance would silently steal one preset's action for the other. Rename one.`,line:K(e.source,[`presets`])})}function NR(e,t,n){let r=[[[`globals`],t.globals.style,`globals.endcaps`],[[`editGlobals`],t.editGlobals.style,`editGlobals.endcaps`],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style,`presets.${e}.globals.endcaps`]),...Object.entries(t.themeDefaults).map(([e,t])=>[[`themeDefaults`,e],t.style,`globals.endcaps`])];for(let[n,i,a]of r){if(i===void 0||_h(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:Ph(i)?SR(r,i,a):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:K(e.source,[...n,`style`])})}t.globals.preset!==void 0&&!Object.prototype.hasOwnProperty.call(t.presets,t.globals.preset)&&e.issues.push({path:`globals.preset`,message:`globals.preset "${t.globals.preset}" does not match any declared preset (have: ${Object.keys(t.presets).join(`, `)})`,line:K(e.source,[`globals`,`preset`])}),MR(e,t.presets);let i=cb(t);for(let t of i.names)t!==`settings`&&!t.startsWith(IR)||e.issues.push({path:`variables`,message:`variable "${t}" is named under "settings", which a segment's templates read as its placement's own settings (.settings.<name>) — rename it`,line:K(e.source,[`variables`,t])});let a=(t,n,r)=>{yP(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${ZM}" ${yP(t)} times — it may appear at most once per layout (it is one disclosure, and one state key holds one open state). Remove all but the placement you want; removing every placement puts the menu at its default position.`,line:r}),bP(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${ZM}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r}),o(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and shade, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of Zh(t)){if(e.kind!==`segment`)continue;let t=qh(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=Yh(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.length} placements with the id "${t}" — an id names one placement (its settings, its menus' open state, and edit mode all address it), so give each its own: { seg: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function o(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>o(n,t||Kh[e.direction]===`cell`))}let s=(n,r)=>{for(let[a,o]of wy(n,r)){let n=K(e.source,o.split(`.`));if(a.when!==void 0&&(JR(e,`${o}.when`,a.when,i,{line:n}),qR(e,`${o}.when`,a.when,n)),a.kind===`segment`){if(gP(a.name)){(a.id!==void 0||a.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${ZM}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${ZM}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,a.name)||e.issues.push({path:o,message:`${r} entry "${a.name}" does not match any declared segment${xI(a.name)}`,line:n}),WR(e,t,a,o,n)}}};n.root!==void 0&&s(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&s(t.root,`presets.${e}.root`);let c=new Map([[`root`,Sy(t.root)]]);for(let e of ky(t.presets)){let{node:n,path:r}=My(t,e);c.set(r,n)}for(let[t,n]of c)a(n,t,K(e.source,t.split(`.`)));tz(e,t,i,()=>!0)}const PR=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function FR(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=K(e.source,[`actions`,n,r]);if(!ky(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${ky(t.presets).join(`, `)})`,line:c});return}if(r===`reset`)return;let l=`removeSegment`in o,u=`insertSegment`in o,d=`insertSegmentFrom`in o;if(!l&&!u&&!d){e.issues.push({path:s,message:`actions.${n}: "${i}" is a "presets.<name>.root" target and can only be paired with "removeSegment", "insertSegment", or "insertSegmentFrom" (not "to"/"from"/"cycle"/bounded — those have no meaning as a tree op)`,line:c});return}let f=(r,i)=>{Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})${xI(i)}`,line:c})},p=new Set(Jh(My(t,a).node)),m=(r,i)=>{!bI.has(i)||p.has(i)||Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" names no placement${xI(i)}`,line:c})};`removeSegment`in o&&m(`removeSegment`,o.removeSegment),`insertSegment`in o&&f(`insertSegment`,o.insertSegment),(`insertSegment`in o||`insertSegmentFrom`in o)&&m(`anchor`,o.anchor)}const IR=`settings.`;function LR(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>IR+e)])}}function RR(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:K(e.source,[`segments`,t,`settings`,n])})},a=VR(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of mg(n,BR(n)))i(e,`the defaults do not stand together: ${t}`)}function zR(e){return VR(e).length>0||mg(e,BR(e)).length>0}function BR(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function VR(e){let t=t=>pg(HR(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||pg(HR(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${UR(e,n).join(`, `)||`none`})`}];let i=[n];for(let e=r;e!==void 0;e=t(e)){if(e===n)return i.every(e=>n<=e)?[{setting:n,message:`atLeast closes a cycle (${[...i,n].join(` ≥ `)}) — every setting on it could only ever equal the rest`}]:[];if(i.includes(e))return[];i.push(e)}return[]})}function HR(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function UR(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&pg(n)!==void 0).map(([e])=>e)}function WR(e,t,n,r,i){let a=Object.prototype.hasOwnProperty.call(t.segments,n.name)?t.segments[n.name]:void 0;if(a===void 0)return;let o=fg(a),s=`${r}: placement "${qh(n)}" of segment "${n.name}"`;for(let[t,a]of Object.entries(n.settings??{})){let c=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0,l=c===void 0?`sets "${t}", which segment "${n.name}" does not declare (it has: ${Object.keys(o).join(`, `)})`:hg(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?ch(a):``}, but it must be ${yg(c)}`;l!==void 0&&e.issues.push({path:r,message:`${s} ${l}`,line:i})}let c=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,n.settings?.[e]??t.default]));if(!(!Object.entries(c).every(([e,t])=>hg(o[e],t))||zR(o)))for(let{message:t}of mg(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function GR(e,t,n,r,i){n.kind===`template`&&JR(e,`${t}.template`,n.template,r,{segCtx:i}),ig(n)&&`key`in n.cache&&JR(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function KR(e,t,n,r,i){if(!(!ig(n)||!(`depends_on`in n.cache)))for(let a=0;a<n.cache.depends_on.length;a++){let o=n.cache.depends_on[a];if(r.names.has(o))continue;let s=i===void 0?void 0:`${i}.${o}`,c=s!==void 0&&r.names.has(s)?` (segment-local vars are namespaced — write "${s}")`:``;e.issues.push({path:`${t}.cache.depends_on[${a}]`,message:`cache.depends_on references unknown variable "${o}"${c}`,line:K(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function qR(e,t,n,r){try{Zk.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function JR(e,t,n,r,i){for(let[a,o]of eb(n,r.helpers)){if(sb(a,r))continue;if(a.startsWith(IR)){let n=o===null?``:` through helper "${o}"`,r=a.slice(9),s=i?.segCtx===void 0||i.settings===void 0?`Template reads ".${a}"${n}, but only a segment's own templates have settings — call it from a segment that declares "${r}"`:`Template reads ".${a}"${n}, but segment "${i.segCtx}" has no setting "${r}" (it has: ${Object.keys(i.settings).join(`, `)}) — declare it under segments.${i.segCtx}.settings`;e.issues.push({path:t,message:s,line:i?.line??K(e.source,t.split(`.`))});continue}if(o!==null){YR(e,o,`Template references unknown variable ".${a}"${jR(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&sb(n,r)?` (segment-local vars are namespaced — write ".${n}")`:jR(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??K(e.source,t.split(`.`))})}}function YR(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:K(e.source,[`helpers`,t])})}function XR(e,t,n,r,i){let a=n.set,o=mk(V_[r].configKey),s=`${a} takes ${ck(o,i)}`;if(`min`in n&&(o===`bool`||!(`min`in o))){e.issues.push({path:`actions.${t}.min`,message:`actions.${t}: a stepper writes the integers from ${n.min} to ${n.max}, and ${a} is not an integer range; ${s}`,line:K(e.source,[`actions`,t,`min`])});return}let c=$R(n,i);if(c===QR){e.issues.push({path:`actions.${t}.int`,message:`actions.${t}.int: an int cursor writes whatever integer the template binds, and a click outside the ${a} domain would change nothing; ${s}`,line:K(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!sk(o,e.value,i));if(l.length!==0){if(a===V_.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>Ph(e.value)))){let r=V_.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:SR(`actions.${t}.to`,n.to,`set: "${r}", to`),line:K(e.source,[`actions`,t,`to`])}:{path:`actions.${t}.set`,message:`actions.${t}.set: "${a}" here writes only endcaps shapes, not styles — endcaps were renamed from "style" to "endcaps"; write set: "${r}"`,line:K(e.source,[`actions`,t,`set`])});return}for(let n of new Set(l.map(e=>e.field))){let r=l.filter(e=>e.field===n).map(e=>JSON.stringify(e.value)),i=r.length<=ZR?r.join(`, `):`${r.slice(0,ZR).join(`, `)} and ${r.length-ZR} more`,o=`actions.${t}.${n}`;e.issues.push({path:o,message:`${o}: ${i} ${r.length===1?`is`:`are`} outside the ${a} domain — a click would write it and nothing would change; ${s}`,line:K(e.source,[`actions`,t,n])})}}}const ZR=3,QR=Symbol(`any integer`);function $R(e,t){return`to`in e?[{field:`to`,value:e.to}]:`cycle`in e?e.cycle.map(e=>({field:`cycle`,value:e})):`from`in e?zy(e.from,t).members.map(e=>({field:`from`,value:e})):`min`in e?[{field:`min`,value:String(e.min)},{field:`max`,value:String(e.max)}]:QR}function ez(e,t){return Object.entries(e).filter(([e])=>t(e))}function tz(e,t,n,r){let i=JP(t),a=Ry(i);for(let[n,o]of ez(t.actions,r)){let[t,r]=`from`in o?[`from`,o.from]:`insertSegmentFrom`in o?[`insertSegmentFrom`,o.insertSegmentFrom]:[null,null];if(t!==null&&typeof r==`string`&&!a.includes(r)){e.issues.push({path:`actions.${n}.${t}`,message:`actions.${n} ${t}: references ${Vy(r,i)}`,line:K(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;G_.has(o.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${o.set}", which has no session pick — globals.${o.set} is set in the config file only, so a click would change nothing; write it with { persist: "${o.set}", … } instead`,line:K(e.source,[`actions`,n,`set`])});let s=Y_.get(o.set);s!==void 0&&XR(e,n,o,s,i)}for(let[n,i]of ez(t.actions,r))`do`in i&&i.do.forEach((r,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,r)?t.actions[r]:void 0,s=o===void 0?`references unknown action "${r}"`:`do`in o?`"${r}" is itself a do action — list its members here instead`:i.do.indexOf(r)===a?a>0&&jL(o)?`"${r}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${r}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:K(e.source,[`actions`,n,`do`])})});for(let[n,i]of ez(t.actions,r)){let r=`persist`in i?i.persist:`reset`in i?i.reset:null;if(r===null)continue;let a=`persist`in i?`persist`:`reset`,o=Kk(r);if(o===null){let t=Pk(r);e.issues.push({path:`actions.${n}.${a}`,message:t===void 0?`actions.${n}: "${r}" is not a config globals field (have: ${Fk().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, a "themeDefaults.<theme>.<shade|variation|style>" target, or a "presets.<name>.root" target`:`actions.${n}: the globals field "${r}" was removed: ${t}`,line:K(e.source,[`actions`,n,a])});continue}let s=PR.filter(e=>e in i);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){FR(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!ky(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names preset "${o.preset}" which is not declared (have: ${ky(t.presets).join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`theme-default`&&!e.allowedPalettes.has(o.theme)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names theme "${o.theme}" which is not installed${ch(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:K(e.source,[`actions`,n,a])});continue}if(o.scope===`segment-palette`){if(!Object.prototype.hasOwnProperty.call(t.segments,o.segment)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${xI(o.segment)}`,line:K(e.source,[`actions`,n,a])});continue}`min`in i&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:K(e.source,[`actions`,n,a])})}}for(let[i,a]of ez(t.variables,r)){GR(e,`variables.${i}`,a,n);let t=AR(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:K(e.source,[`variables`,i])})}for(let[i,a]of ez(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))GR(e,`segments.${i}.vars.${t}`,r,n,i);let r=fg(a);RR(e,i,r);let o=LR(n,r);for(let n of[`template`,`bg`,`fg`,`when`]){let s=a[n];if(typeof s==`string`){JR(e,`segments.${i}.${n}`,s,o,{segCtx:i,settings:r});for(let{name:r,site:a,via:o}of ib(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=a===`options`?` (in a picker, menu, carousel, swatch, swatches or themePreview)`:``;if(o!==null){YR(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${i}.${n}`,message:`${n} references unknown action "${r}"${s}`,line:K(e.source,[`segments`,i,n])})}}}}for(let[i,a]of ez(t.variables,r))KR(e,`variables.${i}`,a,n);for(let[i,a]of ez(t.segments,r))if(a.vars)for(let[t,r]of Object.entries(a.vars))KR(e,`segments.${i}.vars.${t}`,r,n,i)}function nz(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=rz(t),a=new Map,o=[];for(let e of r.keys())a.set(e,0);for(let e of r.keys())if(!(!n(e)||a.get(e)!==0)&&s(e))return;function s(t){a.set(t,1),o.push(t);for(let c of r.get(t)??[]){if(!n(c))continue;let t=a.get(c);if(t===1){let t=o.indexOf(c),n=[...o.slice(t),c],r=n[0],a=i.get(r);return e.issues.push({path:a?.declarationPath??`variables.${r}`,message:`Dependency cycle: ${n.join(` → `)}`,line:K(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function rz(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of eb(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),ig(n)&&(`key`in n.cache&&i(e,n.cache.key),`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}function iz(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?S.homedir()+e.slice(1):e}function az(e,t){return s.resolve(e,iz(t))}function oz(e,t){return typeof t==`string`&&t!==``?az(e,t):void 0}function sz(e){return`plugin ${e.path} was not loaded: ${e.reason}`}const cz=new Set([`data`,`segments`,`helpers`,`actions`]),lz=`plugin.json5`,uz=/^[a-z][a-z0-9_]*$/;function dz(e){let t=s.basename(s.dirname(e));return uz.test(t)?t:void 0}const fz=`plugins.`;function pz(e){return`${fz}${e}.data`}function mz(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,reason:hz(e)}}}function hz(e){return e instanceof Sg?e.issues.map(e=>e.path===``||e.message.includes(e.path)?e.message:`${e.path}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function gz(e,t){return e.map(e=>az(s.dirname(t),e))}function _z(e,t,n,r){let i=new Map;return e.reduce((e,n)=>{let a=dz(n),o=(t,r)=>{let i=new Map(e.rendering);return a!==void 0&&r!==e.config&&i.delete(a),{...e,config:r,rendering:i,dropped:[...e.dropped,{path:n,plugin:a,reason:t}]}};if(s.basename(n)!==`plugin.json5`){let t=`a plugin is a folder holding its ${lz}, and the folder's name is the plugin's: move this file to <dir>/<name>/${lz} and list that`;return o(t,a===void 0?e.config:bz(yz(e.config,a),a,{path:n,plugin:a,reason:t}))}if(a===void 0)return o(`its folder "${s.basename(s.dirname(n))}" is not a plugin name (one matching ${uz}: it prefixes every name the plugin declares)`,e.config);let c=i.get(a);if(c!==void 0)return o(`plugin "${a}" is already listed, from ${c}`,e.config);i.set(a,n);let l=yz(e.config,a),u=mz(()=>{let i=p.readFileSync(n,`utf-8`),o=PF(Ez(n,a,{source:i,json:Jr.default.parse(i)},t),l);return r(o,a,l!==e.config),o});if(u.ok)return{...e,config:u.value,loaded:[...e.loaded,n],rendering:new Map([...e.rendering,[a,n]])};let d={path:n,plugin:a,reason:u.reason};return o(u.reason,bz(l,a,d))},{config:n.config,rendering:n.rendering,loaded:[],dropped:[]})}function vz(e){let t=`${fz}${e}.`;return e=>e.startsWith(t)}function yz(e,t){let n=vz(t),r=e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n(e)));return[e.variables,e.segments,e.helpers,e.actions].some(e=>Object.keys(e).some(n))?{...e,variables:r(e.variables),segments:r(e.segments),helpers:r(e.helpers),actions:r(e.actions)}:e}function bz(e,t,n){return{...e,variables:{...e.variables,[pz(t)]:{kind:`dropped`,reason:sz(n),definition:n.path}}}}function xz(e){return e.startsWith(`plugins.`)?e.slice(8).split(`.`)[0]:void 0}function Sz(e,t){let n=new Set([...Object.keys(e.config.variables),...Object.keys(e.config.segments)].map(xz)),r=[...t,...e.dropped].filter(e=>e.plugin===void 0).map(e=>({definition:e.path,notice:sz(e)}));return t=>{let i=xz(t);if(i===void 0)return[];let a=e.config.variables[pz(i)];return a?.kind===`dropped`?[{definition:a.definition,notice:a.reason}]:n.has(i)?[]:r}}function Cz(e,t){let n=ky(e.presets).flatMap(t=>[...Zh(My(e,t).node)]).flatMap(e=>e.kind===`segment`?[e]:[]),r=[...new Set([...n.map(e=>e.name),...Object.keys(e.segments)])].map(e=>({name:e,cause:t(e)})).filter(({cause:e})=>e.length>0),i=Object.fromEntries(r.map(({name:e,cause:t})=>[e,wz(e,t.map(e=>e.notice),n.filter(t=>t.name===e))])),a=t=>{let n=xz(t),r=n===void 0?void 0:e.variables[pz(n)];return r?.kind===`dropped`?{definition:r.definition,notice:r.reason}:void 0},o=Object.values(e.variables).some(e=>e.kind===`dropped`),s=o?Object.values(e.segments).flatMap(e=>[`template`,`bg`,`fg`,`when`].flatMap(t=>e[t]===void 0?[]:[e[t]])):[],c=o?Object.values(e.actions).flatMap(e=>`do`in e?[...e.do]:[]):[],l=(e,t)=>[...new Set(e)].flatMap(e=>{let n=e in t?void 0:a(e);return n===void 0?[]:[[e,n]]}),u=l([...s.flatMap(t=>ib(t,e.helpers).map(e=>e.name)),...c],e.actions),d=l(s.flatMap(t=>[...ob(t,e.helpers)]),e.helpers),f=new Set([...r.flatMap(({cause:e})=>e.map(e=>e.definition)),...[...u,...d].map(([,e])=>e.definition)]);return{config:{...e,segments:{...e.segments,...i},actions:{...e.actions,...Object.fromEntries(u.map(([e])=>[e,{copy:`{{ .${pz(xz(e)??``)} }}`}]))},helpers:{...e.helpers,...Object.fromEntries(d.map(([e,t])=>[e,`{{ fail ${JSON.stringify(t.notice)} }}`]))}},reached:f}}function wz(e,t,n){let r=`⚠ ${e}: ${t.join(`; `)}`,i=new Map;for(let e of n)for(let[t,n]of Object.entries(e.settings??{})){let e=i.get(t);i.set(t,e===void 0?[n]:[...e,n])}let a=Object.fromEntries([...i].map(([e,t])=>[e,Tz(e,t)]));return{template:`{{ ${JSON.stringify(r)} }}`,bg:`error`,description:`stands in for a segment whose plugin did not load`,settings:a}}function Tz(e,t){let[n]=t,r=t.filter(e=>typeof e==`number`);return typeof n==`boolean`?{label:e,domain:`bool`,default:n}:typeof n==`number`?{label:e,domain:{min:Math.min(...r),max:Math.max(...r),step:1},default:n}:{label:e,domain:[...new Set(t.map(String))],default:n}}function Ez(e,t,{source:n,json:r},{checkout:i}){let a=[],o=()=>{throw new Sg(e,a)};if(!Mg(r))return a.push({path:``,message:`a plugin definition must be an object, got ${Ng(r)}`}),o();for(let e of Object.keys(r))cz.has(e)||a.push({path:e,message:e===`plugin`?`a plugin definition does not name itself: its name is its folder's ("${t}") — remove "plugin"`:`a plugin definition may not declare "${e}". Expected only: ${[...cz].join(`, `)}`});let s=Mz(r.data,e,i,a);if(Mg(r.segments)||a.push({path:`segments`,message:`"segments" must be an object naming the plugin's segments`}),a.length>0||s===void 0)return o();let c={source:n,issues:a,allowedPalettes:new Set(dh()),groups:[]},l=GF(c,`data`,{[pz(t)]:{kind:`file`,path:s,parse:{json:!0},cache:{watch_file:s},default:{}}});for(let[e,t]of Object.entries(r.segments))if(!(!Mg(t)||!Mg(t.vars)))for(let[n,r]of Object.entries(t.vars)){let t=Mg(r)?r.kind:void 0;typeof t!=`string`||t===`state`||a.push({path:`segments.${e}.vars.${n}`,message:`a plugin segment's vars may declare only state variables (kind: "state"), never a source such as ${JSON.stringify(t)}: a plugin's only source is its data file`})}let u={variables:l,segments:Oz(t,Az(t,zI(c,r.segments,new Set))),helpers:Oz(t,DR(c,r.helpers)),actions:Oz(t,jz(t,ML(c,r.actions)))};for(let[e,t]of Dz(u))try{Zk.parse(t)}catch(t){a.push({path:e,message:`Template parse error in ${e}: ${t.message}`})}return a.length>0&&o(),u}function*Dz(e){for(let[t,n]of Object.entries(e.segments??{}))for(let e of[`template`,`bg`,`fg`,`when`]){let r=n[e];r!==void 0&&(yield[`segments.${t}.${e}`,r])}for(let[t,n]of Object.entries(e.helpers??{}))yield[`helpers.${t}`,`{{ define "${t}" }}${n}{{ end }}`];for(let[t,n]of Object.entries(e.actions??{}))`copy`in n&&(yield[`actions.${t}.copy`,n.copy]),`open`in n&&(yield[`actions.${t}.open`,n.open]),`preset`in n&&n.preset===`delete`&&(yield[`actions.${t}.name`,n.name])}function Oz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[`${fz}${e}.${t}`,n]))}function kz(e,t){return`${fz}${e}.${t}`}function Az(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.vars===void 0?n:{...n,vars:Object.fromEntries(Object.entries(n.vars).map(([t,n])=>[t,n.kind===`state`?{...n,key:kz(e,n.key)}:n]))}]))}function jz(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,`set`in n?{...n,set:kz(e,n.set)}:n]))}function Mz(e,t,n,r){if(typeof e==`string`&&e!==``)return az(s.dirname(t),e);if(Mg(e)&&Object.keys(e).length===1&&typeof e.checkout==`string`&&e.checkout!==``){let t=e.checkout;if(s.isAbsolute(t)||t.startsWith(`~`)||s.normalize(t).split(s.sep)[0]===`..`){r.push({path:`data.checkout`,message:`data.checkout "${t}" must be a path inside the checkout, relative to its root (like ".lit/statusline.json"): no absolute path, "~" or ".."`});return}if(n===null){r.push({path:`data.checkout`,message:`data is read from the session's checkout, and this load has no session`});return}return s.resolve(n.root,t)}if(Mg(e)&&`project`in e){r.push({path:`data.project`,message:`data: { project } is now data: { checkout }: the same path, relative to the root of the git checkout the session works in (a linked worktree is its own checkout)`});return}r.push({path:`data`,message:`"data" must be the path of the plugin's JSON data file relative to this definition, or { checkout: "<path>" } relative to the root of the session's checkout`})}function Nz(e){let t=[...[...(process.env.XDG_DATA_DIRS||Iz()).split(`:`).filter(e=>e!==``)].reverse().map(e=>s.join(e,`cc-candybar`,`plugins`)),Pz(),...e===null?[]:[s.join(e,Fz)]];return t.filter((e,n)=>t.lastIndexOf(e)===n)}function Pz(){let e=process.env.XDG_DATA_HOME||s.join(S.homedir(),`.local`,`share`);return s.join(e,`cc-candybar`,`plugins`)}const Fz=s.join(`.cc-candybar`,`plugins`);function Iz(){let e=`/usr/local/share:/usr/share`;return process.platform===`darwin`?`${s.join(process.env.HOMEBREW_PREFIX||`/opt/homebrew`,`share`)}:${e}`:e}function Lz(e){let t=Nz(e),n=new Map,r=[],i=[];for(let e of t){let t=Rz(e);if(`error`in t){r.push(t);continue}for(let r of t.folders)n.delete(r),n.set(r,s.join(e,r,lz));for(let n of t.files)i.push({path:s.join(e,n),plugin:void 0,reason:`a plugin is a folder holding its ${lz}: move this file to ${s.join(e,`<name>`,lz)}`})}return{roots:t,definitions:[...n.values()],unchecked:r,strays:i}}function Rz(e){try{let t=p.readdirSync(e,{withFileTypes:!0}).filter(e=>!e.name.startsWith(`.`)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),n=t=>t.isDirectory()||zz(e,t);return{folders:t.filter(n).map(e=>e.name),files:t.filter(e=>!n(e)).map(e=>e.name)}}catch(t){return t.code===`ENOENT`?{folders:[],files:[]}:{path:e,error:t.message}}}function zz(e,t){if(!t.isSymbolicLink())return!1;try{return p.statSync(s.join(e,t.name)).isDirectory()}catch{return!0}}function Bz(e){try{return p.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}const Vz=[`json5`,`json`];function Hz(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Vz.map(t=>s.join(e,`.cc-candybar.${t}`)):[],...Vz.map(e=>s.join(r,`.cc-candybar.${e}`)),...Vz.map(e=>`${Uz()}.${e}`)])]}function Uz(){let e=process.env.XDG_CONFIG_HOME??s.join(S.homedir(),`.config`);return s.join(e,`cc-candybar`,`config`)}function Wz(e,t,n){let r=[],i=new Map;for(let a of Hz(e,t,n)){let e=Bz(a);if(e===`absent`)continue;if(e!==`present`){r.push(e);continue}let t=s.join(p.realpathSync(s.dirname(a)),s.basename(a).replace(/\.(json5|json)$/,``));i.has(t)||i.set(t,a)}let a=[...i.values()].reverse();if(n===void 0)return{kind:`chain`,layers:a,home:Gz(a),unchecked:r};let[o]=r,c=n;return a.length>0?{kind:`chain`,layers:a,home:c,unchecked:r}:o===void 0?{kind:`missing`,path:n,home:c}:{kind:`unreadable`,...o,home:c}}function Gz(e){let t=Uz();return e.find(e=>Vz.some(n=>e===`${t}.${n}`))??`${t}.${Vz[0]}`}function Kz(e,t,n){let r=Wz(e,t,n),i=r.kind===`chain`?r.layers:[];return{path:r.home,above:i.filter(e=>e!==r.home),projectDir:e??null,cwd:t??null}}function qz(e){return Jz(e).join(`
179
+ `)||null}function Jz(e){switch(e.kind){case`chain`:return e.unchecked.map(e=>`Config location could not be checked: ${e.path} — ${e.error}`);case`missing`:return[`Config file not found: ${e.path} — rendering the bundled default until it appears`];case`unreadable`:return[`Config file could not be read: ${e.path} — ${e.error} — rendering the bundled default until it can be`]}}function Yz(e,t){let n=Hz(e,t).filter(e=>Bz(e)===`present`),r=new Map;for(let e of n){let t=s.dirname(e),n=s.basename(e).replace(/\.(json5|json)$/,``),i=s.join(t,n);r.has(i)||r.set(i,[]),r.get(i).push(e)}let i=[...r.values()].filter(e=>e.length>1);return i.length===0?null:`config-extension collision: ${i.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function Xz(e,t,n,r){return e===null?{...oB,config:PF(oB.raw,t)}:Qz(e,p.readFileSync(e,`utf-8`),t,n,r)}const Zz={projectDir:null,checkout:null,beneath:{dropped:[],rendering:new Map}};function Qz(e,t,n,r,i){let a=lB(e,t,i,(t,a)=>{let o=_z(gz(t,e),r,{config:n,rendering:r.beneath.rendering},(t,n,r)=>iB(t,n,r,e,i)),s=Sz(o,r.beneath.dropped);return{inherited:new Set([...RI(o.config),...a.filter(e=>s(e).length>0)]),layer:{plugins:o,owning:s}}}),{plugins:o,owning:s}=a.layer,c=Cz(PF(a.raw,o.config),s);return{source:t,raw:a.raw,warnings:[...a.warnings,...o.dropped.map(sz)],plugins:{loaded:o.loaded,dropped:o.dropped,reached:c.reached,rendering:o.rendering},config:c.config}}const $z=new WeakMap;function eB(e,t,n,r){let i=JSON.stringify([[...r??[]].sort(),e.map(e=>[e,nB(e)])]),a=$z.get(n)??new Map;$z.set(n,a);let o=JSON.stringify([t.projectDir,t.checkout?.root??null]),s=a.get(o);if(s?.key===i)return s.layer;let c=_z(e,t,{config:n,rendering:new Map},(e,t,n)=>iB(e,t,n,`<installed plugins>`,r));return a.set(o,{key:i,layer:c}),c}function tB(e,t,n){return _z(e,{projectDir:null,checkout:n},{config:t,rendering:new Map},(e,t,n)=>iB(e,t,n,`<plugin install>`,void 0)).dropped}function nB(e){try{let t=p.statSync(e);return`${t.ino}:${t.size}:${t.mtimeMs}`}catch(e){return e.code??`unreadable`}}function rB(e,t,n,r,i=e=>p.readFileSync(e,`utf-8`),a){let o={projectDir:r.projectDir,checkout:r.cwd===null?null:_D(r.cwd)},s=Lz(o.projectDir),c=eB(s.definitions,o,t,a),l={...c,dropped:[...c.dropped,...s.strays]};n.warned(s.unchecked.map(e=>`Plugin folder could not be listed: ${e.path} — ${e.error}`));let u=l.config,d=[];for(let t of e){n.entered(t);let e=d.at(-1)?.plugins,r=Qz(t,i(t),d.at(-1)?.config??u,{...o,beneath:{dropped:[...l.dropped,...d.flatMap(e=>e.plugins.dropped)],rendering:e?.rendering??l.rendering}},a);n.warned(r.warnings),d.push({...r,path:t})}let f=new Set(d.flatMap(e=>[...e.plugins.reached])),m=e=>f.has(e.path),h=l.dropped.filter(m),g=l.dropped.filter(e=>!m(e));n.warned(h.map(sz));let _={checkout:o.checkout,roots:s.roots,loaded:l.loaded,dropped:h,unreached:g,reached:f,rendering:d.at(-1)?.plugins.rendering??l.rendering},v=d.at(-1);if(v===void 0)return{layers:d,base:u,installed:_,config:sB(Xz(null,u,Zz),`<default>`,a)};try{return{layers:d,base:u,installed:_,config:sB(v,v.path,a)}}catch(e){for(let e of d.slice(0,-1))n.entered(e.path),sB(e,e.path,a);throw n.entered(v.path),e}}function iB(e,t,n,r,i){if(n){sB(aB(e),r,i);return}let a=vz(t),o=[],s={source:``,issues:o,allowedPalettes:new Set,groups:[]};if(tz(s,e,cb(e),a),nz(s,e,a),o.length>0)throw new Sg(r,o)}function aB(e){return{config:e,raw:{root:e.root,presets:e.presets},source:``}}const oB={raw:{},source:``,warnings:[],plugins:{loaded:[],dropped:[],reached:new Set,rendering:new Map}};function sB({config:e,raw:t,source:n},r=`<config>`,i=new Set(dh())){let a=[],o={source:n,issues:a,allowedPalettes:i,groups:[]};if(NR(o,e,t),nz(o,e),a.length>0)throw new Sg(r,a);let s=OL(e,a);if(a.length>0)throw new Sg(r,a);return fF(MP(s))}function cB(e,t,n=new Set(dh()),r=uB){return lB(e,t,n,()=>({inherited:r,layer:null})).raw}function lB(e,t,n,r){let i=dB(e,t),a=Tg(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(dh()),groups:[]};if(!Mg(i))throw new Sg(e,[{path:``,message:`Config root must be an object, got ${Ng(i)}`}],o);let{inherited:l,layer:u}=r(i.plugins===void 0?[]:mB({...c,issues:[]},i.plugins)??[],Mg(i.segments)?Object.keys(i.segments):[]),d=fB(c,i,l);if(s.length>0)throw new Sg(e,s,o);return{raw:d,warnings:o,layer:u}}const uB=new Set;function dB(e,t){try{return Jr.default.parse(t)}catch(t){let n=t;throw new Sg(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function fB(e,t,n){for(let n of Object.keys(t))pB.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...pB].join(`, `)}`,line:K(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=Ok(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=GF(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=zI(e,t.segments,n)),t.layout!==void 0&&e.issues.push({path:`layout`,message:`"layout" is no longer supported — use "root" with the A-grammar instead.
180
180
  Replace: layout: [["seg1", "seg2"], ["seg3"]]
181
181
  With: root: { v: [{ h: ["seg1", "seg2"] }, "seg3"] }
182
182
  Single-row example: root: { h: ["seg1", "seg2"] }`,line:K(e.source,[`layout`])}),t.root!==void 0&&(r.root=cL(e,`root`,t.root)),t.actions!==void 0&&(r.actions=ML(e,t.actions)),t.looks!==void 0&&e.issues.push({path:`looks`,message:`"looks" was renamed "styles" — move the block under styles: { … } (and globals.look to globals.style)`,line:K(e.source,[`looks`])}),t.styles!==void 0&&(r.styles=wR(e,t.styles)),t.themeDefaults!==void 0&&(r.themeDefaults=Dk(e,t.themeDefaults)),t.presets!==void 0&&(r.presets=ER(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=jk(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=DR(e,t.helpers)),t.plugins!==void 0&&(r.plugins=mB(e,t.plugins)),gL(e,r),EL(e,r),uA(e,r),XO(e,r,X,`the global settings menu`),r}const pB=new Set([`globals`,`variables`,`segments`,`layout`,`looks`,`root`,`actions`,`styles`,`themeDefaults`,`presets`,`editGlobals`,`helpers`,`plugins`]);function mB(e,t){if(Array.isArray(t)&&t.every(e=>typeof e==`string`&&e!==``))return t;e.issues.push({path:`plugins`,message:`"plugins" must be a list of plugin definition paths, got ${Ng(t)}`,line:K(e.source,[`plugins`])})}const hB={},gB=UM(`commands.`),_B=YM(`autocompact.`,e=>`{{ template "formatTokenCount" ${e} }}`),vB=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,yB=`{{ \$dir := .current_dir }}{{ if and (ne .home "") (or (eq .home .current_dir) (hasPrefix (printf "%s/" .home) .current_dir)) }}{{ \$dir = printf "~%s" (trimPrefix .home .current_dir) }}{{ else }}{{ if or (eq .project_dir .current_dir) (hasPrefix (printf "%s/" .project_dir) .current_dir) }}{{ $dir = ternary (${vB}) (basename .project_dir) (ne (${vB}) "") }}{{ end }}{{ end }}{{ action "copyDir" (abbreviatePath \$dir) }}`,bB=`{{ ${LA} }}`,xB={min:0,max:100,step:5},SB={warnAt:{label:`warning at %`,domain:xB,default:50},errorAt:{label:`error at %`,domain:{...xB,atLeast:`warnAt`},default:80}};function CB(e){return{budget:{label:`budget $`,domain:{min:0,max:1e4,step:5},default:e},warnAt:{label:`warning at %`,domain:xB,default:80}}}const wB={globals:{palette:`tokyo-night`},variables:{...gB.variables,...zO,current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},"effort.level":{kind:`input`,path:`effort.level`,default:``},"effort.glyphs":{kind:`literal`,value:`? 󰅃 󰅃 󰄿 󰶼`},version:{kind:`input`,path:`version`,default:``},home:{kind:`input`,path:`home`,default:``},"tmux.session":{kind:`input`,path:`tmux.session`,default:``},"host.name":{kind:`input`,path:`host.name`,default:``},"host.user":{kind:`input`,path:`host.user`,default:``},"host.ssh":{kind:`input`,path:`host.ssh`,type:`boolean`,default:!1},"git.repoName":{kind:`input`,path:`git.repoName`,default:``},"git.branch":{kind:`input`,path:`git.branch`,default:``},"git.sha":{kind:`input`,path:`git.sha`,default:``},"git.ahead":{kind:`input`,path:`git.ahead`,type:`number`,default:0},"git.behind":{kind:`input`,path:`git.behind`,type:`number`,default:0},"git.staged":{kind:`input`,path:`git.staged`,type:`number`,default:0},"git.unstaged":{kind:`input`,path:`git.unstaged`,type:`number`,default:0},"git.untracked":{kind:`input`,path:`git.untracked`,type:`number`,default:0},"git.conflicts":{kind:`input`,path:`git.conflicts`,type:`number`,default:0},"git.upstream":{kind:`input`,path:`git.upstream`,default:``},"git.tracking":{kind:`input`,path:`git.tracking`,default:``},"git.stash":{kind:`input`,path:`git.stash`,type:`number`,default:0},"git.status":{kind:`input`,path:`git.status`,default:`clean`},"git.operation":{kind:`input`,path:`git.operation`,default:``},"git.timeSinceCommit":{kind:`input`,path:`git.timeSinceCommit`,type:`number`,default:0},"git.color.branch":{kind:`literal`,value:`primary`},"git.color.staged":{kind:`literal`,value:`success`},"git.color.unstaged":{kind:`literal`,value:`warning`},"git.color.untracked":{kind:`literal`,value:`accent`},"git.color.conflicts":{kind:`literal`,value:`error`},"git.color.ahead":{kind:`literal`,value:`success`},"git.color.behind":{kind:`literal`,value:`warning`},"git.color.stash":{kind:`literal`,value:`accent`},"git.detail":{kind:`state`,key:`git-detail`,default:`collapsed`},"git.prNumber":{kind:`input`,path:`git.prNumber`,type:`number`,default:0},"git.prState":{kind:`input`,path:`git.prState`,default:``},"git.prUrl":{kind:`input`,path:`git.prUrl`,default:``},"git.prError":{kind:`input`,path:`git.prError`,default:``},"cache.expiresAt":{kind:`input`,path:`cache.expiresAt`,type:`number`,default:0},"session.cost":{kind:`input`,path:`session.cost`,type:`number`,default:0},"session.tokens":{kind:`input`,path:`session.tokens`,type:`number`,default:0},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"burn.costPerHour":{kind:`input`,path:`burn.costPerHour`,type:`number`,default:-1},"block.etaMinutes":{kind:`input`,path:`block.etaMinutes`,type:`number`,default:-1},"weekly.etaMinutes":{kind:`input`,path:`weekly.etaMinutes`,type:`number`,default:-1},"speed.input":{kind:`input`,path:`speed.input`,type:`number`,default:-1},"speed.output":{kind:`input`,path:`speed.output`,type:`number`,default:-1},"speed.total":{kind:`input`,path:`speed.total`,type:`number`,default:-1},"speed.history":{kind:`input`,path:`speed.history`,type:`string`,default:``},"context.totalTokens":{kind:`input`,path:`context.totalTokens`,type:`number`,default:0},"context.contextLeft":{kind:`input`,path:`context.contextLeft`,type:`number`,default:100},"memento.ceiling":{kind:`input`,path:`memento.ceiling`,type:`number`,default:-1},"memento.off":{kind:`input`,path:`memento.off`,type:`boolean`,default:!1},"memento.session":{kind:`input`,path:`memento.session`,default:``},"memento.error":{kind:`input`,path:`memento.error`,default:``},"metrics.lastResponseTime":{kind:`input`,path:`metrics.lastResponseTime`,type:`number`,default:0},"metrics.responseTime":{kind:`input`,path:`metrics.responseTime`,type:`number`,default:0},"metrics.sessionDuration":{kind:`input`,path:`metrics.sessionDuration`,type:`number`,default:0},"metrics.messageCount":{kind:`input`,path:`metrics.messageCount`,type:`number`,default:0},"metrics.linesAdded":{kind:`input`,path:`metrics.linesAdded`,type:`number`,default:0},"metrics.linesRemoved":{kind:`input`,path:`metrics.linesRemoved`,type:`number`,default:0},"activity.command":{kind:`input`,path:`activity.command`,type:`string`,default:``},"activity.todo.total":{kind:`input`,path:`activity.todo.total`,type:`number`,default:0},"activity.todo.completed":{kind:`input`,path:`activity.todo.completed`,type:`number`,default:0},"activity.todo.position":{kind:`input`,path:`activity.todo.position`,type:`number`,default:0},"activity.todo.active":{kind:`input`,path:`activity.todo.active`,type:`string`,default:``},"activity.tool.running":{kind:`input`,path:`activity.tool.running`,type:`string`,default:``},"activity.tool.done":{kind:`input`,path:`activity.tool.done`,type:`string`,default:``}},segments:{directory:{group:`location`,description:"The current directory, shortened fish-style — `~` under home, project-relative inside the project. Click to copy the full path.",template:yB},model:{group:`model-context`,description:`The active model's display name, followed by the effort gauge (a chevron ladder, climbing on a bubble at max) when an effort level is set.`,template:`✱ {{ formatModelName .model.display_name }}{{ if ne .effort.level "" }} {{ template "effortGauge" . }}{{ end }}`,when:`{{ ne .model.display_name "" }}`},sessionId:{group:`session-tools`,description:`The session id, truncated to 8 characters.`,template:`⌗{{ trunc 8 .session.id }}`,when:`{{ ne .session.id "" }}`},version:{group:`model-context`,description:`The Claude Code version reported in the hook payload.`,template:`◈ v{{ .version }}`,when:`{{ ne .version "" }}`},tmux:{group:`location`,description:`The tmux session name; hidden when not inside tmux.`,template:`tmux:{{ .tmux.session | default "none" }}`,when:`{{ ne .tmux.session "" }}`},host:{group:`location`,description:`user@host on a warning background, shown only over SSH.`,template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,when:`{{ .host.ssh }}`},gitaculous:{group:`git`,description:`The git state: a summary (branch, ahead/behind, S/U/? flags) that the arrow at its right edge expands to every fact — repo, in-progress operation, sha, upstream ±, stash count, time since the last commit.`,template:`{{ if eq .git.detail "expanded" }}{{ template "gitExpanded" . }}{{ else }}{{ template "gitCollapsed" . }}{{ end }} {{ action "gitDetail" "▸" "◂" }}`,fg:bB,when:`{{ ne .git.branch "" }}`,settings:{aheadBehind:{label:`ahead/behind`,domain:`bool`,default:!0},flags:{label:`dirty flags`,domain:`bool`,default:!0},operation:{label:`operation`,domain:`bool`,default:!0},repo:{label:`repo name`,domain:`bool`,default:!0},sha:{label:`commit hash`,domain:`bool`,default:!0},stash:{label:`stash`,domain:`bool`,default:!0},upstream:{label:`upstream`,domain:`bool`,default:!0},age:{label:`time since commit`,domain:`bool`,default:!0}}},gitPr:{group:`git`,description:"The pull request open for this branch, as a link; `⚠ PR` when the forge lookup failed.",template:`{{ if eq .git.prState "open" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,when:`{{ or (eq .git.prState "open") (ne .git.prError "") }}`},toolbar:{group:`session-tools`,description:`Quick actions: copy the session id, and open the project, transcript or repo.`,template:MM(``).template},commands:{group:`session-tools`,description:`Type /compact, /model or /clear into this session; /clear asks for a second click. Hidden when not inside tmux.`,template:gB.template,when:gB.when},themeSwitcher:{group:`session-tools`,description:"`◀ <theme> ▶`: the theme the bar is wearing; ◀ and ▶ switch this session to the previous or next theme, wrapping at the ends.",template:`{{ carousel "stepTheme" 0 }}`},session:{group:`cost-limits`,description:`This session's cost and token total, with a budget warning once a budget is configured.`,template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:CB(0)},today:{group:`cost-limits`,description:`Today's cost and tokens across every session, with a budget warning once a budget is configured.`,template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:CB(50)},block:{group:`cost-limits`,description:`The 5-hour rate-limit block: percent used and time to reset, heating to warning then error.`,template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:SB,when:`{{ gt .block.resetsAt 0 }}`},weekly:{group:`cost-limits`,description:`The weekly rate-limit quota: percent used and time to reset, heating to warning then error.`,template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:SB,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{group:`cost-limits`,description:`Spend per hour, with the projected time to the 5-hour and weekly limits.`,template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 (tint) 0 "error" .settings.errorWithin "warning" .settings.warnWithin (tint) }}`,settings:{errorWithin:{label:`error within (min)`,domain:{min:0,max:300,step:5},default:30},warnWithin:{label:`warning within (min)`,domain:{min:0,max:300,step:5,atLeast:`errorWithin`},default:60}},when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{group:`activity`,description:`Token throughput for the latest exchange: output, input, and total.`,template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{group:`activity`,description:`A sparkline of recent token throughput.`,template:`⚡ {{ sparkline .speed.history 24 }}`,when:`{{ ne .speed.history "" }}`},cacheTimer:{group:`activity`,description:"Minutes until the prompt cache expires, or `cold` once it has.",template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ readableOn (color (cascade (minutesUntilReset .cache.expiresAt) "0:error" "9:warning" "21:foreground")) (bgOf) ${Pm} }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{group:`model-context`,description:`Context used, in tokens and percent remaining, heating as it fills.`,template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 (tint) }}`,when:`{{ gt .context.totalTokens 0 }}`},ceiling:{group:`model-context`,description:`The memento plugin's context ceiling for this session: − and + move it by 100K, ∞ lifts it, ↺ drops this session's own setting.`,template:`{{ if ne .memento.error "" }}⌈ ⚠ {{ .memento.error }} {{ action "ceiling.clear" "↺" }}{{ else }}⌈ {{ if .memento.off }}off{{ else }}{{ template "formatTokenCount" .memento.ceiling }} {{ action "ceiling.lower" "−" }} {{ action "ceiling.raise" "+" }} {{ action "ceiling.off" "∞" }}{{ end }}{{ if ne .memento.session "" }} {{ action "ceiling.clear" "↺" }}{{ end }}{{ end }}`,bg:`{{ if ne .memento.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .memento.ceiling 0) (ne .memento.error "") }}`},autocompact:{group:`model-context`,description:`Claude Code's auto-compact window: − and + move it by 100K, ↺ returns it to auto. Clicks type /autocompact into this session, so the controls show only inside tmux.`,template:_B.template,bg:_B.bg,when:_B.when},metrics:{group:`activity`,description:`Response times, session duration, message count, and lines added/removed.`,template:`{{ if .metrics.lastResponseTime }} Δ {{ template "formatResponseTime" .metrics.lastResponseTime }}{{ end }}{{ if .metrics.responseTime }} ⧖ {{ template "formatResponseTime" .metrics.responseTime }}{{ end }}{{ if .metrics.sessionDuration }} ⧗ {{ template "formatDuration" .metrics.sessionDuration }}{{ end }}{{ if .metrics.messageCount }} ◆ {{ .metrics.messageCount }}{{ end }}{{ if .metrics.linesAdded }} + {{ .metrics.linesAdded }}{{ end }}{{ if .metrics.linesRemoved }} - {{ .metrics.linesRemoved }}{{ end }} `,when:`{{ or (gt .metrics.lastResponseTime 0.0) (gt .metrics.responseTime 0.0) (gt .metrics.sessionDuration 0.0) (gt .metrics.messageCount 0) (gt .metrics.linesAdded 0) (gt .metrics.linesRemoved 0) }}`},activity:{group:`activity`,description:`What Claude is doing: the slash command that opened the turn, the in-progress todo, and the tools in flight.`,template:`{{ if .activity.command }} ⌘ {{ .activity.command }}{{ end }}{{ if .activity.todo.total }}{{ if .activity.todo.active }} ☐ {{ .activity.todo.position }}/{{ .activity.todo.total }} {{ abbrev 32 .activity.todo.active }}{{ else }} ☑ {{ .activity.todo.completed }}/{{ .activity.todo.total }}{{ end }}{{ end }}{{ if .activity.tool.running }} ⟳ {{ template "formatToolTally" .activity.tool.running }}{{ end }}{{ if .activity.tool.done }} ✓ {{ template "formatToolTally" .activity.tool.done }}{{ end }} `,when:`{{ or (ne .activity.command "") (gt .activity.todo.total 0) (ne .activity.tool.running "") (ne .activity.tool.done "") }}`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`activity`}]}}},actions:{...MM(``).actions,...gB.actions,copyDir:{copy:`{{ .current_dir }}`},stepTheme:{set:`theme`,from:`themes`},gitDetail:{set:`git-detail`,cycle:[`collapsed`,`expanded`]},"ceiling.raise":{ceiling:`set`,to:`+100_000`},"ceiling.lower":{ceiling:`set`,to:`-100_000`},"ceiling.off":{ceiling:`set`,to:`off`},"ceiling.clear":{ceiling:`clear`},..._B.actions},styles:{none:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0},vivid:{hueShift:0,chromaScale:1.35,lightnessScale:1,lightnessShift:0},muted:{hueShift:0,chromaScale:.55,lightnessScale:1,lightnessShift:0},dim:{hueShift:0,chromaScale:1,lightnessScale:.85,lightnessShift:0},bright:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:.08},inverted:{hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1}},themeDefaults:hB,presets:{default:{},compact:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`context`}]},globals:{padding:0}},verbose:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},zen:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`context`}]},globals:{endcaps:`plain`,style:`dim`}},git:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`activity`}]}]}},usage:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`session`},{kind:`segment`,name:`today`},{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},dense:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`session`},{kind:`segment`,name:`activity`}]},globals:{padding:0}}},editGlobals:{endcaps:`plain`,default_separator:` | `},helpers:{effortGauge:`{{ \$ord := default 0 (get (dict "low" 1 "medium" 2 "high" 3 "xhigh" 4 "max" 5) .effort.level) }}{{ \$glyphs := compact (splitList " " .effort.glyphs) }}{{ $bubble := readableOn (mix (bgOf) (color "accent") 40) (bgOf) 1.08 }}{{ $climbing := readableOn (stepped 1 (color "primary") 1 (color "secondary") 1 (color "accent")) $bubble ${Pm} }}{{ \$climb := frames 1 (index \$glyphs 1) 1 (index \$glyphs 3) 1 (index \$glyphs 4) }}{{ if eq \$ord 5 }}{{ fg \$bubble "" }}{{ bg \$bubble (fg \$climbing \$climb) }}{{ fg \$bubble "" }}{{ else }}{{ fg (ramp $ord "step" 0 (${LA}) 2 (readableOn (color "accent") (bgOf) ${Pm})) (index $glyphs $ord) }}{{ end }}`,gitPaint:`{{ fg (readableOn (color .color) (bgOf) ${Pm}) .text }}`,gitCollapsed:`{{ template "gitBranch" . }}{{ template "gitAheadBehind" . }}{{ template "gitFlags" . }}`,gitExpanded:`(git){{ template "gitRepo" . }}{{ template "gitOperation" . }}{{ template "gitSha" . }}{{ template "gitFlags" . }} {{ template "gitBranch" . }}{{ template "gitUpstream" . }}{{ template "gitStash" . }}{{ template "gitAge" . }}`,gitBranch:`⎇ {{ template "gitPaint" (dict "color" .git.color.branch "text" .git.branch) }}`,gitRepo:`{{ if and .settings.repo (ne .git.repoName "") }} {{ .git.repoName }}{{ end }}`,gitOperation:`{{ if and .settings.operation (ne .git.operation "") }} [{{ .git.operation }}]{{ end }}`,gitSha:`{{ if and .settings.sha (ne .git.sha "") }} {{ .git.sha }}{{ end }}`,gitFlags:`{{ if and .settings.flags (or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0)) }} {{ if gt .git.staged 0 }}{{ template "gitPaint" (dict "color" .git.color.staged "text" "S") }}{{ end }}{{ if gt .git.unstaged 0 }}{{ template "gitPaint" (dict "color" .git.color.unstaged "text" "U") }}{{ end }}{{ if gt .git.untracked 0 }}{{ template "gitPaint" (dict "color" .git.color.untracked "text" "?") }}{{ end }}{{ if gt .git.conflicts 0 }}{{ template "gitPaint" (dict "color" .git.color.conflicts "text" (printf "!%v" .git.conflicts)) }}{{ end }}{{ end }}`,gitAheadBehind:`{{ if and .settings.aheadBehind (or (gt .git.ahead 0) (gt .git.behind 0)) }} {{ if gt .git.ahead 0 }}{{ template "gitPaint" (dict "color" .git.color.ahead "text" (printf "+%v" .git.ahead)) }}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}{{ template "gitPaint" (dict "color" .git.color.behind "text" (printf "-%v" .git.behind)) }}{{ end }}{{ end }}`,gitUpstream:`{{ if and .settings.upstream (ne .git.upstream "") }} [{{ .git.upstream }}{{ template "gitAheadBehind" . }}]{{ end }}`,gitStash:`{{ if and .settings.stash (gt .git.stash 0) }} {{ template "gitPaint" (dict "color" .git.color.stash "text" (printf "(%v stashed)" .git.stash)) }}{{ end }}`,gitAge:`{{ if and .settings.age (gt .git.timeSinceCommit 0) }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:XM(`.`),formatTokens:`{{ template "formatTokenCount" . }} tokens`,formatToolTally:`{{ $names := splitList "," . }}{{ range $i, $pair := $names }}{{ if lt $i 2 }}{{ if $i }} {{ end }}{{ $kv := splitList ":" $pair }}{{ index $kv 0 }}{{ if ne (index $kv 1) "1" }}×{{ index $kv 1 }}{{ end }}{{ end }}{{ end }}{{ if gt (len $names) 2 }} +{{ sub (len $names) 2 }}{{ end }}`,formatRate:`{{ if lt . 0 }}—/hr{{ else }}{{ template "formatCost" . }}/hr{{ end }}`,formatEta:`{{ if lt . 0 }}—{{ else }}{{ template "formatLongTimeRemaining" . }}{{ end }}`,formatSpeed:`{{ if lt . 0 }}—{{ else }}{{ template "formatTokenCount" (round .) }}/s{{ end }}`,formatTokenBreakdown:`{{ $first := true }}{{ if gt .input 0 }}{{ template "formatTokenCount" .input }} in{{ $first = false }}{{ end }}{{ if gt .output 0 }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" .output }} out{{ $first = false }}{{ end }}{{ if or (gt .cacheCreation 0) (gt .cacheRead 0) }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" (add .cacheCreation .cacheRead) }} cached{{ $first = false }}{{ end }}{{ if $first }}0 tokens{{ end }}`,budgetStatus:`{{ if or (le .budget 0) (lt .cost 0) }}{{ else }}{{ $pct := minf 100 (mulf (divf .cost .budget) 100) }}{{ $p := printf "%.0f%%" $pct }}{{ if ge $pct .warn }} !{{ $p }}{{ else }}{{ if ge $pct 50 }} +{{ $p }}{{ else }} {{ $p }}{{ end }}{{ end }}{{ end }}`,formatTimeSince:`{{ if lt . 60 }}{{ . }}s{{ else if lt . 3600 }}{{ div . 60 }}m{{ else if lt . 86400 }}{{ div . 3600 }}h{{ else if lt . 604800 }}{{ div . 86400 }}d{{ else }}{{ div . 604800 }}w{{ end }}`,formatDuration:`{{ if lt . 60 }}{{ printf "%.0f" . }}s{{ else if lt . 3600 }}{{ printf "%.0f" (divf . 60) }}m{{ else if lt . 86400 }}{{ printf "%.1f" (divf . 3600) }}h{{ else }}{{ printf "%.1f" (divf . 86400) }}d{{ end }}`,formatResponseTime:`{{ if lt . 60 }}{{ printf "%.1f" . }}s{{ else }}{{ printf "%.1f" (divf . 60) }}m{{ end }}`,formatLongTimeRemaining:`{{ if ge . 1440 }}{{ $d := div . 1440 }}{{ $h := div (mod . 1440) 60 }}{{ if gt $h 0 }}{{ $d }}d {{ $h }}h{{ else }}{{ $d }}d{{ end }}{{ else if ge . 60 }}{{ $h := div . 60 }}{{ $m := mod . 60 }}{{ if gt $m 0 }}{{ $h }}h {{ $m }}m{{ else }}{{ $h }}h{{ end }}{{ else }}{{ . }}m{{ end }}`,formatResetCountdown:`{{ template "formatLongTimeRemaining" (add 1 (minutesUntilReset .)) }}`}},TB=new Set([wB.globals.palette,...Object.keys(wB.themeDefaults),...Object.values(wB.segments).map(e=>e.palette)].filter(e=>e!==void 0)),EB=PF(cB(`<default>`,JSON.stringify(wB),TB),wB),DB=ky(EB.presets);function OB(e){return DB.includes(e)}const kB=Object.freeze({});function AB(e,t){return e.kind===`decided`?t[e.name]??kB:kB}function jB(e,t){return{...e,...Object.fromEntries(P_.map(n=>[n,e[n]??t[n]]))}}const MB=e=>d_(t=>e[a_[t].setting]);function NB(e,t,n,r){let i=I_(e);return uh(t[e],i.kind===`session`?n(e):null,r[e],i.floor,i.parse)}function PB(e,t,n){let r=Ay(t(`preset`),e.globals.preset,e.presets),i=Ny(e,r),a=t(`edit.mode`)===`arrange`?e.editGlobals:{},o=my(a.palette,t(`theme`),i.palette),s=jB(i,AB(o,e.themeDefaults));return{...Object.fromEntries(M_.map(e=>[e,NB(e,a,t,s)])),preset:r,presetCustomized:n(r),theme:o,style:Ch(a.style,t(`style`),s.style,e.styles),effect:jh(a.effect,t(`effect`),s.effect),separator:a.default_separator??s.default_separator}}function FB(e,t){let n=e[t];switch(typeof n){case`boolean`:return n?zh:Bh;case`number`:return String(n);case`string`:return n;default:return n.kind===`decided`?n.name:null}}const IB=Object.entries(V_),LB=new Set(U_.map(e=>e.sessionKey)),RB=()=>!1;function zB(e,t){return PB(e,e=>LB.has(e)?t(e):null,RB)}const BB=[`preset`,`theme`];function VB(e,t,n){let r=new Set(BB.slice(0,n).map(e=>V_[e].sessionKey));return PB(e,e=>r.has(e)?t(e):null,RB)}function HB(e,t){let n=Array.from({length:BB.length+1},(n,r)=>VB(e,t,r));return e=>{let t=BB.indexOf(e);return n[t===-1?BB.length:t]}}function UB(e,t,n,r){return e.flatMap(([e,i])=>{let a=FB(t,e);return a===null||a===FB(n(e),e)?[]:[{...i,value:a,target:r(i)}]})}function WB(e,t,n){return FB(zB(e,t),n)}function GB(e,t){let n=zB(e,t);return UB(IB,n,HB(e,t),t=>KB(e,n.preset,t.configKey))}function KB(e,t,n){return n in(jy(e.presets,t).globals??{})?Gk(t,n):n}function qB(e,t,n){let r=Ay(t(V_.preset.sessionKey),e.globals.preset,e.presets),i=Kk(n);return{key:i?.scope===`globals`?KB(e,r,i.field):n,globals:Ny(e,r)}}function JB(e,t){let{preset:n}=zB(e,t);return ZB(e,n).flatMap(({id:e,setting:r,key:i,decl:a,saved:o})=>{let s=t(i),c=s===null?void 0:_g(a,s);return c===void 0||gg(c)===gg(o)?[]:[{preset:n,id:e,setting:r,key:i,value:c}]})}function YB(e,t,n){let r=new Map(n.map(e=>[e.key,e.value]));return ky(e.presets).flatMap(n=>{let i=ZB(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 mg(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:_g(e.decl,n);return[e.setting,i??e.saved]}))).map(({message:t})=>`placement "${e}": ${t}`)})})}const XB=new WeakMap;function ZB(e,t){let n=XB.get(e)??new Map;XB.set(e,n);let r=n.get(t);if(r!==void 0)return r;let i=[...Zh(My(e,t).node)].flatMap(t=>t.kind!==`segment`||t.drafts===void 0?[]:Object.entries(t.drafts).map(([n,{id:r,key:i}])=>{let a=fg(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 QB(e,t){let n=zB(e,t);return{from:n.preset,globals:jy(e.presets,n.preset).globals??{},picks:UB(IB.filter(([e])=>e!==`preset`),n,HB(e,t),e=>e.configKey),placements:JB(e,t)}}function $B(e,t){return PB({...e,globals:{palette:t},presets:{}},()=>null,RB)}function eV(e,t){let n=zB(e,t),r=FB(n,`theme`);if(r===null)return{kind:`rule`};let i=$B(e,r),a=Ny(e,n.preset),o=Object.fromEntries(P_.map(e=>[e,FB(a[e]===void 0?n:i,e)]));return{kind:`look`,theme:r,look:o,differs:P_.some(e=>o[e]!==FB(i,e))}}function tV(e){return{sessionKeys:U_.filter(t=>t.configKey===e).map(e=>e.sessionKey),fileKeys:[e,...Ck(e)?DB.map(t=>Gk(t,e)):[],...Wk(e)?dh().map(t=>Uk(t,e)):[]]}}function nV(e){return new Set(U_.map(e=>e.configKey).filter(t=>tV(t).fileKeys.some(t=>aV(e,iV(t)))))}function rV(e,t,n){let r=GB(e,n),i=new Set(r.map(e=>e.configKey)),a=J_(e=>i.has(V_[e].configKey)||t.has(V_[e].configKey)),o=eV(e,n);return{unsaved:r.length+JB(e,n).length,resettable:a,themeDefault:o.kind===`look`&&o.differs?{differs:!0,theme:o.theme}:{differs:!1}}}function iV(e){let t=Kk(e);if(t===null||t.scope===`preset-root`)throw Error(`reset layer "${e}" is not a value path`);return qk(t)}function aV(e,t){let[n,...r]=t;return n===void 0?e!==void 0:typeof e==`object`&&!!e&&aV(e[n],r)}const oV=dh(),sV=new Set(oV),cV=new Set(Mh),lV=e=>e?sV.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${oV.join(`, `)})`}:{ok:!1,reason:`theme name is required`},uV=e=>e?cV.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown endcaps "${e}" (have: ${Mh.join(`, `)})`}:{ok:!1,reason:`endcaps name is required`},dV=new Set([`1`,`true`]),fV=new Set([`0`,`false`]),pV={endcaps:uV,theme:lV,"toolbar-expanded":e=>dV.has(e)?{ok:!0,value:`1`}:fV.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}},mV=TF(pV,`state`,xV);function hV(e,t){return mV.register(e,t)}function gV(e){return mV.gateFor(e)}function _V(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:zy(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 vV(e){return e.filter(e=>e.spec.kind!==`allow-list`||!Object.hasOwn(pV,e.key))}function yV(e,t,n){let r=Y_.get(n);if(r!==void 0)return WB(e,t,r);for(let[,t]of cg(e))if(t.key===n)return t.default??null;return null}function bV(e){let t=JP(e);return vV(Object.values(e.actions).flatMap(e=>_V(e,t)))}function xV(e){return CF(bV(e))}const SV=`update.dismissed`,CV=`updateNotice`,wV=V_.updateNotice.sessionKey;function TV(e){return e.kind===`source`?e.newer.digest:ya(e.newer)}const EV=e=>`${e.version} [${ey(e.digest)}]`;function DV(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:EV(e.newer),running:EV(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:ya(e.newer),running:ya(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${xa}@${ya(e.newer)}`,`install`]}}}}const OV={kind:`idle`},kV={kind:`running`};function AV(e,t,n){if(e===null)return[];let r=TV(e);if(!n.enabled||n.dismissed===r)return[];let i=DV(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(`
@@ -491,31 +491,31 @@ function run(argv) {
491
491
  `);return{inMode:n!==`0`,screen:r}}function $X(e,t,n){return[`load-buffer`,`-b`,t,`-`,`;`,...n.length===0?[]:[`send-keys`,`-t`,e,...n,`;`],`paste-buffer`,`-p`,`-d`,`-b`,t,`-t`,e,`;`,`send-keys`,`-t`,e,`Enter`]}function eZ(e,t){let n=ZX(e,`claude-input.type`,$X(e.pane,`cc-candybar-slash`,[`C-s`]),t);return n.kind===`ok`?{kind:`typed`}:{kind:`refused`,reason:`cc-candybar typed a command moments ago — click again in a second (${n.reason})`}}function tZ(){return{read:QX,type:eZ}}function nZ(e){if(!e)throw new J(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new J(`invalid session id "${e}"`);return e}function rZ(e){return iZ(()=>decodeURIComponent(e))}function iZ(e){try{return e()}catch(e){throw e instanceof URIError?new J(`malformed wire encoding: ${e.message}`):e}}function aZ(e,t){let n=We({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 oZ=(e,t)=>aZ(rZ(e),t),sZ=(e,t)=>{let n=We({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,rZ(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`})`)}},cZ=(e,t)=>aZ(rZ(e),t),lZ=(e,t)=>aZ(rZ(e),t),uZ=(e,t)=>{let n=nZ(rZ(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},dZ=(e,t)=>{let[n=``,...r]=iZ(()=>xr(e)),i=nZ(n),a=gV(TZ(t,i));if(r.length===0)throw new J(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new J(`set-state: expected even-count <key>/<value> pairs, got ${r.length} segment(s) after session id (have keys: ${a.listKeys().join(`, `)})`);let o=[];for(let e=0;e<r.length;e+=2){let t=r[e],n=r[e+1];if(!t)throw new J(`set-state: empty key at pair ${e/2+1} (expected <sessionId>/<key>/<value>[/<key>/<value>...] segments)`);let i=a.validate(t,n);if(!i.ok)throw new J(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}hZ(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})`)},fZ=/^-?\d+$/;function pZ(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const mZ=(e,t)=>{let[n=``,r=``,i=``]=iZ(()=>xr(e)),a=nZ(n);if(!r)throw new J(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!fZ.test(i))throw new J(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=TZ(t,a),c=gV(s),l=c.rangeParamsFor(r);if(!l)throw new J(`step-state: key "${r}" is not a bounded (range) state key (have keys: ${c.listKeys().join(`, `)})`);let u=t.sessionState.get(a,r),d=u&&fZ.test(u)?gZ(l,parseInt(u,10)):_Z(`step-state`,r,l,yV(s,e=>t.sessionState.get(a,e),r)),f=pZ(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new J(`step-state: ${p.reason}`);hZ(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 hZ(e,t,n,r){let i=r.filter(e=>e.key.startsWith(iA));if(i.length===0)return;let a=YB(TZ(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new J(`${n}: refused — ${a.join(`; `)}`)}function gZ(e,t){return Math.max(e.min,Math.min(e.max,t))}function _Z(e,t,n,r){if(r===null)return n.min;if(!fZ.test(r))throw new J(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return gZ(n,parseInt(r,10))}const vZ=`render-origin`;function yZ(e,t,n){return{...e,configFile:t.get(n,`config-override`)??e.configFile}}function bZ(e){return JSON.stringify(e)}function xZ(e){let t;try{t=JSON.parse(e)}catch{throw new J(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new J(`render origin is not an object: ${e}`);let{projectDir:n,cwd:r,configFile:i}=t;if(typeof n!=`string`||typeof r!=`string`||i!==null&&typeof i!=`string`)throw new J(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,configFile:i}}function SZ(e,t){let n=CZ(e,t);if(n===null)throw new J(`session ${t} has not rendered yet — no config to act on`);return n}function CZ(e,t){let n=e.sessionState.get(t,vZ);return n===null?null:yZ(xZ(n),e.sessionState,t)}function wZ(e,t,n){let r=CZ(e,t);if(r===null)return;let{path:i}=EZ(r);n.some(e=>e.kind===`file`&&e.file===i)&&e.reloadConfig(r)}function TZ(e,t){return e.configFor(SZ(e,t))}function EZ(e){return Kz(e.projectDir,e.cwd,e.configFile??void 0)}function DZ(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.dlog}}const OZ=(e,t)=>{let[n=``,r=``,i=``]=iZ(()=>xr(e)),a=nZ(n),o=SZ(t,a),s=t.configFor(o),c=OF(s);if(!r)throw new J(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new J(`set-config: ${l.reason}`);let u=EZ(o),d=qB(s,e=>t.sessionState.get(a,e),r);Nq(DZ(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.dlog(`info`,`set-config: ${d.key}=${l.value} → ${u.path} (session=${a})`)},kZ=(e,t)=>{let[n=``,r=``,i=``]=iZ(()=>xr(e)),a=nZ(n);if(!r)throw new J(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!fZ.test(i))throw new J(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=SZ(t,a),c=t.configFor(s),l=OF(c),u=l.rangeParamsFor(r);if(!u)throw new J(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=EZ(s),f=qB(c,e=>t.sessionState.get(a,e),r),p=Mq(d.path,f.key),m=typeof p==`number`?gZ(u,p):_Z(`step-config`,r,u,AF(f.globals,r)),h=pZ(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new J(`step-config: ${g.reason}`);Nq(DZ(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})`)},AZ=(e,t)=>{let[n=``]=iZ(()=>xr(e)),r=nZ(n),i=SZ(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=GB(a,o),c=JB(a,o);if(s.length+c.length===0){t.dlog(`info`,`save: nothing unsaved (session=${r})`);return}let l=gV(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new J(`save: ${t.reason}`);return[e.target,t.value]});MZ(`save`,l,c);let d=EZ(i);Pq(DZ(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(jZ)].join(` `)} → ${d.path} (session=${r})`)},jZ=e=>`${e.preset}/${e.id}.settings.${e.setting}=${gg(e.value)}`;function MZ(e,t,n){for(let r of n){let n=t.validate(r.key,gg(r.value));if(!n.ok)throw new J(`${e}: ${n.reason}`)}}const NZ=(e,t)=>{let[n=``]=iZ(()=>xr(e)),r=nZ(n),i=SZ(t,r),a=t.configFor(i),o=QB(a,e=>t.sessionState.get(r,e)),s=gV(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new J(`save-preset: ${t.reason}`);return[e.configKey,t.value]});MZ(`save-preset`,s,o.placements);let l=EZ(i),u=Vq(DZ(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...U_.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,V_.preset.sessionKey,u),t.dlog(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(jZ)].join(` `)} → ${l.path} (session=${r})`)},PZ=(e,t)=>{let[n=``]=iZ(()=>xr(e)),r=nZ(n),i=SZ(t,r),a=eV(t.configFor(i),e=>t.sessionState.get(r,e));if(a.kind===`rule`)throw new J(`save-theme-default: the theme is chosen by a rule (globals.palette), so there is no name to save as a theme's default — pick one in the menu first`);let o=EZ(i);Hq(DZ(t,r),o,a.theme,a.look),t.reloadConfig(i);let s=new Set(GB(t.configFor(i),e=>t.sessionState.get(r,e)).map(e=>e.sessionKey)),c=P_.map(e=>V_[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} ${P_.map(e=>`${e}=${a.look[e]}`).join(` `)} → ${o.path} (session=${r})`)},FZ=(e,t)=>{let[n=``,r=``]=iZ(()=>xr(e)),i=nZ(n);if(!r)throw new J(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=SZ(t,i),o=EZ(a);Uq(DZ(t,i),o,r),t.reloadConfig(a);let s=V_.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.dlog(`info`,`delete-preset: ${r} ← ${o.path} (session=${i})`)},IZ=(e,t)=>{let[n=``,...r]=iZ(()=>xr(e)),i=nZ(n),a=SZ(t,i),o=OF(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new J(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=EZ(a),l=r.map(tV),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);Rq(DZ(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 LZ(e,t){let n=(e,t)=>[...Zh(My(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(ky(t.presets).flatMap(e=>n(t,e).map(t=>aA(UO(e),qh(t)))));return ky(e.presets).flatMap(t=>n(e,t).map(e=>({member:aA(UO(t),qh(e)),node:e})).filter(({member:e})=>!r.has(e)))}function RZ(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[$k]:[]])}const zZ=(e,t)=>{let[n=``,r=``,i=``]=iZ(()=>xr(e)),a=nZ(n),o=SZ(t,a),s=t.configFor(o),c=OF(s);if(!r)throw new J(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new J(`apply-layout-op: ${l.reason}`);let u=mF(l.value);if(u===null)throw new J(`apply-layout-op: "${l.value}" is not a layout op token`);let d=EZ(o),f=Wq(DZ(t,a),d,r,u);t.reloadConfig(o);let p=RZ(LZ(s,t.configFor(o)),t.sessionState.get(a,$k)).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})`)},BZ=(e,t)=>{let[n=``]=iZ(()=>xr(e)),r=nZ(n);t.journal.commit();let i=t.history.undo(r);wZ(t,r,i),t.dlog(`info`,`undo: restored ${fJ(i)} (session=${r})`)},VZ=(e,t)=>{let n=nZ(rZ(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,gV(TZ(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.dlog(`info`,`back: ${a} discarded=${i} (session=${n})`)},HZ=(e,t)=>{let n=nZ(rZ(e));t.journal.commit();let r=t.history.rewind(n);wZ(t,n,r),t.dlog(`info`,`rewind: put back ${fJ(r)||`nothing`} as edit mode found it (session=${n})`)},UZ=(e,t)=>{let[n=``]=iZ(()=>xr(e)),r=nZ(n);t.journal.commit();let i=t.history.redo(r);wZ(t,r,i),t.dlog(`info`,`redo: re-applied ${fJ(i)} (session=${r})`)},WZ=(e,t)=>{nZ(rZ(e)),t.applyUpdate()},GZ=`client-hints`;function KZ(e,t){let n=e.sessionState.get(t,GZ);if(n===null)throw new J(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new J(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new J(`client hints record is not an object: ${n}`);return yt(r)}function qZ(e,t,n){let r=pM(n);e.sessionState.setBatch(t,AM(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} ${OM(n.nerdFont,n.marks)} ${yM(n.terminal,n.clicked)} ${bM(n.terminal,n.width)} ${xM(n.install)} ${SM(n.daemon)} ${CM(n.data)} ${DM(n.transcripts)} ${wM(n.frames,n.claudeSettings)} ${EM(n.claudeSettings.origin.sources)} (session=${t})`)}function JZ(e,t){let n={kind:`clicked`,sessionId:t},r=e.clients.ofSession(t,uO(new Date)),i;try{i=mX(e.doctor,KZ(e,t),SZ(e,t),n=>e.sessionState.get(t,n),{kind:`ok`,value:e.serving()},{kind:`ok`,value:r.map(e=>e.rateLimits)},{kind:`ok`,value:r.map(e=>e.transcript)},n,{kind:`ok`,value:BJ(n,r)},pX(t,r),VY(e.doctorStores))}catch(e){throw e instanceof IJ?new J(e.message):e}return{...i,urlHandler:uX(e.clientVersion),install:zY(e.doctor.install,e.bundle,r.map(e=>e.client)),clicked:YZ(e,i)}}function YZ(e,{terminal:t,clicked:n}){let r=t.kind===`seen`?mj(t.identified):null;if(r===null)return n;try{return e.doctorStores.clicked.update(e=>PJ(e,r))}catch(t){return e.dlog(`warn`,`doctor: clicked terminal not filed for ${JSON.stringify(r)}: ${t instanceof Error?t.message:String(t)}`),n}}const XZ=(e,t)=>{let n=nZ(rZ(e));qZ(t,n,JZ(t,n))},ZZ=(e,t)=>{let n=MX(rZ(e));if(n===null)throw new J(`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`}`)},QZ=(e,t)=>{let[n=``,r=``]=iZ(()=>xr(e)),i=nZ(n),a=mM(r);if(a===void 0)throw new J(`doctor-fix: unknown check "${r}"`);let o=JZ(t,i),s=a.probe(o);if(s.ok||s.fix===void 0)throw new J(`doctor-fix: ${a.label} — ${s.ok?`nothing to fix`:s.reason}`);let c=hX(t.doctorStores,s.fix,o);if(c.kind===`failed`)throw new J(`doctor-fix: ${a.label} — ${c.reason}`);t.dlog(`info`,`doctor-fix: ${a.name} → ${Ej(s.fix)} (session=${i})`),qZ(t,i,c.value)},$Z=(e,t)=>{let[n=``,r=``,i=``]=iZ(()=>xr(e)),a=nZ(n),o=mM(r);if(o===void 0)throw new J(`doctor-mark: unknown check "${r}"`);if(!Cj.includes(i))throw new J(`doctor-mark: the mark is ${JSON.stringify(i)}, not ${Cj.join(` or `)}`);let s=JZ(t,a),c=o.probe(s);if(c.ok||c.sighting===void 0)throw new J(`doctor-mark: ${o.label} — ${c.ok?`nothing to mark`:`shows nothing to look at`}`);let l=[o.name,c.sighting.id,i],u=t.doctorStores.marks.update(e=>jJ(e,...l));if(u.kind===`failed`)throw new J(`doctor-mark: ${u.reason}`);t.dlog(`info`,`doctor-mark: ${o.name} ${i} on ${c.sighting.id} (session=${a})`),qZ(t,a,{...s,marks:u})},eQ=(e,t)=>{let[n=``,...r]=iZ(()=>xr(e)),i=nZ(n),a=SZ(t,i),o=Object.values(t.configFor(a).actions).filter(e=>`ceiling`in e).find(e=>{let t=AL(e);return t.length===r.length&&t.every((e,t)=>e===r[t])});if(o===void 0)throw new J(`ceiling: "${r.join(` `)}" is not a move this config declares`);let s=o.ceiling===`set`?{kind:`set`,to:o.to}:{kind:`clear`},c=rU({sessionId:i,projectDir:a.projectDir,cwd:a.cwd},KZ(t,i));t.memento.move(c,s),t.dlog(`info`,`ceiling: ${r.join(` `)} (session=${i} claudeConfigDir=${c.claudeConfigDir})`)},tQ=(e,t)=>{let[n=``,r=``]=iZ(()=>xr(e)),i=nZ(n),a=Object.values(t.configFor(SZ(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new J(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=XX(t.claudeInput,KZ(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.dlog(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new J(`${r} was not typed: ${s.reason}`);t.dlog(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)},nQ=`config-override`,rQ=new Map([[Xn,oZ],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new J(`load-config: expected <sessionId>/<path> (missing separator)`);let r=nZ(iZ(()=>decodeURIComponent(e.slice(0,n)))),i=iZ(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new J(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new J(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,nQ),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,nQ,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[Zn,sZ],[Jn,dZ],[Yn,mZ],[tr,OZ],[nr,kZ],[sr,IZ],[rr,AZ],[ir,NZ],[ar,PZ],[or,FZ],[cr,zZ],[lr,BZ],[ur,UZ],[dr,VZ],[fr,HZ],[$n,cZ],[er,lZ],[Qn,uZ],[pr,WZ],[mr,XZ],[hr,QZ],[gr,$Z],[_r,ZZ],[vr,eQ],[yr,tQ]]),iQ=new Set([Jn,Yn,tr,nr,sr,rr,ir,ar,or,cr,lr,ur,dr,fr,Qn,pr,mr,hr,gr,vr,yr]),aQ=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of Tr(Cr(e))){if(!i&&iQ.has(a)){let e=xr(o);e.length>0&&e[0]&&(i=e[0])}let e=rQ.get(a);if(!e){n.push(`unknown effect verb "${a}"`);continue}try{e(o,t)}catch(e){e instanceof J||(r=!0),n.push(`${a}: ${e instanceof Error?e.message:String(e)}`)}}if(n.length>0){i&&CJ(t.sessionState,i,n.join(`
492
492
  `),uO(new Date));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new J(e)}};function oQ(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 sQ=new Map([...rQ,[qn,aQ]].map(([e,t])=>[e,oQ(t)]));Object.freeze([...sQ.keys()]);const cQ=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`]),lQ=[[`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`]],uQ=[[`workspace.added_dirs`,`string-list`]];function dQ(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of lQ){let i=mQ(n,e);if(i==null)t.missingRequired.push(e);else{let n=fQ(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of uQ){let i=mQ(n,e),a=i===void 0?r:pQ(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))cQ.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function fQ(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function pQ(e){return Array.isArray(e)&&e.every(e=>fQ(e)===`string`)?`string-list`:fQ(e)}function mQ(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=n[e]}return n}function hQ(e,t){switch(e){case`vars`:return{what:e,vars:gQ(t)};case`segments`:return{what:e,segments:xQ(t)};case`config`:return{what:e,config:TQ(t)}}}function gQ(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=yQ(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=_Q(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:vQ(r.lastUpdatedMs())})}return o}function _Q(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 vQ(e){return e===null?null:Math.max(0,Date.now()-e)}function yQ(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,bQ(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}`,bQ(i));return t}function bQ(e){return e.kind}function xQ(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=CQ(n),o=SQ(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:wQ(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function SQ(e){let t=new Map;for(let n of ky(e.presets))for(let r of Zh(My(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=qh(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function CQ(e){let t=[],n=new Set;for(let r of Zh(Sy(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 wQ(e,t,n){let r=new Set;for(let i of eb(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 TQ(e){return e===null?null:e.config}const EQ=[`vars`,`segments`,`config`];function DQ(e){return typeof e==`string`&&EQ.includes(e)}function OQ(e){return Math.max(1,e-2)}const kQ={moving:1e3/30,still:1e3},AQ=1e3;function jQ(e){return o_.filter(t=>e[t].subscribers>0).map(t=>{let{subscribers:n,fps:r,shown:i}=e[t];return`${t}:${n}sub/${r}fps/${i?`shown`:`offscreen`}`}).join(`,`)||`-`}function MQ(e,t){e.push(t);let n=e.findIndex(e=>e>t-AQ);e.splice(0,n)}const NQ=e=>({resp:e,bytes:JSON.stringify(e)}),PQ=(e,t)=>a_[t].elsewhere===null?e.statusline:e.bar,FQ=e=>Math.round(1e3/e);var IQ=class{requests=new Map;feeds=new Map;stopWatching=null;drawn=0;pushed=0;refused=0;lookups=0;found=0;constructor(e){this.deps=e}note(e,t,n){let r=this.requests.get(e);if(r!==void 0&&r.order>n)return;this.requests.delete(e),this.requests.set(e,{req:t,order:n});for(let e of this.requests.keys()){if(this.requests.size<=256)break;this.feeds.has(e)||this.requests.delete(e)}let i=this.feeds.get(e);i!==void 0&&(i.noted++,this.wake(e))}subscribe(e,t){let n=this.requests.get(e);if(n!==void 0&&!this.deps.lanes(n.req)[t.lane])return this.refuse(e,t),()=>{};let r=this.feeds.get(e)??this.open(e);return r.followers.set(t,null),r.rates.has(t.lane)||r.rates.set(t.lane,[]),this.send(r,t),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${r.followers.size} data=${this.requests.has(e)?`Y`:`N`}`),()=>this.unsubscribe(r,t)}following(e){return new Set([...this.feeds.get(e)?.followers.keys()??[]].map(e=>e.lane))}wake(e){let t=this.feeds.get(e);if(t!==void 0)switch(t.phase.kind){case`drawing`:t.phase.again=!0;return;case`due`:clearTimeout(t.phase.timer),this.draw(t);return;case`waiting`:this.draw(t);return}}wakeWhere(e){for(let{sessionId:t,req:n}of this.watched())e(n)&&this.wake(t)}newestWhere(e){let t=null;for(let[n,{req:r,order:i}]of this.requests)e(r)&&(t===null||i>t.order)&&(t={sessionId:n,order:i});return this.lookups++,t!==null&&this.found++,t?.sessionId??null}watched(){return[...this.feeds.keys()].flatMap(e=>{let t=this.requests.get(e);return t===void 0?[]:[{sessionId:e,req:t.req}]})}feedsOf(e){let t=this.feeds.get(e);if(t===void 0)return f_;let n=this.deps.now()-AQ,r=this.shown(t);return d_(e=>{let i=t.rates.get(e);if(i===void 0)return l_;let a=0;for(let n of t.followers.keys())n.lane===e&&a++;let o=0;for(let e of i)e>n&&o++;return{subscribers:a,fps:o,shown:r}})}getStats(){let e=0;for(let t of this.feeds.values())e+=t.followers.size;return{feeds:this.feeds.size,subscribers:e,drawn:this.drawn,pushed:this.pushed,refused:this.refused,lookups:this.lookups,found:this.found}}open(e){let t=this.deps.now(),n={sessionId:e,followers:new Map,rates:new Map,unwatch:this.deps.watch(e,()=>this.wake(e)),phase:{kind:`waiting`},last:null,since:t,drawn:0,noted:0,moving:0,unseen:0,failed:0,pushed:0,pace:FQ(this.deps.periods.still),drawMs:0,summarizedAt:t};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),this.draw(n),n}unsubscribe(e,t){e.followers.delete(t)&&([...e.followers.keys()].some(e=>e.lane===t.lane)||e.rates.delete(t.lane),!(e.followers.size>0)&&(e.phase.kind===`due`&&clearTimeout(e.phase.timer),e.unwatch(),this.feeds.delete(e.sessionId),this.feeds.size===0&&(this.stopWatching?.(),this.stopWatching=null),this.summarize(e,`closed`)))}draw(e){return this.step(e).catch(t=>{if(this.deps.log(`error`,`feed sid=${JSON.stringify(e.sessionId)} threw: ${ie(t)}`),this.feeds.get(e.sessionId)!==e)return;let n=this.deps.now();this.schedule(e,null,n,n)})}async step(e){let t=this.requests.get(e.sessionId);if(t===void 0){e.phase={kind:`waiting`};return}let{req:n}=t,r={kind:`drawing`,again:!1};e.phase=r;let i=this.deps.now(),a=await this.deps.render(n,e.pace),o=this.deps.now();if(this.drawn++,e.drawn++,e.drawMs+=o-i,this.feeds.get(e.sessionId)===e&&(this.countFailure(e,a),this.push(e,a),this.feeds.get(e.sessionId)===e)){if(o-e.summarizedAt>=6e4&&this.summarize(e,`running`),r.again){this.draw(e);return}this.schedule(e,a,i,o)}}schedule(e,t,n,r){let i=t?.moves===!0,a=i&&this.shown(e);a&&e.moving++,i&&!a&&e.unseen++;let o=a?this.deps.periods.moving:this.deps.periods.still;e.pace=FQ(o),e.phase={kind:`due`,timer:setTimeout(()=>void this.draw(e),Math.max(0,n+o-r))}}shown(e){let t=this.requests.get(e.sessionId);return t===void 0||this.deps.shown(t.req)}countFailure(e,t){t.failure!==null&&e.failed++}push(e,t){let n=this.requests.get(e.sessionId);if(n!==void 0){let t=this.deps.lanes(n.req);for(let n of[...e.followers.keys()])t[n.lane]||(this.unsubscribe(e,n),this.refuse(e.sessionId,n))}if(e.followers.size===0)return;let r={bar:NQ(t.resp),statusline:NQ(t.statusline)};if(e.last?.answers.bar.bytes===r.bar.bytes&&e.last.answers.statusline.bytes===r.statusline.bytes)return;let i=e.last?.answers??null;e.last={answers:r},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);let a=this.deps.now();for(let[t,n]of e.rates)(i===null||PQ(i,t).bytes!==PQ(r,t).bytes)&&MQ(n,a);for(let t of e.followers.keys())this.send(e,t)}send(e,t){if(e.last===null)return;let{resp:n,bytes:r}=PQ(e.last.answers,t.lane);e.followers.get(t)!==r&&(t.frame(n,r),e.followers.set(t,r))}refuse(e,t){this.refused++,this.deps.log(`info`,`feed sid=${JSON.stringify(e)} refused lane=${t.lane} switched-off`),t.refused({ok:!1,error:MA(t.lane),code:`SWITCHED_OFF`,daemonV:3})}summarize(e,t){let n=this.deps.now();this.deps.log(`info`,`feed sid=${JSON.stringify(e.sessionId)} ${t} subscribers=${e.followers.size} lanes=${[...e.followers.keys()].map(e=>e.lane).join(`,`)||`-`} for=${Math.round((n-e.since)/1e3)}s drawn=${e.drawn} noted=${e.noted} moving=${e.moving} unseen=${e.unseen} failed=${e.failed} pushed=${e.pushed} pace=${e.pace}fps meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};function LQ(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 RQ=`#{pane_id} #{session_id} #{session_attached} #{window_active} #{window_zoomed_flag} #{pane_active}`,zQ=`#{session_id} #{client_control_mode}`;function BQ(e){let t=new Set;for(let n of e.split(`
493
493
  `)){let[e,r]=n.trim().split(` `);e!==void 0&&r===`1`&&t.add(e)}return t}function VQ(e,t){let n=new Set;for(let r of e.split(`
494
- `)){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 HQ=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: ${ie(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:VQ(t.stdout,BQ(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),!UQ(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 UQ(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 $=e=>({arity:e,keep:!0}),WQ=e=>({arity:e,keep:!1}),GQ={"--add-dir":$(`variadic`),"--agent":$(`one`),"--agents":$(`one`),"--allow-dangerously-skip-permissions":$(`none`),"--allowedTools":$(`variadic`),"--allowed-tools":$(`variadic`),"--append-system-prompt":$(`one`),"--autocompact":$(`one`),"--ax-screen-reader":$(`none`),"--bg":WQ(`none`),"--background":WQ(`none`),"--bare":$(`none`),"--betas":$(`variadic`),"--brief":$(`none`),"--chrome":$(`none`),"--cloud":WQ(`optional`),"-c":WQ(`none`),"--continue":WQ(`none`),"--dangerously-skip-permissions":$(`none`),"-d":$(`optional`),"--debug":$(`optional`),"--debug-file":$(`one`),"--desktop":WQ(`none`),"--disable-slash-commands":$(`none`),"--disallowedTools":$(`variadic`),"--disallowed-tools":$(`variadic`),"--effort":$(`one`),"--environment":WQ(`one`),"--exclude-dynamic-system-prompt-sections":$(`none`),"--fallback-model":$(`one`),"--file":$(`variadic`),"--fork-session":WQ(`none`),"--forward-subagent-text":$(`none`),"--from-pr":WQ(`optional`),"-h":WQ(`none`),"--help":WQ(`none`),"--ide":$(`none`),"--include-hook-events":$(`none`),"--include-partial-messages":$(`none`),"--input-format":$(`one`),"--json-schema":$(`one`),"--max-budget-usd":$(`one`),"--mcp-config":$(`variadic`),"--model":$(`one`),"-n":$(`one`),"--name":$(`one`),"--no-chrome":$(`none`),"--no-session-persistence":$(`none`),"--output-format":$(`one`),"--permission-mode":$(`one`),"--permission-prompts":$(`one`),"--plugin-dir":$(`one`),"--plugin-url":$(`one`),"-p":WQ(`none`),"--print":WQ(`none`),"--prompt-suggestions":$(`optional`),"--remote-control":$(`optional`),"--remote-control-session-name-prefix":$(`one`),"--replay-user-messages":$(`none`),"--restricted":$(`none`),"-r":WQ(`optional`),"--resume":WQ(`optional`),"--safe-mode":$(`none`),"--session-id":WQ(`one`),"--setting-sources":$(`one`),"--settings":$(`one`),"--strict-mcp-config":$(`none`),"--system-prompt":$(`one`),"--system-prompt-snapshot":$(`one`),"--teleport":WQ(`optional`),"--tmux":WQ(`none`),"--tools":$(`variadic`),"--verbose":$(`none`),"-v":WQ(`none`),"--version":WQ(`none`),"-w":WQ(`optional`),"--worktree":WQ(`optional`)},KQ=e=>e.startsWith(`-`)&&e!==`-`;function qQ(e,t){let n=[],r=e.slice(1),i=0;for(;i<r.length;){let e=r[i];if(i+=1,e===`--`)break;if(!KQ(e))continue;let t=e.indexOf(`=`),a=t===-1?e:e.slice(0,t),o=GQ[a];if(o===void 0)return{kind:`refused`,reason:`Claude Code was started with ${a}, which cc-candybar does not know how to carry to a restart`};let s=t===-1?o.arity===`one`?r.slice(i,i+1):o.arity===`optional`?r.slice(i,i+1).filter(e=>!KQ(e)):o.arity===`variadic`?JQ(r.slice(i),e=>!KQ(e)):[]:[];if(o.arity===`one`&&t===-1&&s.length===0)return{kind:`refused`,reason:`Claude Code was started with ${a} and no value after it`};i+=s.length,o.keep&&n.push(e,...s)}return{kind:`args`,args:[...n,`--resume`,t]}}function JQ(e,t){let n=e.findIndex(e=>!t(e));return n===-1?[...e]:e.slice(0,n)}const YQ=`candybar-band@cc-candybar`,XQ=s.join(`bin`,`cc-candybar-native`),ZQ=`@cc-candybar-bar-pane`,QQ=BM(`/reload-plugins`),$Q=BM(`/exit`),e$=e=>({kind:`done`,said:e});function t$(e){let t=YX(e.hints.tmux);if(t.kind===`refused`)throw new J(t.reason);return t.hint}const n$={band:{on:(e,t,n)=>{let r=ty(t.bundle);if(r===null)throw new J(`${a_.band.label} runs the band mod from a cc-candybar source checkout, and this daemon runs ${t.bundle} — run the daemon from a checkout (mod/README.md)`);let i=s.join(r,XQ);if(!n.fileExists(i))throw new J(`the band mod starts ${i}, which is not built — run \`just install-rust\` in ${r}`);return{kind:`underway`,said:`installing ${YQ} from ${r}`,finished:r$(e,r,n)}},off:()=>e$(`nothing to stop: the band mod draws nothing while the lane is off`)},statusline:{on:(e,t,n)=>{let r=t$(e),i=je(t.bundle);if(!n.fileExists(i))throw new J(`${a_.statusline.label} restarts Claude Code under the attach launcher, which is not at ${i} beside this daemon's bundle — rebuild (\`pnpm build\`) or reinstall cc-candybar`);if(!n.fileExists(e.transcript))throw new J(`this session has no conversation to resume yet — send a first message, then turn ${a_.statusline.label} off and on again`);return{kind:`underway`,said:`restarting Claude Code in ${r.pane} under the attach launcher`,finished:i$(e,r,[t.node[0],i],n)}},off:()=>e$(`nothing to stop: the attached statusline draws its command's output while the lane is off`)},pane:{on:(e,t,n)=>{let r=t$(e),i=n.barPanes(r);return i.length>0?e$(`bar pane ${i.join(`, `)} already draws ${r.pane}'s bar`):e$(`opened bar pane ${n.openBarPane(r,[...t.node,t.bundle,`bar-pane`,r.pane],{CC_CANDYBAR_SOCKET:t.socket})} under ${r.pane}`)},off:(e,t,n)=>{let r=YX(e.hints.tmux);if(r.kind===`refused`)return e$(`no bar pane to close: ${r.reason}`);let i=r.hint,a=n.barPanes(i);for(let e of a)n.closePane(i,e);return e$(a.length===0?`no bar pane draws ${i.pane}'s bar`:`closed bar pane ${a.join(`, `)}`)}}};async function r$(e,t,n){let r=e.hints.claudeConfigDir;await n.claude([`plugin`,`marketplace`,`add`,t],r),await n.claude([`plugin`,`install`,YQ],r);let i=XX(n.claudeInput,e.hints.tmux,QQ);if(i.kind===`refused`)throw Error(`the band mod is installed, but /reload-plugins was not typed: ${i.reason} — or type /reload-plugins yourself`);return`installed ${YQ} from ${t} and typed /reload-plugins into ${i.pane}`}async function i$(e,t,n,r){let i=await r.paneClaude(t);if(i.attached)return`left Claude Code in ${t.pane} running: it already runs under the attach launcher`;if(qX(r.claudeInput.read(t)))throw Error(`Claude Code in ${t.pane} is in the middle of a turn, and restarting it under the attach launcher would end that turn — once it is idle, turn ${a_.statusline.label} off and on again`);if(GX(r.claudeInput.read(t)))throw Error(`the prompt in ${t.pane} holds a draft, which restarting Claude Code under the attach launcher would lose — send or clear it, then turn ${a_.statusline.label} off and on again`);if(!i.fromShell)throw Error(`Claude Code is the first process of pane ${t.pane}, so nothing would be left in the pane to start it again under the attach launcher — start Claude Code from a shell in the pane`);let a=qQ(i.argv,e.sessionId);if(a.kind===`refused`)throw Error(`${a.reason} — restart it with that flag removed`);let[o,s]=n,c=await r.moduleGraph(o,Me(s),i.executable);if(!c.ok)throw Error(`Claude Code in ${t.pane} runs ${i.executable}, which the attach launcher cannot start (${c.reason}) — ${a_.statusline.label} needs the native Claude Code install (\`claude install\`), so it was left running`);let l=r.writeScript(`relaunch-${e.sessionId}.sh`,c$(i.cwd,[...n,i.executable,...a.args],i.env));try{let n=XX(r.claudeInput,t,$Q);if(n.kind===`refused`)throw Error(`Claude Code was not restarted under the attach launcher: /exit was not typed: ${n.reason}`);if(!await r.exited(i.pid,15e3))throw Error(`Claude Code in ${t.pane} did not exit within ${15e3/1e3} s of /exit, so it was not restarted under the attach launcher`);if(r.typeShellLine(t,`sh ${Ur(l)}`),!await r.followed(e.sessionId,`statusline`,3e4))throw Error(`Claude Code in ${t.pane} did not come back attached within ${3e4/1e3} s of its restart — the pane says why`)}finally{r.removeScript(l)}return`restarted Claude Code in ${t.pane} under the attach launcher, resuming ${e.sessionId}, and its statusline follows lane B`}const a$={switches:Object.fromEntries(o_.map(e=>[e,!1])),revision:0};var o$=class{seen=new Map;queued=new Map;constructor(e){this.deps=e}observe(e,t,n){let r=this.seen.get(e.sessionId)??a$;this.seen.delete(e.sessionId),this.seen.set(e.sessionId,{switches:t,revision:n});for(let[e]of this.seen){if(this.seen.size<=1024)break;this.seen.delete(e)}if(r.revision!==n)for(let n of o_){if(r.switches[n]===t[n])continue;let i=t[n];this.deps.defer(()=>this.enqueue(e.sessionId,()=>this.sync(e,n,i)))}}enqueue(e,t){let n=this.queued.get(e);if(n!==void 0){n.push(t);return}let r=[];this.queued.set(e,r);let i=t=>void t().then(()=>{let t=r.shift();t===void 0?this.queued.delete(e):i(t)});i(t)}sync(e,t,n){let r=`(session=${e.sessionId})`,i=i=>{let a=`lane: ${t} ${n?`on`:`off`}: ${i instanceof Error?i.message:String(i)}`;this.deps.log(`warn`,`${a} ${r}`),CJ(this.deps.state,e.sessionId,a,this.deps.now())},a;try{a=n$[t][n?`on`:`off`](e,this.deps.host,this.deps.edge)}catch(e){return i(e),Promise.resolve()}return this.deps.log(`info`,`lane: ${t} ${n?`on`:`off`} — ${a.said} ${r}`),a.kind===`underway`?a.finished.then(e=>this.deps.log(`info`,`lane: ${t} ${e} ${r}`),i):Promise.resolve()}};const s$=/^[A-Za-z_][A-Za-z0-9_]*=/;function c$(e,t,n){let r=n.filter(e=>s$.test(e));return[`cd -- ${Ur(e)} || exit 1`,...r.some(e=>e.startsWith(`CLAUDE_CONFIG_DIR=`))?[]:[`unset CLAUDE_CONFIG_DIR`],...r.map(e=>{let t=e.indexOf(`=`);return`export ${e.slice(0,t)}=${Ur(e.slice(t+1))}`}),`exec ${t.map(Ur).join(` `)}`,``].join(`
495
- `)}function l$(e,t,n){let r=ZH(e,`lane.tmux`,t,n);if(r.kind!==`ok`)throw Error(r.reason);return r.stdout}function u$(e,t){if(t.ok)return t.stdout;let n=t.error??[t.reason,t.stderr.trim(),t.stdout.trim()].filter(e=>e!==``).join(`: `);throw Error(`${e} failed (${n})`)}function d$(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`ok`in t&&t.ok===!1&&`reason`in t&&typeof t.reason==`string`)return`detail`in t&&typeof t.detail==`string`?`${t.reason}: ${t.detail}`:t.reason}catch{}return null}const f$=`#{pane_id} #{${ZQ}}`;function p$(e,t){return e.split(`
496
- `).map(e=>e.trim().split(` `)).filter(([,e])=>e===t).map(([e])=>e)}const m$=/(^|\/)(cc-attach|bun-attach\.js)(\s|$)/;function h$(e,t,n){for(let r of HJ(VJ(e),t)){if(r.command.split(` `).some(e=>m$.test(e)))return!0;if(r.pid===n)return!1}return!1}const g$=[`import ctypes, json, struct, sys`,`libc = ctypes.CDLL(None)`,`mib = (ctypes.c_int * 3)(1, 49, int(sys.argv[1]))`,`size = ctypes.c_size_t(0)`,`if libc.sysctl(mib, 3, None, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`buf = ctypes.create_string_buffer(size.value)`,`if libc.sysctl(mib, 3, buf, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`raw = buf.raw[:size.value]`,`argc = struct.unpack_from('i', raw)[0]`,`rest = raw[4:]`,`end = rest.index(b'\\0')`,`exe = rest[:end].decode('utf-8', 'surrogateescape')`,`rest = rest[end:].lstrip(b'\\0')`,`words = [w.decode('utf-8', 'surrogateescape') for w in rest.split(b'\\0')]`,`end = words.index('', argc) if '' in words[argc:] else len(words)`,`print(json.dumps({'executable': exe, 'argv': words[:argc], 'env': words[argc:end]}))`].join(`
497
- `);async function _$(e){if(process.platform===`linux`)return{executable:await p.promises.readlink(`/proc/${e}/exe`),argv:(await p.promises.readFile(`/proc/${e}/cmdline`,`utf8`)).split(`\0`).slice(0,-1),env:(await p.promises.readFile(`/proc/${e}/environ`,`utf8`)).split(`\0`).slice(0,-1)};let t=u$(`reading process ${e}'s arguments`,await Ue({bin:`python3`,args:[`-c`,g$,String(e)],timeoutMs:5e3,category:`lane.process`}));return JSON.parse(t)}async function v$(e,t){return u$(e,await Ue({bin:`ps`,args:t,timeoutMs:2e3,category:`lane.process`}))}async function y$(e){let t=await QH(e,`lane.tmux`,[`display`,`-p`,`-t`,e.pane,`#{pane_pid} #{pane_current_path}`]);if(t.kind!==`ok`)throw Error(t.reason);let[n=``,r=``]=t.stdout.trimEnd().split(` `),i=Number((await v$(`asking pane ${e.pane}'s foreground job`,[`-o`,`tpgid=`,`-p`,n])).trim()),a=await v$(`listing processes`,[`-A`,`-o`,`pid=,ppid=,args=`]),o=await _$(i);return{pid:i,executable:await p.promises.realpath(o.executable),argv:o.argv,env:o.env,cwd:r,fromShell:String(i)!==n,attached:h$(a,i,Number(n))}}function b$(e){let{CLAUDE_CONFIG_DIR:t,...n}=process.env;return e===void 0?n:{...n,CLAUDE_CONFIG_DIR:e}}function x$(e,t){return{claudeInput:tZ(),barPanes:e=>p$(l$(e,[`list-panes`,`-a`,`-F`,f$]),e.pane),openBarPane:(e,t,n)=>{let r=l$(e,[`split-window`,`-d`,`-v`,`-l`,`1`,`-t`,e.pane,`-P`,`-F`,`#{pane_id}`,...Object.entries(n).flatMap(([e,t])=>[`-e`,`${e}=${t}`]),...t]).trim();return l$(e,[`set-option`,`-p`,`-t`,r,ZQ,e.pane]),r},closePane:(e,t)=>void l$(e,[`kill-pane`,`-t`,t]),claude:async(e,t)=>void u$(`claude ${e.join(` `)}`,await Ue({bin:`claude`,args:[...e],env:b$(t),timeoutMs:3e4,category:`lane.claude`})),fileExists:e=>p.existsSync(e),paneClaude:y$,writeScript:(t,n)=>{let r=s.join(e,t);return p.writeFileSync(r,n,{mode:448}),r},removeScript:e=>p.rmSync(e,{force:!0}),followed:async(e,n,r)=>{let i=Date.now()+r;for(;!t(e).has(n);){if(Date.now()>i)return!1;await _e(200)}return!0},moduleGraph:async(e,t,n)=>{let r=await Ue({bin:e,args:[t,n],timeoutMs:2e4,category:`lane.process`}),i=!r.ok&&r.reason===`non-zero`?d$(r.stdout):null;return i===null?(u$(`reading ${n}'s module graph`,r),{ok:!0}):{ok:!1,reason:i}},exited:async(e,t)=>{let n=Date.now()+t;for(;po(e);){if(Date.now()>n)return!1;await _e(100)}return!0},typeShellLine:(e,t)=>void l$(e,$X(e.pane,`cc-candybar-lane`,[]),t)}}function S$(e,t){return o_.filter(n=>e[n]&&a_[n].elsewhere!==null&&t.has(n))}function C$(e,t){let n=`the bar is drawn in ${t.map(e=>a_[e].elsewhere).join(` and `)}`,r=Sr([{verb:sr,args:[e,...t.map(e=>a_[e].setting)]}]);return{channels:[{severity:Iv,message:n,lines:[[Lv(n,Sr([{verb:Xn,args:[n]}])),Lv(`[⟲ draw it here]`,r)]]}]}}const w$={order:-1/0,text:null,failure:null};var T$=class{synced=new Map;constructor(e){this.dir=e}pathFor(e){return s.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t,n){let r=this.synced.get(e)??w$;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)??w$;return n.text===t?n.failure===null?{kind:`file`,path:this.pathFor(e)}:{kind:`unavailable`,reason:n.failure}:{kind:`unavailable`,reason:`the file holds another render's text until the session's next statusline request`}}forgetOldestClean(){let e=0;for(let t of this.synced.values())t.text===null&&t.failure===null&&e++;for(let[t,n]of this.synced){if(e<=256)return;n.text!==null||n.failure!==null||(this.synced.delete(t),e--)}}write(e,t){let n=this.pathFor(e);try{return t===null?p.rmSync(n,{force:!0}):(p.mkdirSync(this.dir,{recursive:!0,mode:448}),p.writeFileSync(n,t,{mode:384})),null}catch(e){return`${n}: ${e.message}`}}reset(){this.synced.clear();try{return p.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};function E$(e,t){for(let n of Object.entries(t))e.push(n)}const D$={ok:`info`,"bad-request":`warn`,threw:`error`};function O$(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,ie(e.error)]]}}function k$(e,t,n){let r=[...e,[`took`,`${n}ms`],[`outcome`,t.kind],...O$(t)];return{level:D$[t.kind],line:`render${r.map(([e,t])=>` ${e}=${gM(t)}`).join(``)}`}}const A$=new BK,j$=new AX,M$=new $A,N$=i(import.meta.url),P$=BY(Ze());Ve(A$.launchStats);const F$=new QD({counters:A$,logger:j}),I$=gU({watchers:F$,logger:j}),{gitProvider:L$,usageStore:R$,mementoProvider:z$}=I$,B$=new UK,V$=new Qq(B$,j),H$=new xJ,U$=new vv,W$=new o$({edge:x$(l(et()),e=>G$.following(e)),host:{bundle:N$,node:[t.execPath,...t.execArgv],socket:et()},state:B$,log:j,now:()=>uO(new Date),defer:e=>void me(e)}),G$=new IQ({render:(e,t)=>j1(e,t),watch:(e,t)=>(0,mb.reaction)(()=>B$.revision(e),t,{scheduler:e=>me(e)}),lanes:e=>N1(e),shown:e=>K$.shown(e.hints.tmux),watching:()=>K$.follow(),periods:kQ,now:()=>performance.now(),log:j}),K$=new HQ({listPanes:e=>QH({socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,RQ]),listClients:e=>QH({socket:e},`frames.visibility`,[`list-clients`,`-F`,zQ]),sockets:()=>new Set(G$.watched().flatMap(({req:e})=>q$(e))),onChange:e=>G$.wakeWhere(t=>q$(t).some(t=>e.has(t))),intervalMs:1e3,log:j});function q$({hints:{tmux:e}}){return e==null?[]:[e.socket]}const J$=new T$(ft()),Y$=new RK({gitService:L$,sessionState:B$,watchers:F$,log:j},{budgetBytes:()=>(c1(),OK(t1)),observers:{onReload:e=>j(`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)}`)}}),X$=60*1e3,Z$=VV({targets:[...new Set([...import.meta.url.startsWith(`file://`)?[i(import.meta.url)]:[],...t.argv[1]?[t.argv[1]]:[]])],intervalMs:X$,stat:p.statSync,exit:()=>p1(0),log:j}),Q$=RV({entryUrl:import.meta.url,intervalMs:X$,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>Z$.checkNow(),log:j});let $$=null,e1=null,t1=0;function n1(){t.on(`uncaughtException`,e=>{j(`error`,`uncaughtException: ${e.stack||e.message}`),p1(1)}),t.on(`unhandledRejection`,e=>{j(`error`,`unhandledRejection: ${String(e)}`),p1(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{j(`info`,`received ${e}, shutting down`),p1(0)});try{l1(t.env)}catch(e){j(`error`,`refusing to boot: ${e.message}`),p1(1);return}$$=co(t.pid);let e=yo(xo($$));if(!e.decision.allow){j(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),p1(1);return}e1=e.registryPath,p.mkdirSync($e(),{recursive:!0}),rt(et()),B$.useStorage(new GK(ot(),500,j)),V$.useStorage(yJ(st(),j)),fo({anchor:uo(t.env),isAlive:po,onOrphaned:e=>{j(`info`,`parent watchdog: ${e}; shutting down`),p1(0)}}),r1(C.createServer({allowHalfOpen:!1},e=>{m1(e)}),et(),!1)}function r1(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){j(`error`,`server error: ${i.message}`),p1(1);return}if(r){j(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}i1(e,n)}),e.listen(n,()=>a1(n))}function i1(e,n){let r=Qa($a(it(n)),(e,t)=>so(e,t,{readStartTime:oo,pidAlive:po}));if(r.kind===`attach-and-exit`){j(`info`,`EADDRINUSE: ${r.reason} — exiting`),t.exit(0);return}j(`warn`,`EADDRINUSE: ${r.reason} — unlinking stale socket and rebinding`);try{p.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){j(`error`,`cannot unlink stale socket ${n}: ${e.message}`),p1(1);return}}r1(e,n,!0)}function a1(e){let n=no(e);if(n.kind!==`present`){j(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),p1(0);return}u1(e);try{p.chmodSync(e,384)}catch(e){j(`warn`,`chmod socket failed: ${e.message}`)}j(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${hn(w.getHeapStatistics().heap_size_limit)}MB memoryLimit=${hn(t1)}MB`),In();let r=J$.reset();r!==null&&j(`warn`,`diagnostic dump wipe failed: ${r}`),Z$.arm(),Q$.arm(),c1().arm(),o1(e,n.identity)}function o1(e,n){ao({bound:n,myPid:t.pid,readIdentity:()=>no(e),readLease:()=>$a(it(e)),shutdown:e=>p1(e),log:j}).arm()}let s1=null;function c1(){if(s1===null)throw Error(`daemon: limits not yet established`);return s1}function l1(e){t1=gn(e),s1=Sn(Dn(A$.startedAt.getTime(),e=>p1(e),{limitBytes:t1}))}function u1(e){let n=eo(it(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:$$});n!==null&&j(`warn`,`lease write failed: ${n}`)}let d1=0,f1=!1;function p1(e){if(!f1){f1=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{L$.close()}catch(e){j(`warn`,`gitService close failed: ${e.message}`)}try{R$.close()}catch(e){j(`warn`,`usageStore close failed: ${e.message}`)}try{F$.closeAll()}catch(e){j(`warn`,`watcherRegistry close failed: ${e.message}`)}try{B$.flush()}catch(e){j(`warn`,`sessionState flush failed: ${e.message}`)}to(at(),t.pid),e1!==null&&bo(e1,t.pid,_o,e=>p.unlinkSync(e)),t.exit(e)}}function m1(e){d1++,A$.inFlight=d1;let t=!1,n=!0,r=()=>{n&&(n=!1,d1=Math.max(0,d1-1),A$.inFlight=d1)},i=(n,r,i)=>{if(t){r!==null&&j(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let a=r===null?void 0:()=>p1(r);try{e.end(Nt(n),e=>{e??i(),a?.()})}catch(e){j(`warn`,`response write failed: ${e.message}`),a?.()}},a=!1,o=setTimeout(()=>{a=!0,A$.requestsTimedOut++,i({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,h1)},200),s=Ft(e=>{S1(e,()=>a).then(e=>e.kind===`reply`?i(e.resp,e.exitAfterFlush,e.delivered):c(e.sessionId,e.lane)).catch(e=>{j(`error`,`handler threw: ${ie(e)}`),i(y1(e),null,h1)})},e=>{j(`warn`,`frame parse failed: ${e.message}`),i({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null,h1)}),c=(n,i)=>{if(t||e.destroyed)return;clearTimeout(o),r(),e.off(`data`,s);let a=LQ(e),c=G$.subscribe(n,{lane:i,frame:(e,t)=>a(Pt(eH[i](e,t))),refused:t=>e.end(Nt(t))});t=!0,e.on(`close`,c)};e.on(`data`,s),e.on(`error`,e=>{j(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(o),r()})}const h1=()=>{},g1=e=>({resp:e,exitAfterFlush:null,delivered:h1}),_1=e=>({kind:`reply`,...e}),v1={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},y1=e=>({ok:!1,error:e instanceof Error?e.message:ie(e),code:`RENDER_FAILED`,daemonV:3}),b1=(e,t)=>_1(g1({ok:!1,error:t,code:e,daemonV:3}));function x1(e){if(typeof e.sessionId!=`string`||e.sessionId===``)return b1(`BAD_REQUEST`,`subscribe needs a non-empty string sessionId`);if(e.lane===void 0)return b1(`VERSION_MISMATCH`,`this client's subscribe names no lane (${o_.join(`, `)}): it predates the lane toggles — update it`);let t=p_(e.lane);return t===null?b1(`BAD_REQUEST`,`subscribe needs a lane, one of ${o_.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:e.sessionId,lane:t}}async function S1(e,t){return!e||typeof e!=`object`||typeof e.v!=`number`?b1(`BAD_REQUEST`,`malformed request`):e.v===3?e.kind===`subscribe`?x1(e):typeof e.kind!=`string`||!Object.hasOwn(v1,e.kind)?b1(`BAD_REQUEST`,`unknown kind`):_1(await C1(e,t)):(e.v>3?j(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):j(`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:h1})}async function C1(e,t){if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,delivered:h1};if(e.kind===`pane-session`){let{socket:t,pane:n}=e;return g1(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:G$.newestWhere(({hints:{tmux:e}})=>e!=null&&e.socket===t&&e.pane===n)})}if(e.kind===`stats`)return g1({ok:!0,stats:A$.snapshot({gitCache:L$.getStats(),usageCache:R$.getStats(),transcriptReads:qi(),renderCache:Y$.stats,effectCache:U$.getStats(),sessionState:{sessions:B$.size(),observers:B$.observers(),revision:B$.latestRevision()},frameFeeds:G$.getStats(),watchersActive:F$.size(),nextRestartReason:c1().describeNextRestart(),handlerProbes:j$.list(),clients:M$.list(uO(new Date)),bundle:N$,daemon:c1().serving(),doctorStores:VY(P$)})});if(e.kind===`render`){let n=new Date,r=uO(n),i=n.getTime(),a=[],o=++A$.requestsTotal,s=P1(e),c=(e,t)=>M$.see(e.hookData.session_id,{client:e.hints.client??null,termCols:e.hints.termCols??null,rateLimits:e.rateLimits,claudeConfigDir:ra(e.hints.claudeConfigDir),projectDir:e.requested.projectDir,transcript:YA(e.hookData),frame:t},r,o);s.ok&&(c(s.req,`drawing`),G$.note(s.req.hookData.session_id,s.req,o));let l=s.ok?await B1(s.req,o,r,a).then(({answer:e,motion:t,clickShown:n})=>(c(s.req,t),{outcome:{kind:`ok`},resp:{ok:!0,output:e},delivered:n===null?h1:()=>wJ(B$,s.req.hookData.session_id,n)}),e=>(c(s.req,`failed`),{outcome:{kind:`threw`,error:e},resp:y1(e),delivered:h1})):F1(s.problems);l.outcome.kind!==`ok`&&A$.requestsErrored++,E$(a,{timedOut:t()?`Y`:`N`});let{level:u,line:d}=k$(a,l.outcome,Date.now()-i);return j(u,d),{resp:l.resp,exitAfterFlush:null,delivered:l.delivered}}if(e.kind===`click`)return g1(A1(e.verb,e.value,jt(e.clientVersion)));if(e.kind===`debug`){if(!DQ(e.what))return g1({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${EQ.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=Y$.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?O1(t.lastRenderCellsBySegment,t.config.globals.colorCompatibility??L_(`colorCompatibility`)):D1};return g1({ok:!0,debug:hQ(e.what,n)})}throw Error(`no reply for request ${ie(e)}`)}function w1(e,t){let{tokens:n}=ae({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),r=(n??[]).filter(e=>e.kind===`option`&&e.name===`config`).at(-1),i=(n??[]).flatMap(e=>{switch(e.kind){case`option`:return e.name===`config`?e===r&&e.value===void 0?[{arg:e.rawName,why:`no-value`}]:[]:[{arg:e.rawName,why:`unknown`}];case`positional`:return[{arg:e.value,why:`positional`}];case`option-terminator`:return[]}});return{configFile:oz(t,r?.value),refusedArgs:i.filter((e,t)=>i.findIndex(t=>t.arg===e.arg&&t.why===e.why)===t)}}const T1={sessionState:B$,dlog:j,applyUpdate:()=>Q$.act(),doctor:ZY(e=>{let t=[e.projectDir,e.cwd,e.configFile??void 0];Y$.reload(...t);let n=Y$.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}}),doctorStores:P$,probes:j$,clients:M$,bundle:N$,serving:()=>c1().serving(),memento:z$,claudeInput:tZ(),history:V$,navigation:H$,configFor:e=>Y$.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>Y$.reload(e.projectDir,e.cwd,e.configFile??void 0)};T1.reloadConfig;const E1={endcaps:L_(`endcaps`),colorCompatibility:L_(`colorCompatibility`),wrap:L_(`autoWrap`),padding:L_(`padding`),width:1/0},D1=new Map;function O1(e,t){let n=new Map;for(let[r,i]of e)n.set(r,jv(i,{...E1,colorCompatibility:t}));return n}const k1={...I$,history:e=>V$.depth(e),feeds:e=>G$.feedsOf(e)};function A1(e,t,n){let r=sQ.get(e);if(!r)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return r(t,{...T1,clientVersion:n}),{ok:!0,output:``}}catch(e){let t=e instanceof J?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}async function j1(e,t){let n=new Date,r=[];try{let{drawn:i,motion:a,lanes:o}=await I1(e,uO(n),r,{by:`feed`,fps:t}),s=J$.linkFor(e.hookData.session_id,R1(i)),c=e.hookData.session_id,l=L1(i,s);return{resp:{ok:!0,output:l},statusline:{ok:!0,output:V1(c,i,s,l,S$(o,G$.following(c)))},moves:a===`moves`,failure:null}}catch(e){let{level:t,line:i}=k$(r,{kind:`threw`,error:e},Date.now()-n.getTime()),a=y1(e);return{resp:a,statusline:a,moves:!1,failure:{level:t,line:`frame ${i}`}}}}function M1(e,t){return PB(t.config,t=>B$.get(e,t),e=>t.authoredRoots.has(e))}function N1(e){try{var t=zi();let n=e.hookData.session_id,r=yZ(e.requested,B$,n);return MB(M1(n,t.u(Y$.hold(r.projectDir,r.cwd,r.configFile??void 0)).state))}catch(e){t.e=e}finally{t.d()}}function P1(e){let{report:t}=dQ(e.hookData);for(let e of t.unknownTopLevelFields)j(`info`,`schema: unknown field '${e}' — Anthropic may have added it`);let n=[];for(let e of t.missingRequired)n.push(`missing required field '${e}'`);for(let{path:e,expected:r,got:i}of t.typeMismatches)n.push(`field '${e}' expected ${r}, got ${i}`);if((typeof e.cwd!=`string`||!u(e.cwd))&&n.push(`request 'cwd' is not an absolute path: ${JSON.stringify(e.cwd)}`),(!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))&&n.push(`request 'args' is not a list of strings: ${JSON.stringify(e.args)}`),n.length>0)return{ok:!1,problems:n};let r=yt(e),{configFile:i,refusedArgs:a}=w1(e.args,e.cwd);return{ok:!0,req:{...e,hints:r,rateLimits:JA(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,configFile:i??r.configEnv??null},refusedArgs:a}}}const F1=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},delivered:h1});async function I1(e,t,n,r){try{var i=zi();E$(n,{sid:e.hookData.session_id,at:t.toFixed(3)});let a=e.hookData.session_id,o=e.hints,s=bt(e,o),c=xt(s);E$(n,{termCols:String(o.termCols??`?`),termRows:String(o.termRows??`?`),refused:s.map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:o.client?.kind??`unreported`,rateLimits:e.rateLimits});let l=yZ(e.requested,B$,a),{entry:u,state:d}=i.u(Y$.hold(l.projectDir,l.cwd,l.configFile??void 0)),f=o.termCols,p=OQ(f??120),m=Mv(o.termRows);E$(n,{width:String(p)});let h=t=>B$.get(e.hookData.session_id,t),g=M1(a,d),_=MB(g);E$(n,{lanes:o_.filter(e=>_[e]).join(`,`)||`-`}),W$.observe({sessionId:a,hints:o,origin:l,transcript:e.hookData.transcript_path},_,V$.revision(a));let v=await UU(e.hookData,t,{...k1,navigation:e=>H$.depth(e,B$,gV(d.config))},e.cwd,d.neededInputPaths(g.preset),g,o,{...rV(d.config,d.fileHeldSettings,h),configPath:u.configLayers.includes(u.configHome)?u.configHome:null});E$(n,{prompts:String(v.metrics?.messageCount??`-`),nonPrompts:String(v.metrics?.nonPrompts??`-`),pr:EU(v.git),feeds:jQ(v.feeds)});let y=[],b=CU(g,p),ee=U$.of(a),x=hK(d.config,d.compiled,d.store,d.registry,{...v,drawing:r},t,b,{perSegmentSink:d.lastRenderCellsBySegment,onRenderWarning:e=>y.push(e)},{...g,effects:ee}),S=EJ(B$,a,t,r.by),te=S.kind===`held`||S.kind===`owed`?S.error:null,ne=te?.text??null,re=[Ct(e.refusedArgs),c,u.lastError,ne].filter(Boolean).join(`
498
- `),ie=Q$.notice({sessionId:a,dismissed:B$.get(a,SV),enabled:g.updateNotice}),ae=u.lastError===null?null:u.failedFile,oe=[...u.lastWarning===null?[]:[{kind:`load`,message:u.lastWarning}],...y],C=Rv(re,ie,oe.map(e=>e.message).join(`
499
- `)),w=L$.getStats(),se=R$.getStats(),T=ee.lastFrame(),ce=T.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,le=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,ue=oe.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 E$(n,{git:`${w.size}/${w.hits}h/${w.misses}m`,usage:`${se.size}/${se.hits}h/${se.misses}m`,effect:T.effect,effectT:T.t.toFixed(3),effectRows:`${T.made}made/${T.reused}reused`,effectOwn:ce,fadeBasis:T.basis,stateRev:String(T.revision),fades:le(T.fades),leaves:le(T.leaves),motion:x.motion,err:re?`Y`:`N`,clickError:S.kind===`none`?`-`:S.kind,upd:String(ie.length),warn:ue}),{drawn:{body:x.text,diagnostics:C,failedConfigFile:ae,geometry:{width:p,rowCap:m,colorCompatibility:g.colorCompatibility}},motion:x.motion,clickShown:te,lanes:_}}catch(e){i.e=e}finally{i.d()}}function L1(e,t){return Vv(e.body,e.diagnostics,{fullText:t,failedConfigFile:e.failedConfigFile},e.geometry)+`
500
- `}function R1(e){return e.diagnostics===null?null:Bv(e.diagnostics)}function z1(e){let t=e.hookData.session_id,{client:n,...r}=e.hints,i=JSON.stringify(r);B$.get(t,`client-hints`)!==i&&B$.set(t,GZ,i);let a=bZ(e.requested);B$.get(t,`render-origin`)!==a&&B$.set(t,vZ,a)}async function B1(e,t,n,r){z1(e);let{drawn:i,motion:a,clickShown:o,lanes:s}=await I1(e,n,r,s_),{link:c,failure:l}=J$.sync(e.hookData.session_id,t,R1(i));E$(r,{dumpFailed:l===null?`-`:JSON.stringify(l)});let u=L1(i,c),d=e.hookData.session_id,f=S$(s,G$.following(d)),p=V1(d,i,c,u,f),m=QA(e.hints.client??null)===`statusline`;return E$(r,{handoff:(m?f:[]).join(`,`)||`-`}),{answer:m?p:u,motion:a,clickShown:o}}function V1(e,t,n,r,i){let[a,...o]=i;return a===void 0?r:L1({...t,body:Hv(C$(e,[a,...o]),t.geometry)},n)}const H1={connectMs:200,budgetMs:500};async function U1(e,n){let r=n.includes(`--json`),i=await W1(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${Wt(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
501
- `);return}t.stdout.write(G1(i.value))}function W1(e){return Rt({kind:`debug`,what:e},H1,e=>`debug`in e?e.debug:void 0)}function G1(e){switch(e.what){case`vars`:return K1(e.vars);case`segments`:return q1(e.segments);case`config`:return J1(e.config);default:return e}}function K1(e){if(e.length===0)return`no variables (DSL not active)
502
- `;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?``:` ${X1(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${Y1(a.value)}${e}${o}`)}return t.join(`
494
+ `)){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 HQ=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: ${ie(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:VQ(t.stdout,BQ(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),!UQ(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 UQ(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 $=e=>({arity:e,keep:!0}),WQ=e=>({arity:e,keep:!1}),GQ={"--add-dir":$(`variadic`),"--agent":$(`one`),"--agents":$(`one`),"--allow-dangerously-skip-permissions":$(`none`),"--allowedTools":$(`variadic`),"--allowed-tools":$(`variadic`),"--append-system-prompt":$(`one`),"--autocompact":$(`one`),"--ax-screen-reader":$(`none`),"--bg":WQ(`none`),"--background":WQ(`none`),"--bare":$(`none`),"--betas":$(`variadic`),"--brief":$(`none`),"--chrome":$(`none`),"--cloud":WQ(`optional`),"-c":WQ(`none`),"--continue":WQ(`none`),"--dangerously-skip-permissions":$(`none`),"-d":$(`optional`),"--debug":$(`optional`),"--debug-file":$(`one`),"--desktop":WQ(`none`),"--disable-slash-commands":$(`none`),"--disallowedTools":$(`variadic`),"--disallowed-tools":$(`variadic`),"--effort":$(`one`),"--environment":WQ(`one`),"--exclude-dynamic-system-prompt-sections":$(`none`),"--fallback-model":$(`one`),"--file":$(`variadic`),"--fork-session":WQ(`none`),"--forward-subagent-text":$(`none`),"--from-pr":WQ(`optional`),"-h":WQ(`none`),"--help":WQ(`none`),"--ide":$(`none`),"--include-hook-events":$(`none`),"--include-partial-messages":$(`none`),"--input-format":$(`one`),"--json-schema":$(`one`),"--max-budget-usd":$(`one`),"--mcp-config":$(`variadic`),"--model":$(`one`),"-n":$(`one`),"--name":$(`one`),"--no-chrome":$(`none`),"--no-session-persistence":$(`none`),"--output-format":$(`one`),"--permission-mode":$(`one`),"--permission-prompts":$(`one`),"--plugin-dir":$(`one`),"--plugin-url":$(`one`),"-p":WQ(`none`),"--print":WQ(`none`),"--prompt-suggestions":$(`optional`),"--remote-control":$(`optional`),"--remote-control-session-name-prefix":$(`one`),"--replay-user-messages":$(`none`),"--restricted":$(`none`),"-r":WQ(`optional`),"--resume":WQ(`optional`),"--safe-mode":$(`none`),"--session-id":WQ(`one`),"--setting-sources":$(`one`),"--settings":$(`one`),"--strict-mcp-config":$(`none`),"--system-prompt":$(`one`),"--system-prompt-snapshot":$(`one`),"--teleport":WQ(`optional`),"--tmux":WQ(`none`),"--tools":$(`variadic`),"--verbose":$(`none`),"-v":WQ(`none`),"--version":WQ(`none`),"-w":WQ(`optional`),"--worktree":WQ(`optional`)},KQ={resume:`--resume`,fresh:`--session-id`};function qQ(e){return[KQ[e.kind],e.sessionId]}const JQ=e=>e.startsWith(`-`)&&e!==`-`;function YQ(e){let t=XQ(e.argv);if(t.kind===`refused`)return t;let n=ZQ(e.cwd);return n===null?{kind:`relaunch`,dir:e.cwd,args:t.args}:{kind:`relaunch`,dir:n.repo,args:[`--worktree`,n.name,...t.args]}}function XQ(e){let t=[],n=e.slice(1),r=0;for(;r<n.length;){let e=n[r];if(r+=1,e===`--`)break;if(!JQ(e))continue;let i=e.indexOf(`=`),a=i===-1?e:e.slice(0,i),o=GQ[a];if(o===void 0)return{kind:`refused`,reason:`Claude Code was started with ${a}, which cc-candybar does not know how to carry to a restart`};let s=i===-1?o.arity===`one`?n.slice(r,r+1):o.arity===`optional`?n.slice(r,r+1).filter(e=>!JQ(e)):o.arity===`variadic`?QQ(n.slice(r),e=>!JQ(e)):[]:[];if(o.arity===`one`&&i===-1&&s.length===0)return{kind:`refused`,reason:`Claude Code was started with ${a} and no value after it`};r+=s.length,o.keep&&t.push(e,...s)}return{kind:`args`,args:t}}function ZQ(e){let t=e.split(s.sep),n=t.findLastIndex((e,n)=>e===`worktrees`&&t[n-1]===`.claude`&&n+1<t.length);return n===-1?null:{repo:t.slice(0,n-1).join(s.sep)||s.sep,name:t[n+1].replaceAll(`+`,`/`)}}function QQ(e,t){let n=e.findIndex(e=>!t(e));return n===-1?[...e]:e.slice(0,n)}const $Q=`candybar-band@cc-candybar`,e$=s.join(`bin`,`cc-candybar-native`),t$=`@cc-candybar-bar-pane`,n$=BM(`/reload-plugins`),r$=e=>({kind:`done`,said:e});function i$(e){let t=YX(e.hints.tmux);if(t.kind===`refused`)throw new J(t.reason);return t.hint}const a$={band:{on:(e,t,n)=>{let r=ty(t.bundle);if(r===null)throw new J(`${a_.band.label} runs the band mod from a cc-candybar source checkout, and this daemon runs ${t.bundle} — run the daemon from a checkout (mod/README.md)`);let i=s.join(r,e$);if(!n.fileExists(i))throw new J(`the band mod starts ${i}, which is not built — run \`just install-rust\` in ${r}`);return{kind:`underway`,said:`installing ${$Q} from ${r}`,finished:o$(e,r,n)}},off:()=>r$(`nothing to stop: the band mod draws nothing while the lane is off`)},statusline:{on:(e,t,n)=>{let r=i$(e),i=je(t.bundle);if(!n.fileExists(i))throw new J(`${a_.statusline.label} restarts Claude Code under the attach launcher, which is not at ${i} beside this daemon's bundle — rebuild (\`pnpm build\`) or reinstall cc-candybar`);return{kind:`underway`,said:`restarting Claude Code in ${r.pane} under the attach launcher`,finished:s$(e,r,[t.node[0],i],n)}},off:()=>r$(`nothing to stop: the attached statusline draws its command's output while the lane is off`)},pane:{on:(e,t,n)=>{let r=i$(e),i=n.barPanes(r);return i.length>0?r$(`bar pane ${i.join(`, `)} already draws ${r.pane}'s bar`):r$(`opened bar pane ${n.openBarPane(r,[...t.node,t.bundle,`bar-pane`,r.pane],{CC_CANDYBAR_SOCKET:t.socket})} under ${r.pane}`)},off:(e,t,n)=>{let r=YX(e.hints.tmux);if(r.kind===`refused`)return r$(`no bar pane to close: ${r.reason}`);let i=r.hint,a=n.barPanes(i);for(let e of a)n.closePane(i,e);return r$(a.length===0?`no bar pane draws ${i.pane}'s bar`:`closed bar pane ${a.join(`, `)}`)}}};async function o$(e,t,n){let r=e.hints.claudeConfigDir;await n.claude([`plugin`,`marketplace`,`add`,t],r),await n.claude([`plugin`,`install`,$Q],r);let i=XX(n.claudeInput,e.hints.tmux,n$);if(i.kind===`refused`)throw Error(`the band mod is installed, but /reload-plugins was not typed: ${i.reason} — or type /reload-plugins yourself`);return`installed ${$Q} from ${t} and typed /reload-plugins into ${i.pane}`}async function s$(e,t,n,r){let i=await r.paneClaude(t);if(i.attached)return`left Claude Code in ${t.pane} running: it already runs under the attach launcher`;if(!i.fromShell)throw Error(`Claude Code is the first process of pane ${t.pane}, so nothing would be left in the pane to start it again under the attach launcher — start Claude Code from a shell in the pane`);let[a,o]=n,s=await r.moduleGraph(a,Me(o),i.executable);if(!s.ok)throw Error(`Claude Code in ${t.pane} runs ${i.executable}, which the attach launcher cannot start (${s.reason}) — ${a_.statusline.label} needs the native Claude Code install (\`claude install\`), so it was left running`);if((await r.paneClaude(t)).pid!==i.pid)throw Error(`Claude Code in ${t.pane} is no longer the process the restart read (pid ${i.pid}), so it was not restarted under the attach launcher`);let c=f$(r.claudeInput.read(t));if(c!==null)throw Error(`Claude Code in ${t.pane} was left running: ${c} — then turn ${a_.statusline.label} off and on again`);let l=c$(e,r.presence(e.transcript));if(l!==null)throw Error(`Claude Code in ${t.pane} was left running: ${l}`);let u=YQ(i);if(u.kind===`refused`)throw Error(`${u.reason} — restart it with that flag removed`);if(r.terminate(i.pid),!await r.exited(i.pid,15e3))throw Error(`Claude Code in ${t.pane} did not exit within ${15e3/1e3} s of SIGTERM, so it was not restarted under the attach launcher`);let d=(e,n)=>Error(`Claude Code in ${t.pane} exited, but ${e}, so it was not started again — start it with \`cd ${Ur(u.dir)} && claude ${[...u.args,...n].map(Ur).join(` `)}\``),f=l$(e,r.presence(e.transcript));if(f.kind===`unchecked`)throw d(`whether session ${e.sessionId} has a conversation could not be seen (${f.error})`,qQ({kind:`resume`,sessionId:e.sessionId}));let p;try{p=r.writeScript(`relaunch-${e.sessionId}.sh`,g$(u.dir,[...n,i.executable,...u.args,...qQ(f)],i.env))}catch(e){throw d(`its restart script could not be written (${e.message})`,qQ(f))}try{if(r.typeShellLine(t,`sh ${Ur(p)}`),!await r.followed(e.sessionId,`statusline`,3e4))throw Error(`Claude Code in ${t.pane} did not come back attached within ${3e4/1e3} s of its restart — the pane says why`)}finally{r.removeScript(p)}return`restarted Claude Code in ${t.pane} under the attach launcher from ${u.dir}, ${u$[f.kind](e.sessionId)}, and its statusline follows lane B`}function c$(e,t){return typeof t==`object`?`whether session ${e.sessionId} has a conversation could not be seen (${t.error})`:t===`present`||e.answered===`no`?null:e.answered===`yes`?`session ${e.sessionId} has a conversation but no transcript to resume it from (is session persistence off?), so a restart would lose it`:`this Claude Code does not say whether session ${e.sessionId} has a conversation, and it has no transcript to resume one from`}function l$(e,t){return typeof t==`object`?{kind:`unchecked`,error:t.error}:{kind:t===`present`?`resume`:`fresh`,sessionId:e.sessionId}}const u$={resume:e=>`resuming ${e}`,fresh:e=>`starting ${e} afresh, since it had no conversation yet`},d$={"in-mode":`its pane is in tmux copy mode — leave it (q)`,stashed:`it holds a stashed prompt (ctrl+s), which ending it would lose — restore or send it`,"no-prompt":`it is not at its prompt (a dialog or picker is open) — close it`};function f$(e){let t=WX(e);return t.kind===`ready`?qX(e)?`it is in the middle of a turn, which ending it would end — wait until it is idle`:GX(e)?`its prompt holds a draft, which ending it would lose — send or clear it`:null:d$[t.kind]}const p$={switches:Object.fromEntries(o_.map(e=>[e,!1])),revision:0};var m$=class{seen=new Map;queued=new Map;constructor(e){this.deps=e}observe(e,t,n){let r=this.seen.get(e.sessionId)??p$;this.seen.delete(e.sessionId),this.seen.set(e.sessionId,{switches:t,revision:n});for(let[e]of this.seen){if(this.seen.size<=1024)break;this.seen.delete(e)}if(r.revision!==n)for(let n of o_){if(r.switches[n]===t[n])continue;let i=t[n];this.deps.defer(()=>this.enqueue(e.sessionId,()=>this.sync(e,n,i)))}}enqueue(e,t){let n=this.queued.get(e);if(n!==void 0){n.push(t);return}let r=[];this.queued.set(e,r);let i=t=>void t().then(()=>{let t=r.shift();t===void 0?this.queued.delete(e):i(t)});i(t)}sync(e,t,n){let r=`(session=${e.sessionId})`,i=i=>{let a=`lane: ${t} ${n?`on`:`off`}: ${i instanceof Error?i.message:String(i)}`;this.deps.log(`warn`,`${a} ${r}`),CJ(this.deps.state,e.sessionId,a,this.deps.now())},a;try{a=a$[t][n?`on`:`off`](e,this.deps.host,this.deps.edge)}catch(e){return i(e),Promise.resolve()}return this.deps.log(`info`,`lane: ${t} ${n?`on`:`off`} — ${a.said} ${r}`),a.kind===`underway`?a.finished.then(e=>this.deps.log(`info`,`lane: ${t} ${e} ${r}`),i):Promise.resolve()}};const h$=/^[A-Za-z_][A-Za-z0-9_]*=/;function g$(e,t,n){let r=n.filter(e=>h$.test(e));return[`cd -- ${Ur(e)} || exit 1`,...r.some(e=>e.startsWith(`CLAUDE_CONFIG_DIR=`))?[]:[`unset CLAUDE_CONFIG_DIR`],...r.map(e=>{let t=e.indexOf(`=`);return`export ${e.slice(0,t)}=${Ur(e.slice(t+1))}`}),`exec ${t.map(Ur).join(` `)}`,``].join(`
495
+ `)}function _$(e,t,n){let r=ZH(e,`lane.tmux`,t,n);if(r.kind!==`ok`)throw Error(r.reason);return r.stdout}function v$(e,t){if(t.ok)return t.stdout;let n=t.error??[t.reason,t.stderr.trim(),t.stdout.trim()].filter(e=>e!==``).join(`: `);throw Error(`${e} failed (${n})`)}function y$(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`ok`in t&&t.ok===!1&&`reason`in t&&typeof t.reason==`string`)return`detail`in t&&typeof t.detail==`string`?`${t.reason}: ${t.detail}`:t.reason}catch{}return null}const b$=`#{pane_id} #{${t$}}`;function x$(e,t){return e.split(`
496
+ `).map(e=>e.trim().split(` `)).filter(([,e])=>e===t).map(([e])=>e)}const S$=/(^|\/)(cc-attach|bun-attach\.js)(\s|$)/;function C$(e,t,n){for(let r of HJ(VJ(e),t)){if(r.command.split(` `).some(e=>S$.test(e)))return!0;if(r.pid===n)return!1}return!1}const w$=[`import ctypes, json, struct, sys`,`libc = ctypes.CDLL(None)`,`mib = (ctypes.c_int * 3)(1, 49, int(sys.argv[1]))`,`size = ctypes.c_size_t(0)`,`if libc.sysctl(mib, 3, None, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`buf = ctypes.create_string_buffer(size.value)`,`if libc.sysctl(mib, 3, buf, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`raw = buf.raw[:size.value]`,`argc = struct.unpack_from('i', raw)[0]`,`rest = raw[4:]`,`end = rest.index(b'\\0')`,`exe = rest[:end].decode('utf-8', 'surrogateescape')`,`rest = rest[end:].lstrip(b'\\0')`,`words = [w.decode('utf-8', 'surrogateescape') for w in rest.split(b'\\0')]`,`end = words.index('', argc) if '' in words[argc:] else len(words)`,`print(json.dumps({'executable': exe, 'argv': words[:argc], 'env': words[argc:end]}))`].join(`
497
+ `);async function T$(e){if(process.platform===`linux`)return{executable:await p.promises.readlink(`/proc/${e}/exe`),argv:(await p.promises.readFile(`/proc/${e}/cmdline`,`utf8`)).split(`\0`).slice(0,-1),env:(await p.promises.readFile(`/proc/${e}/environ`,`utf8`)).split(`\0`).slice(0,-1)};let t=v$(`reading process ${e}'s arguments`,await Ue({bin:`python3`,args:[`-c`,w$,String(e)],timeoutMs:5e3,category:`lane.process`}));return JSON.parse(t)}async function E$(e,t){return v$(e,await Ue({bin:`ps`,args:t,timeoutMs:2e3,category:`lane.process`}))}async function D$(e){let t=await QH(e,`lane.tmux`,[`display`,`-p`,`-t`,e.pane,`#{pane_pid} #{pane_current_path}`]);if(t.kind!==`ok`)throw Error(t.reason);let[n=``,r=``]=t.stdout.trimEnd().split(` `),i=Number((await E$(`asking pane ${e.pane}'s foreground job`,[`-o`,`tpgid=`,`-p`,n])).trim()),a=await E$(`listing processes`,[`-A`,`-o`,`pid=,ppid=,args=`]),o=await T$(i);return{pid:i,executable:await p.promises.realpath(o.executable),argv:o.argv,env:o.env,cwd:r,fromShell:String(i)!==n,attached:C$(a,i,Number(n))}}function O$(e){let{CLAUDE_CONFIG_DIR:t,...n}=process.env;return e===void 0?n:{...n,CLAUDE_CONFIG_DIR:e}}function k$(e,t){return{claudeInput:tZ(),barPanes:e=>x$(_$(e,[`list-panes`,`-a`,`-F`,b$]),e.pane),openBarPane:(e,t,n)=>{let r=_$(e,[`split-window`,`-d`,`-v`,`-l`,`1`,`-t`,e.pane,`-P`,`-F`,`#{pane_id}`,...Object.entries(n).flatMap(([e,t])=>[`-e`,`${e}=${t}`]),...t]).trim();return _$(e,[`set-option`,`-p`,`-t`,r,t$,e.pane]),r},closePane:(e,t)=>void _$(e,[`kill-pane`,`-t`,t]),claude:async(e,t)=>void v$(`claude ${e.join(` `)}`,await Ue({bin:`claude`,args:[...e],env:O$(t),timeoutMs:3e4,category:`lane.claude`})),fileExists:e=>p.existsSync(e),presence:Bz,paneClaude:D$,writeScript:(t,n)=>{let r=s.join(e,t);return p.writeFileSync(r,n,{mode:448}),r},removeScript:e=>p.rmSync(e,{force:!0}),followed:async(e,n,r)=>{let i=Date.now()+r;for(;!t(e).has(n);){if(Date.now()>i)return!1;await _e(200)}return!0},moduleGraph:async(e,t,n)=>{let r=await Ue({bin:e,args:[t,n],timeoutMs:2e4,category:`lane.process`}),i=!r.ok&&r.reason===`non-zero`?y$(r.stdout):null;return i===null?(v$(`reading ${n}'s module graph`,r),{ok:!0}):{ok:!1,reason:i}},terminate:e=>{try{process.kill(e,`SIGTERM`)}catch(t){throw Error(`Claude Code (pid ${e}) could not be sent SIGTERM: ${t instanceof Error?t.message:String(t)}`)}},exited:async(e,t)=>{let n=Date.now()+t;for(;po(e);){if(Date.now()>n)return!1;await _e(100)}return!0},typeShellLine:(e,t)=>void _$(e,$X(e.pane,`cc-candybar-lane`,[]),t)}}function A$(e,t){return o_.filter(n=>e[n]&&a_[n].elsewhere!==null&&t.has(n))}function j$(e,t){let n=`the bar is drawn in ${t.map(e=>a_[e].elsewhere).join(` and `)}`,r=Sr([{verb:sr,args:[e,...t.map(e=>a_[e].setting)]}]);return{channels:[{severity:Iv,message:n,lines:[[Lv(n,Sr([{verb:Xn,args:[n]}])),Lv(`[⟲ draw it here]`,r)]]}]}}const M$={order:-1/0,text:null,failure:null};var N$=class{synced=new Map;constructor(e){this.dir=e}pathFor(e){return s.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t,n){let r=this.synced.get(e)??M$;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)??M$;return n.text===t?n.failure===null?{kind:`file`,path:this.pathFor(e)}:{kind:`unavailable`,reason:n.failure}:{kind:`unavailable`,reason:`the file holds another render's text until the session's next statusline request`}}forgetOldestClean(){let e=0;for(let t of this.synced.values())t.text===null&&t.failure===null&&e++;for(let[t,n]of this.synced){if(e<=256)return;n.text!==null||n.failure!==null||(this.synced.delete(t),e--)}}write(e,t){let n=this.pathFor(e);try{return t===null?p.rmSync(n,{force:!0}):(p.mkdirSync(this.dir,{recursive:!0,mode:448}),p.writeFileSync(n,t,{mode:384})),null}catch(e){return`${n}: ${e.message}`}}reset(){this.synced.clear();try{return p.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};function P$(e,t){for(let n of Object.entries(t))e.push(n)}const F$={ok:`info`,"bad-request":`warn`,threw:`error`};function I$(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,ie(e.error)]]}}function L$(e,t,n){let r=[...e,[`took`,`${n}ms`],[`outcome`,t.kind],...I$(t)];return{level:F$[t.kind],line:`render${r.map(([e,t])=>` ${e}=${gM(t)}`).join(``)}`}}const R$=new BK,z$=new AX,B$=new $A,V$=i(import.meta.url),H$=BY(Ze());Ve(R$.launchStats);const U$=new QD({counters:R$,logger:j}),W$=gU({watchers:U$,logger:j}),{gitProvider:G$,usageStore:K$,mementoProvider:q$}=W$,J$=new UK,Y$=new Qq(J$,j),X$=new xJ,Z$=new vv,Q$=new m$({edge:k$(l(et()),e=>$$.following(e)),host:{bundle:V$,node:[t.execPath,...t.execArgv],socket:et()},state:J$,log:j,now:()=>uO(new Date),defer:e=>void me(e)}),$$=new IQ({render:(e,t)=>z1(e,t),watch:(e,t)=>(0,mb.reaction)(()=>J$.revision(e),t,{scheduler:e=>me(e)}),lanes:e=>V1(e),shown:e=>e1.shown(e.hints.tmux),watching:()=>e1.follow(),periods:kQ,now:()=>performance.now(),log:j}),e1=new HQ({listPanes:e=>QH({socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,RQ]),listClients:e=>QH({socket:e},`frames.visibility`,[`list-clients`,`-F`,zQ]),sockets:()=>new Set($$.watched().flatMap(({req:e})=>t1(e))),onChange:e=>$$.wakeWhere(t=>t1(t).some(t=>e.has(t))),intervalMs:1e3,log:j});function t1({hints:{tmux:e}}){return e==null?[]:[e.socket]}const n1=new N$(ft()),r1=new RK({gitService:G$,sessionState:J$,watchers:U$,log:j},{budgetBytes:()=>(g1(),OK(l1)),observers:{onReload:e=>j(`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)}`)}}),i1=60*1e3,a1=VV({targets:[...new Set([...import.meta.url.startsWith(`file://`)?[i(import.meta.url)]:[],...t.argv[1]?[t.argv[1]]:[]])],intervalMs:i1,stat:p.statSync,exit:()=>x1(0),log:j}),o1=RV({entryUrl:import.meta.url,intervalMs:i1,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>a1.checkNow(),log:j});let s1=null,c1=null,l1=0;function u1(){t.on(`uncaughtException`,e=>{j(`error`,`uncaughtException: ${e.stack||e.message}`),x1(1)}),t.on(`unhandledRejection`,e=>{j(`error`,`unhandledRejection: ${String(e)}`),x1(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{j(`info`,`received ${e}, shutting down`),x1(0)});try{_1(t.env)}catch(e){j(`error`,`refusing to boot: ${e.message}`),x1(1);return}s1=co(t.pid);let e=yo(xo(s1));if(!e.decision.allow){j(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),x1(1);return}c1=e.registryPath,p.mkdirSync($e(),{recursive:!0}),rt(et()),J$.useStorage(new GK(ot(),500,j)),Y$.useStorage(yJ(st(),j)),fo({anchor:uo(t.env),isAlive:po,onOrphaned:e=>{j(`info`,`parent watchdog: ${e}; shutting down`),x1(0)}}),d1(C.createServer({allowHalfOpen:!1},e=>{S1(e)}),et(),!1)}function d1(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){j(`error`,`server error: ${i.message}`),x1(1);return}if(r){j(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}f1(e,n)}),e.listen(n,()=>p1(n))}function f1(e,n){let r=Qa($a(it(n)),(e,t)=>so(e,t,{readStartTime:oo,pidAlive:po}));if(r.kind===`attach-and-exit`){j(`info`,`EADDRINUSE: ${r.reason} — exiting`),t.exit(0);return}j(`warn`,`EADDRINUSE: ${r.reason} — unlinking stale socket and rebinding`);try{p.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){j(`error`,`cannot unlink stale socket ${n}: ${e.message}`),x1(1);return}}d1(e,n,!0)}function p1(e){let n=no(e);if(n.kind!==`present`){j(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),x1(0);return}v1(e);try{p.chmodSync(e,384)}catch(e){j(`warn`,`chmod socket failed: ${e.message}`)}j(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${hn(w.getHeapStatistics().heap_size_limit)}MB memoryLimit=${hn(l1)}MB`),In();let r=n1.reset();r!==null&&j(`warn`,`diagnostic dump wipe failed: ${r}`),a1.arm(),o1.arm(),g1().arm(),m1(e,n.identity)}function m1(e,n){ao({bound:n,myPid:t.pid,readIdentity:()=>no(e),readLease:()=>$a(it(e)),shutdown:e=>x1(e),log:j}).arm()}let h1=null;function g1(){if(h1===null)throw Error(`daemon: limits not yet established`);return h1}function _1(e){l1=gn(e),h1=Sn(Dn(R$.startedAt.getTime(),e=>x1(e),{limitBytes:l1}))}function v1(e){let n=eo(it(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:s1});n!==null&&j(`warn`,`lease write failed: ${n}`)}let y1=0,b1=!1;function x1(e){if(!b1){b1=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{G$.close()}catch(e){j(`warn`,`gitService close failed: ${e.message}`)}try{K$.close()}catch(e){j(`warn`,`usageStore close failed: ${e.message}`)}try{U$.closeAll()}catch(e){j(`warn`,`watcherRegistry close failed: ${e.message}`)}try{J$.flush()}catch(e){j(`warn`,`sessionState flush failed: ${e.message}`)}to(at(),t.pid),c1!==null&&bo(c1,t.pid,_o,e=>p.unlinkSync(e)),t.exit(e)}}function S1(e){y1++,R$.inFlight=y1;let t=!1,n=!0,r=()=>{n&&(n=!1,y1=Math.max(0,y1-1),R$.inFlight=y1)},i=(n,r,i)=>{if(t){r!==null&&j(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let a=r===null?void 0:()=>x1(r);try{e.end(Nt(n),e=>{e??i(),a?.()})}catch(e){j(`warn`,`response write failed: ${e.message}`),a?.()}},a=!1,o=setTimeout(()=>{a=!0,R$.requestsTimedOut++,i({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,C1)},200),s=Ft(e=>{A1(e,()=>a).then(e=>e.kind===`reply`?i(e.resp,e.exitAfterFlush,e.delivered):c(e.sessionId,e.lane)).catch(e=>{j(`error`,`handler threw: ${ie(e)}`),i(D1(e),null,C1)})},e=>{j(`warn`,`frame parse failed: ${e.message}`),i({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null,C1)}),c=(n,i)=>{if(t||e.destroyed)return;clearTimeout(o),r(),e.off(`data`,s);let a=LQ(e),c=$$.subscribe(n,{lane:i,frame:(e,t)=>a(Pt(eH[i](e,t))),refused:t=>e.end(Nt(t))});t=!0,e.on(`close`,c)};e.on(`data`,s),e.on(`error`,e=>{j(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(o),r()})}const C1=()=>{},w1=e=>({resp:e,exitAfterFlush:null,delivered:C1}),T1=e=>({kind:`reply`,...e}),E1={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},D1=e=>({ok:!1,error:e instanceof Error?e.message:ie(e),code:`RENDER_FAILED`,daemonV:3}),O1=(e,t)=>T1(w1({ok:!1,error:t,code:e,daemonV:3}));function k1(e){if(typeof e.sessionId!=`string`||e.sessionId===``)return O1(`BAD_REQUEST`,`subscribe needs a non-empty string sessionId`);if(e.lane===void 0)return O1(`VERSION_MISMATCH`,`this client's subscribe names no lane (${o_.join(`, `)}): it predates the lane toggles — update it`);let t=p_(e.lane);return t===null?O1(`BAD_REQUEST`,`subscribe needs a lane, one of ${o_.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:e.sessionId,lane:t}}async function A1(e,t){return!e||typeof e!=`object`||typeof e.v!=`number`?O1(`BAD_REQUEST`,`malformed request`):e.v===3?e.kind===`subscribe`?k1(e):typeof e.kind!=`string`||!Object.hasOwn(E1,e.kind)?O1(`BAD_REQUEST`,`unknown kind`):T1(await j1(e,t)):(e.v>3?j(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):j(`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:C1})}async function j1(e,t){if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,delivered:C1};if(e.kind===`pane-session`){let{socket:t,pane:n}=e;return w1(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:$$.newestWhere(({hints:{tmux:e}})=>e!=null&&e.socket===t&&e.pane===n)})}if(e.kind===`stats`)return w1({ok:!0,stats:R$.snapshot({gitCache:G$.getStats(),usageCache:K$.getStats(),transcriptReads:qi(),renderCache:r1.stats,effectCache:Z$.getStats(),sessionState:{sessions:J$.size(),observers:J$.observers(),revision:J$.latestRevision()},frameFeeds:$$.getStats(),watchersActive:U$.size(),nextRestartReason:g1().describeNextRestart(),handlerProbes:z$.list(),clients:B$.list(uO(new Date)),bundle:V$,daemon:g1().serving(),doctorStores:VY(H$)})});if(e.kind===`render`){let n=new Date,r=uO(n),i=n.getTime(),a=[],o=++R$.requestsTotal,s=H1(e),c=(e,t)=>B$.see(e.hookData.session_id,{client:e.hints.client??null,termCols:e.hints.termCols??null,rateLimits:e.rateLimits,claudeConfigDir:ra(e.hints.claudeConfigDir),projectDir:e.requested.projectDir,transcript:YA(e.hookData),frame:t},r,o);s.ok&&(c(s.req,`drawing`),$$.note(s.req.hookData.session_id,s.req,o));let l=s.ok?await J1(s.req,o,r,a).then(({answer:e,motion:t,clickShown:n})=>(c(s.req,t),{outcome:{kind:`ok`},resp:{ok:!0,output:e},delivered:n===null?C1:()=>wJ(J$,s.req.hookData.session_id,n)}),e=>(c(s.req,`failed`),{outcome:{kind:`threw`,error:e},resp:D1(e),delivered:C1})):U1(s.problems);l.outcome.kind!==`ok`&&R$.requestsErrored++,P$(a,{timedOut:t()?`Y`:`N`});let{level:u,line:d}=L$(a,l.outcome,Date.now()-i);return j(u,d),{resp:l.resp,exitAfterFlush:null,delivered:l.delivered}}if(e.kind===`click`)return w1(R1(e.verb,e.value,jt(e.clientVersion)));if(e.kind===`debug`){if(!DQ(e.what))return w1({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${EQ.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=r1.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?I1(t.lastRenderCellsBySegment,t.config.globals.colorCompatibility??L_(`colorCompatibility`)):F1};return w1({ok:!0,debug:hQ(e.what,n)})}throw Error(`no reply for request ${ie(e)}`)}function M1(e,t){let{tokens:n}=ae({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),r=(n??[]).filter(e=>e.kind===`option`&&e.name===`config`).at(-1),i=(n??[]).flatMap(e=>{switch(e.kind){case`option`:return e.name===`config`?e===r&&e.value===void 0?[{arg:e.rawName,why:`no-value`}]:[]:[{arg:e.rawName,why:`unknown`}];case`positional`:return[{arg:e.value,why:`positional`}];case`option-terminator`:return[]}});return{configFile:oz(t,r?.value),refusedArgs:i.filter((e,t)=>i.findIndex(t=>t.arg===e.arg&&t.why===e.why)===t)}}const N1={sessionState:J$,dlog:j,applyUpdate:()=>o1.act(),doctor:ZY(e=>{let t=[e.projectDir,e.cwd,e.configFile??void 0];r1.reload(...t);let n=r1.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}}),doctorStores:H$,probes:z$,clients:B$,bundle:V$,serving:()=>g1().serving(),memento:q$,claudeInput:tZ(),history:Y$,navigation:X$,configFor:e=>r1.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>r1.reload(e.projectDir,e.cwd,e.configFile??void 0)};N1.reloadConfig;const P1={endcaps:L_(`endcaps`),colorCompatibility:L_(`colorCompatibility`),wrap:L_(`autoWrap`),padding:L_(`padding`),width:1/0},F1=new Map;function I1(e,t){let n=new Map;for(let[r,i]of e)n.set(r,jv(i,{...P1,colorCompatibility:t}));return n}const L1={...W$,history:e=>Y$.depth(e),feeds:e=>$$.feedsOf(e)};function R1(e,t,n){let r=sQ.get(e);if(!r)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return r(t,{...N1,clientVersion:n}),{ok:!0,output:``}}catch(e){let t=e instanceof J?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}async function z1(e,t){let n=new Date,r=[];try{let{drawn:i,motion:a,lanes:o}=await W1(e,uO(n),r,{by:`feed`,fps:t}),s=n1.linkFor(e.hookData.session_id,K1(i)),c=e.hookData.session_id,l=G1(i,s);return{resp:{ok:!0,output:l},statusline:{ok:!0,output:Y1(c,i,s,l,A$(o,$$.following(c)))},moves:a===`moves`,failure:null}}catch(e){let{level:t,line:i}=L$(r,{kind:`threw`,error:e},Date.now()-n.getTime()),a=D1(e);return{resp:a,statusline:a,moves:!1,failure:{level:t,line:`frame ${i}`}}}}function B1(e,t){return PB(t.config,t=>J$.get(e,t),e=>t.authoredRoots.has(e))}function V1(e){try{var t=zi();let n=e.hookData.session_id,r=yZ(e.requested,J$,n);return MB(B1(n,t.u(r1.hold(r.projectDir,r.cwd,r.configFile??void 0)).state))}catch(e){t.e=e}finally{t.d()}}function H1(e){let{report:t}=dQ(e.hookData);for(let e of t.unknownTopLevelFields)j(`info`,`schema: unknown field '${e}' — Anthropic may have added it`);let n=[];for(let e of t.missingRequired)n.push(`missing required field '${e}'`);for(let{path:e,expected:r,got:i}of t.typeMismatches)n.push(`field '${e}' expected ${r}, got ${i}`);if((typeof e.cwd!=`string`||!u(e.cwd))&&n.push(`request 'cwd' is not an absolute path: ${JSON.stringify(e.cwd)}`),(!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))&&n.push(`request 'args' is not a list of strings: ${JSON.stringify(e.args)}`),n.length>0)return{ok:!1,problems:n};let r=yt(e),{configFile:i,refusedArgs:a}=M1(e.args,e.cwd);return{ok:!0,req:{...e,hints:r,rateLimits:JA(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,configFile:i??r.configEnv??null},refusedArgs:a}}}const U1=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},delivered:C1});async function W1(e,t,n,r){try{var i=zi();P$(n,{sid:e.hookData.session_id,at:t.toFixed(3)});let a=e.hookData.session_id,o=e.hints,s=bt(e,o),c=xt(s);P$(n,{termCols:String(o.termCols??`?`),termRows:String(o.termRows??`?`),refused:s.map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:o.client?.kind??`unreported`,rateLimits:e.rateLimits});let l=yZ(e.requested,J$,a),{entry:u,state:d}=i.u(r1.hold(l.projectDir,l.cwd,l.configFile??void 0)),f=o.termCols,p=OQ(f??120),m=Mv(o.termRows);P$(n,{width:String(p)});let h=t=>J$.get(e.hookData.session_id,t),g=B1(a,d),_=MB(g);P$(n,{lanes:o_.filter(e=>_[e]).join(`,`)||`-`}),Q$.observe({sessionId:a,hints:o,origin:l,transcript:e.hookData.transcript_path,answered:KA(e.hookData)},_,Y$.revision(a));let v=await UU(e.hookData,t,{...L1,navigation:e=>X$.depth(e,J$,gV(d.config))},e.cwd,d.neededInputPaths(g.preset),g,o,{...rV(d.config,d.fileHeldSettings,h),configPath:u.configLayers.includes(u.configHome)?u.configHome:null});P$(n,{prompts:String(v.metrics?.messageCount??`-`),nonPrompts:String(v.metrics?.nonPrompts??`-`),pr:EU(v.git),feeds:jQ(v.feeds)});let y=[],b=CU(g,p),ee=Z$.of(a),x=hK(d.config,d.compiled,d.store,d.registry,{...v,drawing:r},t,b,{perSegmentSink:d.lastRenderCellsBySegment,onRenderWarning:e=>y.push(e)},{...g,effects:ee}),S=EJ(J$,a,t,r.by),te=S.kind===`held`||S.kind===`owed`?S.error:null,ne=te?.text??null,re=[Ct(e.refusedArgs),c,u.lastError,ne].filter(Boolean).join(`
498
+ `),ie=o1.notice({sessionId:a,dismissed:J$.get(a,SV),enabled:g.updateNotice}),ae=u.lastError===null?null:u.failedFile,oe=[...u.lastWarning===null?[]:[{kind:`load`,message:u.lastWarning}],...y],C=Rv(re,ie,oe.map(e=>e.message).join(`
499
+ `)),w=G$.getStats(),se=K$.getStats(),T=ee.lastFrame(),ce=T.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,le=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,ue=oe.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 P$(n,{git:`${w.size}/${w.hits}h/${w.misses}m`,usage:`${se.size}/${se.hits}h/${se.misses}m`,effect:T.effect,effectT:T.t.toFixed(3),effectRows:`${T.made}made/${T.reused}reused`,effectOwn:ce,fadeBasis:T.basis,stateRev:String(T.revision),fades:le(T.fades),leaves:le(T.leaves),motion:x.motion,err:re?`Y`:`N`,clickError:S.kind===`none`?`-`:S.kind,upd:String(ie.length),warn:ue}),{drawn:{body:x.text,diagnostics:C,failedConfigFile:ae,geometry:{width:p,rowCap:m,colorCompatibility:g.colorCompatibility}},motion:x.motion,clickShown:te,lanes:_}}catch(e){i.e=e}finally{i.d()}}function G1(e,t){return Vv(e.body,e.diagnostics,{fullText:t,failedConfigFile:e.failedConfigFile},e.geometry)+`
500
+ `}function K1(e){return e.diagnostics===null?null:Bv(e.diagnostics)}function q1(e){let t=e.hookData.session_id,{client:n,...r}=e.hints,i=JSON.stringify(r);J$.get(t,`client-hints`)!==i&&J$.set(t,GZ,i);let a=bZ(e.requested);J$.get(t,`render-origin`)!==a&&J$.set(t,vZ,a)}async function J1(e,t,n,r){q1(e);let{drawn:i,motion:a,clickShown:o,lanes:s}=await W1(e,n,r,s_),{link:c,failure:l}=n1.sync(e.hookData.session_id,t,K1(i));P$(r,{dumpFailed:l===null?`-`:JSON.stringify(l)});let u=G1(i,c),d=e.hookData.session_id,f=A$(s,$$.following(d)),p=Y1(d,i,c,u,f),m=QA(e.hints.client??null)===`statusline`;return P$(r,{handoff:(m?f:[]).join(`,`)||`-`}),{answer:m?p:u,motion:a,clickShown:o}}function Y1(e,t,n,r,i){let[a,...o]=i;return a===void 0?r:G1({...t,body:Hv(j$(e,[a,...o]),t.geometry)},n)}const X1={connectMs:200,budgetMs:500};async function Z1(e,n){let r=n.includes(`--json`),i=await Q1(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${Wt(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
501
+ `);return}t.stdout.write($1(i.value))}function Q1(e){return Rt({kind:`debug`,what:e},X1,e=>`debug`in e?e.debug:void 0)}function $1(e){switch(e.what){case`vars`:return e0(e.vars);case`segments`:return t0(e.segments);case`config`:return n0(e.config);default:return e}}function e0(e){if(e.length===0)return`no variables (DSL not active)
502
+ `;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?``:` ${i0(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${r0(a.value)}${e}${o}`)}return t.join(`
503
503
  `)+`
504
- `}function q1(e){if(e.length===0)return`no segments (DSL not active)
504
+ `}function t0(e){if(e.length===0)return`no segments (DSL not active)
505
505
  `;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(`
506
506
  `)+`
507
- `}function J1(e){return e===null?`config: DSL not active
507
+ `}function n0(e){return e===null?`config: DSL not active
508
508
  `:JSON.stringify(e,null,2)+`
509
- `}function Y1(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function X1(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function Z1(){let e=$1();return e===null?null:p.readFileSync(e,`utf-8`)}function Q1(){let e;try{e=Z1()}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 $1(){let e=s.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=s.dirname(s.resolve(n));for(;;){let t=s.join(r,e);if(p.existsSync(t))return t;let n=s.dirname(r);if(n===r)return null;r=n}}function e0(e,t){return oz(t,e.CC_CANDYBAR_CONFIG)}const t0=5e3;function n0(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:JM(4e5,1e6),...wU(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:J_(()=>!0),themeDefault:{differs:!0,theme:`<theme>`},resumeCommand:SU(o,a,void 0),configPath:t??`${r}/.config/cc-candybar/config.json5`}}function r0(e,t){let n=Wz(e,e),r=qz(n);return r!==null&&t.push(r),n.kind===`chain`?n.layers:[]}async function i0(e,n=t.cwd()){let r=[],i=oz(n,e)??null,a=i===null?r0(n,r):[i];if(i!==null){let e;try{e=p.statSync(i,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:i,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:i,message:`not a file`}}let o=Yz(n,n);o!==null&&r.push(o);try{return{kind:`clean`,layers:a,warnings:r,rendered:await s0(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 Sg&&r.push(...e.warnings),{kind:`fatal`,layers:a,message:e instanceof Sg||e instanceof Error?e.message:String(e),warnings:r})}}async function a0(e,t,n){let r=rB(e,EB,{entered:()=>{},warned:e=>n.push(...e)},{projectDir:t,cwd:t}),{config:i}=r,a=new DK,o=new PO(a,i.globals.default_empty_value??``,void 0,new UK);try{let s=tK(i,o,{cwd:t});n.push(...s.loadWarnings);let c=await o.settled(t0);return c.length>0&&n.push(`source${c.length===1?``:`s`} still running after ${t0} 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 o0({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=new Map,l=new Set;return{rendered:mK(t,n,r,i,n0(a,e.at(-1)??null,s),s,CU(a,o),{onSegmentError:(e,t)=>c.set(`segment "${e}"`,t),onRenderWarning:e=>{switch(e.kind){case`rule`:c.set(`${e.slot} rule`,e.message);return;case`when`:c.set(e.where,e.error);return;case`refresh`:c.set(`variable "${e.variable}"`,`cannot refresh: ${e.error}`);return;case`band-floor`:l.add(e.message);return;default:}}},a),failures:c,advisories:l}}async function s0(e,t,n){let r=await a0(e,t,n),{config:i}=r,a=uO(new Date);try{let e=LV();try{gV(i),OF(i)}finally{e()}let t=Ay(null,i.globals.preset,i.presets),o=(e,t)=>{let n=PB(i,t=>t===`preset`?e:null,()=>t),o;try{o=o0(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),...ky(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(`
509
+ `}function r0(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function i0(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function a0(){let e=s0();return e===null?null:p.readFileSync(e,`utf-8`)}function o0(){let e;try{e=a0()}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 s0(){let e=s.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=s.dirname(s.resolve(n));for(;;){let t=s.join(r,e);if(p.existsSync(t))return t;let n=s.dirname(r);if(n===r)return null;r=n}}function c0(e,t){return oz(t,e.CC_CANDYBAR_CONFIG)}const l0=5e3;function u0(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:JM(4e5,1e6),...wU(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:J_(()=>!0),themeDefault:{differs:!0,theme:`<theme>`},resumeCommand:SU(o,a,void 0),configPath:t??`${r}/.config/cc-candybar/config.json5`}}function d0(e,t){let n=Wz(e,e),r=qz(n);return r!==null&&t.push(r),n.kind===`chain`?n.layers:[]}async function f0(e,n=t.cwd()){let r=[],i=oz(n,e)??null,a=i===null?d0(n,r):[i];if(i!==null){let e;try{e=p.statSync(i,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:i,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:i,message:`not a file`}}let o=Yz(n,n);o!==null&&r.push(o);try{return{kind:`clean`,layers:a,warnings:r,rendered:await h0(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 Sg&&r.push(...e.warnings),{kind:`fatal`,layers:a,message:e instanceof Sg||e instanceof Error?e.message:String(e),warnings:r})}}async function p0(e,t,n){let r=rB(e,EB,{entered:()=>{},warned:e=>n.push(...e)},{projectDir:t,cwd:t}),{config:i}=r,a=new DK,o=new PO(a,i.globals.default_empty_value??``,void 0,new UK);try{let s=tK(i,o,{cwd:t});n.push(...s.loadWarnings);let c=await o.settled(l0);return c.length>0&&n.push(`source${c.length===1?``:`s`} still running after ${l0} 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 m0({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=new Map,l=new Set;return{rendered:mK(t,n,r,i,u0(a,e.at(-1)??null,s),s,CU(a,o),{onSegmentError:(e,t)=>c.set(`segment "${e}"`,t),onRenderWarning:e=>{switch(e.kind){case`rule`:c.set(`${e.slot} rule`,e.message);return;case`when`:c.set(e.where,e.error);return;case`refresh`:c.set(`variable "${e.variable}"`,`cannot refresh: ${e.error}`);return;case`band-floor`:l.add(e.message);return;default:}}},a),failures:c,advisories:l}}async function h0(e,t,n){let r=await p0(e,t,n),{config:i}=r,a=uO(new Date);try{let e=LV();try{gV(i),OF(i)}finally{e()}let t=Ay(null,i.globals.preset,i.presets),o=(e,t)=>{let n=PB(i,t=>t===`preset`?e:null,()=>t),o;try{o=m0(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),...ky(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(`
510
510
  `)]:[]];if(p.length>0||d===void 0)throw Error(p.join(`
511
- `));return d}finally{r.registry.dispose()}}function c0(e){return e.map(e=>`warning: ${e}\n`).join(``)}function l0(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:c0(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:c0(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 u0=`--render`,d0=`Usage: cc-candybar check [${u0}] [config-file]\n`;function f0(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==u0);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${d0}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${d0}`}:{kind:`run`,target:n[0],render:t.includes(u0)}}async function p0(e){let n=f0(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:l0(await i0(n.target??e0(t.env,t.cwd())),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const m0=/^[a-z][a-z0-9+.-]*:\/\//i,h0=/^[^@\s/]+@[^:\s/]+:/,g0=/^([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;function _0(e){if(!URL.canParse(e))return e;let t=new URL(e);return t.password===``?e:(t.password=`***`,t.href)}function v0(e,t,n){let r=az(t,e);if(n(r))return{kind:`path`,dir:r};if(m0.test(e)||h0.test(e))return{kind:`git`,url:e,shown:_0(e)};let i=g0.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 y0(e,t){let n=s.join(e,Fz),r=Rz(n);if(`error`in r)throw Error(`${t}: could not list ${Fz}: ${r.error}`);if(r.folders.length===0)throw Error(`${t} has no plugins: none at ${Fz}/<name>/${lz}`);return r.folders.map(e=>s.join(n,e,lz))}function b0(e,t,n){let r=(n,...r)=>{let i=We({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(`
512
- `))delete i[e];r(i,`clone`,`--quiet`,`--depth`,`1`,`--filter=blob:none`,`--sparse`,`--`,e,n),r(i,`-C`,n,`sparse-checkout`,`set`,`--no-cone`,`/${Fz}/`)}function x0(e,t){switch(e.kind){case`path`:return t(e.dir);case`git`:{let n=p.mkdtempSync(s.join(S.tmpdir(),`cc-candybar-plugin-`));try{return b0(e.url,e.shown,s.join(n,`repo`)),t(s.join(n,`repo`))}finally{p.rmSync(n,{recursive:!0,force:!0})}}}}function S0(e){let t;try{t=p.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return`installed`;throw e}if(t.isDirectory())return`updated`;if(t.isSymbolicLink())return`replaced`;throw Error(`${e} is a file, not a plugin folder: move it, then install again`)}function C0(e,t,n,r){switch(r){case`updated`:p.renameSync(s.join(e,lz),s.join(t,lz));return;case`replaced`:p.renameSync(t,n),p.renameSync(e,t);return;case`installed`:p.renameSync(e,t);return}}function w0(e,t,n){let r=y0(e,n);p.mkdirSync(t,{recursive:!0});let i=p.mkdtempSync(s.join(t,`.install-`));try{let a=r.map(e=>{let t=s.join(i,s.basename(s.dirname(e)));p.mkdirSync(t);try{p.copyFileSync(e,s.join(t,lz))}catch(e){if(e.code!==`ENOENT`)throw e}return t}),o=tB(a.map(e=>s.join(e,lz)),EB,{root:e,git:!1});if(o.length>0)throw Error(o.map(e=>`${n}: ${s.join(Fz,s.relative(i,e.path))} would not load: ${e.reason.split(i).join(s.join(n,Fz))}`).join(`
513
- `));let c=a.map(e=>{let n=s.basename(e),r=s.join(t,n);return{folder:e,name:n,target:r,placed:S0(r)}}),l=[];try{for(let{folder:e,name:t,target:n,placed:r}of c)C0(e,n,s.join(i,`.replaced-${t}`),r),l.push(t)}catch(e){throw Error(`${e.message} (placed before it: ${l.join(`, `)||`none`})`)}return c.map(({target:e,placed:t})=>({path:s.join(e,lz),placed:t}))}finally{p.rmSync(i,{recursive:!0,force:!0})}}function T0(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=v0(n,process.cwd(),EO);if(`error`in i)return console.error(`plugin install: ${i.error}`),2;try{let e=i.kind===`path`?i.dir:i.shown,t=x0(i,t=>w0(t,Pz(),e));for(let{path:n,placed:r}of t)console.log(`${r} plugin ${s.basename(s.dirname(n))} → ${n} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}function E0(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 D0=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function O0(e,t,n){return{termCols:E0(e.COLUMNS,n.columns),termRows:E0(e.LINES,n.rows),ssh:D0.some(t=>(e[t]??``)!==``),tmux:zA(e),configEnv:e0(e,t),claudeConfigDir:na(e,t),mementoEnv:mt(e,t),terminalEnv:gt(e)}}function k0(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function A0(e){let t=yX(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=k0(e);return n.every(e=>typeof e.ago==`number`&&typeof e.sessionId==`string`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:Lt(e.client)??null,sessionId:e.sessionId,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age or session: ${JSON.stringify(e.clients)}`}}const j0=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)},M0=e=>{let t=e??{};if(t.kind===`unmeasured`)return!0;let n=t.charge;return t.kind===`measured`&&typeof t.rss==`number`&&typeof t.heapTotal==`number`&&typeof n?.bytes==`number`&&(n.kind===`charged`&&(n.measure===`phys_footprint`||n.measure===`rss`)||n.kind===`stand-in`&&typeof n.unread==`string`)};function N0(e,t){let n=e;if(n?.kind===`failed`&&typeof n.reason==`string`)return{kind:`failed`,reason:n.reason};if(n?.kind!==`ok`)return{kind:`misshapen`,reason:`is not an answer`};let r=t(n.value);return r.kind===`ok`?r:{kind:`misshapen`,reason:r.reason}}function P0(e){let t=yX(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=N0(n?.postMortems,e=>Array.isArray(e)&&e.every(j0)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of post-mortems`});return typeof n?.pid==`number`&&M0(n.memory)&&typeof n.limit==`number`&&r.kind!==`misshapen`?{kind:`ok`,value:{...n,postMortems:r}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function F0(e,t,n){let r=yX(e,[`clients`]);if(r!==null)return{kind:`failed`,reason:r};let i=k0(e);return i.every(t)?{kind:`ok`,value:i}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without ${n} — restart it on this build: ${JSON.stringify(e.clients)}`}}const I0=e=>ZA.includes(e.role),L0=e=>F0(e,e=>typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof e.claudeConfigDir==`string`&&qA.includes(e.rateLimits),`the rate-limit windows they carried`),R0=e=>F0(e,e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof t?.path==`string`&&typeof t.answered==`boolean`},`their transcripts`),z0=e=>F0(e,e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&typeof e.projectDir==`string`&&typeof e.sessionId==`string`&&typeof e.since==`number`&&Array.isArray(e.redrawn)&&e.redrawn.length>0&&e.redrawn.every(Number.isInteger)&&I0(e)&&XA.includes(e.frame),`what they drew, when, and from which project`),B0=e=>F0(e,e=>typeof e.sessionId==`string`&&typeof e.ago==`number`&&I0(e)&&(e.termCols===null||typeof e.termCols==`number`),`whose they were or the width they measured`);function V0(e,t,n){let r=e.doctorStores?.[t],i=N0(r,n);return i.kind===`misshapen`?{kind:`failed`,reason:`the running daemon (${e.version}) reported its ${t} as ${JSON.stringify(r)}, which ${i.reason}`}:i}function H0(e){let t=yX(e,[`doctorStores`]);if(t!==null){let e={kind:`failed`,reason:t};return{marks:e,clicked:e,postMortemsRead:e}}return{marks:V0(e,`marks`,AJ),clicked:V0(e,`clicked`,NJ),postMortemsRead:V0(e,`postMortemsRead`,FY)}}async function U0(){let e=await vX();if(e.kind!==`ok`){let t={kind:`failed`,reason:Wt(e).split(`
514
- `).join(` — `)};return{clients:t,rateLimits:t,transcripts:t,frames:t,widths:t,serving:t,stores:{marks:t,clicked:t,postMortemsRead:t}}}return{clients:A0(e.value),rateLimits:L0(e.value),transcripts:R0(e.value),frames:z0(e.value),widths:B0(e.value),serving:P0(e.value),stores:H0(e.value)}}const W0=` (fix: click the settings menu (${kr} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,G0=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${kr} by default) › 🧰 tools › 🩺 doctor`;function K0({check:e,verdict:t}){return t.ok?`✓ ${e.label}${t.note===void 0?``:` — ${t.note}`}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:W0}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${G0}\n`)}function q0(e){let t={sessionState:new UK},n=IK(e.projectDir,e.cwd,e.configFile??void 0,t),r=n.state??LK(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 J0(e,t,n){return n.kind===`failed`?n:zY(e,n.value.bundle,RJ(t,n.value.clients).map(({client:e})=>e))}function Y0(e,t,n){return t.kind===`failed`?t:{kind:`ok`,value:RJ(e,t.value).filter(e=>e.claudeConfigDir===n).map(e=>e.rateLimits)}}function X0(e,t){return t.kind===`failed`?t:{kind:`ok`,value:RJ(e,t.value).map(e=>e.transcript)}}function Z0(e,t){return t.kind===`failed`?t:{kind:`ok`,value:BJ(e,t.value)}}function Q0(e,t,n){return e.kind===`recent`?{kind:`ok`,value:{columns:n,of:{kind:`command`}}}:t.kind===`failed`?t:pX(e.sessionId,RJ(e,t.value))}async function $0(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=O0(r,i,a()),u=LJ(r.CLAUDE_CODE_SESSION_ID);s={...mX(e,l,{projectDir:zJ(u,c.frames.kind===`ok`?c.frames.value:[],i),cwd:i,configFile:oz(i,o)??e0(r,i)??null},()=>null,c.serving,Y0(u,c.rateLimits,ra(l.claudeConfigDir)),X0(u,c.transcripts),u,Z0(u,c.frames),Q0(u,c.widths,l.termCols??null),c.stores),urlHandler:await FX(t),install:J0(e.install,u,c.clients)}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=pM(s);return{stdout:c.map(K0).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function e2(){if(t.stderr.isTTY)return t.stderr;let e;try{e=v(`/dev/tty`,`r+`)}catch{return{}}let n=new ve(e),{columns:r}=n;return n.destroy(),{columns:r}}async function t2(e){(e.length>1||e[0]===``||e[0]?.startsWith(`--`))&&(t.stderr.write(`doctor: expected at most one config file
511
+ `));return d}finally{r.registry.dispose()}}function g0(e){return e.map(e=>`warning: ${e}\n`).join(``)}function _0(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:g0(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:g0(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 v0=`--render`,y0=`Usage: cc-candybar check [${v0}] [config-file]\n`;function b0(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==v0);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${y0}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${y0}`}:{kind:`run`,target:n[0],render:t.includes(v0)}}async function x0(e){let n=b0(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:_0(await f0(n.target??c0(t.env,t.cwd())),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const S0=/^[a-z][a-z0-9+.-]*:\/\//i,C0=/^[^@\s/]+@[^:\s/]+:/,w0=/^([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;function T0(e){if(!URL.canParse(e))return e;let t=new URL(e);return t.password===``?e:(t.password=`***`,t.href)}function E0(e,t,n){let r=az(t,e);if(n(r))return{kind:`path`,dir:r};if(S0.test(e)||C0.test(e))return{kind:`git`,url:e,shown:T0(e)};let i=w0.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 D0(e,t){let n=s.join(e,Fz),r=Rz(n);if(`error`in r)throw Error(`${t}: could not list ${Fz}: ${r.error}`);if(r.folders.length===0)throw Error(`${t} has no plugins: none at ${Fz}/<name>/${lz}`);return r.folders.map(e=>s.join(n,e,lz))}function O0(e,t,n){let r=(n,...r)=>{let i=We({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(`
512
+ `))delete i[e];r(i,`clone`,`--quiet`,`--depth`,`1`,`--filter=blob:none`,`--sparse`,`--`,e,n),r(i,`-C`,n,`sparse-checkout`,`set`,`--no-cone`,`/${Fz}/`)}function k0(e,t){switch(e.kind){case`path`:return t(e.dir);case`git`:{let n=p.mkdtempSync(s.join(S.tmpdir(),`cc-candybar-plugin-`));try{return O0(e.url,e.shown,s.join(n,`repo`)),t(s.join(n,`repo`))}finally{p.rmSync(n,{recursive:!0,force:!0})}}}}function A0(e){let t;try{t=p.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return`installed`;throw e}if(t.isDirectory())return`updated`;if(t.isSymbolicLink())return`replaced`;throw Error(`${e} is a file, not a plugin folder: move it, then install again`)}function j0(e,t,n,r){switch(r){case`updated`:p.renameSync(s.join(e,lz),s.join(t,lz));return;case`replaced`:p.renameSync(t,n),p.renameSync(e,t);return;case`installed`:p.renameSync(e,t);return}}function M0(e,t,n){let r=D0(e,n);p.mkdirSync(t,{recursive:!0});let i=p.mkdtempSync(s.join(t,`.install-`));try{let a=r.map(e=>{let t=s.join(i,s.basename(s.dirname(e)));p.mkdirSync(t);try{p.copyFileSync(e,s.join(t,lz))}catch(e){if(e.code!==`ENOENT`)throw e}return t}),o=tB(a.map(e=>s.join(e,lz)),EB,{root:e,git:!1});if(o.length>0)throw Error(o.map(e=>`${n}: ${s.join(Fz,s.relative(i,e.path))} would not load: ${e.reason.split(i).join(s.join(n,Fz))}`).join(`
513
+ `));let c=a.map(e=>{let n=s.basename(e),r=s.join(t,n);return{folder:e,name:n,target:r,placed:A0(r)}}),l=[];try{for(let{folder:e,name:t,target:n,placed:r}of c)j0(e,n,s.join(i,`.replaced-${t}`),r),l.push(t)}catch(e){throw Error(`${e.message} (placed before it: ${l.join(`, `)||`none`})`)}return c.map(({target:e,placed:t})=>({path:s.join(e,lz),placed:t}))}finally{p.rmSync(i,{recursive:!0,force:!0})}}function N0(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=E0(n,process.cwd(),EO);if(`error`in i)return console.error(`plugin install: ${i.error}`),2;try{let e=i.kind===`path`?i.dir:i.shown,t=k0(i,t=>M0(t,Pz(),e));for(let{path:n,placed:r}of t)console.log(`${r} plugin ${s.basename(s.dirname(n))} → ${n} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}function P0(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 F0=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function I0(e,t,n){return{termCols:P0(e.COLUMNS,n.columns),termRows:P0(e.LINES,n.rows),ssh:F0.some(t=>(e[t]??``)!==``),tmux:zA(e),configEnv:c0(e,t),claudeConfigDir:na(e,t),mementoEnv:mt(e,t),terminalEnv:gt(e)}}function L0(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function R0(e){let t=yX(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=L0(e);return n.every(e=>typeof e.ago==`number`&&typeof e.sessionId==`string`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:Lt(e.client)??null,sessionId:e.sessionId,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age or session: ${JSON.stringify(e.clients)}`}}const z0=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)},B0=e=>{let t=e??{};if(t.kind===`unmeasured`)return!0;let n=t.charge;return t.kind===`measured`&&typeof t.rss==`number`&&typeof t.heapTotal==`number`&&typeof n?.bytes==`number`&&(n.kind===`charged`&&(n.measure===`phys_footprint`||n.measure===`rss`)||n.kind===`stand-in`&&typeof n.unread==`string`)};function V0(e,t){let n=e;if(n?.kind===`failed`&&typeof n.reason==`string`)return{kind:`failed`,reason:n.reason};if(n?.kind!==`ok`)return{kind:`misshapen`,reason:`is not an answer`};let r=t(n.value);return r.kind===`ok`?r:{kind:`misshapen`,reason:r.reason}}function H0(e){let t=yX(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=V0(n?.postMortems,e=>Array.isArray(e)&&e.every(z0)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of post-mortems`});return typeof n?.pid==`number`&&B0(n.memory)&&typeof n.limit==`number`&&r.kind!==`misshapen`?{kind:`ok`,value:{...n,postMortems:r}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function U0(e,t,n){let r=yX(e,[`clients`]);if(r!==null)return{kind:`failed`,reason:r};let i=L0(e);return i.every(t)?{kind:`ok`,value:i}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without ${n} — restart it on this build: ${JSON.stringify(e.clients)}`}}const W0=e=>ZA.includes(e.role),G0=e=>U0(e,e=>typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof e.claudeConfigDir==`string`&&qA.includes(e.rateLimits),`the rate-limit windows they carried`),K0=e=>U0(e,e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof t?.path==`string`&&typeof t.answered==`boolean`},`their transcripts`),q0=e=>U0(e,e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&typeof e.projectDir==`string`&&typeof e.sessionId==`string`&&typeof e.since==`number`&&Array.isArray(e.redrawn)&&e.redrawn.length>0&&e.redrawn.every(Number.isInteger)&&W0(e)&&XA.includes(e.frame),`what they drew, when, and from which project`),J0=e=>U0(e,e=>typeof e.sessionId==`string`&&typeof e.ago==`number`&&W0(e)&&(e.termCols===null||typeof e.termCols==`number`),`whose they were or the width they measured`);function Y0(e,t,n){let r=e.doctorStores?.[t],i=V0(r,n);return i.kind===`misshapen`?{kind:`failed`,reason:`the running daemon (${e.version}) reported its ${t} as ${JSON.stringify(r)}, which ${i.reason}`}:i}function X0(e){let t=yX(e,[`doctorStores`]);if(t!==null){let e={kind:`failed`,reason:t};return{marks:e,clicked:e,postMortemsRead:e}}return{marks:Y0(e,`marks`,AJ),clicked:Y0(e,`clicked`,NJ),postMortemsRead:Y0(e,`postMortemsRead`,FY)}}async function Z0(){let e=await vX();if(e.kind!==`ok`){let t={kind:`failed`,reason:Wt(e).split(`
514
+ `).join(` — `)};return{clients:t,rateLimits:t,transcripts:t,frames:t,widths:t,serving:t,stores:{marks:t,clicked:t,postMortemsRead:t}}}return{clients:R0(e.value),rateLimits:G0(e.value),transcripts:K0(e.value),frames:q0(e.value),widths:J0(e.value),serving:H0(e.value),stores:X0(e.value)}}const Q0=` (fix: click the settings menu (${kr} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,$0=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${kr} by default) › 🧰 tools › 🩺 doctor`;function e2({check:e,verdict:t}){return t.ok?`✓ ${e.label}${t.note===void 0?``:` — ${t.note}`}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:Q0}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${$0}\n`)}function t2(e){let t={sessionState:new UK},n=IK(e.projectDir,e.cwd,e.configFile??void 0,t),r=n.state??LK(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 n2(e,t,n){return n.kind===`failed`?n:zY(e,n.value.bundle,RJ(t,n.value.clients).map(({client:e})=>e))}function r2(e,t,n){return t.kind===`failed`?t:{kind:`ok`,value:RJ(e,t.value).filter(e=>e.claudeConfigDir===n).map(e=>e.rateLimits)}}function i2(e,t){return t.kind===`failed`?t:{kind:`ok`,value:RJ(e,t.value).map(e=>e.transcript)}}function a2(e,t){return t.kind===`failed`?t:{kind:`ok`,value:BJ(e,t.value)}}function o2(e,t,n){return e.kind===`recent`?{kind:`ok`,value:{columns:n,of:{kind:`command`}}}:t.kind===`failed`?t:pX(e.sessionId,RJ(e,t.value))}async function s2(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=I0(r,i,a()),u=LJ(r.CLAUDE_CODE_SESSION_ID);s={...mX(e,l,{projectDir:zJ(u,c.frames.kind===`ok`?c.frames.value:[],i),cwd:i,configFile:oz(i,o)??c0(r,i)??null},()=>null,c.serving,r2(u,c.rateLimits,ra(l.claudeConfigDir)),i2(u,c.transcripts),u,a2(u,c.frames),o2(u,c.widths,l.termCols??null),c.stores),urlHandler:await FX(t),install:n2(e.install,u,c.clients)}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=pM(s);return{stdout:c.map(e2).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function c2(){if(t.stderr.isTTY)return t.stderr;let e;try{e=v(`/dev/tty`,`r+`)}catch{return{}}let n=new ve(e),{columns:r}=n;return n.destroy(),{columns:r}}async function l2(e){(e.length>1||e[0]===``||e[0]?.startsWith(`--`))&&(t.stderr.write(`doctor: expected at most one config file
515
515
  Usage: cc-candybar doctor [config-file]
516
- `),t.exit(2));let n=t.cwd(),r=await $0(ZY(q0),zX(),U0,t.env,n,e2,e[0]);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}function n2(e){return!e.ok&&e.code!==`RENDER_FAILED`}function r2(e,t,n,r,i){let a=null,o=e=>{a===null&&(a=e,s.destroy(),i(e))},s=C.createConnection({path:e}),c={v:3,kind:`subscribe`,sessionId:t,lane:n};return s.once(`connect`,()=>s.write(Nt(c))),s.on(`data`,Ft(e=>{let t=e;n2(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 i2(e,t){switch(t){case`frame-ok`:return 250;case`frame-failed`:return e;case`fault`:return Math.min(2e3,e*2)}}function a2(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 o2(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=r2(e,t,n,e=>{s=i2(s,e.ok?`frame-ok`:`frame-failed`),r.frame(e)},e=>{if(e.kind===`closed-here`||o)return;let t=a2(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&&On();let e=s;s=i2(s,`fault`),c(e,!0);return}}})};return l(),{close:()=>{o=!0,a!==null&&clearTimeout(a),i?.close()}}}function s2(e,t){return t.kind===`frame`||t.kind!==e.kind?!0:t.kind===`fault`&&e.kind===`fault`&&t.reason!==e.reason}async function c2(e,n){let{values:r,tokens:i}=ae({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=p_(r.lane);c===null&&(s(`--lane needs one of ${o_.join(`, `)}`),t.exit(2)),t.stdout.on(`error`,()=>t.exit(0));let l=LQ(t.stdout),u=null,d=null,f=null,p={kind:`none`},m=(e,t)=>{s2(p,e)&&t(),p=e},h=async e=>{let r=await Yt(e,a,o,{...O0(t.env,o,t.stderr),client:O(`frames`,n)});r.kind!==`ok`&&(s(Wt(r)),r.kind===`transient`&&On())},g=e=>{f?.close(),f=o2(et(),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 ye({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 l2(e){let t=e.replace(/\n+$/,``).split(`
517
- `);return{bytes:t.map((e,t)=>`\x1b[${t+1}H${e}`).join(``)+`\x1B[J`,rows:t.length}}const u2=5e3,d2=`usage: cc-candybar bar-pane <claude-code-pane-id, e.g. %3>`;function f2(e,t,n,r){let i=e.split(`
518
- `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?VQ(e,BQ(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function p2(e,t){let[n,r]=await Promise.all([QH(e,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${t}},#{==:#{pane_id},${e.pane}}}`,`-F`,RQ]),QH(e,`bar-pane.tmux`,[`list-clients`,`-F`,zQ])]);return n.kind===`ok`?r.kind===`ok`?{kind:`ok`,placement:f2(n.stdout,r.stdout,t,e.pane)}:r:n}function m2(){let e=Date.now();return t=>{if(t.kind===`ok`)e=Date.now();else if(Date.now()-e>u2)throw Error(`tmux has not answered for ${u2/1e3} s: ${t.reason}`)}}function h2(e){let{positionals:t}=(()=>{try{return ae({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${d2}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(d2);return{pane:n}}async function g2(e){try{return await _2(e),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function _2(e){let{pane:n}=h2(e),r=zA(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 p2(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=m2(),f=async()=>{if(a.kind!==`shown`)return;let e=l2(l());e.rows!==t.stdout.rows&&!a.zoomed&&d(await QH(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:o2(et(),e,`pane`,{frame:e=>n(GV(Jt(e)).output),off:e=>n(e.error),fault:n,exit:e=>o(Error(e))})}},_=m2();for(;a.kind!==`gone`;){if(a.kind===`hidden`)g(null);else{let e=await Xt(r.socket,n);e.kind===`ok`?(g(e.value),c=e.value===null?`waiting for pane ${n}'s statusline to render on ${et()}`:`waiting for pane ${n}'s bar`):(e.kind===`transient`&&(On(),u=``),c=Wt(e))}h(),await _e(500);let e=await p2(r,n);_(e),e.kind===`ok`&&(a=e.placement)}g(null),t.stderr.write(`cc-candybar bar-pane: pane ${n} closed\n`)}const v2=i(import.meta.url),y2=e=>e.some(e=>t.argv.includes(e));function b2(){console.log(IA)}const x2={install:async e=>{await Xa(e,v2),t.exit(0)},"install-url-handler":async()=>{Ga(v2),t.exit(0)},"url-handle":async e=>{await qa(e[0])},daemon:async()=>{n1()},"daemon-stats":async e=>{await _X(e),t.exit(0)},frames:async()=>{await c2(t.argv,v2)},check:async e=>{await p0(e)},lint:async e=>{await p0(e)},plugin:async e=>{t.exit(T0(e))},schema:async()=>{Q1()},doctor:async e=>{await t2(e)},"bar-pane":async e=>{t.exit(await g2(e))},...Object.fromEntries(EQ.map(e=>[e,async n=>{await U1(e,n),t.exit(0)}]))};async function S2(){try{let e=t.argv[2],n=e!==void 0&&!e.startsWith(`-`)?e:null;if(n!==null&&!Object.hasOwn(x2,n)&&(console.error(`cc-candybar: unknown subcommand ${JSON.stringify(n)} — see --help`),t.exit(2)),y2(SA.help)&&(b2(),t.exit(0)),y2(SA.version)&&(console.log(`cc-candybar ${Gt}`),t.exit(0)),n!==null){await x2[n](t.argv.slice(3));return}t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
516
+ `),t.exit(2));let n=t.cwd(),r=await s2(ZY(t2),zX(),Z0,t.env,n,c2,e[0]);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}function u2(e){return!e.ok&&e.code!==`RENDER_FAILED`}function d2(e,t,n,r,i){let a=null,o=e=>{a===null&&(a=e,s.destroy(),i(e))},s=C.createConnection({path:e}),c={v:3,kind:`subscribe`,sessionId:t,lane:n};return s.once(`connect`,()=>s.write(Nt(c))),s.on(`data`,Ft(e=>{let t=e;u2(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 f2(e,t){switch(t){case`frame-ok`:return 250;case`frame-failed`:return e;case`fault`:return Math.min(2e3,e*2)}}function p2(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 m2(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=d2(e,t,n,e=>{s=f2(s,e.ok?`frame-ok`:`frame-failed`),r.frame(e)},e=>{if(e.kind===`closed-here`||o)return;let t=p2(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&&On();let e=s;s=f2(s,`fault`),c(e,!0);return}}})};return l(),{close:()=>{o=!0,a!==null&&clearTimeout(a),i?.close()}}}function h2(e,t){return t.kind===`frame`||t.kind!==e.kind?!0:t.kind===`fault`&&e.kind===`fault`&&t.reason!==e.reason}async function g2(e,n){let{values:r,tokens:i}=ae({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=p_(r.lane);c===null&&(s(`--lane needs one of ${o_.join(`, `)}`),t.exit(2)),t.stdout.on(`error`,()=>t.exit(0));let l=LQ(t.stdout),u=null,d=null,f=null,p={kind:`none`},m=(e,t)=>{h2(p,e)&&t(),p=e},h=async e=>{let r=await Yt(e,a,o,{...I0(t.env,o,t.stderr),client:O(`frames`,n)});r.kind!==`ok`&&(s(Wt(r)),r.kind===`transient`&&On())},g=e=>{f?.close(),f=m2(et(),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 ye({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 _2(e){let t=e.replace(/\n+$/,``).split(`
517
+ `);return{bytes:t.map((e,t)=>`\x1b[${t+1}H${e}`).join(``)+`\x1B[J`,rows:t.length}}const v2=5e3,y2=`usage: cc-candybar bar-pane <claude-code-pane-id, e.g. %3>`;function b2(e,t,n,r){let i=e.split(`
518
+ `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?VQ(e,BQ(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function x2(e,t){let[n,r]=await Promise.all([QH(e,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${t}},#{==:#{pane_id},${e.pane}}}`,`-F`,RQ]),QH(e,`bar-pane.tmux`,[`list-clients`,`-F`,zQ])]);return n.kind===`ok`?r.kind===`ok`?{kind:`ok`,placement:b2(n.stdout,r.stdout,t,e.pane)}:r:n}function S2(){let e=Date.now();return t=>{if(t.kind===`ok`)e=Date.now();else if(Date.now()-e>v2)throw Error(`tmux has not answered for ${v2/1e3} s: ${t.reason}`)}}function C2(e){let{positionals:t}=(()=>{try{return ae({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${y2}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(y2);return{pane:n}}async function w2(e){try{return await T2(e),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function T2(e){let{pane:n}=C2(e),r=zA(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 x2(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=S2(),f=async()=>{if(a.kind!==`shown`)return;let e=_2(l());e.rows!==t.stdout.rows&&!a.zoomed&&d(await QH(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:m2(et(),e,`pane`,{frame:e=>n(GV(Jt(e)).output),off:e=>n(e.error),fault:n,exit:e=>o(Error(e))})}},_=S2();for(;a.kind!==`gone`;){if(a.kind===`hidden`)g(null);else{let e=await Xt(r.socket,n);e.kind===`ok`?(g(e.value),c=e.value===null?`waiting for pane ${n}'s statusline to render on ${et()}`:`waiting for pane ${n}'s bar`):(e.kind===`transient`&&(On(),u=``),c=Wt(e))}h(),await _e(500);let e=await x2(r,n);_(e),e.kind===`ok`&&(a=e.placement)}g(null),t.stderr.write(`cc-candybar bar-pane: pane ${n} closed\n`)}const E2=i(import.meta.url),D2=e=>e.some(e=>t.argv.includes(e));function O2(){console.log(IA)}const k2={install:async e=>{await Xa(e,E2),t.exit(0)},"install-url-handler":async()=>{Ga(E2),t.exit(0)},"url-handle":async e=>{await qa(e[0])},daemon:async()=>{u1()},"daemon-stats":async e=>{await _X(e),t.exit(0)},frames:async()=>{await g2(t.argv,E2)},check:async e=>{await x0(e)},lint:async e=>{await x0(e)},plugin:async e=>{t.exit(N0(e))},schema:async()=>{o0()},doctor:async e=>{await l2(e)},"bar-pane":async e=>{t.exit(await w2(e))},...Object.fromEntries(EQ.map(e=>[e,async n=>{await Z1(e,n),t.exit(0)}]))};async function A2(){try{let e=t.argv[2],n=e!==void 0&&!e.startsWith(`-`)?e:null;if(n!==null&&!Object.hasOwn(k2,n)&&(console.error(`cc-candybar: unknown subcommand ${JSON.stringify(n)} — see --help`),t.exit(2)),D2(SA.help)&&(O2(),t.exit(0)),D2(SA.version)&&(console.log(`cc-candybar ${Gt}`),t.exit(0)),n!==null){await k2[n](t.argv.slice(3));return}t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
519
519
 
520
520
  cc-candybar is designed to be used as a Claude Code statusLine command.
521
521
  It reads hook data from stdin and outputs formatted statusline.
@@ -531,4 +531,4 @@ Add to ~/.claude/settings.json:
531
531
  Run with --help for more options.
532
532
 
533
533
  To test output manually:
534
- 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)),E(`Working directory: ${t.cwd()}`),E(`Process args:`,t.argv);let r=await o(t.stdin);E(`Received hook data:`,JSON.stringify(r,null,2)),r||(console.error(`Error: No input data received from stdin`),b2(),t.exit(1));let i=GV(await Yt(r,t.argv.slice(1),t.cwd(),{...O0(t.env,t.cwd(),t.stderr),client:O(`node`,v2)}));i.debug!==null&&E(i.debug),i.kick&&On(),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)}}S2();export{};
534
+ 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)),E(`Working directory: ${t.cwd()}`),E(`Process args:`,t.argv);let r=await o(t.stdin);E(`Received hook data:`,JSON.stringify(r,null,2)),r||(console.error(`Error: No input data received from stdin`),O2(),t.exit(1));let i=GV(await Yt(r,t.argv.slice(1),t.cwd(),{...I0(t.env,t.cwd(),t.stderr),client:O(`node`,E2)}));i.debug!==null&&E(i.debug),i.kick&&On(),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)}}A2();export{};