@promptctl/cc-candybar 1.148.1 → 1.148.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.
- package/dist/index.mjs +4 -4
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i,pathToFileURL as a}from"node:url";import{json as o}from"node:stream/consumers";import s,{closeSync as c,constants as l,createReadStream as u,existsSync as d,fstatSync as f,openSync as p,readSync as m,realpathSync as h,statSync as g,watch as _}from"node:fs";import v,{basename as y,dirname as b,isAbsolute as x,join as S,sep as C}from"node:path";import w,{homedir as ee}from"node:os";import{spawn as te,spawnSync as ne}from"node:child_process";import{inspect as T,parseArgs as re,types as E}from"node:util";import D from"node:net";import ie from"node:v8";import{open as O,readFile as ae,readdir as oe,stat as se}from"node:fs/promises";import ce,{createHash as le,randomUUID as ue}from"node:crypto";import{clearInterval as de,setImmediate as fe,setInterval as pe}from"node:timers";import{get as me}from"node:https";import{setTimeout as he}from"node:timers/promises";import{createInterface as ge}from"node:readline";import{WriteStream as _e}from"node:tty";var ve=Object.create,ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,xe=Object.getOwnPropertyNames,Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty,we=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ce.call(e,s)&&s!==n&&ye(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=be(t,s))||r.enumerable});return e},Ee=(e,t,n)=>(n=e==null?{}:ve(Se(e)),Te(t||!e||!e.__esModule?ye(n,`default`,{value:e,enumerable:!0}):n,e));function k(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}function De(e,t){return E.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!d(t)?`working directory does not exist: ${t}`:e.message:String(e)}const Oe={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3},ke=new Map;function Ae(e){let t=Oe[e];if(t===void 0)return{allowed:!0};let n=ke.get(e);if(n===void 0)return{allowed:!0};let r=Date.now()-n;return r>=t?{allowed:!0}:{allowed:!1,minIntervalMs:t,sinceLastMs:r}}function je(e){ke.set(e,Date.now())}function Me(e){return e.env??process.env}function Ne(e,t,n){return{ok:!1,reason:`rate-limited`,stdout:``,stderr:``,exitCode:null,signal:null,error:`rate-limited: ${e} min interval ${t}ms, last start ${n}ms ago`}}let Pe=null;function Fe(e){Pe=e}function Ie(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Le(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();return Pe?.onStart(e.category),new Promise(t=>{let r;try{r=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){Pe?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(r,e.cwd)});return}let i=``,a=``,o=!1,s=null,c=null,l=null,u=()=>m(`aborted`),d=t=>{o||(o=!0,s&&clearTimeout(s),c&&clearTimeout(c),e.signal?.removeEventListener(`abort`,u),Pe?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{Ie(e,t)}catch(e){f({ok:!1,reason:`signal-refused`,stdout:i,stderr:a,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)})}},m=t=>{l=t,s&&clearTimeout(s),e.signal?.removeEventListener(`abort`,u);let n=r.pid;n!==void 0&&(c=setTimeout(()=>p(n,`SIGKILL`),250),p(n,`SIGTERM`))};r.stdout?.on(`data`,e=>{i+=e.toString(`utf8`)}),r.stderr?.on(`data`,e=>{a+=e.toString(`utf8`)}),r.on(`error`,t=>{f({ok:!1,reason:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:null,error:De(t,e.cwd)})}),r.on(`close`,(e,t)=>{if(l!==null){f({ok:!1,reason:l,stdout:i,stderr:a,exitCode:e,signal:t});return}if(e===0){f({ok:!0,stdout:i,stderr:a,exitCode:e});return}f({ok:!1,reason:t?`signal`:`non-zero`,stdout:i,stderr:a,exitCode:e,signal:t})}),e.timeoutMs&&e.timeoutMs>0&&(s=setTimeout(()=>m(`timeout`),e.timeoutMs)),e.signal?.addEventListener(`abort`,u,{once:!0}),e.stdinInput!==void 0&&r.stdin?r.stdin.end(e.stdinInput):r.stdin&&r.stdin.end()})}function Re(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=ne(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});Pe?.onEnd(e.category,Date.now()-n);let i=typeof t.stdout==`string`?t.stdout:``,a=typeof t.stderr==`string`?t.stderr:``;if(t.error)return{ok:!1,reason:t.error.code===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:t.signal??null,error:De(t.error,e.cwd)};if(t.status===0)return{ok:!0,stdout:i,stderr:a,exitCode:t.status};let o=e.timeoutMs!==void 0&&e.timeoutMs>0;return{ok:!1,reason:t.signal?o&&t.signal===`SIGTERM`?`timeout`:`signal`:`non-zero`,stdout:i,stderr:a,exitCode:t.status,signal:t.signal??null}}catch(t){return Pe?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(t,e.cwd)}}}function ze(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=Be(e);return Pe?.onEnd(e.category,Date.now()-n),r}function Be(e){let t;try{t=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(t,e.cwd)}}return t.once(`error`,()=>{}),t.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${e.bin}): no pid (binary not found or unexecutable)`}:(t.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}function Ve(e,t,n){let r=He(e);s.mkdirSync(v.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??s.statSync(r,{throwIfNoEntry:!1})?.mode;try{s.writeFileSync(i,t,a===void 0?{}:{mode:a}),s.renameSync(i,r)}catch(e){throw s.rmSync(i,{force:!0}),e}}function He(e){let t=e;for(let e=0;e<Ue;e++){let e;try{e=s.lstatSync(t)}catch(e){if(e.code===`ENOENT`)return t;throw e}if(!e.isSymbolicLink())return t;t=v.resolve(s.realpathSync(v.dirname(t)),s.readlinkSync(t))}throw Error(`${e}: more than ${Ue} symbolic links`)}const Ue=40;function We(e,t){let n=e[t];return n&&n.length>0?n:void 0}function Ge(e=process.env){let t=We(e,`XDG_STATE_HOME`)??v.join(w.homedir(),`.local`,`state`);return v.join(t,`cc-candybar`)}function Ke(){let e=We(process.env,`XDG_CACHE_HOME`)??v.join(w.homedir(),`.cache`);return v.join(e,`cc-candybar`)}function qe(){return Ge()}function Je(){return process.env.CC_CANDYBAR_SOCKET||Ye()}function Ye(){let e=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function Xe(e){s.mkdirSync(e,{recursive:!0,mode:448});let t=s.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=w.userInfo().uid;if(typeof n==`number`&&t.uid!==n)throw Error(`directory is not owned by uid ${n}: ${e} (owner uid=${t.uid})`);if(t.mode&63)throw Error(`directory has unsafe permissions: ${e} (mode=${(t.mode&511).toString(8)}, expected 0700)`)}function Ze(e){Xe(v.dirname(e));for(let t of[e,Qe(e)])try{if(s.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function Qe(e){return`${e}.lease`}function $e(){return Qe(Je())}function et(){return v.join(Ge(),`session-state.json`)}function tt(){return v.join(Ge(),`settings-history.json`)}function nt(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function rt(){return v.join(Ge(),`spawn.lock`)}function it(){return v.join(Ge(),`spawn.cooldown`)}function at(){return v.join(Ge(),`spawn.backoff`)}function ot(){return v.join(Ge(),`diagnostics`)}function st(e=process.env){return v.join(Ge(e),`daemon.log`)}const ct=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function lt(e,t){return Object.fromEntries(ct.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,v.resolve(t,r)]]}))}const ut=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function A(e){return Object.fromEntries(ut.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const dt=[`native`,`node`,`frames`];function ft(e,t){return{kind:e,bundle:t,source:null}}const pt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,mementoEnv:!0,terminalEnv:!0,client:!0});function mt(e){let t=xt(e.termCols),n=xt(e.termRows),r=St(e.ssh),i=yt(e.tmux),a=vt(e.configEnv),o=vt(e.claudeConfigDir),s=gt(e.mementoEnv),c=_t(e.terminalEnv),l=kt(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 j(e,t){return pt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function ht(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}function gt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ct.filter(e=>t[e]!==void 0);return n.every(e=>vt(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function _t(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ut.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 vt(e){return typeof e==`string`&&v.isAbsolute(e)?e:void 0}function yt(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 bt=1e4;function xt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>bt?bt:t}function St(e){return typeof e==`boolean`?e:void 0}function Ct(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var wt=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Tt(e){return Et(JSON.stringify(e))}function Et(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Dt(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 wt(`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 wt(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Ot(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=Dt(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(Tt(t))})}function kt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=vt(n);return dt.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function At(e,t,n){let r=null;try{r=await Ft(Je(),t.connectMs);let i=await Ot(r,{v:3,...e},t.budgetMs);return Nt(e.kind,i,n)}catch(e){return Pt(e)}finally{r&&r.destroy()}}function jt(e,t){return typeof e==`string`?e:t}function Mt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function Nt(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=jt(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:Mt(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 Pt(e){if(e instanceof wt||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 Ft(e,t){return new Promise((n,r)=>{let i=D.createConnection({path:e}),a=setTimeout(()=>{i.destroy(),r(Error(`CONNECT_TIMEOUT`))},t);i.once(`connect`,()=>{clearTimeout(a),n(i)}),i.once(`error`,e=>{clearTimeout(a),r(e)})})}function It(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 Lt=`1.148.1`,Rt={connectMs:50,budgetMs:150},zt={connectMs:50,budgetMs:200};function Bt(e){let t=e.output;return typeof t==`string`?t:void 0}function Vt(e){return Nt(`render`,e,Bt)}function Ht(e,t,n,r){return At({kind:`render`,hookData:e,args:t,cwd:n,...r},Rt,Bt)}function M(e,t){return At({kind:`pane-session`,socket:e,pane:t},zt,e=>`paneSession`in e?e.paneSession:void 0)}function Ut(e,t){return At({kind:`click`,verb:e,value:t,clientVersion:Lt},zt,Bt)}let Wt=null;function Gt(e){if(Wt!==null)return Wt;s.mkdirSync(v.dirname(e),{recursive:!0});try{Wt=s.statSync(e).size}catch{Wt=0}return Wt}function Kt(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,r=`${e}.${t+1}`;try{s.renameSync(n,r)}catch{}}try{s.renameSync(e,`${e}.1`)}catch{}Wt=0}const qt=(e,t)=>k(t);function N(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=st(),t=Gt(e);s.appendFileSync(e,n),Wt=t+Buffer.byteLength(n,`utf8`),Wt>=5242880&&Kt(e)}catch(e){Wt=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}function P(e){let t=[];for(let n of e){let e=n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
|
|
2
|
+
import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i,pathToFileURL as a}from"node:url";import{json as o}from"node:stream/consumers";import s,{closeSync as c,constants as l,createReadStream as u,existsSync as d,fstatSync as f,openSync as p,readSync as m,realpathSync as h,statSync as g,watch as _}from"node:fs";import v,{basename as y,dirname as b,isAbsolute as x,join as S,sep as C}from"node:path";import w,{homedir as ee}from"node:os";import{spawn as te,spawnSync as ne}from"node:child_process";import{inspect as T,parseArgs as re,types as E}from"node:util";import D from"node:net";import ie from"node:v8";import{open as O,readFile as ae,readdir as oe,stat as se}from"node:fs/promises";import ce,{createHash as le,randomUUID as ue}from"node:crypto";import{clearInterval as de,setImmediate as fe,setInterval as pe}from"node:timers";import{get as me}from"node:https";import{setTimeout as he}from"node:timers/promises";import{createInterface as ge}from"node:readline";import{WriteStream as _e}from"node:tty";var ve=Object.create,ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,xe=Object.getOwnPropertyNames,Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty,we=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ce.call(e,s)&&s!==n&&ye(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=be(t,s))||r.enumerable});return e},Ee=(e,t,n)=>(n=e==null?{}:ve(Se(e)),Te(t||!e||!e.__esModule?ye(n,`default`,{value:e,enumerable:!0}):n,e));function k(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}function De(e,t){return E.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!d(t)?`working directory does not exist: ${t}`:e.message:String(e)}const Oe={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3},ke=new Map;function Ae(e){let t=Oe[e];if(t===void 0)return{allowed:!0};let n=ke.get(e);if(n===void 0)return{allowed:!0};let r=Date.now()-n;return r>=t?{allowed:!0}:{allowed:!1,minIntervalMs:t,sinceLastMs:r}}function je(e){ke.set(e,Date.now())}function Me(e){return e.env??process.env}function Ne(e,t,n){return{ok:!1,reason:`rate-limited`,stdout:``,stderr:``,exitCode:null,signal:null,error:`rate-limited: ${e} min interval ${t}ms, last start ${n}ms ago`}}let Pe=null;function Fe(e){Pe=e}function Ie(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Le(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();return Pe?.onStart(e.category),new Promise(t=>{let r;try{r=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){Pe?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(r,e.cwd)});return}let i=``,a=``,o=!1,s=null,c=null,l=null,u=()=>m(`aborted`),d=t=>{o||(o=!0,s&&clearTimeout(s),c&&clearTimeout(c),e.signal?.removeEventListener(`abort`,u),Pe?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{Ie(e,t)}catch(e){f({ok:!1,reason:`signal-refused`,stdout:i,stderr:a,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)})}},m=t=>{l=t,s&&clearTimeout(s),e.signal?.removeEventListener(`abort`,u);let n=r.pid;n!==void 0&&(c=setTimeout(()=>p(n,`SIGKILL`),250),p(n,`SIGTERM`))};r.stdout?.on(`data`,e=>{i+=e.toString(`utf8`)}),r.stderr?.on(`data`,e=>{a+=e.toString(`utf8`)}),r.on(`error`,t=>{f({ok:!1,reason:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:null,error:De(t,e.cwd)})}),r.on(`close`,(e,t)=>{if(l!==null){f({ok:!1,reason:l,stdout:i,stderr:a,exitCode:e,signal:t});return}if(e===0){f({ok:!0,stdout:i,stderr:a,exitCode:e});return}f({ok:!1,reason:t?`signal`:`non-zero`,stdout:i,stderr:a,exitCode:e,signal:t})}),e.timeoutMs&&e.timeoutMs>0&&(s=setTimeout(()=>m(`timeout`),e.timeoutMs)),e.signal?.addEventListener(`abort`,u,{once:!0}),e.stdinInput!==void 0&&r.stdin?r.stdin.end(e.stdinInput):r.stdin&&r.stdin.end()})}function Re(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=ne(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});Pe?.onEnd(e.category,Date.now()-n);let i=typeof t.stdout==`string`?t.stdout:``,a=typeof t.stderr==`string`?t.stderr:``;if(t.error)return{ok:!1,reason:t.error.code===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:t.signal??null,error:De(t.error,e.cwd)};if(t.status===0)return{ok:!0,stdout:i,stderr:a,exitCode:t.status};let o=e.timeoutMs!==void 0&&e.timeoutMs>0;return{ok:!1,reason:t.signal?o&&t.signal===`SIGTERM`?`timeout`:`signal`:`non-zero`,stdout:i,stderr:a,exitCode:t.status,signal:t.signal??null}}catch(t){return Pe?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(t,e.cwd)}}}function ze(e){let t=Ae(e.category);if(!t.allowed)return Ne(e.category,t.minIntervalMs,t.sinceLastMs);je(e.category);let n=Date.now();Pe?.onStart(e.category);let r=Be(e);return Pe?.onEnd(e.category,Date.now()-n),r}function Be(e){let t;try{t=te(e.bin,e.args??[],{cwd:e.cwd,env:Me(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:De(t,e.cwd)}}return t.once(`error`,()=>{}),t.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${e.bin}): no pid (binary not found or unexecutable)`}:(t.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}function Ve(e,t,n){let r=He(e);s.mkdirSync(v.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??s.statSync(r,{throwIfNoEntry:!1})?.mode;try{s.writeFileSync(i,t,a===void 0?{}:{mode:a}),s.renameSync(i,r)}catch(e){throw s.rmSync(i,{force:!0}),e}}function He(e){let t=e;for(let e=0;e<Ue;e++){let e;try{e=s.lstatSync(t)}catch(e){if(e.code===`ENOENT`)return t;throw e}if(!e.isSymbolicLink())return t;t=v.resolve(s.realpathSync(v.dirname(t)),s.readlinkSync(t))}throw Error(`${e}: more than ${Ue} symbolic links`)}const Ue=40;function We(e,t){let n=e[t];return n&&n.length>0?n:void 0}function Ge(e=process.env){let t=We(e,`XDG_STATE_HOME`)??v.join(w.homedir(),`.local`,`state`);return v.join(t,`cc-candybar`)}function Ke(){let e=We(process.env,`XDG_CACHE_HOME`)??v.join(w.homedir(),`.cache`);return v.join(e,`cc-candybar`)}function qe(){return Ge()}function Je(){return process.env.CC_CANDYBAR_SOCKET||Ye()}function Ye(){let e=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function Xe(e){s.mkdirSync(e,{recursive:!0,mode:448});let t=s.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=w.userInfo().uid;if(typeof n==`number`&&t.uid!==n)throw Error(`directory is not owned by uid ${n}: ${e} (owner uid=${t.uid})`);if(t.mode&63)throw Error(`directory has unsafe permissions: ${e} (mode=${(t.mode&511).toString(8)}, expected 0700)`)}function Ze(e){Xe(v.dirname(e));for(let t of[e,Qe(e)])try{if(s.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function Qe(e){return`${e}.lease`}function $e(){return Qe(Je())}function et(){return v.join(Ge(),`session-state.json`)}function tt(){return v.join(Ge(),`settings-history.json`)}function nt(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=w.userInfo().uid;return v.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function rt(){return v.join(Ge(),`spawn.lock`)}function it(){return v.join(Ge(),`spawn.cooldown`)}function at(){return v.join(Ge(),`spawn.backoff`)}function ot(){return v.join(Ge(),`diagnostics`)}function st(e=process.env){return v.join(Ge(e),`daemon.log`)}const ct=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function lt(e,t){return Object.fromEntries(ct.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,v.resolve(t,r)]]}))}const ut=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function A(e){return Object.fromEntries(ut.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const dt=[`native`,`node`,`frames`];function ft(e,t){return{kind:e,bundle:t,source:null}}const pt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,mementoEnv:!0,terminalEnv:!0,client:!0});function mt(e){let t=xt(e.termCols),n=xt(e.termRows),r=St(e.ssh),i=yt(e.tmux),a=vt(e.configEnv),o=vt(e.claudeConfigDir),s=gt(e.mementoEnv),c=_t(e.terminalEnv),l=kt(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 j(e,t){return pt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function ht(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}function gt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ct.filter(e=>t[e]!==void 0);return n.every(e=>vt(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function _t(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=ut.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 vt(e){return typeof e==`string`&&v.isAbsolute(e)?e:void 0}function yt(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 bt=1e4;function xt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>bt?bt:t}function St(e){return typeof e==`boolean`?e:void 0}function Ct(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var wt=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Tt(e){return Et(JSON.stringify(e))}function Et(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Dt(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 wt(`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 wt(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Ot(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=Dt(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(Tt(t))})}function kt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=vt(n);return dt.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function At(e,t,n){let r=null;try{r=await Ft(Je(),t.connectMs);let i=await Ot(r,{v:3,...e},t.budgetMs);return Nt(e.kind,i,n)}catch(e){return Pt(e)}finally{r&&r.destroy()}}function jt(e,t){return typeof e==`string`?e:t}function Mt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function Nt(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=jt(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:Mt(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 Pt(e){if(e instanceof wt||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 Ft(e,t){return new Promise((n,r)=>{let i=D.createConnection({path:e}),a=setTimeout(()=>{i.destroy(),r(Error(`CONNECT_TIMEOUT`))},t);i.once(`connect`,()=>{clearTimeout(a),n(i)}),i.once(`error`,e=>{clearTimeout(a),r(e)})})}function It(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 Lt=`1.148.2`,Rt={connectMs:50,budgetMs:150},zt={connectMs:50,budgetMs:200};function Bt(e){let t=e.output;return typeof t==`string`?t:void 0}function Vt(e){return Nt(`render`,e,Bt)}function Ht(e,t,n,r){return At({kind:`render`,hookData:e,args:t,cwd:n,...r},Rt,Bt)}function M(e,t){return At({kind:`pane-session`,socket:e,pane:t},zt,e=>`paneSession`in e?e.paneSession:void 0)}function Ut(e,t){return At({kind:`click`,verb:e,value:t,clientVersion:Lt},zt,Bt)}let Wt=null;function Gt(e){if(Wt!==null)return Wt;s.mkdirSync(v.dirname(e),{recursive:!0});try{Wt=s.statSync(e).size}catch{Wt=0}return Wt}function Kt(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,r=`${e}.${t+1}`;try{s.renameSync(n,r)}catch{}}try{s.renameSync(e,`${e}.1`)}catch{}Wt=0}const qt=(e,t)=>k(t);function N(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=st(),t=Gt(e);s.appendFileSync(e,n),Wt=t+Buffer.byteLength(n,`utf8`),Wt>=5242880&&Kt(e)}catch(e){Wt=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}function P(e){let t=[];for(let n of e){let e=n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
|
|
3
3
|
`)}function Jt(e,t){return e===`darwin`?[Yt(`footprint`,[`-p`,String(t)]),Yt(`vmmap`,[`--summary`,String(t)])]:e===`linux`?[Xt(`/proc/self/smaps_rollup`),Xt(`/proc/self/status`)]:[]}function Yt(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=Re({bin:e,args:[...t],timeoutMs:5e3,category:`limits.memory-report`});return n.ok?n.stdout.trim().length>0?{kind:`text`,text:n.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:`${n.reason}${n.error===void 0?``:`: ${n.error}`}${Zt(n.stderr)}`}}}}function Xt(e){return{name:e,read:()=>{try{let t=s.readFileSync(e,`utf8`);return t.trim().length>0?{kind:`text`,text:t}:{kind:`unavailable`,reason:`empty file`}}catch(e){return{kind:`unavailable`,reason:e.message}}}}}function Zt(e){let t=e.split(`
|
|
4
4
|
`).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const Qt=`CC_CANDYBAR_RSS_LIMIT_MB`;function $t(e){let t=e[Qt];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${Qt} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function en(e){return $t(e)*2}const tn=1024*1024,nn=e=>Math.round(e/tn);function rn(e){return $t(e)*tn}const an={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function on(e,t){return e>t}function sn(e,t){return e>t*.75}function cn(e,t,n){let{prefix:r,suffix:i}=an[t];return v.join(e,`${r}${n}${i}`)}function ln(e){for(let t of Object.keys(an)){let{prefix:n,suffix:r}=an[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function un(e){let t=e.rssLimitBytes??512*tn,n=e.snapshotsKeep??3,r=!1;function i(){if(r)return!0;let{rss:i,heapTotal:a}=e.memoryBytes();if(i<=t)return!1;r=!0,e.log(`warn`,`RSS ${i} > limit ${t} (v8 heap ${a}); recording memory then shutting down`);let o=`${new Date(e.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return dn(e.log,`memory report`,()=>{let t=cn(e.snapshotDir,`memoryReport`,o);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),dn(e.log,`heap snapshot`,()=>{let t=cn(e.snapshotDir,`heapSnapshot`,o);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),dn(e.log,`artifact rotation`,()=>{for(let{artifacts:t}of fn(e.listArtifacts()).slice(n))for(let n of Object.values(t))dn(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0}function a(){let{rss:n,heapTotal:r}=e.memoryBytes();return sn(n,t)?`rss ${n} approaching limit ${t} (v8 heap ${r})`:null}function o(){let{rss:n}=e.memoryBytes(),r;try{r={kind:`ok`,value:fn(e.listArtifacts())}}catch(e){r={kind:`failed`,reason:e.message}}return{pid:e.pid,rss:n,rssLimit:t,postMortems:r}}function s(e=6e4){let t=setInterval(()=>{i()},e);return t.unref(),{disarm:()=>clearInterval(t)}}return{checkRss:i,describeNextRestart:a,serving:o,arm:s}}function dn(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function fn(e){let t=new Map;for(let n of e){let e=v.basename(n),r=ln(e);if(r===null)continue;let{prefix:i,suffix:a}=an[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(an);return[...t].sort(([e],[t])=>on(e,t)?-1:1).map(([e,t])=>({identity:e,artifacts:Object.fromEntries(n.flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}))}function pn(e,t,n={}){let r=qe();return{now:()=>Date.now(),pid:process.pid,snapshotDir:r,log:N,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},captureMemoryReport:()=>P(Jt(process.platform,process.pid)),writeMemoryReport:(e,t)=>s.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>ie.writeHeapSnapshot(e),listArtifacts:()=>{let e;try{e=s.readdirSync(r)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>ln(e)!==null).map(e=>v.join(r,e))},removeFile:e=>s.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function mn(e={}){if(kn()!==null)return;let n=e.spawn??An,r=En();if(r.kind===`contended`){let e=gn();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),hn(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),hn(n);return}try{hn(n)}finally{On()}}function hn(e){Cn()&&_n(e)}function gn(){try{let e=s.statSync(rt());return Date.now()-e.mtimeMs}catch{return null}}function _n(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
|
|
5
5
|
`)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function vn(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function yn(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function bn(e){try{let t=s.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function xn(e,n){try{s.mkdirSync(v.dirname(e),{recursive:!0}),s.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function Sn(){try{s.unlinkSync(at())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function Cn(){let e=it(),n=at(),r=bn(n),i=vn(F(e),yn(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`),wn(e),xn(n,Math.min(r+1,5)),!0)}function F(e){try{return Date.now()-s.statSync(e).mtimeMs}catch{return null}}function wn(e){try{s.mkdirSync(v.dirname(e),{recursive:!0}),s.writeFileSync(e,`${t.pid} ${Date.now()}\n`,{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.cooldown: ${e.message}\n`)}}let Tn=null;function En(){let e=rt();for(let n=0;n<2;n++){try{let n=s.openSync(e,`wx`,384);try{s.writeSync(n,JSON.stringify({pid:t.pid,ts:Date.now()}))}catch{}return Tn={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(!Dn(e))return{kind:`contended`};try{s.unlinkSync(e)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function Dn(e){try{let t=s.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function On(){if(!Tn)return;let{fd:e,path:t}=Tn;Tn=null;try{s.closeSync(e)}catch{}try{s.unlinkSync(t)}catch{}}function kn(){try{return s.mkdirSync(qe(),{recursive:!0}),null}catch(e){return`mkdir ${qe()}: ${e.message}`}}function An(){let e=t.execPath,n=t.argv[1];return n?ze({bin:e,args:[`--max-old-space-size=${en(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const jn=`cc-candybar`,Mn=`dispatch`,Nn=`set-state`,Pn=`step-state`,Fn=`copy`,In=`open-vscode`,Ln=`toolbar-toggle`,Rn=`show-config-error`,zn=`show-config-warning`,Bn=`set-config`,Vn=`step-config`,Hn=`save`,Un=`save-preset`,Wn=`save-theme-default`,Gn=`delete-preset`,Kn=`reset-config`,qn=`apply-layout-op`,Jn=`undo`,Yn=`redo`,Xn=`back`,Zn=`rewind`,Qn=`apply-update`,$n=`doctor-run`,er=`doctor-fix`,tr=`doctor-mark`,nr=`doctor-probe`,rr=`ceiling`,ir=`slash`;function ar(e){return e.map(encodeURIComponent).join(`/`)}function or(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function sr(e){return`${jn}://${Mn}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${ar(e.args)}`)}`).join(`&`)}`}function cr(e){return new r(e).getAll(`e`).map(fr)}const lr=new Set([Nn,Kn]);function ur(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&dr(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function dr(e,t){if(e.verb!==t.verb||!lr.has(e.verb))return;let[n,r]=[fr(e.value),fr(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function fr(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const pr=`closed`,mr=`🍫`;function hr(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 gr(e,t,n,r){let i=hr(e,t.length,n);if(i!==void 0)throw Error(i);return t.length===1?t[0]:t[r]}function _r(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function vr(e,t,n,r,i){return{kind:`segment`,name:e,opens:{ref:t,body:n,placement:r},...i!==void 0&&{when:i}}}function yr(e,...t){return`{{ and ${[e,...t].map(br).join(` `)} }}`}function br(e){return`(eq .${e.variable} "${_r(e.member)}")`}function xr(e,t,n){return`{{ ${Sr(e,Cr(t),Cr(n))} }}`}function Sr(e,t,n){return`action "${e}" ${t} ${n}`}function Cr(e){return`"${_r(e)}"`}function wr(e,t){return{kind:`state`,key:e,default:t}}function Tr(e,t){return{set:e,cycle:[pr,t]}}const Er=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Dr(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Or(e){return Er.test(e)?e:Dr(e)}var kr=we(((e,t)=>{t.exports.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,t.exports.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,t.exports.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/})),Ar=we(((e,t)=>{let n=kr();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)}}})),jr=we(((e,t)=>{let n=Ar(),r,i,a,o,s,c,l,u,d;t.exports=function(e,t){r=String(e),i=`start`,a=[],o=0,s=1,c=0,l=void 0,u=void 0,d=void 0;do l=v(),ne[i]();while(l.type!==`eof`);return typeof t==`function`?f({"":d},``,t):d};function f(e,t,n){let r=e[t];if(typeof r==`object`&&r)if(Array.isArray(r))for(let e=0;e<r.length;e++){let t=String(e),i=f(r,t,n);i===void 0?delete r[t]:Object.defineProperty(r,t,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let e in r){let t=f(r,e,n);t===void 0?delete r[e]:Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}return n.call(e,t,r)}let p,m,h,g,_;function v(){for(p=`default`,m=``,h=!1,g=1;;){_=y();let e=x[p]();if(e)return e}}function y(){if(r[o])return String.fromCodePoint(r.codePointAt(o))}function b(){let e=y();return e===`
|
|
@@ -30,7 +30,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
|
|
|
30
30
|
`}function Qr(e,t,n){return e.split(`
|
|
31
31
|
`).join(`${n}${t}`)}function $r(e,t,n){let[r,...i]=e,a=i.length===0?t:`{\n ${Qr($r(i,t,n),` `,`
|
|
32
32
|
`)}${n.trailingComma}\n}`;return`${n.key(r)}: ${a}`}function ei(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}function ti(e,t){return e.lastIndexOf(`
|
|
33
|
-
`,t-1)+1}function ni(e){return/^[ \t]*$/.test(e)}function ri(e,t){let n=ti(e,t);return/^[ \t]*/.exec(e.slice(n))[0]}function ii(e,t){return ni(e.slice(ti(e,t),t))}const ai=/(?:\/\/[^\n]*?)?(\r\n|\n|$)/y;function I(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;let r=e[n]===`,`?n+1:-1;for(r!==-1&&(n=r);n<e.length&&(e[n]===` `||e[n]===` `);)n++;ai.lastIndex=n;let i=ai.exec(e);if(i===null)return{commaEnd:r,line:null};let a=n+i[0].length;return{commaEnd:r,line:{at:a-i[1].length,next:a}}}function oi(e,t){let{commaEnd:n,line:r}=I(e,t.end);if(ii(e,t.start)&&r!==null)return ei(e,ti(e,t.start),r.next,``);if(n!==-1){let r=n;for(;r<e.length&&e[r]===` `;)r++;return ei(e,t.start,r,``)}let i=t.start;for(;i>0&&(e[i-1]===` `||e[i-1]===` `);)i--;return e[i-1]===`,`?ei(e,i-1,t.end,``):ei(e,t.start,t.end,``)}function si(e,t,n,r,i){let a=n.commaEnd!==-1,o=a?e:ei(e,t.end,t.end,`,`),s=n.line.at+ +!a,c=Zr(e);return ei(o,s,s,`${c}${i}${Qr(r,i,c)}${a?`,`:``}`)}function ci(e,t,n,r){let i=t.kind===`object`?t.entries:t.elements,a=i[i.length-1],o=ri(e,t.span.start);if(a===void 0){let i=o+` `,a=Zr(e);return ei(e,t.span.start+1,t.span.end-1,`${a}${i}${Qr(n,i,a)}${r.trailingComma}${a}${o}`)}let{commaEnd:s,line:c}=I(e,a.span.end);if(ii(e,a.span.start)&&c!==null){let t=e.slice(ti(e,a.span.start),a.span.start);return si(e,a.span,{commaEnd:s,line:c},n,t)}let l=s===-1?a.span.end:s;return ei(e,l,l,`${s===-1?`, `:` `}${n}${s===-1?``:`,`}`)}function li(e,t,n,r){if(t.length===0)throw new Pr(`setValue needs a non-empty path`,0);if(/^\s*$/.test(e)){let i=Zr(e);return`{${i} ${Qr($r(t,n,r),` `,i)}${r.trailingComma}${i}}${i}`}return ui(e,Br(e),t,n,r)}function ui(e,t,n,r,i){let a=t;for(let t=0;t<n.length;t++){if(a.kind!==`object`)throw new Pr(`cannot set ${n.join(`.`)}: ${n.slice(0,t).join(`.`)||`the document`} is not an object`,a.span.start);let o=Vr(a,n[t]);if(o===void 0)return ci(e,a,$r(n.slice(t),r,i),i);if(t===n.length-1){let t=ri(e,o.keySpan.start);return ei(e,o.value.span.start,o.value.span.end,Qr(r,t,Zr(e)))}a=o.value}throw new Pr(`unreachable: path exhausted`,0)}function di(e,t,n=0){if(t.length===0)throw new Pr(`deleteValue needs a non-empty path`,0);if(/^\s*$/.test(e))return e;let r=t.slice(0,-1),i=Hr(Br(e),r),a=i===void 0?void 0:Vr(i,t[t.length-1]);if(a===void 0||i?.kind!==`object`)return e;let o=oi(e,a.span);return r.length>n&&i.entries.length===1?di(o,r,n):o}const fi=[`h`,`v`,`children`];function pi(e){if(e.kind===`string`)return e.value;if(e.kind!==`object`)return;let t=Vr(e,`seg`)?.value,n=Vr(e,`kind`)?.value,r=Vr(e,`name`)?.value,i=t?.kind===`string`?t.value:n?.kind===`string`&&n.value===`segment`&&r?.kind===`string`?r.value:void 0;if(i===void 0)return;let a=Vr(e,`id`)?.value;return a?.kind===`string`?a.value:i}function mi(e){return e.kind===`object`?fi.map(t=>Vr(e,t)?.value).filter(e=>e?.kind===`array`):[]}function hi(e){let t=Vr(e,`rows`)?.value;return t?.kind===`object`?t.entries:null}function gi(e){if(e.kind!==`object`)return!0;let t=hi(e);return t===null||t.length>0||e.entries.some(e=>e.key!==`rows`)}function*_i(e,t){yield{node:e,bareAt:t};for(let t of mi(e))for(let e of t.elements)yield*_i(e,null);for(let n of hi(e)??[])yield*_i(n.value,t===null?null:[...t,`rows`,n.key])}function vi(e,t){for(let{node:n}of _i(e,null))if(pi(n)===t)return!0;return!1}function yi(e,t,n){let r=Hr(Br(e),t);if(r===void 0)return null;for(let{node:i,bareAt:a}of _i(r,t))if(pi(i)===n)return a===null?{text:e,ref:i}:yi(li(e,a,`{ h: [${Ur(e,i)}] }`,Jr),t,n);return null}function bi(e,t,n){let r=yi(e,t,n);return r===null?null:oi(r.text,r.ref.span)}function xi(e,t,n,r,i){let a=yi(e,t,r);if(a===null)return null;let{text:o,ref:s}=a,c=n.id===void 0?JSON.stringify(n.seg):`{ seg: ${JSON.stringify(n.seg)}, id: ${JSON.stringify(n.id)} }`,{commaEnd:l,line:u}=I(o,s.span.end);if(ii(o,s.span.start)&&u!==null){let e=o.slice(ti(o,s.span.start),s.span.start);return i===`after`?si(o,s.span,{commaEnd:l,line:u},c,e):ei(o,s.span.start,s.span.start,`${c},${Zr(o)}${e}`)}let d=Ur(o,s),f=i===`before`?`${c}, ${d}`:`${d}, ${c}`;return ei(o,s.span.start,s.span.end,f)}function Si(e,t,n,r,i){let a=yi(e,t,n);if(a===null)return null;let{text:o,ref:s}=a,c=`{ ${qr(r)}: ${i} }`;return s.kind===`string`?ei(o,s.span.start,s.span.end,`{ seg: ${JSON.stringify(s.value)}, settings: ${c} }`):Vr(s,`settings`)===void 0?ui(o,s,[`settings`],c,Jr):ui(o,s,[`settings`,r],i,Jr)}function L(e){return{kind:`ok`,value:e}}const R={kind:`absent`};function z(e){return{kind:`failed`,reason:e}}function Ci(e,t){return e?.kind===`ok`?e.value:t}function wi(e){if(!e)return``;try{return Ti(g(e))}catch{return``}}function Ti(e){return`${e.mtimeMs}:${e.size}`}const Ei=new class{slots;head=null;tail=null;constructor(e){this.slots=e}async run(e){await this.acquire();try{return await e()}finally{this.release()}}async acquire(){if(this.slots>0){this.slots--;return}await new Promise(e=>{let t={wake:e,next:null};this.tail?this.tail.next=t:this.head=t,this.tail=t})}release(){let e=this.head;if(!e){this.slots++;return}this.head=e.next,this.head||(this.tail=null),e.wake()}}(8);function Di(e){return((...t)=>Ei.run(()=>e(...t)))}const Oi=Di(oe),ki=Di(ae),Ai=Di(se);async function ji(e,t){return Ei.run(async()=>{let n=null;try{n=await O(e,`r`);let r=await n.stat(),{size:i,ino:a}=r,o=Ti(r),s=t!==void 0&&(a!==t.ino||i<t.offset),c=s||t===void 0?0:t.offset;if(c>=i)return L({buf:Buffer.alloc(0),start:c,size:i,stamp:o,ino:a,reset:s});let l=Buffer.alloc(i-c),u=0;for(;u<l.length;){let{bytesRead:e}=await n.read(l,u,l.length-u,c+u);if(e===0)break;u+=e}return L({buf:u===l.length?l:l.subarray(0,u),start:c,size:i,stamp:o,ino:a,reset:s})}catch(t){return t.code===`ENOENT`?R:z(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function Mi(e,t){return Ei.run(async()=>{let n=null;try{n=await O(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let{bytesRead:e}=await n.read(a,o,a.length-o,i+o);if(e===0)break;o+=e}return L({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?R:z(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function Ni(e,t){let n;try{n=p(e,l.O_RDONLY|l.O_NONBLOCK)}catch(e){let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`?R:z(e instanceof Error?e.message:String(e))}try{let e=f(n);if(!e.isFile())return z(`not a regular file`);let{size:r}=e,i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let e=m(n,a,o,a.length-o,i+o);if(e===0)break;o+=e}return L({buf:a.subarray(0,o),fromStart:i===0})}catch(e){return z(e instanceof Error?e.message:String(e))}finally{try{c(n)}catch(e){k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)}}}function Pi(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:v.resolve(t,n)}function Fi(e){return e??v.join(w.homedir(),`.claude`)}function Ii(e){return v.join(e,`settings.json`)}function Li(e){return v.join(e,`plugins`,`installed_plugins.json`)}function Ri(e){let t=Ni(e,2**53-1);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`cannot read ${e}: ${t.reason}`);case`ok`:return t.value.buf.toString(`utf8`)}}const zi=(e,t)=>Error(`cannot read ${e}: ${qi(t)}`,{cause:t});function Bi(e){return Ri(e)??``}function Vi(e){return Hi(e,Bi(e))}function Hi(e,t){let n;try{if(/^\s*$/.test(t))return{};n=Yr.parse(t)}catch(t){throw zi(e,t)}if(!Ki(n))throw Error(`cannot read ${e}: not a JSON object`);return n}function Ui(e){switch(e){case`darwin`:return`/Library/Application Support/ClaudeCode`;case`win32`:return`C:\\Program Files\\ClaudeCode`;default:return`/etc/claude-code`}}function Wi(e){let t=v.join(e.managedDir,`managed-settings.d`);return[...Gi(t).reverse().map(e=>({scope:`managed`,path:v.join(t,e)})),{scope:`managed`,path:v.join(e.managedDir,`managed-settings.json`)},{scope:`project-local`,path:v.join(e.projectDir,`.claude`,`settings.local.json`)},{scope:`project`,path:v.join(e.projectDir,`.claude`,`settings.json`)},{scope:`user`,path:e.userFile}].flatMap(e=>{let t=Ri(e.path);if(t===null)return[];let n=Hi(e.path,t),{env:r={}}=n;if(!Ki(r))throw Error(`cannot read ${e.path}: \`env\` is not an object`);return[{...e,settings:n,env:r}]})}function Gi(e){try{return s.readdirSync(e).filter(e=>!e.startsWith(`.`)&&e.endsWith(`.json`)).sort()}catch(t){if(t.code===`ENOENT`)return[];throw zi(e,t)}}const Ki=e=>typeof e==`object`&&!!e&&!Array.isArray(e),qi=e=>e instanceof Error?e.message:String(e),Ji=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Yi(e){let t=Ji.exec(e);return t?{kind:`ok`,value:[Number(t[1]),Number(t[2]),Number(t[3])]}:{kind:`failed`,reason:`"${e}" is not a release version (expected MAJOR.MINOR.PATCH)`}}function Xi(e){return e.join(`.`)}function Zi([e,t,n],[r,i,a]){return e-r||t-i||n-a}const Qi=`@promptctl/cc-candybar`;async function $i(e,t,n){let r=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(r,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return z(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?Yi(n.latest):R}catch(e){return z(e instanceof Error?e.message:String(e))}}function ea(e,t){let n=Yi(e);if(n.kind===`failed`)return{kind:`unchecked`,installed:e,reason:n.reason};switch(t.kind){case`failed`:return{kind:`unchecked`,installed:e,reason:t.reason};case`absent`:return{kind:`unchecked`,installed:e,reason:"the registry lists no `latest` dist-tag"};case`ok`:{let e=Zi(n.value,t.value);return e<0?{kind:`stale`,installed:n.value,latest:t.value}:e>0?{kind:`ahead`,installed:n.value,latest:t.value}:{kind:`current`,installed:n.value}}}}function ta(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${Xi(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${Xi(t.installed)} is newer than the registry's latest release (${Xi(t.latest)}): an unpublished build.\n`};case`stale`:{let n=Xi(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${Xi(t.installed)} was staged, but the latest release is ${n}.\n pnpm's release-age gate (minimumReleaseAge) and its dlx cache can both\n resolve \`@latest\` to an older release without saying so.\n To install ${n} now, name it explicitly:\n pnpm dlx ${e}@${n} install\n`}}case`unchecked`:return{stream:`stderr`,text:`⚠ Could not check for a cc-candybar release newer than ${t.installed} (${t.reason}); the registry check was skipped.\n`}}}const na={"darwin-arm64":`@promptctl/cc-candybar-darwin-arm64`,"darwin-x64":`@promptctl/cc-candybar-darwin-x64`,"linux-x64":`@promptctl/cc-candybar-linux-x64`,"linux-arm64":`@promptctl/cc-candybar-linux-arm64`};function ra(e,t){return`${e}-${t}`in na}const ia=`CCCandybarURLHandler`,aa=[];function oa(e,t){return[e,...t].map(Or).join(` `)}function sa(){return v.join(w.homedir(),`Applications`,`${ia}.app`)}function ca(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function la(){if(process.platform===`darwin`)return v.join(w.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??v.join(w.homedir(),`.local`,`share`);return v.join(e,`cc-candybar`)}function ua(){return v.join(la(),`bin`,`cc-candybar`)}function da(){return v.join(la(),`dist`,`index.mjs`)}function fa(e,t){return[`on open location L`,`\tdo shell script "'${e.replace(/"/g,`\\"`)}' '${t.replace(/"/g,`\\"`)}' url-handle " & quoted form of L`,`end open location`].join(`
|
|
33
|
+
`,t-1)+1}function ni(e){return/^[ \t]*$/.test(e)}function ri(e,t){let n=ti(e,t);return/^[ \t]*/.exec(e.slice(n))[0]}function ii(e,t){return ni(e.slice(ti(e,t),t))}const ai=/(?:\/\/[^\n]*?)?(\r\n|\n|$)/y;function I(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;let r=e[n]===`,`?n+1:-1;for(r!==-1&&(n=r);n<e.length&&(e[n]===` `||e[n]===` `);)n++;ai.lastIndex=n;let i=ai.exec(e);if(i===null)return{commaEnd:r,line:null};let a=n+i[0].length;return{commaEnd:r,line:{at:a-i[1].length,next:a}}}function oi(e,t){let{commaEnd:n,line:r}=I(e,t.end);if(ii(e,t.start)&&r!==null)return ei(e,ti(e,t.start),r.next,``);if(n!==-1){let r=n;for(;r<e.length&&e[r]===` `;)r++;return ei(e,t.start,r,``)}let i=t.start;for(;i>0&&(e[i-1]===` `||e[i-1]===` `);)i--;return e[i-1]===`,`?ei(e,i-1,t.end,``):ei(e,t.start,t.end,``)}function si(e,t,n,r,i){let a=n.commaEnd!==-1,o=a?e:ei(e,t.end,t.end,`,`),s=n.line.at+ +!a,c=Zr(e);return ei(o,s,s,`${c}${i}${Qr(r,i,c)}${a?`,`:``}`)}function ci(e,t,n,r){let i=t.kind===`object`?t.entries:t.elements,a=i[i.length-1],o=ri(e,t.span.start);if(a===void 0){let i=o+` `,a=Zr(e);return ei(e,t.span.start+1,t.span.end-1,`${a}${i}${Qr(n,i,a)}${r.trailingComma}${a}${o}`)}let{commaEnd:s,line:c}=I(e,a.span.end);if(ii(e,a.span.start)&&c!==null){let t=e.slice(ti(e,a.span.start),a.span.start);return si(e,a.span,{commaEnd:s,line:c},n,t)}let l=s===-1?a.span.end:s;return ei(e,l,l,`${s===-1?`, `:` `}${n}${s===-1?``:`,`}`)}function li(e,t,n,r){if(t.length===0)throw new Pr(`setValue needs a non-empty path`,0);if(/^\s*$/.test(e)){let i=Zr(e);return`{${i} ${Qr($r(t,n,r),` `,i)}${r.trailingComma}${i}}${i}`}return ui(e,Br(e),t,n,r)}function ui(e,t,n,r,i){let a=t;for(let t=0;t<n.length;t++){if(a.kind!==`object`)throw new Pr(`cannot set ${n.join(`.`)}: ${n.slice(0,t).join(`.`)||`the document`} is not an object`,a.span.start);let o=Vr(a,n[t]);if(o===void 0)return ci(e,a,$r(n.slice(t),r,i),i);if(t===n.length-1){let t=ri(e,o.keySpan.start);return ei(e,o.value.span.start,o.value.span.end,Qr(r,t,Zr(e)))}a=o.value}throw new Pr(`unreachable: path exhausted`,0)}function di(e,t,n=0){if(t.length===0)throw new Pr(`deleteValue needs a non-empty path`,0);if(/^\s*$/.test(e))return e;let r=t.slice(0,-1),i=Hr(Br(e),r),a=i===void 0?void 0:Vr(i,t[t.length-1]);if(a===void 0||i?.kind!==`object`)return e;let o=oi(e,a.span);return r.length>n&&i.entries.length===1?di(o,r,n):o}const fi=[`h`,`v`,`children`];function pi(e){if(e.kind===`string`)return e.value;if(e.kind!==`object`)return;let t=Vr(e,`seg`)?.value,n=Vr(e,`kind`)?.value,r=Vr(e,`name`)?.value,i=t?.kind===`string`?t.value:n?.kind===`string`&&n.value===`segment`&&r?.kind===`string`?r.value:void 0;if(i===void 0)return;let a=Vr(e,`id`)?.value;return a?.kind===`string`?a.value:i}function mi(e){return e.kind===`object`?fi.map(t=>Vr(e,t)?.value).filter(e=>e?.kind===`array`):[]}function hi(e){let t=Vr(e,`rows`)?.value;return t?.kind===`object`?t.entries:null}function gi(e){if(e.kind!==`object`)return!0;let t=hi(e);return t===null||t.length>0||e.entries.some(e=>e.key!==`rows`)}function*_i(e,t){yield{node:e,bareAt:t};for(let t of mi(e))for(let e of t.elements)yield*_i(e,null);for(let n of hi(e)??[])yield*_i(n.value,t===null?null:[...t,`rows`,n.key])}function vi(e,t){for(let{node:n}of _i(e,null))if(pi(n)===t)return!0;return!1}function yi(e,t,n){let r=Hr(Br(e),t);if(r===void 0)return null;for(let{node:i,bareAt:a}of _i(r,t))if(pi(i)===n)return a===null?{text:e,ref:i}:yi(li(e,a,`{ h: [${Ur(e,i)}] }`,Jr),t,n);return null}function bi(e,t,n){let r=yi(e,t,n);return r===null?null:oi(r.text,r.ref.span)}function xi(e,t,n,r,i){let a=yi(e,t,r);if(a===null)return null;let{text:o,ref:s}=a,c=n.id===void 0?JSON.stringify(n.seg):`{ seg: ${JSON.stringify(n.seg)}, id: ${JSON.stringify(n.id)} }`,{commaEnd:l,line:u}=I(o,s.span.end);if(ii(o,s.span.start)&&u!==null){let e=o.slice(ti(o,s.span.start),s.span.start);return i===`after`?si(o,s.span,{commaEnd:l,line:u},c,e):ei(o,s.span.start,s.span.start,`${c},${Zr(o)}${e}`)}let d=Ur(o,s),f=i===`before`?`${c}, ${d}`:`${d}, ${c}`;return ei(o,s.span.start,s.span.end,f)}function Si(e,t,n,r,i){let a=yi(e,t,n);if(a===null)return null;let{text:o,ref:s}=a,c=`{ ${qr(r)}: ${i} }`;return s.kind===`string`?ei(o,s.span.start,s.span.end,`{ seg: ${JSON.stringify(s.value)}, settings: ${c} }`):Vr(s,`settings`)===void 0?ui(o,s,[`settings`],c,Jr):ui(o,s,[`settings`,r],i,Jr)}function L(e){return{kind:`ok`,value:e}}const R={kind:`absent`};function z(e){return{kind:`failed`,reason:e}}function Ci(e,t){return e?.kind===`ok`?e.value:t}function wi(e){if(!e)return``;try{return Ti(g(e))}catch{return``}}function Ti(e){return`${e.mtimeMs}:${e.size}`}const Ei=new class{slots;head=null;tail=null;constructor(e){this.slots=e}async run(e){await this.acquire();try{return await e()}finally{this.release()}}async acquire(){if(this.slots>0){this.slots--;return}await new Promise(e=>{let t={wake:e,next:null};this.tail?this.tail.next=t:this.head=t,this.tail=t})}release(){let e=this.head;if(!e){this.slots++;return}this.head=e.next,this.head||(this.tail=null),e.wake()}}(8);function Di(e){return((...t)=>Ei.run(()=>e(...t)))}const Oi=Di(oe),ki=Di(ae),Ai=Di(se);async function ji(e,t){return Ei.run(async()=>{let n=null;try{n=await O(e,`r`);let r=await n.stat(),{size:i,ino:a}=r,o=Ti(r),s=t!==void 0&&(a!==t.ino||i<t.offset),c=s||t===void 0?0:t.offset;if(c>=i)return L({buf:Buffer.alloc(0),start:c,size:i,stamp:o,ino:a,reset:s});let l=Buffer.alloc(i-c),u=0;for(;u<l.length;){let{bytesRead:e}=await n.read(l,u,l.length-u,c+u);if(e===0)break;u+=e}return L({buf:u===l.length?l:l.subarray(0,u),start:c,size:i,stamp:o,ino:a,reset:s})}catch(t){return t.code===`ENOENT`?R:z(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function Mi(e,t){return Ei.run(async()=>{let n=null;try{n=await O(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let{bytesRead:e}=await n.read(a,o,a.length-o,i+o);if(e===0)break;o+=e}return L({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?R:z(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function Ni(e,t){let n;try{n=p(e,l.O_RDONLY|l.O_NONBLOCK)}catch(e){let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`?R:z(e instanceof Error?e.message:String(e))}try{let e=f(n,{bigint:!0});if(!e.isFile())return z(`not a regular file`);let r=Number(e.size),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let e=m(n,a,o,a.length-o,i+o);if(e===0)break;o+=e}return L({buf:a.subarray(0,o),fromStart:i===0,file:`${e.dev}:${e.ino}`})}catch(e){return z(e instanceof Error?e.message:String(e))}finally{try{c(n)}catch(e){k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)}}}function Pi(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:v.resolve(t,n)}function Fi(e){return e??v.join(w.homedir(),`.claude`)}function Ii(e){return v.join(e,`settings.json`)}function Li(e){return v.join(e,`plugins`,`installed_plugins.json`)}function Ri(e){let t=Ni(e,2**53-1);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`cannot read ${e}: ${t.reason}`);case`ok`:return{text:t.value.buf.toString(`utf8`),file:t.value.file}}}const zi=(e,t)=>Error(`cannot read ${e}: ${qi(t)}`,{cause:t});function Bi(e){return Ri(e)?.text??``}function Vi(e){return Hi(e,Bi(e))}function Hi(e,t){let n;try{if(/^\s*$/.test(t))return{};n=Yr.parse(t)}catch(t){throw zi(e,t)}if(!Ki(n))throw Error(`cannot read ${e}: not a JSON object`);return n}function Ui(e){switch(e){case`darwin`:return`/Library/Application Support/ClaudeCode`;case`win32`:return`C:\\Program Files\\ClaudeCode`;default:return`/etc/claude-code`}}function Wi(e){let t=v.join(e.managedDir,`managed-settings.d`),n=[...Gi(t).reverse().map(e=>({scope:`managed`,path:v.join(t,e)})),{scope:`managed`,path:v.join(e.managedDir,`managed-settings.json`)},{scope:`project-local`,path:v.join(e.projectDir,`.claude`,`settings.local.json`)},{scope:`project`,path:v.join(e.projectDir,`.claude`,`settings.json`)},{scope:`user`,path:e.userFile}].flatMap(e=>{let t=Ri(e.path);if(t===null)return[];let n=Hi(e.path,t.text),{env:r={}}=n;if(!Ki(r))throw Error(`cannot read ${e.path}: \`env\` is not an object`);return[{source:{...e,settings:n,env:r},file:t.file}]}),r=n.find(e=>e.source.scope===`user`);return n.filter(e=>e.source.scope!==`project`||e.file!==r?.file).map(e=>e.source)}function Gi(e){try{return s.readdirSync(e).filter(e=>!e.startsWith(`.`)&&e.endsWith(`.json`)).sort()}catch(t){if(t.code===`ENOENT`)return[];throw zi(e,t)}}const Ki=e=>typeof e==`object`&&!!e&&!Array.isArray(e),qi=e=>e instanceof Error?e.message:String(e),Ji=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Yi(e){let t=Ji.exec(e);return t?{kind:`ok`,value:[Number(t[1]),Number(t[2]),Number(t[3])]}:{kind:`failed`,reason:`"${e}" is not a release version (expected MAJOR.MINOR.PATCH)`}}function Xi(e){return e.join(`.`)}function Zi([e,t,n],[r,i,a]){return e-r||t-i||n-a}const Qi=`@promptctl/cc-candybar`;async function $i(e,t,n){let r=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(r,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return z(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?Yi(n.latest):R}catch(e){return z(e instanceof Error?e.message:String(e))}}function ea(e,t){let n=Yi(e);if(n.kind===`failed`)return{kind:`unchecked`,installed:e,reason:n.reason};switch(t.kind){case`failed`:return{kind:`unchecked`,installed:e,reason:t.reason};case`absent`:return{kind:`unchecked`,installed:e,reason:"the registry lists no `latest` dist-tag"};case`ok`:{let e=Zi(n.value,t.value);return e<0?{kind:`stale`,installed:n.value,latest:t.value}:e>0?{kind:`ahead`,installed:n.value,latest:t.value}:{kind:`current`,installed:n.value}}}}function ta(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${Xi(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${Xi(t.installed)} is newer than the registry's latest release (${Xi(t.latest)}): an unpublished build.\n`};case`stale`:{let n=Xi(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${Xi(t.installed)} was staged, but the latest release is ${n}.\n pnpm's release-age gate (minimumReleaseAge) and its dlx cache can both\n resolve \`@latest\` to an older release without saying so.\n To install ${n} now, name it explicitly:\n pnpm dlx ${e}@${n} install\n`}}case`unchecked`:return{stream:`stderr`,text:`⚠ Could not check for a cc-candybar release newer than ${t.installed} (${t.reason}); the registry check was skipped.\n`}}}const na={"darwin-arm64":`@promptctl/cc-candybar-darwin-arm64`,"darwin-x64":`@promptctl/cc-candybar-darwin-x64`,"linux-x64":`@promptctl/cc-candybar-linux-x64`,"linux-arm64":`@promptctl/cc-candybar-linux-arm64`};function ra(e,t){return`${e}-${t}`in na}const ia=`CCCandybarURLHandler`,aa=[];function oa(e,t){return[e,...t].map(Or).join(` `)}function sa(){return v.join(w.homedir(),`Applications`,`${ia}.app`)}function ca(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function la(){if(process.platform===`darwin`)return v.join(w.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??v.join(w.homedir(),`.local`,`share`);return v.join(e,`cc-candybar`)}function ua(){return v.join(la(),`bin`,`cc-candybar`)}function da(){return v.join(la(),`dist`,`index.mjs`)}function fa(e,t){return[`on open location L`,`\tdo shell script "'${e.replace(/"/g,`\\"`)}' '${t.replace(/"/g,`\\"`)}' url-handle " & quoted form of L`,`end open location`].join(`
|
|
34
34
|
`)}function pa(e){let t=/do shell script "'([^']+)' '([^']+)' url-handle "/.exec(e);if(t===null)return null;let n=e=>e.replace(/\\"/g,`"`);return{node:n(t[1]),script:n(t[2])}}function ma(e){return v.join(e,`Contents`,`Resources`,`Scripts`,`main.scpt`)}function ha(t){let n=na[`${process.platform}-${process.arch}`];if(n){let r=e(t);try{return{kind:`native`,sourcePath:r.resolve(`${n}/bin/cc-candybar`)}}catch{}}return{kind:`node-shim`,sourcePath:v.resolve(v.dirname(t),`..`,`bin`,`cc-candybar`)}}function ga(e,t){v.resolve(e)!==v.resolve(t)&&s.copyFileSync(e,t)}function _a(e){let t=s.openSync(e,`r`);try{let n=Buffer.alloc(2),r=s.readSync(t,n,0,2,0);if(r<2)throw Error(`install: staged render entry at ${e} is truncated (${r} byte(s)). Re-run: pnpm dlx ${Qi}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{s.closeSync(t)}}function va(e){if(!s.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let t=ha(e);if(!s.existsSync(t.sourcePath))throw Error(`install: render entry not found at ${t.sourcePath}. Reinstall the package.`);s.mkdirSync(v.dirname(da()),{recursive:!0}),s.mkdirSync(v.dirname(ua()),{recursive:!0}),ga(e,da()),ga(t.sourcePath,ua()),s.chmodSync(ua(),493),s.rmSync(v.join(la(),`url-handler.mjs`),{force:!0});let n=_a(ua());return process.stdout.write(`Staged cc-candybar v${Lt} runtime at ${la()}\n`+(n===`native`?` render entry: native binary (${process.platform}-${process.arch})\n`:` render entry: node shim (no native binary for ${process.platform}-${process.arch}; renders are correct but pay node startup)\n`)),{binPath:ua(),distPath:da(),entryKind:n}}function ya(){return[{key:`CFBundleIdentifier`,xml:`<string>com.cccandybar.url-handler</string>`},{key:`CFBundleURLTypes`,xml:[`<array>`,` <dict>`,` <key>CFBundleURLName</key>`,` <string>Claude Powerline Click Action</string>`,` <key>CFBundleURLSchemes</key>`,` <array>`,` <string>${jn}</string>`,` </array>`,` </dict>`,`</array>`].join(`
|
|
35
35
|
`)}]}function ba(e){let t=sa();s.mkdirSync(v.dirname(t),{recursive:!0}),s.existsSync(t)&&s.rmSync(t,{recursive:!0,force:!0}),process.stdout.write(`Building ${t}\n`);let n=Re({bin:`/usr/bin/osacompile`,args:[`-o`,t,`-e`,fa(process.execPath,e)],category:`install.osacompile`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`osacompile failed (${n.reason})`);let r=v.join(t,`Contents`,`Info.plist`);for(let{key:e}of ya())Re({bin:`/usr/bin/plutil`,args:[`-remove`,e,r],category:`install.plutil`});for(let{key:e,xml:t}of ya()){let n=Re({bin:`/usr/bin/plutil`,args:[`-insert`,e,`-xml`,t,r],category:`install.plutil`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`plutil -insert ${e} failed (${n.reason})`)}process.stdout.write(`Registering ${jn}:// with Launch Services\n`);let i=Re({bin:`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister`,args:[`-f`,t],category:`install.lsregister`});if(!i.ok)throw process.stderr.write(i.stderr),Error(`lsregister failed (${i.reason})`);process.stdout.write(`✓ ${ia}.app installed and registered.\n`),process.stdout.write(` Test: open '${jn}://hello-world' && pbpaste\n`)}function xa(e){ca(),ba(va(e).distPath)}function Sa(e,t=jn){let n=`${t}://`;if(!e.startsWith(n))throw Error(`expected ${n} scheme, got: ${e}`);let r=e.slice(n.length),i=r.indexOf(`/`);return i===-1?{verb:Fn,value:r}:{verb:decodeURIComponent(r.slice(0,i)),value:r.slice(i+1)}}async function Ca(e){e||(process.stderr.write(`url-handle: missing URL argument.
|
|
36
36
|
`),process.exit(1));let t;try{t=Sa(e)}catch(e){process.stderr.write(`url-handle: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}let n=await Ut(t.verb,t.value);n.kind===`ok`&&process.exit(0),n.kind===`transient`&&(mn(),process.stderr.write(`url-handle: daemon unavailable (${n.cause}: ${n.message})\n`),process.exit(1)),process.stderr.write(wa(n)+`
|
|
@@ -54,7 +54,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
|
|
|
54
54
|
`))throw Error(`drawStripCells: rich-js strip output did not end its last line`);return{text:s.text.slice(0,-1),moves:s.moves}}function kg(e,t){return Og(e,t).text}function Ag(e){return Math.min(20,e??20)}const jg={heading:`ERROR`,glyph:`⚠`,colors:Zp},Mg={heading:`WARNING`,glyph:`⚠`,colors:Qp},Ng={heading:`UPDATE`,glyph:`⬆`,colors:Qp};function Pg(e,t){return{text:Gp(e),link:t}}function Fg(e,t,n){let[r,...i]=[Ig(e,jg,Rn),t,Ig(n,Mg,zn)].flat();return r===void 0?null:{channels:[r,...i]}}function Ig(e,t,n){let r=sr([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>Pg(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function Lg(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
|
|
55
55
|
`)}function Rg(e,t,n,r){if(t===null)return e;let i=zg(r),a=t.channels.flatMap(e=>Bg(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[Vg(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
|
|
56
56
|
`);return e?`${l}\n${e}`:l}function zg(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,colorCompatibility:e.colorCompatibility}}function Bg(e,t){let n=new U({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=wo(Math.max(2,t.width-1)),i=(e,t)=>new K(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>kg([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=>ko(e,r)).map(e=>i(e,t))})],t).split(`
|
|
57
|
-
`))}function Vg(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:o,failedConfigFile:s}=t,c=new U({bgcolor:i.bg,color:i.fg}),l=(e,t)=>new K(e,{style:t,end:``,overflow:`ignore`}),u=n>0?[l(`${n} more rows · `,c),o.kind===`file`?l(`open full text`,c.withLink(a(o.path).href)):l(`full text unavailable: ${Gp(o.reason)}`,c)]:[],d=s===null?[]:[l(`${u.length>0?` · `:``}open `,c),l(Gp(s),c.withLink(a(s).href))],f=[l(`↳ `,c),...u,...d.slice(0,-1)],p=f.reduce((e,t)=>e+t.cellLength,0),m=d.slice(-1).map(e=>e.truncate(Math.max(1,r.width-p),{mode:`middle`})),h=K.fromFragments([...f,...m]).truncate(r.width);return h.overflow=`ignore`,kg([h],r)}const Hg=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Ug(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function Wg(e,t,n=Hg){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=v.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Wg(e,r):[[v.relative(e,r).split(v.sep).join(`/`),Ug(r,i)]]})}function Gg(e){let t=ce.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Kg(e){return Gg(Wg(e,e))}const qg=[`Cargo.toml`,`Cargo.lock`,`src`];function Jg(e){return Gg(Wg(e,e,e=>qg.includes(e)))}const Yg=e=>e.slice(0,7);function Xg(e){let t=v.dirname(v.dirname(e));return s.existsSync(v.join(t,`src`))?t:null}function Zg(){let e=Qg();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:Lt,digest:e}}function Qg(){return`b2ae0313322c0192e1829a2f5d8a00e1187dfece13d0810acecbe88f94cc2008`}function $g(e){let t=JSON.parse(s.readFileSync(v.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${v.join(e,`package.json`)} has no version string`);return n}function e_(e,t){try{let n=Xg(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Kg(v.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:$g(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}var q=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const t_=new Map;function n_(e){let t=i_(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 r_(e,t){return e===`bar`?t:n_(e)}function i_(e){let t=t_.get(e);if(t!==void 0)return t;let n=Bc(e);return n===null?null:(t_.set(e,n),n)}function a_(e,t){return o_(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>Qc(e,t))}const o_=tm();function s_(e){let t=i_(e);return t===null?null:{kind:`decided`,name:e,value:t}}function c_(e,t,n){let r=s_(e);return r===null?(n(Ah(t,`palette`,`"${e}" names no installed theme${fh(e)}`)),u_()):r}function l_(e,t,n){return Sh(e,t,n,u_(),s_)}function u_(){return{kind:`decided`,name:ph,value:n_(ph)}}const d_=[`vertical`,`horizontal`],f_={vertical:`row`,horizontal:`cell`};function p_(e){return e.id??e.name}function m_(e){return[...__(e)].flatMap(e=>e.kind===`segment`?[p_(e)]:[])}function h_(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function g_(e,t){return e.opens===void 0?e:{...e,opens:{...e.opens,body:t(e.opens.body)}}}function*__(e){yield e;for(let t of x_(e))yield*__(t)}const v_=(e,t)=>`${e}.children[${t}]`,y_=e=>`${e}.opens.body`;function*b_(e,t){if(yield[e,t],e.kind===`container`)for(let[n,r]of e.children.entries())yield*b_(r,v_(t,n));else e.opens!==void 0&&(yield*b_(e.opens.body,y_(t)))}function x_(e){return e.kind===`container`?e.children:e.opens===void 0?[]:[e.opens.body]}const S_=[`shade`,`variation`,`style`];function C_(e){return e===void 0||`text`in e?`text`:`regex`in e?`regex`:`json`}const w_=[`ttl`,`watch_file`,`depends_on`,`key`,`never`];function T_(e){return e.kind===`file`||e.kind===`shell`}const E_=[`branch`,`sha`,`dirty`,`ahead`,`behind`,`stash`],D_=[`fail`,`ignore`];function O_(e){return e.missingData??`fail`}function*k_(e){for(let[t,n]of Object.entries(e.variables))n.kind===`state`&&(yield[t,n]);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))r.kind===`state`&&(yield[`${t}.${e}`,r])}const A_=`theme`,j_=`effect`,M_=[A_,j_];function N_(e){return{...e.settings,[A_]:{label:A_,domain:`theme`,default:e.palette??`bar`},[j_]:{label:j_,domain:Mh,default:`bar`}}}function P_(e){let t=e?.domain;return typeof t==`object`&&`min`in t?t:void 0}function F_(e,t){return Object.entries(e).flatMap(([n,r])=>{let i=P_(r)?.atLeast;if(i===void 0)return[];let a=t[n],o=t[i];return a>=o?[]:[{setting:n,message:`"${n}" (${a}) is below "${i}" (${o}) — ${r.label} must be at least ${e[i].label}`}]})}function I_(e,t){let{domain:n}=e;return n===`bool`?typeof t==`boolean`:n===`theme`?typeof t==`string`&&vh(t):`min`in n?typeof t==`number`&&Number.isInteger(t)&&t>=n.min&&t<=n.max:typeof t==`string`&&n.includes(t)}function L_(e){return String(e)}function R_(e,t){let{domain:n}=e;if(typeof n==`object`&&`min`in n)return eg(t,n)??void 0;let r=n===`bool`?t===`true`?!0:t===`false`?!1:t:t;return I_(e,r)?r:void 0}function z_(e,t,n,r){let i=e.settings?.[t]??n.default,a=e.drafts?.[t],o=a===void 0?null:r(a);return(o===null?void 0:R_(n,o))??i}function B_(e){let{domain:t}=e;return t===`bool`?`true or false`:t===`theme`?`"bar" (the bar's own theme) or an installed theme name`:`min`in t?`an integer from ${t.min} to ${t.max}`:`one of ${t.map(e=>JSON.stringify(e)).join(`, `)}`}const V_=[`left`,`center`,`right`],H_=[`right`,`left`,`middle`],U_=/^[A-Za-z_][A-Za-z0-9_]*$/;function W_(e){return`#${e+1}`}const G_={rows:{}};function K_(e){return`rows`in e}function q_(e){return Object.fromEntries(e.map((e,t)=>[W_(t),e]))}function J_(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:q_(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:q_([n])}}function Y_(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function X_(e){return K_(e)?Y_(e):e}function*Z_(e,t){if(!K_(e)){yield*b_(e,t);return}yield[Y_(e),t];for(let[n,r]of Object.entries(e.rows))yield*b_(r,`${t}.rows.${n}`)}function Q_(e,t){return K_(e)?{...t,...e,rows:{...t.rows,...e.rows}}:J_(e)}function $_(e){if(!K_(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const ev=`default`,tv={};function nv(e){return[...new Set([ev,...Object.keys(e)])]}function rv(e,t,n){return yh(void 0,e,t,ev,n)}function iv(e,t){let n={[ev]:tv,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${ev}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function av(e,t){let n=iv(e.presets,t).root??G_;return{node:Y_(Q_(n,e.root)),path:$_(n)?`presets.${t}.root`:`root`}}function ov(e,t){return{...e.globals,...iv(e.presets,t).globals}}const sv=new Map;function cv(e,t,n){sv.set(e,{permanent:!0,resolve:t,paletteOf:n})}cv(`themes`,()=>hh(),e=>n_(e));const lv=`placementThemes`;cv(lv,gh,(e,t)=>r_(e,t.palette)),cv(`endcaps`,()=>Ih),cv(`variations`,()=>Uh),cv(`shades`,()=>Kh),cv(`colorCompatibilities`,()=>Vh);function uv(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>a_(n.basePalette,e.styles[t])}],[`presets`,{members:nv(e.presets)}]])}function dv(e){return[...new Set([...sv.keys(),...e.keys()])]}function fv(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=sv.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(mv(e,t))}const pv=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function mv(e,t){let n=pv.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${dv(t).join(`, `)})`}const hv=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*gv(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 _v=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,vv=RegExp(`^(?:(\\$)(?:\\.(${_v}))?|\\.(${_v})?)(?=[\\s)]|$)`);function yv(e,t,n){let r=vv.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 bv=/^(\w+)\b\s*([\s\S]*)$/;function*xv(e,t){let n=[t];for(let r of gv(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=bv.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:yv(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(yv(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const Sv=/(?<![.$])\btemplate\s+$/;function*Cv(e,t,n){let r=0;for(let i of[...e.matchAll(hv)]){let a=i.index+i[0].length;Sv.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:yv(e.slice(a),t,n)}),r=a}}function*wv(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...xv(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...Cv(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 Tv=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${_v})`,`g`);function*Ev({code:e,dot:t,root:n}){let r=e.replace(hv,``);for(let e of[...r.matchAll(Tv)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function Dv(e,t){let n=new Map;for(let r of wv(e,t))for(let e of Ev(r))n.has(e)||n.set(e,r.via);return n}const Ov=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,kv={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*Av(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(hv)]){let o=e.slice(t,a.index),s=Ov.exec(o);if(s!==null)n=kv[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 jv(e,t){let n=new Map;for(let{code:r,via:i}of wv(e,t))for(let{name:e,site:t}of Av(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function Mv(e,t){return new Set([...Nv(e,t)].filter(e=>Object.hasOwn(t,e)))}function Nv(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of wv(e,t))for(let{name:e}of Cv(r,i,a))n.add(e);return n}function Pv(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 Fv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),Iv(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 Iv(e){return e.kind===`dropped`||(e.kind===`shell`||e.kind===`file`)&&C_(e.parse)===`json`}function Lv(e){let t=v.basename(e),n=v.dirname(e);for(;;){let r=Rv(n);if(r!==null)return{dir:r,name:t,leaf:n===v.dirname(e)};t=v.basename(n),n=v.dirname(n)}}function Rv(e){try{return s.statSync(e).isDirectory()?s.realpathSync(e):null}catch{return null}}var zv=we((e=>{function t(e,...t){throw Error(`[MobX] minified error nr: ${e}${t.length?` `+t.map(String).join(`,`):``}. See mobx.js.org/errors`)}function n(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function r(e){return typeof e==`function`}function i(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function a(e){return typeof e==`object`&&!!e}function o(e){if(!a(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=p(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===zt}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){Ft(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function l(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return a(e)&&!0===e[n]}}function u(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function d(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function f(e){return e===null?null:typeof e==`object`?``+e:e}function p(e,t){return It.hasOwnProperty.call(e,t)}function m(e,t){return!!(e&t)}function h(e,t,n){return n?e|=t:e&=~t,e}function g(e,t=Bt,n=Bt){let r=new Ut(e);return t!==Bt&&(r.onBOL=new Set([t])),n!==Bt&&(r.onBUOL=new Set([n])),r}function _(e,t){return Ot(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||$e(e)?e:Array.isArray(e)?an.array(e,{name:n}):o(e)?an.object(e,void 0,{name:n}):u(e)?an.map(e,{name:n}):d(e)?an.set(e,{name:n}):typeof e!=`function`||He(e)||Xe(e)?e:s(e)?Un(e):Fn(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:x,u:S}}function x(e,t,n,r){var i;return(i=this.i)!=null&&i.bound?this.u(e,t,n,!1)===null?0:1:r===e.h?this.u(e,t,n,!1)===null?0:2:He(n.value)?1:(Ft(r,t,w(e,this,t,n,!1)),2)}function S(e,t,n,r){let i=w(e,this,t,n);return e.l(t,i,r)}function C(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return _e(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return He(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(He(n)||(n=c(n)),(l=s.i)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),n):void t(43,s.t,String(a),i);var l}function w(e,t,n,r,i=F.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:_e(t.i?.name??n.toString(),c,(o=t.i?.autoAction)!=null&&o,(s=t.i)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function ee(e,t){return{t:e,i:t,o:te,u:ne}}function te(e,t,n,r){var i;return r===e.h?this.u(e,t,n,!1)===null?0:2:(i=this.i)!=null&&i.bound&&(!p(e.h,t)||!Xe(e.h[t]))&&this.u(e,t,n,!1)===null?0:Xe(n.value)?1:(Ft(r,t,re(e,0,0,n,!1,!1)),2)}function ne(e,t,n,r){let i=re(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function T(e,t,n){var r;let{name:i,addInitializer:a}=n;return Xe(t)||(t=Un(t)),(r=e.i)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function re(e,t,n,r,i,a=F.safeDescriptors){let{value:o}=r;return Xe(o)||(o=Un(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function E(e,t){return{t:e,i:t,o:D,u:ie}}function D(e,t,n){return this.u(e,t,n,!1)===null?0:1}function ie(e,t,n,r){return e.m(t,Nt({},this.i,{get:n.get,set:n.set}),r)}function O(e,t,n){function r(e){let n=Nt({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new _n(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=xt(this)[M],n=this,i=e.j.get(a);i instanceof _n&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[M],n=e.j.get(a);if(n instanceof _n&&n.derivation!==t){let e=s?.get(this);return e||(e=r(this),(s??=new WeakMap).set(this,e)),e.get()}return e._(a)}}function ae(e,t){return{t:e,i:t,o:oe,u:se}}function oe(e,t,n){return this.u(e,t,n,!1)===null?0:1}function se(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function ce(e,t,n){function r(e,t){let n=xt(e)[M];return(n.V??=new Map).set(o,()=>new hn(t,i.i?.A??v,`ObservableObject.${o.toString()}`,!1)),n}let i=e,{kind:a,name:o}=n;if(a===`accessor`)return{get(){return(this[M]??r(this,t.get.call(this)))._(o)},set(e){return(this[M]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function le(e){return{t:qt,i:e,o:ue,u:de}}function ue(e,t,n,r){var i,a,o;if(n.get)return ln.o(e,t,n,r);if(n.set){let i=He(n.set)?n.set:_e(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!F.safeDescriptors||e.p,set:i})===null?0:2:(Ft(r,t,{configurable:!0,set:i}),2)}if(r!==e.h&&typeof n.value==`function`)return s(n.value)?((o=this.i)!=null&&o.autoBind?Wn:Un).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?Ln:Fn).o(e,t,n,r);let c=!1===this.i?.deep?en:an;return typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function de(e,t,n,r){var i;return n.get?ln.u(e,t,n,r):n.set?e.l(t,{configurable:!F.safeDescriptors||e.p,set:_e(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.i?.deep?en:an).u(e,t,n,r))}function fe(e,t){return Nt(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function pe(e){return e||Jt}function me(e){return fe(e,ce)}function he(e){return!0===e.deep?v:!1===e.deep?y:(t=e.defaultDecorator)&&(n=(r=t.i)?.A)!=null?n:v;var t,n,r}function ge(e){return fe(e,O)}function _e(e,t,n=!1,r){function i(){return ve(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),pn&&(mn.value=e,Ft(i,`name`,mn)),i}function ve(e,t,n,r,i){let a=ye(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{be(a)}}function ye(e,t){let n=F.trackingDerivation,r=!t||!n;Me();let i=F.allowStateChanges;r&&k();let a={R:r,k:n,C:i,I:F.allowStateReads,P:!1,T:0,B:fn++,D:dn};return dn=a.B,a}function be(e){dn!==e.B&&t(30),dn=e.D,e.N!==void 0&&(F.suppressReactionErrors=!0),Ne(),e.R&&De(e.k),F.suppressReactionErrors=!1}function xe(e,t){let n=function(e){let t=F.allowStateChanges;return F.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){F.allowStateChanges=e})(n)}}function Se(e){return e instanceof yn}function Ce(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=k(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(vn(r)){if(F.disableErrorBoundaries)r.get();else try{r.get()}catch{return De(t),!0}if(e.K===2)return De(t),!0}}return Oe(e),De(t),!1}}}function we(e,t,n){Oe(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++F.runId;let r=F.trackingDerivation,i;if(F.trackingDerivation=e,F.inBatch++,!0===F.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new yn(e)}return F.inBatch--,F.trackingDerivation=r,function(e){let t=e.L,n=e.L=e.$,r=0,i=0,a=e.W;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.K>r&&(r=t.K)}for(n.length=i,e.$=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&Ae(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,ke(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function Te(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Ae(t[n],e);e.K=-1}function Ee(e){let t=k();try{return e()}finally{De(t)}}function k(){let e=F.trackingDerivation;return F.trackingDerivation=null,e}function De(e){F.trackingDerivation=e}function Oe(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function ke(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Ae(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&je(e))}function je(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,F.pendingUnobservations.push(e))}function Me(){F.inBatch++}function Ne(){--F.inBatch===0&&(Le(),!F.isRunningUnobservations&&F.pendingUnobservations.length>0&&function(){F.isRunningUnobservations=!0;try{let e=F.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,n.H&&n.H.size!==0||(n.H=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof _n&&n.G())}F.pendingUnobservations=[]}finally{F.isRunningUnobservations=!1}}())}function Pe(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Pe))}function Fe(e){let t=F.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&F.inBatch>0&&je(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&F.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Ie(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(e=>{e.K===0&&e.q(),e.K=2}))}function Le(){F.inBatch>0||F.isRunningReactions||En(Re)}function Re(){F.isRunningReactions=!0;let e=F.pendingReactions,t=0;for(;e.length>0;){++t===Tn&&(console.error(`[mobx] cycle in reaction: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].X()}F.isRunningReactions=!1}function ze(e){return fe(e,C)}function Be(e){return function(t,n){return n&&typeof n.kind==`string`?C(e?Mn:An,t,n):r(t)?_e(t.name||`<unnamed action>`,t,e):r(n)?_e(t,n,e):i(t)?ze(b(e?kn:On,{name:t,autoAction:e})):void 0}}function Ve(e){return ve(0,!1,e,this,void 0)}function He(e){return r(e)&&!0===e.isMobxAction}function Ue(e,t=Rt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=We(t),r=!1;a=new wn(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new wn(i,function(){this.track(n)},t.onError,t.requiresObservable);return t!=null&&(r=t.signal)!=null&&r.aborted||a.Y(),a.Z(t?.signal)}function We(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Rn}function Ge(e,t,n,i){let a=typeof i==`function`?wt(t,n):wt(t),o=r(i)?i:n,s=`${e}L`;return a[s]?a[s].add(o):a[s]=new Set([o]),function(){let e=a[s];e&&(e.delete(o),e.size===0&&delete a[s])}}function Ke(e,t,n,r){let i=Ht(t);return Dt(()=>{let t=xt(e,r)[M];Vt(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function qe(e){let t={name:e.tt};var n;return e.L&&e.L.length>0&&(t.dependencies=(n=e.L,Array.from(new Set(n))).map(qe)),t}function Je(e){let t={name:e.tt};return function(e){return!!e.H&&e.H.size>0}(e)&&(t.observers=Array.from(function(e){return e.H??new Set}(e),Je)),t}function Ye(e){r(e.cancel)&&e.cancel()}function Xe(e){return!0===e?.isMobXFlow}function Ze(e,t){var n;if(t===void 0)return vn(e);if(!1===Ct(e))return!1;let r=e[M];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?vn(wt(e,t)):!1}function Qe(e,t){if(!e)return!1;if(t!==void 0){if(Ct(e)){var n,r;let i=e[M];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return Ct(e)||!!e[M]||Wt(e)||Dn(e)||vn(e)}function $e(e){return Qe(e)}function et(e){return Ct(e)?e[M].nt():nr(e)||ar(e)?Array.from(e.keys()):vt(e)?e.map((e,t)=>t):void t(5)}function tt(e,n){return Ct(e)?e[M].et(n):nr(e)||ar(e)?e.has(n):vt(e)?n>=0&&n<e.length:void t(10)}function nt(e){if(Ct(e))return e[M].it();t(38)}function rt(e,t,n){if(vn(e)){let r,i=!0;return Ue(()=>{let a=e.get();if(!i||n){let n=k();t({observableKind:`computed`,debugObjectName:e.tt,type:Jn,object:e,newValue:a,oldValue:r}),De(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Jn,newValue:e.rt,oldValue:void 0}),ft(e,t)}function it(e,t,n){return e.set(t,n),n}function at(e,t){if(typeof e!=`object`||!e||e instanceof Date||!$e(e))return e;if(gn(e)||vn(e))return at(e.get(),t);if(t.has(e))return t.get(e);if(vt(e)){let n=it(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=at(e,t)}),n}if(ar(e)){let n=it(t,e,new Set);return e.forEach(e=>{n.add(at(e,t))}),n}if(nr(e)){let n=it(t,e,new Map);return e.forEach((e,r)=>{n.set(r,at(e,t))}),n}{let n=it(t,e,{});return nt(e).forEach(r=>{It.propertyIsEnumerable.call(e,r)&&(n[r]=at(e[r],t))}),n}}function ot(e,t){Me();try{return e.apply(t)}finally{Ne()}}function st(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[M].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=_e(`When-effect`,t);var a=Ue(t=>{xe(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function ct(e){return e[M]}function lt(e){return e.st!==void 0&&e.st.length>0}function ut(e,t){let r=e.st;return r?r.push(t):r=e.st=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function A(e,n){let r=k();try{let r=[...e.st||[]];for(let e=0,i=r.length;e<i&&((n=r[e](n))&&!n.type&&t(14),n);e++);return n}finally{De(r)}}function dt(e){return e.ot!==void 0&&e.ot.length>0}function ft(e,t){let r=e.ot;return r?r.push(t):r=e.ot=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function pt(e,t){let n=k(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);De(n)}}function mt(e,n,r){if(!0===r&&(r=e.ut),!1===r)return;n in e.h||t(1,r.t,`${e.tt}.${n.toString()}`);let i=e.h;for(;i&&i!==It;){let t=Pt(i,n);if(t){let a=r.o(e,n,t,i);if(a===0)return;if(a===1)break}i=Object.getPrototypeOf(i)}}function j(e,t){typeof Array.prototype[e]==`function`&&(Zn[e]=t(e))}function ht(e){return function(){let t=this[M];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function gt(e){return function(t,n){let r=this[M];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function _t(e){return function(){let t=this[M];t.ct.reportObserved();let n=t.ht(t.j),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}function vt(e){return a(e)&&Qn(e[M])}function yt(e){return e[Symbol.toStringTag]=`MapIterator`,jt(e)}function bt(e){return e[Symbol.toStringTag]=`SetIterator`,jt(e)}function xt(e,t){if(p(e,M))return e;let n=t?.name??`ObservableObject`;return c(e,M,new cr(e,new Map,String(n),function(e){return e?e.defaultDecorator??function(e){let t=!1!==e.deep,n=!!e.autoBind,r=!t|(n?2:0);return P[r]??(P[r]=le({deep:t,autoBind:n}))}(e):void 0}(t))),e}function St(e){return or[e]||(or[e]={get(){return this[M]._(e)},set(t){return this[M].M(e,t)}})}function Ct(e){return!!a(e)&&lr(e[M])}function wt(e,n){if(typeof e==`object`&&e){if(vt(e))return n!==void 0&&t(23),e[M].ct;if(ar(e))return e.ct;if(nr(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,Et(e)),r}if(Ct(e)){if(!n)return t(26);let r=e[M],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,Et(e)),i}if(Wt(e)||vn(e)||Dn(e))return e}else if(r(e)&&Dn(e[M]))return e[M];t(28)}function Tt(e,n){return e||t(29),n===void 0?Wt(e)||vn(e)||Dn(e)||nr(e)||ar(e)?e:e[M]?e[M]:void t(24,e):Tt(wt(e,n))}function Et(e,t){let n;if(t!==void 0)n=wt(e,t);else{if(He(e))return e.name;n=Ct(e)||nr(e)||ar(e)?Tt(e):wt(e)}return n.tt}function Dt(e){let t=k();Me();try{return e()}finally{Ne(),De(t)}}function Ot(e,t,n=-1){return kt(e,t,n)}function kt(e,t,n,i,a){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!=e)return t!=t;let o=typeof e;if(o!==`function`&&o!==`object`&&typeof t!=`object`)return!1;let s=ur.call(e);if(s!==ur.call(t))return!1;switch(s){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++}e=At(e),t=At(t);let c=s===`[object Array]`;if(!c){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,i=t.constructor;if(n!==i&&!(r(n)&&n instanceof n&&r(i)&&i instanceof i)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),a||=[];let l=(i||=[]).length;for(;l--;)if(i[l]===e)return a[l]===t;if(i.push(e),a.push(t),c){if(l=e.length,l!==t.length)return!1;for(;l--;)if(!kt(e[l],t[l],n-1,i,a))return!1}else{let r=Object.keys(e),o=r.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=r[s];if(!p(t,o)||!kt(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function At(e){return vt(e)?e.slice():u(e)||nr(e)||d(e)||ar(e)?Array.from(e.entries()):e}function jt(e){return e[Symbol.iterator]=Mt,Nt(Object.create(dr),e)}function Mt(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let Nt=Object.assign,Pt=Object.getOwnPropertyDescriptor,Ft=Object.defineProperty,It=Object.prototype,Lt=[];Object.freeze(Lt);let Rt={};Object.freeze(Rt);let zt=Object.toString(),Bt=()=>{},Vt=Reflect.ownKeys,Ht=Object.getOwnPropertyDescriptors,M=Symbol(`mobx administration`);var Ut=class{constructor(e=`Atom`){this.tt=void 0,this.yt=0,this.H=null,this.J=0,this.F=-1,this.onBOL=void 0,this.onBUOL=void 0,this.tt=e}get isBeingObserved(){return m(this.yt,1)}set isBeingObserved(e){this.yt=h(this.yt,1,e)}get isPendingUnobservation(){return m(this.yt,2)}set isPendingUnobservation(e){this.yt=h(this.yt,2,e)}get diffValue(){return+!!m(this.yt,4)}set diffValue(e){this.yt=h(this.yt,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return Fe(this)}reportChanged(){Me(),Ie(this),Ne()}toString(){return this.tt}};let Wt=l(`Atom`,Ut),Gt=Object.is,Kt={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},qt=`true`,N=le(),P=[N],Jt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Jt);let Yt=ae(`observable`),Xt=ae(`observable.ref`,{A:y}),Zt=ae(`observable.shallow`,{A:function(e,t,n){return e==null||Ct(e)||vt(e)||nr(e)||ar(e)?e:Array.isArray(e)?an.array(e,{name:n,deep:!1}):o(e)?an.object(e,void 0,{name:n,deep:!1}):u(e)?an.map(e,{name:n,deep:!1}):d(e)?an.set(e,{name:n,deep:!1}):void 0}}),Qt=ae(`observable.struct`,{A:function(e,t){return Ot(e,t)?t:e}}),$t={box(e,t){let n=pe(t);return new hn(e,he(n),n.name,!0,n.equals)},array(e,t){let n=pe(t);return function(e,t,n=`ObservableArray`,r=!1){return Dt(()=>{let i=new Xn(n,t,r);Ft(i.j,M,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Yn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,he(n),n.name)},map(e,t){let n=pe(t);return new tr(e,he(n),n.name)},set(e,t){let n=pe(t);return new ir(e,he(n),n.name)},object:(e,t,n)=>Dt(()=>Ke(function(e,t){var n;return(n=(e=xt(e,t))[M]).v??(n.v=new Proxy(e,Gn))}({},n),e,t))},en=me(Xt),tn=me(Zt),nn=me(Yt),rn=me(Qt);var an=Nt(function(e,t,n){return t&&typeof t.kind==`string`?ce(Yt,e,t):$e(e)?e:o(e)?an.object(e,t,n):Array.isArray(e)?an.array(e,t):u(e)?an.map(e,t):d(e)?an.set(e,t):typeof e==`object`&&e?e:an.box(e,t)},Yt,$t);let on=`computed`,sn=E(on),cn=ge(E(`computed.struct`,{equals:_})),ln=function(e,t){if(t&&typeof t.kind==`string`)return O(sn,e,t);if(o(e))return ge(E(on,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new _n(n)};var un;Nt(ln,sn);let dn=0,fn=1,pn=(un=Pt(()=>{},`name`)?.configurable)!=null&&un,mn={value:`action`,configurable:!0,writable:!1,enumerable:!1};var hn=class extends Ut{constructor(e,t,n=`ObservableValue`,r=!0,i=Gt){super(n),this.A=void 0,this.tt=void 0,this.xt=void 0,this.gt=!1,this.st=void 0,this.ot=void 0,this.rt=void 0,this.dehancer=void 0,this.A=t,this.tt=n,this.xt=i,this.rt=t(e,void 0,n)}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){(e=this.jt(e))!==F.UNCHANGED&&this.Ot(e)}jt(e){if(lt(this)){let t=A(this,{object:this,type:Jn,newValue:e});if(!t)return F.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?F.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),dt(this)&&pt(this,{type:Jn,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.rt)}raw(){return this.rt}toJSON(){return this.get()}toString(){return`${this.tt}[${this.rt}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let gn=l(`ObservableValue`,hn);var _n=class{constructor(e){this.K=-1,this.L=[],this.$=null,this.H=null,this.U=0,this.J=0,this.F=0,this.W=0,this.rt=new yn(null),this.tt=void 0,this._t=void 0,this.yt=0,this.derivation=void 0,this.St=void 0,this.At=void 0,this.xt=void 0,this.Vt=void 0,this.Mt=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||t(31),this.derivation=e.get,this.tt=e.name||`ComputedValue`,e.set&&(this.St=_e(`ComputedValue-setter`,e.set)),this.xt=e.equals||Gt,this.At=e.context,this.Vt=e.requiresReaction,this.Mt=!!e.keepAlive}q(){(function(e){var t;e.F===0&&(e.F=1,(t=e.H)==null||t.forEach(e=>{e.K===0&&(e.K=1,e.q())}))})(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return m(this.yt,1)}set isComputing(e){this.yt=h(this.yt,1,e)}get isRunningSetter(){return m(this.yt,2)}set isRunningSetter(e){this.yt=h(this.yt,2,e)}get isBeingObserved(){return m(this.yt,4)}set isBeingObserved(e){this.yt=h(this.yt,4,e)}get isPendingUnobservation(){return m(this.yt,8)}set isPendingUnobservation(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}get(){if(this.isComputing&&t(32,this.tt,this.derivation),F.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Fe(this),Ce(this)){let e=F.trackingContext;e||!this.Mt&&!this.isBeingObserved||(F.trackingContext=this),this.trackAndCompute()&&function(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(t=>{t.K===1?t.K=2:t.K===0&&(e.F=0)}))}(this),F.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Pe)}else Ce(this)&&(this.Nt(),Me(),this.rt=this.Rt(!1),Ne());let e=this.rt;if(Se(e))throw e.cause;return e}set(e){if(this.St){this.isRunningSetter&&t(33,this.tt),this.isRunningSetter=!0;try{this.St.call(this.At,e)}finally{this.isRunningSetter=!1}}else t(34,this.tt)}trackAndCompute(){let e=this.rt,t=this.K===-1,n=this.Rt(!0),r=t||Se(e)||Se(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=we(this,this.derivation,this.At);else if(!0===F.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new yn(e)}return this.isComputing=!1,t}G(){this.Mt||(Te(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let vn=l(`ComputedValue`,_n);var yn=class{constructor(e){this.cause=void 0,this.cause=e}};let bn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var xn=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let Sn=!0,Cn=!1,F=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Sn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Sn=!1),Sn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new xn):(setTimeout(()=>{Cn||t(35)},1),new xn)}();var wn=class{constructor(e=`Reaction`,t,n,r){this.tt=void 0,this.Et=void 0,this.kt=void 0,this.Ct=void 0,this.L=[],this.$=[],this.K=-1,this.U=0,this.W=0,this.yt=0,this.It=void 0,this.tt=e,this.Et=t,this.kt=n,this.Ct=r}get isDisposed(){return m(this.yt,1)}set isDisposed(e){this.yt=h(this.yt,1,e)}get isScheduled(){return m(this.yt,2)}set isScheduled(e){this.yt=h(this.yt,2,e)}get isTrackPending(){return m(this.yt,4)}set isTrackPending(e){this.yt=h(this.yt,4,e)}get isRunning(){return m(this.yt,8)}set isRunning(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}q(){this.Y()}Y(){this.isScheduled||(this.isScheduled=!0,F.pendingReactions.push(this),Le())}X(){if(!this.isDisposed){Me(),this.isScheduled=!1;let e=F.trackingContext;if(F.trackingContext=this,Ce(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}F.trackingContext=e,Ne()}}track(e){if(this.isDisposed)return;Me(),this.isRunning=!0;let t=F.trackingContext;F.trackingContext=this;let n=we(this,e,void 0);F.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Te(this),Se(n)&&this.Pt(n.cause),Ne()}Pt(e){if(this.kt)this.kt(e,this);else{if(F.disableErrorBoundaries)throw e;F.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),F.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(Me(),Te(this),Ne()))}Z(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.It=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[M]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let Tn=100,En=e=>e(),Dn=l(`Reaction`,wn),On=`action`,kn=`autoAction`,An=b(On),jn=b(`action.bound`,{bound:!0}),Mn=b(kn,{autoAction:!0}),Nn=b(`autoAction.bound`,{autoAction:!0,bound:!0}),Pn=Be(!1);Nt(Pn,An);let Fn=Be(!0);Nt(Fn,Mn);let In=ze(jn),Ln=ze(Nn),Rn=e=>e(),zn=`always`;var Bn=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Vn=ee(`flow`),Hn=ee(`flow.bound`,{bound:!0}),Un=Nt(function(e,t){if(t&&typeof t.kind==`string`)return T(Vn,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=Pn(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=Pn(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=Pn(i,t.throw).call(t,e)}catch(e){return n(e)}l(r)}function l(t){if(!r(t?.then))return t.done?e(t.value):(o=Promise.resolve(t.value),o.then(s,c));t.then(l,n)}a=n,s(void 0)});return s.cancel=Pn(i,function(){try{o&&Ye(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Bt,Bt),Ye(n),a(new Bn)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Vn),Wn=fe(Hn,T),Gn={has:(e,t)=>ct(e).et(t),get:(e,t)=>ct(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=ct(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=ct(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=ct(e).l(t,n))==null||r},ownKeys:e=>ct(e).it(),preventExtensions(e){t(13)}},Kn=Symbol(`mobx-keys`),qn=`splice`,Jn=`update`,Yn={get(e,t){let n=e[M];return t===M?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p(Zn,t)?Zn[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[M];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var Xn=class{constructor(e=`ObservableArray`,t,n){this.$t=void 0,this.ct=void 0,this.j=[],this.st=void 0,this.ot=void 0,this.A=void 0,this.dehancer=void 0,this.v=void 0,this.Ut=0,this.$t=n,this.ct=new Ut(e),this.A=(e,n)=>t(e,n,`ObservableArray[..]`)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}ht(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}Kt(){return this.ct.reportObserved(),this.j.length}Lt(e){(!Number.isInteger(e)||e<0)&&t(40,e);let n=this.j.length;if(e!==n)if(e>n){let t=Array.from({length:e-n});this.wt(n,0,t)}else this.wt(e,n-e)}zt(e,n){e!==this.Ut&&t(16),this.Ut+=n}wt(e,t,n){let r=this.j.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=Lt),lt(this)){let r=A(this,{object:this.v,type:qn,index:e,removedCount:t,added:n});if(!r)return Lt;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.A(e,void 0));let i=this.qt(e,t,n);return t===0&&n.length===0||this.Ft(e,n,i),this.ht(i)}qt(e,t,n){if(n.length<1e4)return this.j.splice(e,t,...n);{let r=this.j.slice(e,e+t),i=this.j.slice(e+t);this.j.length+=n.length-t;for(let t=0;t<n.length;t++)this.j[e+t]=n[t];for(let t=0;t<i.length;t++)this.j[e+n.length+t]=i[t];return r}}Ht(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,type:Jn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&pt(this,i)}Ft(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:qn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&pt(this,i)}Tt(e){return this.ct.reportObserved(),this.Wt(this.j[e])}Bt(e,t){let n=this.j;if(e<n.length){let r=n[e];if(lt(this)){let n=A(this,{type:Jn,object:this.v,index:e,newValue:t});if(!n)return;t=n.newValue}(t=this.A(t,r))!==r&&(n[e]=t,this.Ht(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.wt(n.length,0,r)}}},Zn={clear(){return this.splice(0)},replace(e){let t=this[M];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[M];switch(arguments.length){case 0:return[];case 1:return r.wt(e);case 2:return r.wt(e,t)}return r.wt(e,t,n)},spliceWithArray(e,t,n){return this[M].wt(e,t,n)},push(...e){let t=this[M];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[M].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[M];return t.wt(0,0,e),t.j.length},reverse(){return F.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){F.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[M],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};j(`at`,ht),j(`concat`,ht),j(`flat`,ht),j(`includes`,ht),j(`indexOf`,ht),j(`join`,ht),j(`lastIndexOf`,ht),j(`slice`,ht),j(`toString`,ht),j(`toLocaleString`,ht),j(`toSorted`,ht),j(`toSpliced`,ht),j(`with`,ht),j(`every`,gt),j(`filter`,gt),j(`find`,gt),j(`findIndex`,gt),j(`findLast`,gt),j(`findLastIndex`,gt),j(`flatMap`,gt),j(`forEach`,gt),j(`map`,gt),j(`some`,gt),j(`toReversed`,gt),j(`reduce`,_t),j(`reduceRight`,_t);let Qn=l(`ObservableArrayAdministration`,Xn),$n={},er=`delete`;var tr=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[M]=$n,this.ft=void 0,this.dt=void 0,this.lt=void 0,this.st=void 0,this.ot=void 0,this.dehancer=void 0,this.A=t,this.tt=n,Dt(()=>{this.lt=g(`ObservableMap.keys()`),this.ft=new Map,this.dt=new Map,e&&this.merge(e)})}et(e){return this.ft.has(e)}has(e){if(!F.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new hn(this.et(e),y,`ObservableMap.key?`,!1);this.dt.set(e,n),n.onBUOL=new Set([()=>this.dt.delete(e)])}return t.get()}set(e,t){let n=this.et(e);if(lt(this)){let r=A(this,{type:n?Jn:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.Gt(e,t):this.Jt(e,t),this}delete(e){if(lt(this)&&!A(this,{type:er,object:this,name:e}))return!1;if(this.et(e)){let t=dt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:er,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return ot(()=>{var t;this.lt.reportChanged(),(t=this.dt.get(e))==null||t.Ot(!1),this.ft.get(e).Ot(void 0),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Jn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}}Jt(e,t){ot(()=>{var n;let r=new hn(t,this.A,`ObservableMap.key`,!1);this.ft.set(e,r),t=r.rt,(n=this.dt.get(e))==null||n.Ot(!0),this.lt.reportChanged()});let n=dt(this);n&&pt(this,n?{observableKind:`map`,debugObjectName:this.tt,type:`add`,object:this,name:e,newValue:t}:null)}get(e){return this.has(e)?this.Wt(this.ft.get(e).get()):this.Wt(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.lt.reportObserved(),this.ft.keys()}values(){let e=this,t=this.keys();return yt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return yt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return nr(e)&&(e=new Map(e)),ot(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>It.propertyIsEnumerable.call(e,t))]:t}(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):u(e)?(function(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}(e)||t(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&t(20,e)}),this}clear(){ot(()=>{Ee(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return ot(()=>{let n=function(e){if(u(e)||nr(e))return e;if(Array.isArray(e))return new Map(e);if(o(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}return t(21,e)}(e),r=new Map,i=!1;for(let e of this.ft.keys())if(!n.has(e))if(this.delete(e))i=!0;else{let t=this.ft.get(e);r.set(e,t)}for(let[e,t]of n.entries()){let n=this.ft.has(e);if(this.set(e,t),this.ft.has(e)){let t=this.ft.get(e);r.set(e,t),n||(i=!0)}}if(!i)if(this.ft.size!==r.size)this.lt.reportChanged();else{let e=this.ft.keys(),t=r.keys(),n=e.next(),i=t.next();for(;!n.done;){if(n.value!==i.value){this.lt.reportChanged();break}n=e.next(),i=t.next()}}this.ft=r}),this}get size(){return this.lt.reportObserved(),this.ft.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},nr=l(`ObservableMap`,tr);let rr={};var ir=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[M]=rr,this.ft=new Set,this.ct=void 0,this.ot=void 0,this.st=void 0,this.dehancer=void 0,this.A=void 0,this.tt=n,this.A=(e,r)=>t(e,r,n),Dt(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){ot(()=>{Ee(()=>{for(let e of this.ft.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.ct.reportObserved(),this.ft.size}add(e){if(lt(this)){let t=A(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){ot(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=dt(this);t&&pt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(lt(this)&&!A(this,{type:er,object:this,oldValue:e}))return!1;if(this.has(e)){let t=dt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:er,object:this,oldValue:e}:null;return ot(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return bt({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.ct.reportObserved();let e=this,t=this.ft.values();return bt({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.Wt(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return ar(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?ot(()=>{let t=d(e)?e:new Set(e);if(t.size!==0)if(this.ft.size!==0){for(let e of this.ft.values())t.has(this.Wt(e))||this.delete(e);t.forEach(e=>this.add(e))}else t.forEach(e=>this.add(e));else this.clear()}):e!=null&&t(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},ar=l(`ObservableSet`,ir);let or=Object.create(null),sr=`remove`;var cr=class{constructor(e,t=new Map,n,r=N){this.h=void 0,this.j=void 0,this.tt=void 0,this.ut=void 0,this.lt=void 0,this.ot=void 0,this.st=void 0,this.v=void 0,this.p=void 0,this.Xt=void 0,this.Qt=void 0,this.O=void 0,this.V=void 0,this.h=e,this.j=t,this.tt=n,this.ut=r,this.lt=new Ut(`ObservableObject.keys`),this.p=o(this.h)}_(e){return(this.j.get(e)??this.vt(e)??this.bt(e)).get()}vt(e){let t=this.O?.get(e);if(!t)return;this.O.delete(e),this.O.size===0&&(this.O=void 0);let n=t();return this.j.set(e,n),n}bt(e){let t=this.V?.get(e);if(!t)return;this.V.delete(e),this.V.size===0&&(this.V=void 0);let n=t();return this.j.set(e,n),n}M(e,t){let n=this.j.get(e)??this.vt(e)??this.bt(e);if(n instanceof _n)return n.set(t),!0;if(lt(this)){let n=A(this,{type:Jn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{type:Jn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}return!0}Tt(e){return F.trackingDerivation&&!p(this.h,e)&&this.et(e),this.h[e]}Bt(e,t,n=!1){return p(this.h,e)?this.j.has(e)?this.M(e,t):n?Reflect.set(this.h,e,t):(this.h[e]=t,!0):this.u(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.ut,n)}et(e){if(!F.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new hn(e in this.h,y,`ObservableObject.key?`,!1),this.Qt.set(e,t)),t.get()}u(e,t,n,r=!1){return!0===n&&(n=this.ut),!1===n?this.l(e,t,r):n.u(this,e,t,r)}l(e,t,n=!1){try{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)){let n=A(this,{object:this.v||this.h,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:r}=n;t.value!==r&&(t=Nt({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else Ft(this.h,e,t);this.Yt(e,t.value)}finally{Ne()}return!0}S(e,t,n,r=!1){try{Me();let i=this.Dt(e);if(!i)return i;if(lt(this)){let n=A(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=St(e),o={configurable:!F.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else Ft(this.h,e,o);let s=new hn(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Ne()}return!0}m(e,t,n=!1){try{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)&&!A(this,{object:this.v||this.h,name:e,type:`add`,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;let i=St(e),a={configurable:!F.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else Ft(this.h,e,a);this.j.set(e,new _n(t)),this.Yt(e,void 0)}finally{Ne()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(lt(this)&&!A(this,{object:this.v||this.h,name:e,type:sr}))return null;try{var n;Me();let r=dt(this),i=this.j.get(e),a;if(i||!r||(a=Pt(this.h,e)?.value),t){if(!Reflect.deleteProperty(this.h,e))return!1}else delete this.h[e];i&&(this.j.delete(e),i instanceof hn&&(a=i.rt),Ie(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&pt(this,{type:sr,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Ne()}return!0}Yt(e,t){var n;let r=dt(this);r&&r&&pt(this,r?{type:`add`,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,name:e,newValue:t}:null),(n=this.Qt)==null||(n=n.get(e))==null||n.set(!0),this.lt.reportChanged()}it(){return this.lt.reportObserved(),Vt(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let lr=l(`ObservableObjectAdministration`,cr),ur=It.toString,dr=globalThis.Iterator?.prototype||{};e.$mobx=M,e.FlowCancellationError=Bn,e.ObservableMap=tr,e.ObservableSet=ir,e.Reaction=wn,e._allowStateChanges=xe,e._allowStateChangesInsideComputed=Ve,e._allowStateReadsEnd=function(e){F.allowStateReads=e},e._allowStateReadsStart=function(e){let t=F.allowStateReads;return F.allowStateReads=e,t},e._autoAction=Fn,e._autoActionBound=Ln,e._endAction=be,e._getAdministration=Tt,e._getGlobalState=function(){return F},e._interceptReads=function(e,t,n){let r;return nr(e)||vt(e)||gn(e)?r=Tt(e):Ct(e)&&(r=Tt(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return F.trackingDerivation!==null},e._resetGlobalState=function(){let e=new xn;for(let t in e)bn.indexOf(t)===-1&&(F[t]=e[t]);F.allowStateChanges=!F.enforceActions},e._startAction=ye,e.action=Pn,e.actionBound=In,e.autorun=Ue,e.compareDefault=Gt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return Ot(e,t,1)},e.compareStructural=_,e.computed=ln,e.computedStruct=cn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((F.pendingReactions.length||F.inBatch||F.isRunningReactions)&&t(36),Cn=!0,Sn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),F=new xn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===zn?zn:n===`observed`;F.enforceActions=e,F.allowStateChanges=!0!==e&&e!==zn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(F[t]=!!e[t])}),F.allowStateReads=!F.observableRequiresReaction,e.reactionScheduler&&function(e){let t=En;En=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(Ct(e))return e[M].l(n,r);t(39)},e.entries=function(e){return Ct(e)?et(e).map(t=>[t,e[t]]):nr(e)?et(e).map(t=>[t,e.get(t)]):ar(e)?Array.from(e.entries()):vt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ke,e.flow=Un,e.flowBound=Wn,e.flowResult=function(e){return e},e.get=function(e,n){if(tt(e,n))return Ct(e)?e[M].Tt(n):nr(e)?e.get(n):vt(e)?e[n]:void t(11)},e.getAtom=wt,e.getDebugName=Et,e.getDependencyTree=function(e,t){return qe(wt(e,t))},e.getObserverTree=function(e,t){return Je(wt(e,t))},e.has=tt,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return ut(Tt(e,t),n)}(e,t,n):function(e,t){return ut(Tt(e),t)}(e,t)},e.isAction=He,e.isBoxedObservable=gn,e.isComputed=function(e){return Ze(e)},e.isComputedProp=function(e,t){return Ze(e,t)},e.isFlow=Xe,e.isFlowCancellationError=function(e){return e instanceof Bn},e.isObservable=$e,e.isObservableArray=vt,e.isObservableMap=nr,e.isObservableObject=Ct,e.isObservableProp=function(e,t){return Qe(e,t)},e.isObservableSet=ar,e.keys=et,e.makeAutoObservable=function(e,t,n){return o(e)?Ke(e,e,t,n):(Dt(()=>{let r=xt(e,n)[M];if(!e[Kn]){let t=Object.getPrototypeOf(e),n=new Set([...Vt(e),...Vt(t)]);n.delete(`constructor`),n.delete(M),c(t,Kn,n)}e[Kn].forEach(e=>mt(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return Dt(()=>{let r=xt(e,n)[M];Vt(t).forEach(e=>mt(r,e,t[e]))}),e},e.observable=an,e.observableDeep=nn,e.observableRef=en,e.observableShallow=tn,e.observableStruct=rn,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return rt(Tt(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Tt(e);if(vt(e))n&&t({observableKind:`array`,object:r.v,debugObjectName:r.ct.tt,type:`splice`,index:0,added:r.j.slice(),addedCount:r.j.length,removed:[],removedCount:0});else if(!nr(e)&&!ar(e)&&!Ct(e))return rt(r,t,n);return ft(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return Ge(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return Ge(`onBUO`,e,t,n)},e.onReactionError=function(e){return F.globalReactionErrorHandlers.push(e),()=>{let t=F.globalReactionErrorHandlers.indexOf(e);t>=0&&F.globalReactionErrorHandlers.splice(t,1)}},e.override=Kt,e.ownKeys=nt,e.reaction=function(e,t,n=Rt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=xe(!1,()=>e(h));t=f||!m(d,n),d=n}),(f&&n.fireImmediately||!f&&t)&&o(d,r,h),f=!1}var i;let a=n.name??`Reaction`,o=Pn(a,n.onError?(s=n.onError,c=t,function(){try{return c.apply(this,arguments)}catch(e){s.call(this,e)}}):t);var s,c;let l=!n.scheduler&&!n.delay,u=We(n),d,f=!0,p=!1,m=n.equals||Gt,h=new wn(a,()=>{f||l?r():p||(p=!0,u(r))},n.onError,n.requiresObservable);return n!=null&&(i=n.signal)!=null&&i.aborted||h.Y(),h.Z(n?.signal)},e.remove=function(e,n){Ct(e)?e[M].Dt(n):nr(e)||ar(e)?e.delete(n):vt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=Ve,e.set=function e(n,r,i){if(arguments.length===2&&!ar(n)){Me();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Ne()}return}Ct(n)?n[M].Bt(r,i):nr(n)?n.set(r,i):ar(n)?n.add(r):vt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),Me(),r>=n.length&&(n.length=r+1),n[r]=i,Ne()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return at(e,new Map)},e.transaction=ot,e.untracked=Ee,e.values=function(e){return Ct(e)?et(e).map(t=>e[t]):nr(e)?et(e).map(t=>e.get(t)):ar(e)?Array.from(e.values()):vt(e)?e.slice():void t(6)},e.when=function(e,t,n){return arguments.length===1||t&&typeof t==`object`?function(e,t){var n;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Nt(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=st(e,n,Nt({},t,{onError:a}));r=()=>{s(),a(Error(`WHEN_CANCELLED`))},i=()=>{s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)});return a.cancel=r,a}(e,t):st(e,t,n||{})}})),Bv=we((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t={0:`Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,1(e,t){return`Cannot apply '${e}' to '${t.toString()}': Field not found.`},5:`'keys()' can only be used on observable objects, arrays, sets and maps`,6:`'values()' can only be used on observable objects, arrays, sets and maps`,7:`'entries()' can only be used on observable objects, arrays and maps`,8:`'set()' can only be used on observable objects, arrays and maps`,9:`'remove()' can only be used on observable objects, arrays and maps`,10:`'has()' can only be used on observable objects, arrays and maps`,11:`'get()' can only be used on observable objects, arrays and maps`,12:`Invalid annotation`,13:`Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,14:`Intercept handlers should return nothing or a change object`,15:`Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,16:`Modification exception: the internal structure of an observable array was changed.`,19(e){return`Cannot initialize from classes that inherit from Map: `+e.constructor.name},20(e){return`Cannot initialize map from `+e},21(e){return`Cannot convert to map from '${e}'`},23:`It is not possible to get index atoms from arrays`,24(e){return`Cannot obtain administration from `+e},25(e,t){return`the entry '${e}' does not exist in the observable map '${t}'`},26:`please specify a property`,27(e,t){return`no observable property '${e.toString()}' found on the observable object '${t}'`},28(e){return`Cannot obtain atom from `+e},29:`Expecting some object`,30:`invalid action stack. did you forget to finish an action?`,31:`missing option for computed: get`,32(e,t){return`Cycle detected in computation ${e}: ${t}`},33(e){return`The setter of computed value '${e}' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?`},34(e){return`[ComputedValue '${e}'] It is not possible to assign a new value to a computed value.`},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:`isolateGlobalState should be called before MobX is running any reactions`,37(e){return`[mobx] \`observableArray.${e}()\` mutates the array in-place, which is not allowed inside a derivation. Use \`array.slice().${e}()\` instead`},38:`'ownKeys()' can only be used on observable objects`,39:`'defineProperty()' can only be used on observable objects`,40(e){return`Out of range: `+e},41(e){return`Cannot initialize set from `+e},42(e){return`Invalid index: '${e}'`},43(e,t,n){return`Cannot apply '${e}' to '${t}' (kind: ${n}):\n'${e}' can only be used on properties with a function value.`},44(e){return`'${e}' can only be used with 'makeObservable'`}};function n(e,...n){{let r=typeof e==`string`?e:t[e];throw typeof r==`function`&&(r=r.apply(null,n)),Error(`[MobX] ${r}`)}}let r=Object.assign,i=Object.getOwnPropertyDescriptor,a=Object.defineProperty,o=Object.prototype,s=[];Object.freeze(s);let c={};Object.freeze(c);let l=Object.toString();function u(){return++P.mobxGuid}function d(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}let f=()=>{};function p(e){return typeof e==`function`}function m(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function h(e){return typeof e==`object`&&!!e}function g(e){if(!h(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=T(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===l}function _(e){let t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function v(e,t,n){a(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function y(e,t,n){a(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function b(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return h(e)&&e[n]===!0}}function x(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function S(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function C(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function w(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let ee=Reflect.ownKeys;function te(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ne(e){return e===null?null:typeof e==`object`?``+e:e}function T(e,t){return o.hasOwnProperty.call(e,t)}let re=Object.getOwnPropertyDescriptors;function E(e,t){return!!(e&t)}function D(e,t,n){return n?e|=t:e&=~t,e}function ie(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let O=Symbol(`mobx administration`);var ae=class{constructor(e=`Atom@`+u()){this.name_=void 0,this.flags_=0,this.observers_=null,this.lastAccessedBy_=0,this.lowestObserverState_=-1,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}get isBeingObserved(){return E(this.flags_,1)}set isBeingObserved(e){this.flags_=D(this.flags_,1,e)}get isPendingUnobservation(){return E(this.flags_,2)}set isPendingUnobservation(e){this.flags_=D(this.flags_,2,e)}get diffValue(){return+!!E(this.flags_,4)}set diffValue(e){this.flags_=D(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return sn(this)}reportChanged(){nn(),cn(this),rn()}toString(){return this.name_}};let oe=b(`Atom`,ae);function se(e,t=f,n=f){let r=new ae(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function ce(e,t){return e===t}function le(e,t){return Mi(e,t)}function ue(e,t){return Mi(e,t,1)}let de=Object.is;function fe(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||yr(e)?e:Array.isArray(e)?A.array(e,{name:n}):g(e)?A.object(e,void 0,{name:n}):x(e)?A.map(e,{name:n}):C(e)?A.set(e,{name:n}):typeof e==`function`&&!Ln(e)&&!ur(e)?_(e)?or(e):Nn(n,e):e}function pe(e,t,r){if(e==null||wi(e)||ui(e)||mi(e)||yi(e))return e;if(Array.isArray(e))return A.array(e,{name:r,deep:!1});if(g(e))return A.object(e,void 0,{name:r,deep:!1});if(x(e))return A.map(e,{name:r,deep:!1});if(C(e))return A.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function me(e){return e}function he(e,t){return yr(e)&&n(`observable.struct should not be used with observable values`),Mi(e,t)?t:e}let ge=`override`,_e={annotationType_:ge,make_:ye,extend_:be};function ve(e){return e.annotationType_===ge}function ye(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),T(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function be(e,t,r,i){n(44,this.annotationType_)}function xe(e,t){return{annotationType_:e,options_:t,make_:Se,extend_:Ce}}function Se(e,t,n,r){var i;return(i=this.options_)!=null&&i.bound?this.extend_(e,t,n,!1)===null?0:1:r===e.target_?this.extend_(e,t,n,!1)===null?0:2:Ln(n.value)?1:(a(r,t,Ee(e,this,t,n,!1)),2)}function Ce(e,t,n,r){let i=Ee(e,this,t,n);return e.defineProperty_(t,i,r)}function we(e,t,r){ie(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>yt(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return Ln(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return Ln(t)||(t=c(t)),(l=s.options_)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),t}n(43,s.annotationType_,String(a),i)}function Te(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a function value.`)}function Ee(e,t,n,r,i=P.safeDescriptors){var a,o;Te(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:yt(t.options_?.name??n.toString(),s,t.options_?.autoAction??!1,(o=t.options_)!=null&&o.bound?e.proxy_??e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function k(e,t){return{annotationType_:e,options_:t,make_:De,extend_:Oe}}function De(e,t,n,r){var i;return r===e.target_?this.extend_(e,t,n,!1)===null?0:2:(i=this.options_)!=null&&i.bound&&(!T(e.target_,t)||!ur(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:ur(n.value)?1:(a(r,t,je(e,this,t,n,!1,!1)),2)}function Oe(e,t,n,r){let i=je(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function ke(e,t,n){var r;ie(n,[`method`]);let{name:i,addInitializer:a}=n;return ur(t)||(t=or(t)),(r=e.options_)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function Ae(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a generator function value.`)}function je(e,t,n,r,i,a=P.safeDescriptors){Ae(e,t,n,r);let{value:o}=r;return ur(o)||(o=or(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function Me(e,t){return{annotationType_:e,options_:t,make_:Ne,extend_:Pe}}function Ne(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Pe(e,t,n,i){return Ie(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Fe(e,t,n){ie(n,[`getter`]);let i=e,{name:a,addInitializer:o}=n,s;function c(e,n){let o=r({},i.options_,{get:t,context:e});return o.name||=`${n.name_}.${a.toString()}`,new Ot(o)}return o(function(){let e=R(this)[O],n=this,r=e.values_.get(a);r instanceof Ot&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[O],n=e.values_.get(a);if(n instanceof Ot&&n.derivation!==t){let t=s?.get(this);return t||(t=c(this,e),(s??=new WeakMap).set(this,t)),t.get()}return e.getObservablePropValue_(a)}}function Ie(e,{annotationType_:t},r,{get:i}){i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on getter(+setter) properties.`)}function Le(e,t){return{annotationType_:e,options_:t,make_:Re,extend_:ze}}function Re(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function ze(e,t,n,r){return Ve(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??fe,r)}function Be(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);ie(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=R(e)[O];return(n.lazyObservableKeys_??=new Map).set(o,()=>new Et(t,i.options_?.enhancer_??fe,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[O]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[O]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function Ve(e,{annotationType_:t},r,i){`value`in i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' cannot be used on getter/setter properties`)}let He=Ue();function Ue(e){return{annotationType_:`true`,options_:e,make_:Ke,extend_:qe}}let We=[He];function Ge(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return We[r]??(We[r]=Ue({deep:t,autoBind:n}))}function Ke(e,t,n,r){var i;if(n.get)return j.make_(e,t,n,r);if(n.set){let i=Ln(n.set)?n.set:yt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:P.safeDescriptors?e.isPlainObject_:!0,set:i})===null?0:2:(a(r,t,{configurable:!0,set:i}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(_(n.value)){var s;return((s=this.options_)!=null&&s.autoBind?sr:or).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Fn:Nn).make_(e,t,n,r)}let c=this.options_?.deep===!1?st:A;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),c.make_(e,t,n,r)}function qe(e,t,n,r){var i;return n.get?j.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:P.safeDescriptors?e.isPlainObject_:!0,set:yt(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),(this.options_?.deep===!1?st:A).extend_(e,t,n,r))}function Je(e,t){return r(function(r,i){if(i&&typeof i.kind==`string`)return t(e,r,i);n(`Invalid arguments for \`${e.annotationType_}\``)},e)}let Ye={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Ye);function Xe(e){return e||Ye}let Ze=Le(`observable`),Qe=Le(`observable.ref`,{enhancer_:me}),$e=Le(`observable.shallow`,{enhancer_:pe}),et=Le(`observable.struct`,{enhancer_:he});function tt(e){return Je(e,Be)}function nt(e){return e.deep===!0?fe:e.deep===!1?me:it(e.defaultDecorator)}function rt(e){return e?e.defaultDecorator??Ge(e):void 0}function it(e){return e?e.options_?.enhancer_??fe:fe}function at(e,t,n){return t&&typeof t.kind==`string`?Be(Ze,e,t):yr(e)?e:g(e)?A.object(e,t,n):Array.isArray(e)?A.array(e,t):x(e)?A.map(e,t):C(e)?A.set(e,t):typeof e==`object`&&e?e:A.box(e,t)}let ot={box(e,t){let n=Xe(t);return new Et(e,nt(n),n.name,!0,n.equals)},array(e,t){let n=Xe(t);return ii(e,nt(n),n.name)},map(e,t){let n=Xe(t);return new pi(e,nt(n),n.name)},set(e,t){let n=Xe(t);return new vi(e,nt(n),n.name)},object(e,t,n){return Ai(()=>Jn(Ur({},n),e,t))}},st=tt(Qe),ct=tt($e),lt=tt(Ze),ut=tt(et);var A=r(at,Ze,ot);let dt=`computed`;function ft(e){return Je(e,Fe)}let pt=Me(dt),mt=ft(Me(`computed.struct`,{equals:le})),j=function(e,t){if(t&&typeof t.kind==`string`)return Fe(pt,e,t);if(g(e))return ft(Me(dt,e));p(e)||n("First argument to `computed` should be an expression."),p(t)&&n("A setter as second argument is no longer supported, use `{ set: fn }` option instead");let r=g(t)?t:{};return r.get=e,r.name||=e.name||``,new Ot(r)};r(j,pt);let ht=0,gt=1,_t=i(()=>{},`name`)?.configurable??!1,vt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function yt(e,t,r=!1,i){p(t)||n("`action` can only be invoked on functions"),(typeof e!=`string`||!e)&&n(`actions should have valid names, got: '${e}'`);function o(){return bt(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),_t&&(vt.value=e,a(o,`name`,vt)),o}function bt(e,t,n,r,i){let a=xt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{St(a)}}function xt(e,t,n,r){let i=vn()&&!!e,a=0;i&&(a=Date.now(),bn({type:F,name:e,object:n,arguments:r?Array.from(r):s}));let o=P.trackingDerivation,c=!t||!o;nn();let l=P.allowStateChanges;c&&(Vt(),l=wt(!0));let u=P.allowStateReads;M(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:gt++,parentActionId_:ht};return ht=d.actionId_,d}function St(e){ht!==e.actionId_&&n(30),ht=e.parentActionId_,e.error_!==void 0&&(P.suppressReactionErrors=!0),Tt(e.prevAllowStateChanges_),Ut(e.prevAllowStateReads_),rn(),e.runAsAction_&&Ht(e.prevDerivation_),e.notifySpy_&&Sn({time:Date.now()-e.startTime_}),P.suppressReactionErrors=!1}function Ct(e,t){let n=wt(e);try{return t()}finally{Tt(n)}}function wt(e){let t=P.allowStateChanges;return P.allowStateChanges=e,t}function Tt(e){P.allowStateChanges=e}var Et=class extends ae{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=de){super(n),this.enhancer_=void 0,this.name_=void 0,this.equals_=void 0,this.hasUnreportedChange_=!1,this.interceptors_=void 0,this.changeListeners_=void 0,this.value_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,this.equals_=i,this.value_=t(e,void 0,n),r&&vn()&&yn({type:`create`,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:this.value_})}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){let t=this.value_;if(e=this.prepareNewValue_(e),e!==P.UNCHANGED){let n=vn();n&&bn({type:ti,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Sn()}}prepareNewValue_(e){if(Pt(this),Wr(this)){let t=Kr(this,{object:this,type:ti,newValue:e});if(!t)return P.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?P.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),qr(this)&&Yr(this,{type:ti,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.value_)}raw(){return this.value_}toJSON(){return this.get()}toString(){return`${this.name_}[${this.value_}]`}valueOf(){return ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Dt=b(`ObservableValue`,Et);var Ot=class{constructor(e){this.dependenciesState_=-1,this.observing_=[],this.newObserving_=null,this.observers_=null,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=0,this.unboundDepsCount_=0,this.value_=new At(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||n(31),this.derivation=e.get,this.name_=e.name||`ComputedValue@`+u(),e.set&&(this.setter_=yt(this.name_+`-setter`,e.set)),this.equals_=e.equals||de,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){un(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return E(this.flags_,1)}set isComputing(e){this.flags_=D(this.flags_,1,e)}get isRunningSetter(){return E(this.flags_,2)}set isRunningSetter(e){this.flags_=D(this.flags_,2,e)}get isBeingObserved(){return E(this.flags_,4)}set isBeingObserved(e){this.flags_=D(this.flags_,4,e)}get isPendingUnobservation(){return E(this.flags_,8)}set isPendingUnobservation(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),P.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Mt(this)&&(this.warnAboutUntrackedRead_(),nn(),this.value_=this.computeValue_(!1),rn());else{let e=this.isBeingObserved;if(sn(this),Mt(this)){let e=P.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(P.trackingContext=this),this.trackAndCompute()&&ln(this),P.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(on)}let e=this.value_;if(jt(e))throw e.cause;return e}set(e){if(this.setter_){this.isRunningSetter&&n(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter=!1}}else n(34,this.name_)}trackAndCompute(){let e=this.value_,t=this.dependenciesState_===-1,n=this.computeValue_(!0),r=t||jt(e)||jt(n)||!this.equals_(e,n);return r&&(this.value_=n,vn()&&yn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=wt(!1),n;if(e)n=It(this,this.derivation,this.scope_);else if(P.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new At(e)}return Tt(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(zt(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:P.computedRequiresReaction)&&console.warn(`[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`)}toString(){return`${this.name_}[${this.derivation.toString()}]`}valueOf(){return ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let kt=b(`ComputedValue`,Ot);var At=class{constructor(e){this.cause=void 0,this.cause=e}};function jt(e){return e instanceof At}function Mt(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=M(!0),n=Vt(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(kt(i)){if(P.disableErrorBoundaries)i.get();else try{i.get()}catch{return Ht(n),Ut(t),!0}if(e.dependenciesState_===2)return Ht(n),Ut(t),!0}}return Wt(e),Ht(n),Ut(t),!1}}}function Nt(){return P.trackingDerivation!==null}function Pt(e){let t=!!e.observers_&&e.observers_.size>0;!P.allowStateChanges&&(t||P.enforceActions===`always`)&&console.warn(`[MobX] `+(P.enforceActions?`Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: `:`Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: `)+e.name_)}function Ft(e){!P.allowStateReads&&P.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function It(e,t,n){let r=M(!0);Wt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++P.runId;let i=P.trackingDerivation;P.trackingDerivation=e,P.inBatch++;let a;if(P.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new At(e)}return P.inBatch--,P.trackingDerivation=i,Rt(e),Lt(e),Ut(r),a}function Lt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:P.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function Rt(e){let t=e.observing_,n=e.observing_=e.newObserving_,r=0,i=0,a=e.unboundDepsCount_;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.dependenciesState_>r&&(r=t.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&en(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,$t(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function zt(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)en(t[n],e);e.dependenciesState_=-1}function Bt(e){let t=Vt();try{return e()}finally{Ht(t)}}function Vt(){let e=P.trackingDerivation;return P.trackingDerivation=null,e}function Ht(e){P.trackingDerivation=e}function M(e){let t=P.allowStateReads;return P.allowStateReads=e,t}function Ut(e){P.allowStateReads=e}function Wt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Gt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Kt=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 qt=!0,N=!1,P=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(qt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(qt=!1),qt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Kt):(setTimeout(()=>{N||n(35)},1),new Kt)}();function Jt(){if((P.pendingReactions.length||P.inBatch||P.isRunningReactions)&&n(36),N=!0,qt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),P=new Kt}}function Yt(){return P}function Xt(){let e=new Kt;for(let t in e)Gt.indexOf(t)===-1&&(P[t]=e[t]);P.allowStateChanges=!P.enforceActions}function Zt(e){return!!e.observers_&&e.observers_.size>0}function Qt(e){return e.observers_??new Set}function $t(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function en(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&tn(e))}function tn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,P.pendingUnobservations.push(e))}function nn(){P.inBatch++}function rn(){--P.inBatch===0&&(mn(),!P.isRunningUnobservations&&P.pendingUnobservations.length>0&&an())}function an(){P.isRunningUnobservations=!0;try{let e=P.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,(!n.observers_||n.observers_.size===0)&&(n.observers_=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof Ot&&n.suspend_())}P.pendingUnobservations=[]}finally{P.isRunningUnobservations=!1}}function on(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(on))}function sn(e){Ft(e);let t=P.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&P.inBatch>0&&tn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&P.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function cn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&e.onBecomeStale_(),e.dependenciesState_=2}))}function ln(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(t=>{t.dependenciesState_===1?t.dependenciesState_=2:t.dependenciesState_===0&&(e.lowestObserverState_=0)}))}function un(e){var t;e.lowestObserverState_===0&&(e.lowestObserverState_=1,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&(e.dependenciesState_=1,e.onBecomeStale_())}))}var dn=class{constructor(e=`Reaction@`+u(),t,n,r){this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=-1,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.removeAbortListener_=void 0,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}get isDisposed(){return E(this.flags_,1)}set isDisposed(e){this.flags_=D(this.flags_,1,e)}get isScheduled(){return E(this.flags_,2)}set isScheduled(e){this.flags_=D(this.flags_,2,e)}get isTrackPending(){return E(this.flags_,4)}set isTrackPending(e){this.flags_=D(this.flags_,4,e)}get isRunning(){return E(this.flags_,8)}set isRunning(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,P.pendingReactions.push(this),mn())}runReaction_(){if(!this.isDisposed){nn(),this.isScheduled=!1;let e=P.trackingContext;if(P.trackingContext=this,Mt(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&vn()&&yn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}P.trackingContext=e,rn()}}track(e){if(this.isDisposed)return;nn();let t=vn(),n;t&&(n=Date.now(),bn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=P.trackingContext;P.trackingContext=this;let i=It(this,e,void 0);P.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&zt(this),jt(i)&&this.reportExceptionInDerivation_(i.cause),t&&Sn({time:Date.now()-n}),rn()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(P.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;P.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),vn()&&yn({type:`error`,name:this.name_,message:t,error:``+e}),P.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(nn(),zt(this),rn())}}getDisposer_(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.removeAbortListener_=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[O]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function fn(e){return P.globalReactionErrorHandlers.push(e),()=>{let t=P.globalReactionErrorHandlers.indexOf(e);t>=0&&P.globalReactionErrorHandlers.splice(t,1)}}let pn=e=>e();function mn(){P.inBatch>0||P.isRunningReactions||pn(hn)}function hn(){P.isRunningReactions=!0;let e=P.pendingReactions,t=0;for(;e.length>0;){++t===100&&(console.error(`Reaction doesn't converge to a stable state after 100 iterations. Probably there is a cycle in the reactive function: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].runReaction_()}P.isRunningReactions=!1}let gn=b(`Reaction`,dn);function _n(e){let t=pn;pn=n=>e(()=>t(n))}function vn(){return!!P.spyListeners.length}function yn(e){if(!P.spyListeners.length)return;let t=P.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function bn(e){yn(r({},e,{spyReportStart:!0}))}let xn={type:`report-end`,spyReportEnd:!0};function Sn(e){yn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):xn)}function Cn(e){return P.spyListeners.push(e),d(()=>{P.spyListeners=P.spyListeners.filter(t=>t!==e)})}let F=`action`,wn=`autoAction`,Tn=`<unnamed action>`,En=xe(F),Dn=xe(`action.bound`,{bound:!0}),On=xe(wn,{autoAction:!0}),kn=xe(`autoAction.bound`,{autoAction:!0,bound:!0});function An(e){return Je(e,we)}function jn(e){return function(t,r){if(r&&typeof r.kind==`string`)return we(e?On:En,t,r);if(p(t))return yt(t.name||Tn,t,e);if(p(r))return yt(t,r,e);if(m(t))return An(xe(e?wn:F,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Mn=jn(!1);r(Mn,En);let Nn=jn(!0);r(Nn,On);let Pn=An(Dn),Fn=An(kn);function In(e){return bt(e.name||Tn,!1,e,this,void 0)}function Ln(e){return p(e)&&e.isMobxAction===!0}function Rn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),Ln(e)&&n(`Autorun does not accept actions since actions are untrackable`);let i=t?.name??(e.name||`Autorun@`+u()),a=!t.scheduler&&!t.delay,o;if(a)o=new dn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Bn(t),n=!1;o=new dn(i,()=>{n||(n=!0,e(()=>{n=!1,o.isDisposed||o.track(s)}))},t.onError,t.requiresObservable)}function s(){e(o)}return t!=null&&(r=t.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}let zn=e=>e();function Bn(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):zn}function Vn(e,t,r=c){var i;(!p(e)||!p(t))&&n(`First and second argument to reaction should be functions`),g(r)||n(`Third argument of reactions should be an object`);let a=r.name??`Reaction@`+u(),o=Mn(a,r.onError?Hn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Bn(r),d=!0,f=!1,m,h=r.equals||de,_=new dn(a,()=>{d||s?v():f||(f=!0,l(v))},r.onError,r.requiresObservable);function v(){if(f=!1,_.isDisposed)return;let t=!1,n=m;_.track(()=>{let n=Ct(!1,()=>e(_));t=d||!h(m,n),m=n}),(d&&r.fireImmediately||!d&&t)&&o(m,n,_),d=!1}return r!=null&&(i=r.signal)!=null&&i.aborted||_.schedule_(),_.getDisposer_(r?.signal)}function Hn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Un(e,t,n){return Gn(`onBO`,e,t,n)}function Wn(e,t,n){return Gn(`onBUO`,e,t,n)}function Gn(e,t,n,r){let i=typeof r==`function`?Di(t,n):Di(t),a=p(r)?r:n,o=`${e}L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){let e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}let Kn=`always`;function qn(e){e.isolateGlobalState===!0&&Jt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Kn?Kn:t===`observed`;P.enforceActions=e,P.allowStateChanges=!(e===!0||e===Kn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(P[t]=!!e[t])}),P.allowStateReads=!P.observableRequiresReaction,P.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&_n(e.reactionScheduler)}function Jn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),mi(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(yr(t)||yr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=re(t);return Ai(()=>{let t=R(e,i)[O];ee(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Yn(e,t){return Xn(Di(e,t))}function Xn(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=$n(e.observing_).map(Xn)),t}function Zn(e,t){return Qn(Di(e,t))}function Qn(e){let t={name:e.name_};return Zt(e)&&(t.observers=Array.from(Qt(e),Qn)),t}function $n(e){return Array.from(new Set(e))}let er=0;var tr=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function nr(e){return e instanceof tr}function rr(e){return Je(e,ke)}let ir=k(`flow`),ar=k(`flow.bound`,{bound:!0}),or=r(function(e,t){if(t&&typeof t.kind==`string`)return ke(ir,e,t);arguments.length!==1&&n(`Flow expects single argument with generator function`);let r=e,i=r.name||`<unnamed flow>`,a=function(){let e=this,t=arguments,n=++er,a=Mn(`${i} - runid: ${n} - init`,r).apply(e,t),o,s,c=new Promise(function(e,t){let r=0;o=t;function c(e){s=void 0;let o;try{o=Mn(`${i} - runid: ${n} - yield ${r++}`,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;let o;try{o=Mn(`${i} - runid: ${n} - yield ${r++}`,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(p(n?.then)){n.then(u,t);return}return n.done?e(n.value):(s=Promise.resolve(n.value),s.then(c,l))}c(void 0)});return c.cancel=Mn(`${i} - runid: ${n} - cancel`,function(){try{s&&cr(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),cr(t),o(new tr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},ir),sr=rr(ar);function cr(e){p(e.cancel)&&e.cancel()}function lr(e){return e}function ur(e){return e?.isMobXFlow===!0}function dr(e,t,r){let i;if(mi(e)||ui(e)||Dt(e))i=Oi(e);else if(wi(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=Oi(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 fr(e,t,n){return p(n)?mr(e,t,n):pr(e,t)}function pr(e,t){return Gr(Oi(e),t)}function mr(e,t,n){return Gr(Oi(e,t),n)}function hr(e,t){var n;if(t===void 0)return kt(e);if(wi(e)===!1)return!1;let r=e[O];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?kt(Di(e,t)):!1}function gr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):hr(e)}function _r(e,t){return m(t)?hr(e,t):n(`isComputed expected a property name as second argument`)}function vr(e,t){if(!e)return!1;if(t!==void 0){if(mi(e)||ui(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(wi(e)){var r,i;let n=e[O];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return wi(e)||!!e[O]||oe(e)||gn(e)||kt(e)}function yr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),vr(e)}function br(e,t){return m(t)?vr(e,t):n(`expected a property name as second argument`)}function xr(e){if(wi(e))return e[O].keys_();if(mi(e)||yi(e))return Array.from(e.keys());if(ui(e))return e.map((e,t)=>t);n(5)}function Sr(e){if(wi(e))return xr(e).map(t=>e[t]);if(mi(e))return xr(e).map(t=>e.get(t));if(yi(e))return Array.from(e.values());if(ui(e))return e.slice();n(6)}function Cr(e){if(wi(e))return xr(e).map(t=>[t,e[t]]);if(mi(e))return xr(e).map(t=>[t,e.get(t)]);if(yi(e))return Array.from(e.entries());if(ui(e))return e.map((e,t)=>[t,e]);n(7)}function wr(e,t,r){if(arguments.length===2&&!yi(e)){nn();let n=t;try{for(let t in n)wr(e,t,n[t])}finally{rn()}return}wi(e)?e[O].set_(t,r):mi(e)?e.set(t,r):yi(e)?e.add(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),nn(),t>=e.length&&(e.length=t+1),e[t]=r,rn()):n(8)}function Tr(e,t){wi(e)?e[O].delete_(t):mi(e)||yi(e)?e.delete(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function Er(e,t){if(wi(e))return e[O].has_(t);if(mi(e)||yi(e))return e.has(t);if(ui(e))return t>=0&&t<e.length;n(10)}function Dr(e,t){if(Er(e,t)){if(wi(e))return e[O].get_(t);if(mi(e))return e.get(t);if(ui(e))return e[t];n(11)}}function Or(e,t,r){if(wi(e))return e[O].defineProperty_(t,r);n(39)}function kr(e){if(wi(e))return e[O].ownKeys_();n(38)}function Ar(e,t,n,r){return p(n)?Mr(e,t,n,r):jr(e,t,n)}function jr(e,t,r){let i=Oi(e);if(ui(e))r&&t({observableKind:`array`,object:i.proxy_,debugObjectName:i.atom_.name_,type:`splice`,index:0,added:i.values_.slice(),addedCount:i.values_.length,removed:[],removedCount:0});else if(mi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(yi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(wi(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Nr(i,t,r);return Jr(i,t)}function Mr(e,t,n,r){return Nr(Oi(e,t),n,r)}function Nr(e,t,n){if(kt(e)){let r=!0,i;return Rn(()=>{let a=e.get();if(!r||n){let n=Vt();t({observableKind:`computed`,debugObjectName:e.name_,type:ti,object:e,newValue:a,oldValue:i}),Ht(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ti,newValue:e.value_,oldValue:void 0}),Jr(e,t)}function Pr(e,t,n){return e.set(t,n),n}function Fr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!yr(e))return e;if(Dt(e)||kt(e))return Fr(e.get(),t);if(t.has(e))return t.get(e);if(ui(e)){let n=Pr(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Fr(e,t)}),n}if(yi(e)){let n=Pr(t,e,new Set);return e.forEach(e=>{n.add(Fr(e,t))}),n}if(mi(e)){let n=Pr(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Fr(e,t))}),n}else{let n=Pr(t,e,{});return kr(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Fr(e[r],t))}),n}}function Ir(e,t){return t&&n(`toJS no longer supports options`),Fr(e,new Map)}function Lr(e,t=void 0){nn();try{return e.apply(t)}finally{rn()}}function Rr(e,t,n){return arguments.length===1||t&&typeof t==`object`?Br(e,t):zr(e,t,n||{})}function zr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[O].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=yt(n.name+`-effect`,t);var a=Rn(t=>{Ct(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function Br(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=zr(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 Vr(e){return e[O]}let Hr={has(e,t){return Vr(e).has_(t)},get(e,t){return Vr(e).get_(t)},set(e,t,n){return m(t)?Vr(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Vr(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Vr(e).defineProperty_(t,n)??!0},ownKeys(e){return Vr(e).ownKeys_()},preventExtensions(e){n(13)}};function Ur(e,t){var n;return e=R(e,t),(n=e[O]).proxy_??(n.proxy_=new Proxy(e,Hr))}function Wr(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function Gr(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 Kr(e,t){let r=Vt();try{let r=[...e.interceptors_||[]];for(let e=0,i=r.length;e<i&&(t=r[e](t),t&&!t.type&&n(14),t);e++);return t}finally{Ht(r)}}function qr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Jr(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 Yr(e,t){let n=Vt(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ht(n)}}function Xr(e,t,n){return Ai(()=>{let r=R(e,n)[O];ee(t).forEach(e=>$r(r,e,t[e]))}),e}let Zr=Symbol(`mobx-keys`);function Qr(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),wi(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Jn(e,e,t,r):(Ai(()=>{let n=R(e,r)[O];if(!e[Zr]){let t=Object.getPrototypeOf(e),n=new Set([...ee(e),...ee(t)]);n.delete(`constructor`),n.delete(O),v(t,Zr,n)}e[Zr].forEach(e=>$r(n,e,t&&e in t?t[e]:!0))}),e)}function $r(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;Ei(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)}Ti(e,r,t)}let ei=`splice`,ti=`update`,ni={get(e,t){let n=e[O];return t===O?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):T(ai,t)?ai[t]:e[t]},set(e,t,n){let r=e[O];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var ri=class{constructor(e=`ObservableArray@`+u(),t,n){this.owned_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=n,this.atom_=new ae(e),this.enhancer_=(n,r)=>t(n,r,e+`[..]`)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}dehanceValues_(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}getArrayLength_(){return this.atom_.reportObserved(),this.values_.length}setArrayLength_(e){(!Number.isInteger(e)||e<0)&&n(40,e);let t=this.values_.length;if(e!==t)if(e>t){let n=Array.from({length:e-t});this.spliceWithArray_(t,0,n)}else this.spliceWithArray_(e,t-e)}updateArrayLength_(e,t){e!==this.lastKnownLength_&&n(16),this.lastKnownLength_+=t}spliceWithArray_(e,t,n){Pt(this.atom_);let r=this.values_.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=s),Wr(this)){let r=Kr(this,{object:this.proxy_,type:ei,index:e,removedCount:t,added:n});if(!r)return s;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.enhancer_(e,void 0));{let e=n.length-t;this.updateArrayLength_(r,e)}let i=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,i),this.dehanceValues_(i)}spliceItemsIntoValues_(e,t,n){if(n.length<1e4)return this.values_.splice(e,t,...n);{let r=this.values_.slice(e,e+t),i=this.values_.slice(e+t);this.values_.length+=n.length-t;for(let t=0;t<n.length;t++)this.values_[e+t]=n[t];for(let t=0;t<i.length;t++)this.values_[e+n.length+t]=i[t];return r}}notifyArrayChildUpdate_(e,t,n){let r=!this.owned_&&vn(),i=qr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ti,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&bn(a),this.atom_.reportChanged(),i&&Yr(this,a),r&&Sn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&vn(),i=qr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:ei,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&bn(a),this.atom_.reportChanged(),i&&Yr(this,a),r&&Sn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Pt(this.atom_);let r=n[e];if(Wr(this)){let n=Kr(this,{type:ti,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 ii(e,t,n=`ObservableArray@`+u(),r=!1){return Ai(()=>{let i=new ri(n,t,r);y(i.values_,O,i);let a=new Proxy(i.values_,ni);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var ai={clear(){return this.splice(0)},replace(e){let t=this[O];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[O];switch(arguments.length){case 0:return[];case 1:return r.spliceWithArray_(e);case 2:return r.spliceWithArray_(e,t)}return r.spliceWithArray_(e,t,n)},spliceWithArray(e,t,n){return this[O].spliceWithArray_(e,t,n)},push(...e){let t=this[O];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[O].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[O];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return P.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){P.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[O],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};I(`at`,oi),I(`concat`,oi),I(`flat`,oi),I(`includes`,oi),I(`indexOf`,oi),I(`join`,oi),I(`lastIndexOf`,oi),I(`slice`,oi),I(`toString`,oi),I(`toLocaleString`,oi),I(`toSorted`,oi),I(`toSpliced`,oi),I(`with`,oi),I(`every`,si),I(`filter`,si),I(`find`,si),I(`findIndex`,si),I(`findLast`,si),I(`findLastIndex`,si),I(`flatMap`,si),I(`forEach`,si),I(`map`,si),I(`some`,si),I(`toReversed`,si),I(`reduce`,ci),I(`reduceRight`,ci);function I(e,t){typeof Array.prototype[e]==`function`&&(ai[e]=t(e))}function oi(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function si(e){return function(t,n){let r=this[O];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function ci(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}let li=b(`ObservableArrayAdministration`,ri);function ui(e){return h(e)&&li(e[O])}let di={},fi=`delete`;var pi=class{constructor(e,t=fe,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[O]=di,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,Ai(()=>{this.keysAtom_=se(`${this.name_}.keys()`),this.data_=new Map,this.hasMap_=new Map,e&&this.merge(e)})}has_(e){return this.data_.has(e)}has(e){if(!P.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new Et(this.has_(e),me,`${this.name_}.${te(e)}?`,!1);this.hasMap_.set(e,n),n.onBUOL=new Set([()=>this.hasMap_.delete(e)])}return t.get()}set(e,t){let n=this.has_(e);if(Wr(this)){let r=Kr(this,{type:n?ti:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this}delete(e){if(Pt(this.keysAtom_),Wr(this)&&!Kr(this,{type:fi,object:this,name:e}))return!1;if(this.has_(e)){let t=vn(),n=qr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:fi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&bn(r),Lr(()=>{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&&Yr(this,r),t&&Sn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=vn(),i=qr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ti,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&bn(a),n.setNewValue_(t),i&&Yr(this,a),r&&Sn()}}addValue_(e,t){Pt(this.keysAtom_),Lr(()=>{var n;let r=new Et(t,this.enhancer_,`${this.name_}.${te(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=vn(),r=qr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&bn(i),r&&Yr(this,i),n&&Sn()}get(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.keysAtom_.reportObserved(),this.data_.keys()}values(){let e=this,t=this.keys();return hi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return hi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return mi(e)&&(e=new Map(e)),Lr(()=>{g(e)?w(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):x(e)?(S(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){Lr(()=>{Bt(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return Lr(()=>{let t=gi(e),n=new Map,r=!1;for(let e of this.data_.keys())if(!t.has(e))if(this.delete(e))r=!0;else{let t=this.data_.get(e);n.set(e,t)}for(let[e,i]of t.entries()){let t=this.data_.has(e);if(this.set(e,i),this.data_.has(e)){let i=this.data_.get(e);n.set(e,i),t||(r=!0)}}if(!r)if(this.data_.size!==n.size)this.keysAtom_.reportChanged();else{let e=this.data_.keys(),t=n.keys(),r=e.next(),i=t.next();for(;!r.done;){if(r.value!==i.value){this.keysAtom_.reportChanged();break}r=e.next(),i=t.next()}}this.data_=n}),this}get size(){return this.keysAtom_.reportObserved(),this.data_.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},mi=b(`ObservableMap`,pi);function hi(e){return e[Symbol.toStringTag]=`MapIterator`,Ii(e)}function gi(e){if(x(e)||mi(e))return e;if(Array.isArray(e))return new Map(e);if(g(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}else return n(21,e)}let _i={};var vi=class{constructor(e,t=fe,n=`ObservableSet@`+u()){this.name_=void 0,this[O]=_i,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,this.enhancer_=(e,r)=>t(e,r,n),Ai(()=>{this.atom_=se(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){Lr(()=>{Bt(()=>{for(let e of this.data_.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.atom_.reportObserved(),this.data_.size}add(e){if(Pt(this.atom_),Wr(this)){let t=Kr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){Lr(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=vn(),n=qr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&bn(r),n&&Yr(this,r),t&&Sn()}return this}delete(e){if(Wr(this)&&!Kr(this,{type:fi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=vn(),n=qr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:fi,object:this,oldValue:e}:null;return t&&bn(r),Lr(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Yr(this,r),t&&Sn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return bi({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.atom_.reportObserved();let e=this,t=this.data_.values();return bi({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.dehanceValue_(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return yi(e)&&(e=new Set(e)),Array.isArray(e)||C(e)?Lr(()=>{let t=C(e)?e:new Set(e);if(t.size===0){this.clear();return}if(this.data_.size===0){t.forEach(e=>this.add(e));return}for(let e of this.data_.values())t.has(this.dehanceValue_(e))||this.delete(e);t.forEach(e=>this.add(e))}):e!=null&&n(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},yi=b(`ObservableSet`,vi);function bi(e){return e[Symbol.toStringTag]=`SetIterator`,Ii(e)}let xi=Object.create(null),Si=`remove`;var L=class{constructor(e,t=new Map,r,i=He){this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.lazyComputedKeys_=void 0,this.lazyObservableKeys_=void 0,this.target_=e,this.values_=t,this.name_=r,this.defaultAnnotation_=i,this.keysAtom_=new ae(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Ri(this.defaultAnnotation_)||n(`defaultAnnotation must be valid annotation`),this.appliedAnnotations_={}}getObservablePropValue_(e){return(this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e)).get()}materializeLazyComputed_(e){let t=this.lazyComputedKeys_?.get(e);if(!t)return;this.lazyComputedKeys_.delete(e),this.lazyComputedKeys_.size===0&&(this.lazyComputedKeys_=void 0);let n=t();return this.values_.set(e,n),n}materializeLazyObservable_(e){let t=this.lazyObservableKeys_?.get(e);if(!t)return;this.lazyObservableKeys_.delete(e),this.lazyObservableKeys_.size===0&&(this.lazyObservableKeys_=void 0);let n=t();return this.values_.set(e,n),n}setObservablePropValue_(e,t){let n=this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e);if(n instanceof Ot)return n.set(t),!0;if(Wr(this)){let n=Kr(this,{type:ti,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=qr(this),i=vn(),a=r||i?{type:ti,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&bn(a),n.setNewValue_(t),r&&Yr(this,a),i&&Sn()}return!0}get_(e){return P.trackingDerivation&&!T(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return T(this.target_,e)?this.values_.has(e)?this.setObservablePropValue_(e,t):n?Reflect.set(this.target_,e,t):(this.target_[e]=t,!0):this.extend_(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,n)}has_(e){if(!P.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new Et(e in this.target_,me,`${this.name_}.${te(e)}?`,!1),this.pendingKeys_.set(e,t)),t.get()}extend_(e,t,n,r=!1){if(n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);Ei(this,n,e);let i=n.extend_(this,e,t,r);return i&&Ti(this,n,e),i}defineProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Wr(this)){let n=Kr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:i}=n;t.value!==i&&(t=r({},t,{value:i}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else a(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{rn()}return!0}defineObservableProperty_(e,t,n,r=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Wr(this)){let n=Kr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=Ci(e),s={configurable:P.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,s))return!1}else a(this.target_,e,s);let c=new Et(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{rn()}return!0}defineComputedProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let r=this.delete_(e);if(!r)return r;if(Wr(this)&&!Kr(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=Ci(e),o={configurable:P.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,o))return!1}else a(this.target_,e,o);this.values_.set(e,new Ot(t)),this.notifyPropertyAddition_(e,void 0)}finally{rn()}return!0}delete_(e,t=!1){if(Pt(this.keysAtom_),!T(this.target_,e))return!0;if(Wr(this)&&!Kr(this,{object:this.proxy_||this.target_,name:e,type:Si}))return null;try{var n;nn();let r=qr(this),a=vn(),o=this.values_.get(e),s;if(!o&&(r||a)&&(s=i(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(delete this.appliedAnnotations_[e],o&&(this.values_.delete(e),o instanceof Et&&(s=o.value_),cn(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Si,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&bn(t),r&&Yr(this,t),a&&Sn()}}finally{rn()}return!0}notifyPropertyAddition_(e,t){var n;let r=qr(this),i=vn();if(r||i){let n=r||i?{type:`add`,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;i&&bn(n),r&&Yr(this,n),i&&Sn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),ee(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function R(e,t){if(t&&wi(e)&&n(`Options can't be provided for already observable objects.`),T(e,O))return Oi(e)instanceof L||n(`Cannot convert '${ki(e)}' into observable object:\nThe target is already observable of different type.\nExtending builtins is not supported.`),e;Object.isExtensible(e)||n(`Cannot make the designated object observable; it is not extensible`);let r=t?.name??`${g(e)?`ObservableObject`:e.constructor.name}@${u()}`;return v(e,O,new L(e,new Map,String(r),rt(t))),e}let z=b(`ObservableObjectAdministration`,L);function Ci(e){return xi[e]||(xi[e]={get(){return this[O].getObservablePropValue_(e)},set(t){return this[O].setObservablePropValue_(e,t)}})}function wi(e){return h(e)?z(e[O]):!1}function Ti(e,t,n){e.appliedAnnotations_[n]=t}function Ei(e,t,r){if(Ri(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!ve(t)&&T(e.appliedAnnotations_,r)){let i=`${e.name_}.${r.toString()}`,a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '${o}' to '${i}':\nThe field is already annotated with '${a}'.\nRe-annotating fields is not allowed.\nUse 'override' annotation for methods overridden by subclass.`)}}function Di(e,t){if(typeof e==`object`&&e){if(ui(e))return t!==void 0&&n(23),e[O].atom_;if(yi(e))return e.atom_;if(mi(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,ki(e)),r}if(wi(e)){if(!t)return n(26);let r=e[O],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,ki(e)),i}if(oe(e)||kt(e)||gn(e))return e}else if(p(e)&&gn(e[O]))return e[O];n(28)}function Oi(e,t){if(e||n(29),t!==void 0)return Oi(Di(e,t));if(oe(e)||kt(e)||gn(e)||mi(e)||yi(e))return e;if(e[O])return e[O];n(24,e)}function ki(e,t){let n;if(t!==void 0)n=Di(e,t);else if(Ln(e))return e.name;else n=wi(e)||mi(e)||yi(e)?Oi(e):Di(e);return n.name_}function Ai(e){let t=Vt(),n=wt(!0);nn();try{return e()}finally{rn(),Tt(n),Ht(t)}}let ji=o.toString;function Mi(e,t,n=-1){return Ni(e,t,n)}function Ni(e,t,n,r,i){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;let a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;let o=ji.call(e);if(o!==ji.call(t))return!1;switch(o){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++;break}e=Pi(e),t=Pi(t);let s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,r=t.constructor;if(n!==r&&!(p(n)&&n instanceof n&&p(r)&&r instanceof r)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];let c=r.length;for(;c--;)if(r[c]===e)return i[c]===t;if(r.push(e),i.push(t),s){if(c=e.length,c!==t.length)return!1;for(;c--;)if(!Ni(e[c],t[c],n-1,r,i))return!1}else{let a=Object.keys(e),o=a.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=a[s];if(!(T(t,o)&&Ni(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function Pi(e){return ui(e)?e.slice():x(e)||mi(e)||C(e)||yi(e)?Array.from(e.entries()):e}let Fi=globalThis.Iterator?.prototype||{};function Ii(e){return e[Symbol.iterator]=Li,r(Object.create(Fi),e)}function Li(){return this}function Ri(e){return e instanceof Object&&typeof e.annotationType_==`string`&&p(e.make_)&&p(e.extend_)}{let e=globalThis;[`Symbol`,`Map`,`Set`,`Proxy`].forEach(t=>{e[t]===void 0&&n(`MobX requires global '${t}' to be available or polyfilled`)})}typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Cn,extras:{getDebugName:ki},$mobx:O}),e.$mobx=O,e.FlowCancellationError=tr,e.ObservableMap=pi,e.ObservableSet=vi,e.Reaction=dn,e._allowStateChanges=Ct,e._allowStateChangesInsideComputed=In,e._allowStateReadsEnd=Ut,e._allowStateReadsStart=M,e._autoAction=Nn,e._autoActionBound=Fn,e._endAction=St,e._getAdministration=Oi,e._getGlobalState=Yt,e._interceptReads=dr,e._isComputingDerivation=Nt,e._resetGlobalState=Xt,e._startAction=xt,e.action=Mn,e.actionBound=Pn,e.autorun=Rn,e.compareDefault=de,e.compareIdentity=ce,e.compareShallow=ue,e.compareStructural=le,e.computed=j,e.computedStruct=mt,e.configure=qn,e.createAtom=se,e.defineProperty=Or,e.entries=Cr,e.extendObservable=Jn,e.flow=or,e.flowBound=sr,e.flowResult=lr,e.get=Dr,e.getAtom=Di,e.getDebugName=ki,e.getDependencyTree=Yn,e.getObserverTree=Zn,e.has=Er,e.intercept=fr,e.isAction=Ln,e.isBoxedObservable=Dt,e.isComputed=gr,e.isComputedProp=_r,e.isFlow=ur,e.isFlowCancellationError=nr,e.isObservable=yr,e.isObservableArray=ui,e.isObservableMap=mi,e.isObservableObject=wi,e.isObservableProp=br,e.isObservableSet=yi,e.keys=xr,e.makeAutoObservable=Qr,e.makeObservable=Xr,e.observable=A,e.observableDeep=lt,e.observableRef=st,e.observableShallow=ct,e.observableStruct=ut,e.observe=Ar,e.onBecomeObserved=Un,e.onBecomeUnobserved=Wn,e.onReactionError=fn,e.override=_e,e.ownKeys=kr,e.reaction=Vn,e.remove=Tr,e.runInAction=In,e.set=wr,e.spy=Cn,e.toJS=Ir,e.transaction=Lr,e.untracked=Bt,e.values=Sr,e.when=Rr})),Vv=we(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=zv():t.exports=Bv()}))();function Hv(e){if(Array.isArray(e))return Object.freeze(e.map(Hv));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]=Hv(r);return Object.freeze(t)}return e}function Uv(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 Wv(e){return typeof e==`string`?e:String(e)}function Gv(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 Kv(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 qv=class extends Error{constructor(e,t){super(t),this.variable=e}};function Jv(e){return e instanceof qv||e instanceof Error&&e.cause!==void 0&&Jv(e.cause)}var Yv=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?iy(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}},Xv=class extends Yv{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},Zv=class extends Yv{name=`EvalError`;kind=`EvalError`},Qv=class extends Zv{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=ay(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}},$v=class extends Zv{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}},ey=class extends Zv{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}},ty=class extends ey{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)}`}},ny=class extends Zv{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},ry=class extends Zv{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function iy(e,t){let n=e.split(`
|
|
57
|
+
`))}function Vg(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:o,failedConfigFile:s}=t,c=new U({bgcolor:i.bg,color:i.fg}),l=(e,t)=>new K(e,{style:t,end:``,overflow:`ignore`}),u=n>0?[l(`${n} more rows · `,c),o.kind===`file`?l(`open full text`,c.withLink(a(o.path).href)):l(`full text unavailable: ${Gp(o.reason)}`,c)]:[],d=s===null?[]:[l(`${u.length>0?` · `:``}open `,c),l(Gp(s),c.withLink(a(s).href))],f=[l(`↳ `,c),...u,...d.slice(0,-1)],p=f.reduce((e,t)=>e+t.cellLength,0),m=d.slice(-1).map(e=>e.truncate(Math.max(1,r.width-p),{mode:`middle`})),h=K.fromFragments([...f,...m]).truncate(r.width);return h.overflow=`ignore`,kg([h],r)}const Hg=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Ug(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function Wg(e,t,n=Hg){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=v.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Wg(e,r):[[v.relative(e,r).split(v.sep).join(`/`),Ug(r,i)]]})}function Gg(e){let t=ce.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Kg(e){return Gg(Wg(e,e))}const qg=[`Cargo.toml`,`Cargo.lock`,`src`];function Jg(e){return Gg(Wg(e,e,e=>qg.includes(e)))}const Yg=e=>e.slice(0,7);function Xg(e){let t=v.dirname(v.dirname(e));return s.existsSync(v.join(t,`src`))?t:null}function Zg(){let e=Qg();if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:Lt,digest:e}}function Qg(){return`fc0b46730e87b1a155583ac3167d92adb464626199f3467db79bd144d6aab835`}function $g(e){let t=JSON.parse(s.readFileSync(v.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${v.join(e,`package.json`)} has no version string`);return n}function e_(e,t){try{let n=Xg(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Kg(v.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:$g(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}var q=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const t_=new Map;function n_(e){let t=i_(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 r_(e,t){return e===`bar`?t:n_(e)}function i_(e){let t=t_.get(e);if(t!==void 0)return t;let n=Bc(e);return n===null?null:(t_.set(e,n),n)}function a_(e,t){return o_(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>Qc(e,t))}const o_=tm();function s_(e){let t=i_(e);return t===null?null:{kind:`decided`,name:e,value:t}}function c_(e,t,n){let r=s_(e);return r===null?(n(Ah(t,`palette`,`"${e}" names no installed theme${fh(e)}`)),u_()):r}function l_(e,t,n){return Sh(e,t,n,u_(),s_)}function u_(){return{kind:`decided`,name:ph,value:n_(ph)}}const d_=[`vertical`,`horizontal`],f_={vertical:`row`,horizontal:`cell`};function p_(e){return e.id??e.name}function m_(e){return[...__(e)].flatMap(e=>e.kind===`segment`?[p_(e)]:[])}function h_(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function g_(e,t){return e.opens===void 0?e:{...e,opens:{...e.opens,body:t(e.opens.body)}}}function*__(e){yield e;for(let t of x_(e))yield*__(t)}const v_=(e,t)=>`${e}.children[${t}]`,y_=e=>`${e}.opens.body`;function*b_(e,t){if(yield[e,t],e.kind===`container`)for(let[n,r]of e.children.entries())yield*b_(r,v_(t,n));else e.opens!==void 0&&(yield*b_(e.opens.body,y_(t)))}function x_(e){return e.kind===`container`?e.children:e.opens===void 0?[]:[e.opens.body]}const S_=[`shade`,`variation`,`style`];function C_(e){return e===void 0||`text`in e?`text`:`regex`in e?`regex`:`json`}const w_=[`ttl`,`watch_file`,`depends_on`,`key`,`never`];function T_(e){return e.kind===`file`||e.kind===`shell`}const E_=[`branch`,`sha`,`dirty`,`ahead`,`behind`,`stash`],D_=[`fail`,`ignore`];function O_(e){return e.missingData??`fail`}function*k_(e){for(let[t,n]of Object.entries(e.variables))n.kind===`state`&&(yield[t,n]);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))r.kind===`state`&&(yield[`${t}.${e}`,r])}const A_=`theme`,j_=`effect`,M_=[A_,j_];function N_(e){return{...e.settings,[A_]:{label:A_,domain:`theme`,default:e.palette??`bar`},[j_]:{label:j_,domain:Mh,default:`bar`}}}function P_(e){let t=e?.domain;return typeof t==`object`&&`min`in t?t:void 0}function F_(e,t){return Object.entries(e).flatMap(([n,r])=>{let i=P_(r)?.atLeast;if(i===void 0)return[];let a=t[n],o=t[i];return a>=o?[]:[{setting:n,message:`"${n}" (${a}) is below "${i}" (${o}) — ${r.label} must be at least ${e[i].label}`}]})}function I_(e,t){let{domain:n}=e;return n===`bool`?typeof t==`boolean`:n===`theme`?typeof t==`string`&&vh(t):`min`in n?typeof t==`number`&&Number.isInteger(t)&&t>=n.min&&t<=n.max:typeof t==`string`&&n.includes(t)}function L_(e){return String(e)}function R_(e,t){let{domain:n}=e;if(typeof n==`object`&&`min`in n)return eg(t,n)??void 0;let r=n===`bool`?t===`true`?!0:t===`false`?!1:t:t;return I_(e,r)?r:void 0}function z_(e,t,n,r){let i=e.settings?.[t]??n.default,a=e.drafts?.[t],o=a===void 0?null:r(a);return(o===null?void 0:R_(n,o))??i}function B_(e){let{domain:t}=e;return t===`bool`?`true or false`:t===`theme`?`"bar" (the bar's own theme) or an installed theme name`:`min`in t?`an integer from ${t.min} to ${t.max}`:`one of ${t.map(e=>JSON.stringify(e)).join(`, `)}`}const V_=[`left`,`center`,`right`],H_=[`right`,`left`,`middle`],U_=/^[A-Za-z_][A-Za-z0-9_]*$/;function W_(e){return`#${e+1}`}const G_={rows:{}};function K_(e){return`rows`in e}function q_(e){return Object.fromEntries(e.map((e,t)=>[W_(t),e]))}function J_(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:q_(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:q_([n])}}function Y_(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function X_(e){return K_(e)?Y_(e):e}function*Z_(e,t){if(!K_(e)){yield*b_(e,t);return}yield[Y_(e),t];for(let[n,r]of Object.entries(e.rows))yield*b_(r,`${t}.rows.${n}`)}function Q_(e,t){return K_(e)?{...t,...e,rows:{...t.rows,...e.rows}}:J_(e)}function $_(e){if(!K_(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const ev=`default`,tv={};function nv(e){return[...new Set([ev,...Object.keys(e)])]}function rv(e,t,n){return yh(void 0,e,t,ev,n)}function iv(e,t){let n={[ev]:tv,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${ev}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function av(e,t){let n=iv(e.presets,t).root??G_;return{node:Y_(Q_(n,e.root)),path:$_(n)?`presets.${t}.root`:`root`}}function ov(e,t){return{...e.globals,...iv(e.presets,t).globals}}const sv=new Map;function cv(e,t,n){sv.set(e,{permanent:!0,resolve:t,paletteOf:n})}cv(`themes`,()=>hh(),e=>n_(e));const lv=`placementThemes`;cv(lv,gh,(e,t)=>r_(e,t.palette)),cv(`endcaps`,()=>Ih),cv(`variations`,()=>Uh),cv(`shades`,()=>Kh),cv(`colorCompatibilities`,()=>Vh);function uv(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>a_(n.basePalette,e.styles[t])}],[`presets`,{members:nv(e.presets)}]])}function dv(e){return[...new Set([...sv.keys(),...e.keys()])]}function fv(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=sv.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(mv(e,t))}const pv=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function mv(e,t){let n=pv.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${dv(t).join(`, `)})`}const hv=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*gv(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 _v=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,vv=RegExp(`^(?:(\\$)(?:\\.(${_v}))?|\\.(${_v})?)(?=[\\s)]|$)`);function yv(e,t,n){let r=vv.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 bv=/^(\w+)\b\s*([\s\S]*)$/;function*xv(e,t){let n=[t];for(let r of gv(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=bv.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:yv(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(yv(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const Sv=/(?<![.$])\btemplate\s+$/;function*Cv(e,t,n){let r=0;for(let i of[...e.matchAll(hv)]){let a=i.index+i[0].length;Sv.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:yv(e.slice(a),t,n)}),r=a}}function*wv(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...xv(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...Cv(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 Tv=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${_v})`,`g`);function*Ev({code:e,dot:t,root:n}){let r=e.replace(hv,``);for(let e of[...r.matchAll(Tv)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function Dv(e,t){let n=new Map;for(let r of wv(e,t))for(let e of Ev(r))n.has(e)||n.set(e,r.via);return n}const Ov=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,kv={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*Av(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(hv)]){let o=e.slice(t,a.index),s=Ov.exec(o);if(s!==null)n=kv[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 jv(e,t){let n=new Map;for(let{code:r,via:i}of wv(e,t))for(let{name:e,site:t}of Av(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function Mv(e,t){return new Set([...Nv(e,t)].filter(e=>Object.hasOwn(t,e)))}function Nv(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of wv(e,t))for(let{name:e}of Cv(r,i,a))n.add(e);return n}function Pv(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 Fv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),Iv(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 Iv(e){return e.kind===`dropped`||(e.kind===`shell`||e.kind===`file`)&&C_(e.parse)===`json`}function Lv(e){let t=v.basename(e),n=v.dirname(e);for(;;){let r=Rv(n);if(r!==null)return{dir:r,name:t,leaf:n===v.dirname(e)};t=v.basename(n),n=v.dirname(n)}}function Rv(e){try{return s.statSync(e).isDirectory()?s.realpathSync(e):null}catch{return null}}var zv=we((e=>{function t(e,...t){throw Error(`[MobX] minified error nr: ${e}${t.length?` `+t.map(String).join(`,`):``}. See mobx.js.org/errors`)}function n(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function r(e){return typeof e==`function`}function i(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function a(e){return typeof e==`object`&&!!e}function o(e){if(!a(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=p(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===zt}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){Ft(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function l(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return a(e)&&!0===e[n]}}function u(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function d(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function f(e){return e===null?null:typeof e==`object`?``+e:e}function p(e,t){return It.hasOwnProperty.call(e,t)}function m(e,t){return!!(e&t)}function h(e,t,n){return n?e|=t:e&=~t,e}function g(e,t=Bt,n=Bt){let r=new Ut(e);return t!==Bt&&(r.onBOL=new Set([t])),n!==Bt&&(r.onBUOL=new Set([n])),r}function _(e,t){return Ot(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||$e(e)?e:Array.isArray(e)?an.array(e,{name:n}):o(e)?an.object(e,void 0,{name:n}):u(e)?an.map(e,{name:n}):d(e)?an.set(e,{name:n}):typeof e!=`function`||He(e)||Xe(e)?e:s(e)?Un(e):Fn(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:x,u:S}}function x(e,t,n,r){var i;return(i=this.i)!=null&&i.bound?this.u(e,t,n,!1)===null?0:1:r===e.h?this.u(e,t,n,!1)===null?0:2:He(n.value)?1:(Ft(r,t,w(e,this,t,n,!1)),2)}function S(e,t,n,r){let i=w(e,this,t,n);return e.l(t,i,r)}function C(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return _e(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return He(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(He(n)||(n=c(n)),(l=s.i)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),n):void t(43,s.t,String(a),i);var l}function w(e,t,n,r,i=F.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:_e(t.i?.name??n.toString(),c,(o=t.i?.autoAction)!=null&&o,(s=t.i)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function ee(e,t){return{t:e,i:t,o:te,u:ne}}function te(e,t,n,r){var i;return r===e.h?this.u(e,t,n,!1)===null?0:2:(i=this.i)!=null&&i.bound&&(!p(e.h,t)||!Xe(e.h[t]))&&this.u(e,t,n,!1)===null?0:Xe(n.value)?1:(Ft(r,t,re(e,0,0,n,!1,!1)),2)}function ne(e,t,n,r){let i=re(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function T(e,t,n){var r;let{name:i,addInitializer:a}=n;return Xe(t)||(t=Un(t)),(r=e.i)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function re(e,t,n,r,i,a=F.safeDescriptors){let{value:o}=r;return Xe(o)||(o=Un(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function E(e,t){return{t:e,i:t,o:D,u:ie}}function D(e,t,n){return this.u(e,t,n,!1)===null?0:1}function ie(e,t,n,r){return e.m(t,Nt({},this.i,{get:n.get,set:n.set}),r)}function O(e,t,n){function r(e){let n=Nt({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new _n(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=xt(this)[M],n=this,i=e.j.get(a);i instanceof _n&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[M],n=e.j.get(a);if(n instanceof _n&&n.derivation!==t){let e=s?.get(this);return e||(e=r(this),(s??=new WeakMap).set(this,e)),e.get()}return e._(a)}}function ae(e,t){return{t:e,i:t,o:oe,u:se}}function oe(e,t,n){return this.u(e,t,n,!1)===null?0:1}function se(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function ce(e,t,n){function r(e,t){let n=xt(e)[M];return(n.V??=new Map).set(o,()=>new hn(t,i.i?.A??v,`ObservableObject.${o.toString()}`,!1)),n}let i=e,{kind:a,name:o}=n;if(a===`accessor`)return{get(){return(this[M]??r(this,t.get.call(this)))._(o)},set(e){return(this[M]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function le(e){return{t:qt,i:e,o:ue,u:de}}function ue(e,t,n,r){var i,a,o;if(n.get)return ln.o(e,t,n,r);if(n.set){let i=He(n.set)?n.set:_e(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!F.safeDescriptors||e.p,set:i})===null?0:2:(Ft(r,t,{configurable:!0,set:i}),2)}if(r!==e.h&&typeof n.value==`function`)return s(n.value)?((o=this.i)!=null&&o.autoBind?Wn:Un).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?Ln:Fn).o(e,t,n,r);let c=!1===this.i?.deep?en:an;return typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function de(e,t,n,r){var i;return n.get?ln.u(e,t,n,r):n.set?e.l(t,{configurable:!F.safeDescriptors||e.p,set:_e(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.i?.deep?en:an).u(e,t,n,r))}function fe(e,t){return Nt(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function pe(e){return e||Jt}function me(e){return fe(e,ce)}function he(e){return!0===e.deep?v:!1===e.deep?y:(t=e.defaultDecorator)&&(n=(r=t.i)?.A)!=null?n:v;var t,n,r}function ge(e){return fe(e,O)}function _e(e,t,n=!1,r){function i(){return ve(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),pn&&(mn.value=e,Ft(i,`name`,mn)),i}function ve(e,t,n,r,i){let a=ye(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{be(a)}}function ye(e,t){let n=F.trackingDerivation,r=!t||!n;Me();let i=F.allowStateChanges;r&&k();let a={R:r,k:n,C:i,I:F.allowStateReads,P:!1,T:0,B:fn++,D:dn};return dn=a.B,a}function be(e){dn!==e.B&&t(30),dn=e.D,e.N!==void 0&&(F.suppressReactionErrors=!0),Ne(),e.R&&De(e.k),F.suppressReactionErrors=!1}function xe(e,t){let n=function(e){let t=F.allowStateChanges;return F.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){F.allowStateChanges=e})(n)}}function Se(e){return e instanceof yn}function Ce(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=k(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(vn(r)){if(F.disableErrorBoundaries)r.get();else try{r.get()}catch{return De(t),!0}if(e.K===2)return De(t),!0}}return Oe(e),De(t),!1}}}function we(e,t,n){Oe(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++F.runId;let r=F.trackingDerivation,i;if(F.trackingDerivation=e,F.inBatch++,!0===F.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new yn(e)}return F.inBatch--,F.trackingDerivation=r,function(e){let t=e.L,n=e.L=e.$,r=0,i=0,a=e.W;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.K>r&&(r=t.K)}for(n.length=i,e.$=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&Ae(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,ke(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function Te(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Ae(t[n],e);e.K=-1}function Ee(e){let t=k();try{return e()}finally{De(t)}}function k(){let e=F.trackingDerivation;return F.trackingDerivation=null,e}function De(e){F.trackingDerivation=e}function Oe(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function ke(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Ae(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&je(e))}function je(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,F.pendingUnobservations.push(e))}function Me(){F.inBatch++}function Ne(){--F.inBatch===0&&(Le(),!F.isRunningUnobservations&&F.pendingUnobservations.length>0&&function(){F.isRunningUnobservations=!0;try{let e=F.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,n.H&&n.H.size!==0||(n.H=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof _n&&n.G())}F.pendingUnobservations=[]}finally{F.isRunningUnobservations=!1}}())}function Pe(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Pe))}function Fe(e){let t=F.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&F.inBatch>0&&je(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&F.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Ie(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(e=>{e.K===0&&e.q(),e.K=2}))}function Le(){F.inBatch>0||F.isRunningReactions||En(Re)}function Re(){F.isRunningReactions=!0;let e=F.pendingReactions,t=0;for(;e.length>0;){++t===Tn&&(console.error(`[mobx] cycle in reaction: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].X()}F.isRunningReactions=!1}function ze(e){return fe(e,C)}function Be(e){return function(t,n){return n&&typeof n.kind==`string`?C(e?Mn:An,t,n):r(t)?_e(t.name||`<unnamed action>`,t,e):r(n)?_e(t,n,e):i(t)?ze(b(e?kn:On,{name:t,autoAction:e})):void 0}}function Ve(e){return ve(0,!1,e,this,void 0)}function He(e){return r(e)&&!0===e.isMobxAction}function Ue(e,t=Rt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=We(t),r=!1;a=new wn(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new wn(i,function(){this.track(n)},t.onError,t.requiresObservable);return t!=null&&(r=t.signal)!=null&&r.aborted||a.Y(),a.Z(t?.signal)}function We(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Rn}function Ge(e,t,n,i){let a=typeof i==`function`?wt(t,n):wt(t),o=r(i)?i:n,s=`${e}L`;return a[s]?a[s].add(o):a[s]=new Set([o]),function(){let e=a[s];e&&(e.delete(o),e.size===0&&delete a[s])}}function Ke(e,t,n,r){let i=Ht(t);return Dt(()=>{let t=xt(e,r)[M];Vt(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function qe(e){let t={name:e.tt};var n;return e.L&&e.L.length>0&&(t.dependencies=(n=e.L,Array.from(new Set(n))).map(qe)),t}function Je(e){let t={name:e.tt};return function(e){return!!e.H&&e.H.size>0}(e)&&(t.observers=Array.from(function(e){return e.H??new Set}(e),Je)),t}function Ye(e){r(e.cancel)&&e.cancel()}function Xe(e){return!0===e?.isMobXFlow}function Ze(e,t){var n;if(t===void 0)return vn(e);if(!1===Ct(e))return!1;let r=e[M];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?vn(wt(e,t)):!1}function Qe(e,t){if(!e)return!1;if(t!==void 0){if(Ct(e)){var n,r;let i=e[M];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return Ct(e)||!!e[M]||Wt(e)||Dn(e)||vn(e)}function $e(e){return Qe(e)}function et(e){return Ct(e)?e[M].nt():nr(e)||ar(e)?Array.from(e.keys()):vt(e)?e.map((e,t)=>t):void t(5)}function tt(e,n){return Ct(e)?e[M].et(n):nr(e)||ar(e)?e.has(n):vt(e)?n>=0&&n<e.length:void t(10)}function nt(e){if(Ct(e))return e[M].it();t(38)}function rt(e,t,n){if(vn(e)){let r,i=!0;return Ue(()=>{let a=e.get();if(!i||n){let n=k();t({observableKind:`computed`,debugObjectName:e.tt,type:Jn,object:e,newValue:a,oldValue:r}),De(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Jn,newValue:e.rt,oldValue:void 0}),ft(e,t)}function it(e,t,n){return e.set(t,n),n}function at(e,t){if(typeof e!=`object`||!e||e instanceof Date||!$e(e))return e;if(gn(e)||vn(e))return at(e.get(),t);if(t.has(e))return t.get(e);if(vt(e)){let n=it(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=at(e,t)}),n}if(ar(e)){let n=it(t,e,new Set);return e.forEach(e=>{n.add(at(e,t))}),n}if(nr(e)){let n=it(t,e,new Map);return e.forEach((e,r)=>{n.set(r,at(e,t))}),n}{let n=it(t,e,{});return nt(e).forEach(r=>{It.propertyIsEnumerable.call(e,r)&&(n[r]=at(e[r],t))}),n}}function ot(e,t){Me();try{return e.apply(t)}finally{Ne()}}function st(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[M].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=_e(`When-effect`,t);var a=Ue(t=>{xe(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function ct(e){return e[M]}function lt(e){return e.st!==void 0&&e.st.length>0}function ut(e,t){let r=e.st;return r?r.push(t):r=e.st=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function A(e,n){let r=k();try{let r=[...e.st||[]];for(let e=0,i=r.length;e<i&&((n=r[e](n))&&!n.type&&t(14),n);e++);return n}finally{De(r)}}function dt(e){return e.ot!==void 0&&e.ot.length>0}function ft(e,t){let r=e.ot;return r?r.push(t):r=e.ot=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function pt(e,t){let n=k(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);De(n)}}function mt(e,n,r){if(!0===r&&(r=e.ut),!1===r)return;n in e.h||t(1,r.t,`${e.tt}.${n.toString()}`);let i=e.h;for(;i&&i!==It;){let t=Pt(i,n);if(t){let a=r.o(e,n,t,i);if(a===0)return;if(a===1)break}i=Object.getPrototypeOf(i)}}function j(e,t){typeof Array.prototype[e]==`function`&&(Zn[e]=t(e))}function ht(e){return function(){let t=this[M];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function gt(e){return function(t,n){let r=this[M];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function _t(e){return function(){let t=this[M];t.ct.reportObserved();let n=t.ht(t.j),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}function vt(e){return a(e)&&Qn(e[M])}function yt(e){return e[Symbol.toStringTag]=`MapIterator`,jt(e)}function bt(e){return e[Symbol.toStringTag]=`SetIterator`,jt(e)}function xt(e,t){if(p(e,M))return e;let n=t?.name??`ObservableObject`;return c(e,M,new cr(e,new Map,String(n),function(e){return e?e.defaultDecorator??function(e){let t=!1!==e.deep,n=!!e.autoBind,r=!t|(n?2:0);return P[r]??(P[r]=le({deep:t,autoBind:n}))}(e):void 0}(t))),e}function St(e){return or[e]||(or[e]={get(){return this[M]._(e)},set(t){return this[M].M(e,t)}})}function Ct(e){return!!a(e)&&lr(e[M])}function wt(e,n){if(typeof e==`object`&&e){if(vt(e))return n!==void 0&&t(23),e[M].ct;if(ar(e))return e.ct;if(nr(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,Et(e)),r}if(Ct(e)){if(!n)return t(26);let r=e[M],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,Et(e)),i}if(Wt(e)||vn(e)||Dn(e))return e}else if(r(e)&&Dn(e[M]))return e[M];t(28)}function Tt(e,n){return e||t(29),n===void 0?Wt(e)||vn(e)||Dn(e)||nr(e)||ar(e)?e:e[M]?e[M]:void t(24,e):Tt(wt(e,n))}function Et(e,t){let n;if(t!==void 0)n=wt(e,t);else{if(He(e))return e.name;n=Ct(e)||nr(e)||ar(e)?Tt(e):wt(e)}return n.tt}function Dt(e){let t=k();Me();try{return e()}finally{Ne(),De(t)}}function Ot(e,t,n=-1){return kt(e,t,n)}function kt(e,t,n,i,a){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!=e)return t!=t;let o=typeof e;if(o!==`function`&&o!==`object`&&typeof t!=`object`)return!1;let s=ur.call(e);if(s!==ur.call(t))return!1;switch(s){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++}e=At(e),t=At(t);let c=s===`[object Array]`;if(!c){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,i=t.constructor;if(n!==i&&!(r(n)&&n instanceof n&&r(i)&&i instanceof i)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),a||=[];let l=(i||=[]).length;for(;l--;)if(i[l]===e)return a[l]===t;if(i.push(e),a.push(t),c){if(l=e.length,l!==t.length)return!1;for(;l--;)if(!kt(e[l],t[l],n-1,i,a))return!1}else{let r=Object.keys(e),o=r.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=r[s];if(!p(t,o)||!kt(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function At(e){return vt(e)?e.slice():u(e)||nr(e)||d(e)||ar(e)?Array.from(e.entries()):e}function jt(e){return e[Symbol.iterator]=Mt,Nt(Object.create(dr),e)}function Mt(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let Nt=Object.assign,Pt=Object.getOwnPropertyDescriptor,Ft=Object.defineProperty,It=Object.prototype,Lt=[];Object.freeze(Lt);let Rt={};Object.freeze(Rt);let zt=Object.toString(),Bt=()=>{},Vt=Reflect.ownKeys,Ht=Object.getOwnPropertyDescriptors,M=Symbol(`mobx administration`);var Ut=class{constructor(e=`Atom`){this.tt=void 0,this.yt=0,this.H=null,this.J=0,this.F=-1,this.onBOL=void 0,this.onBUOL=void 0,this.tt=e}get isBeingObserved(){return m(this.yt,1)}set isBeingObserved(e){this.yt=h(this.yt,1,e)}get isPendingUnobservation(){return m(this.yt,2)}set isPendingUnobservation(e){this.yt=h(this.yt,2,e)}get diffValue(){return+!!m(this.yt,4)}set diffValue(e){this.yt=h(this.yt,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return Fe(this)}reportChanged(){Me(),Ie(this),Ne()}toString(){return this.tt}};let Wt=l(`Atom`,Ut),Gt=Object.is,Kt={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},qt=`true`,N=le(),P=[N],Jt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Jt);let Yt=ae(`observable`),Xt=ae(`observable.ref`,{A:y}),Zt=ae(`observable.shallow`,{A:function(e,t,n){return e==null||Ct(e)||vt(e)||nr(e)||ar(e)?e:Array.isArray(e)?an.array(e,{name:n,deep:!1}):o(e)?an.object(e,void 0,{name:n,deep:!1}):u(e)?an.map(e,{name:n,deep:!1}):d(e)?an.set(e,{name:n,deep:!1}):void 0}}),Qt=ae(`observable.struct`,{A:function(e,t){return Ot(e,t)?t:e}}),$t={box(e,t){let n=pe(t);return new hn(e,he(n),n.name,!0,n.equals)},array(e,t){let n=pe(t);return function(e,t,n=`ObservableArray`,r=!1){return Dt(()=>{let i=new Xn(n,t,r);Ft(i.j,M,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Yn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,he(n),n.name)},map(e,t){let n=pe(t);return new tr(e,he(n),n.name)},set(e,t){let n=pe(t);return new ir(e,he(n),n.name)},object:(e,t,n)=>Dt(()=>Ke(function(e,t){var n;return(n=(e=xt(e,t))[M]).v??(n.v=new Proxy(e,Gn))}({},n),e,t))},en=me(Xt),tn=me(Zt),nn=me(Yt),rn=me(Qt);var an=Nt(function(e,t,n){return t&&typeof t.kind==`string`?ce(Yt,e,t):$e(e)?e:o(e)?an.object(e,t,n):Array.isArray(e)?an.array(e,t):u(e)?an.map(e,t):d(e)?an.set(e,t):typeof e==`object`&&e?e:an.box(e,t)},Yt,$t);let on=`computed`,sn=E(on),cn=ge(E(`computed.struct`,{equals:_})),ln=function(e,t){if(t&&typeof t.kind==`string`)return O(sn,e,t);if(o(e))return ge(E(on,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new _n(n)};var un;Nt(ln,sn);let dn=0,fn=1,pn=(un=Pt(()=>{},`name`)?.configurable)!=null&&un,mn={value:`action`,configurable:!0,writable:!1,enumerable:!1};var hn=class extends Ut{constructor(e,t,n=`ObservableValue`,r=!0,i=Gt){super(n),this.A=void 0,this.tt=void 0,this.xt=void 0,this.gt=!1,this.st=void 0,this.ot=void 0,this.rt=void 0,this.dehancer=void 0,this.A=t,this.tt=n,this.xt=i,this.rt=t(e,void 0,n)}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){(e=this.jt(e))!==F.UNCHANGED&&this.Ot(e)}jt(e){if(lt(this)){let t=A(this,{object:this,type:Jn,newValue:e});if(!t)return F.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?F.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),dt(this)&&pt(this,{type:Jn,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.rt)}raw(){return this.rt}toJSON(){return this.get()}toString(){return`${this.tt}[${this.rt}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let gn=l(`ObservableValue`,hn);var _n=class{constructor(e){this.K=-1,this.L=[],this.$=null,this.H=null,this.U=0,this.J=0,this.F=0,this.W=0,this.rt=new yn(null),this.tt=void 0,this._t=void 0,this.yt=0,this.derivation=void 0,this.St=void 0,this.At=void 0,this.xt=void 0,this.Vt=void 0,this.Mt=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||t(31),this.derivation=e.get,this.tt=e.name||`ComputedValue`,e.set&&(this.St=_e(`ComputedValue-setter`,e.set)),this.xt=e.equals||Gt,this.At=e.context,this.Vt=e.requiresReaction,this.Mt=!!e.keepAlive}q(){(function(e){var t;e.F===0&&(e.F=1,(t=e.H)==null||t.forEach(e=>{e.K===0&&(e.K=1,e.q())}))})(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return m(this.yt,1)}set isComputing(e){this.yt=h(this.yt,1,e)}get isRunningSetter(){return m(this.yt,2)}set isRunningSetter(e){this.yt=h(this.yt,2,e)}get isBeingObserved(){return m(this.yt,4)}set isBeingObserved(e){this.yt=h(this.yt,4,e)}get isPendingUnobservation(){return m(this.yt,8)}set isPendingUnobservation(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}get(){if(this.isComputing&&t(32,this.tt,this.derivation),F.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Fe(this),Ce(this)){let e=F.trackingContext;e||!this.Mt&&!this.isBeingObserved||(F.trackingContext=this),this.trackAndCompute()&&function(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(t=>{t.K===1?t.K=2:t.K===0&&(e.F=0)}))}(this),F.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Pe)}else Ce(this)&&(this.Nt(),Me(),this.rt=this.Rt(!1),Ne());let e=this.rt;if(Se(e))throw e.cause;return e}set(e){if(this.St){this.isRunningSetter&&t(33,this.tt),this.isRunningSetter=!0;try{this.St.call(this.At,e)}finally{this.isRunningSetter=!1}}else t(34,this.tt)}trackAndCompute(){let e=this.rt,t=this.K===-1,n=this.Rt(!0),r=t||Se(e)||Se(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=we(this,this.derivation,this.At);else if(!0===F.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new yn(e)}return this.isComputing=!1,t}G(){this.Mt||(Te(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let vn=l(`ComputedValue`,_n);var yn=class{constructor(e){this.cause=void 0,this.cause=e}};let bn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var xn=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let Sn=!0,Cn=!1,F=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Sn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Sn=!1),Sn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new xn):(setTimeout(()=>{Cn||t(35)},1),new xn)}();var wn=class{constructor(e=`Reaction`,t,n,r){this.tt=void 0,this.Et=void 0,this.kt=void 0,this.Ct=void 0,this.L=[],this.$=[],this.K=-1,this.U=0,this.W=0,this.yt=0,this.It=void 0,this.tt=e,this.Et=t,this.kt=n,this.Ct=r}get isDisposed(){return m(this.yt,1)}set isDisposed(e){this.yt=h(this.yt,1,e)}get isScheduled(){return m(this.yt,2)}set isScheduled(e){this.yt=h(this.yt,2,e)}get isTrackPending(){return m(this.yt,4)}set isTrackPending(e){this.yt=h(this.yt,4,e)}get isRunning(){return m(this.yt,8)}set isRunning(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}q(){this.Y()}Y(){this.isScheduled||(this.isScheduled=!0,F.pendingReactions.push(this),Le())}X(){if(!this.isDisposed){Me(),this.isScheduled=!1;let e=F.trackingContext;if(F.trackingContext=this,Ce(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}F.trackingContext=e,Ne()}}track(e){if(this.isDisposed)return;Me(),this.isRunning=!0;let t=F.trackingContext;F.trackingContext=this;let n=we(this,e,void 0);F.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Te(this),Se(n)&&this.Pt(n.cause),Ne()}Pt(e){if(this.kt)this.kt(e,this);else{if(F.disableErrorBoundaries)throw e;F.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),F.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(Me(),Te(this),Ne()))}Z(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.It=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[M]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let Tn=100,En=e=>e(),Dn=l(`Reaction`,wn),On=`action`,kn=`autoAction`,An=b(On),jn=b(`action.bound`,{bound:!0}),Mn=b(kn,{autoAction:!0}),Nn=b(`autoAction.bound`,{autoAction:!0,bound:!0}),Pn=Be(!1);Nt(Pn,An);let Fn=Be(!0);Nt(Fn,Mn);let In=ze(jn),Ln=ze(Nn),Rn=e=>e(),zn=`always`;var Bn=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Vn=ee(`flow`),Hn=ee(`flow.bound`,{bound:!0}),Un=Nt(function(e,t){if(t&&typeof t.kind==`string`)return T(Vn,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=Pn(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=Pn(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=Pn(i,t.throw).call(t,e)}catch(e){return n(e)}l(r)}function l(t){if(!r(t?.then))return t.done?e(t.value):(o=Promise.resolve(t.value),o.then(s,c));t.then(l,n)}a=n,s(void 0)});return s.cancel=Pn(i,function(){try{o&&Ye(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Bt,Bt),Ye(n),a(new Bn)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Vn),Wn=fe(Hn,T),Gn={has:(e,t)=>ct(e).et(t),get:(e,t)=>ct(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=ct(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=ct(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=ct(e).l(t,n))==null||r},ownKeys:e=>ct(e).it(),preventExtensions(e){t(13)}},Kn=Symbol(`mobx-keys`),qn=`splice`,Jn=`update`,Yn={get(e,t){let n=e[M];return t===M?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p(Zn,t)?Zn[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[M];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var Xn=class{constructor(e=`ObservableArray`,t,n){this.$t=void 0,this.ct=void 0,this.j=[],this.st=void 0,this.ot=void 0,this.A=void 0,this.dehancer=void 0,this.v=void 0,this.Ut=0,this.$t=n,this.ct=new Ut(e),this.A=(e,n)=>t(e,n,`ObservableArray[..]`)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}ht(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}Kt(){return this.ct.reportObserved(),this.j.length}Lt(e){(!Number.isInteger(e)||e<0)&&t(40,e);let n=this.j.length;if(e!==n)if(e>n){let t=Array.from({length:e-n});this.wt(n,0,t)}else this.wt(e,n-e)}zt(e,n){e!==this.Ut&&t(16),this.Ut+=n}wt(e,t,n){let r=this.j.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=Lt),lt(this)){let r=A(this,{object:this.v,type:qn,index:e,removedCount:t,added:n});if(!r)return Lt;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.A(e,void 0));let i=this.qt(e,t,n);return t===0&&n.length===0||this.Ft(e,n,i),this.ht(i)}qt(e,t,n){if(n.length<1e4)return this.j.splice(e,t,...n);{let r=this.j.slice(e,e+t),i=this.j.slice(e+t);this.j.length+=n.length-t;for(let t=0;t<n.length;t++)this.j[e+t]=n[t];for(let t=0;t<i.length;t++)this.j[e+n.length+t]=i[t];return r}}Ht(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,type:Jn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&pt(this,i)}Ft(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:qn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&pt(this,i)}Tt(e){return this.ct.reportObserved(),this.Wt(this.j[e])}Bt(e,t){let n=this.j;if(e<n.length){let r=n[e];if(lt(this)){let n=A(this,{type:Jn,object:this.v,index:e,newValue:t});if(!n)return;t=n.newValue}(t=this.A(t,r))!==r&&(n[e]=t,this.Ht(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.wt(n.length,0,r)}}},Zn={clear(){return this.splice(0)},replace(e){let t=this[M];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[M];switch(arguments.length){case 0:return[];case 1:return r.wt(e);case 2:return r.wt(e,t)}return r.wt(e,t,n)},spliceWithArray(e,t,n){return this[M].wt(e,t,n)},push(...e){let t=this[M];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[M].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[M];return t.wt(0,0,e),t.j.length},reverse(){return F.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){F.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[M],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};j(`at`,ht),j(`concat`,ht),j(`flat`,ht),j(`includes`,ht),j(`indexOf`,ht),j(`join`,ht),j(`lastIndexOf`,ht),j(`slice`,ht),j(`toString`,ht),j(`toLocaleString`,ht),j(`toSorted`,ht),j(`toSpliced`,ht),j(`with`,ht),j(`every`,gt),j(`filter`,gt),j(`find`,gt),j(`findIndex`,gt),j(`findLast`,gt),j(`findLastIndex`,gt),j(`flatMap`,gt),j(`forEach`,gt),j(`map`,gt),j(`some`,gt),j(`toReversed`,gt),j(`reduce`,_t),j(`reduceRight`,_t);let Qn=l(`ObservableArrayAdministration`,Xn),$n={},er=`delete`;var tr=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[M]=$n,this.ft=void 0,this.dt=void 0,this.lt=void 0,this.st=void 0,this.ot=void 0,this.dehancer=void 0,this.A=t,this.tt=n,Dt(()=>{this.lt=g(`ObservableMap.keys()`),this.ft=new Map,this.dt=new Map,e&&this.merge(e)})}et(e){return this.ft.has(e)}has(e){if(!F.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new hn(this.et(e),y,`ObservableMap.key?`,!1);this.dt.set(e,n),n.onBUOL=new Set([()=>this.dt.delete(e)])}return t.get()}set(e,t){let n=this.et(e);if(lt(this)){let r=A(this,{type:n?Jn:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.Gt(e,t):this.Jt(e,t),this}delete(e){if(lt(this)&&!A(this,{type:er,object:this,name:e}))return!1;if(this.et(e)){let t=dt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:er,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return ot(()=>{var t;this.lt.reportChanged(),(t=this.dt.get(e))==null||t.Ot(!1),this.ft.get(e).Ot(void 0),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Jn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}}Jt(e,t){ot(()=>{var n;let r=new hn(t,this.A,`ObservableMap.key`,!1);this.ft.set(e,r),t=r.rt,(n=this.dt.get(e))==null||n.Ot(!0),this.lt.reportChanged()});let n=dt(this);n&&pt(this,n?{observableKind:`map`,debugObjectName:this.tt,type:`add`,object:this,name:e,newValue:t}:null)}get(e){return this.has(e)?this.Wt(this.ft.get(e).get()):this.Wt(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.lt.reportObserved(),this.ft.keys()}values(){let e=this,t=this.keys();return yt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return yt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return nr(e)&&(e=new Map(e)),ot(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>It.propertyIsEnumerable.call(e,t))]:t}(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):u(e)?(function(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}(e)||t(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&t(20,e)}),this}clear(){ot(()=>{Ee(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return ot(()=>{let n=function(e){if(u(e)||nr(e))return e;if(Array.isArray(e))return new Map(e);if(o(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}return t(21,e)}(e),r=new Map,i=!1;for(let e of this.ft.keys())if(!n.has(e))if(this.delete(e))i=!0;else{let t=this.ft.get(e);r.set(e,t)}for(let[e,t]of n.entries()){let n=this.ft.has(e);if(this.set(e,t),this.ft.has(e)){let t=this.ft.get(e);r.set(e,t),n||(i=!0)}}if(!i)if(this.ft.size!==r.size)this.lt.reportChanged();else{let e=this.ft.keys(),t=r.keys(),n=e.next(),i=t.next();for(;!n.done;){if(n.value!==i.value){this.lt.reportChanged();break}n=e.next(),i=t.next()}}this.ft=r}),this}get size(){return this.lt.reportObserved(),this.ft.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},nr=l(`ObservableMap`,tr);let rr={};var ir=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[M]=rr,this.ft=new Set,this.ct=void 0,this.ot=void 0,this.st=void 0,this.dehancer=void 0,this.A=void 0,this.tt=n,this.A=(e,r)=>t(e,r,n),Dt(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){ot(()=>{Ee(()=>{for(let e of this.ft.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.ct.reportObserved(),this.ft.size}add(e){if(lt(this)){let t=A(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){ot(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=dt(this);t&&pt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(lt(this)&&!A(this,{type:er,object:this,oldValue:e}))return!1;if(this.has(e)){let t=dt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:er,object:this,oldValue:e}:null;return ot(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return bt({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.ct.reportObserved();let e=this,t=this.ft.values();return bt({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.Wt(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return ar(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?ot(()=>{let t=d(e)?e:new Set(e);if(t.size!==0)if(this.ft.size!==0){for(let e of this.ft.values())t.has(this.Wt(e))||this.delete(e);t.forEach(e=>this.add(e))}else t.forEach(e=>this.add(e));else this.clear()}):e!=null&&t(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},ar=l(`ObservableSet`,ir);let or=Object.create(null),sr=`remove`;var cr=class{constructor(e,t=new Map,n,r=N){this.h=void 0,this.j=void 0,this.tt=void 0,this.ut=void 0,this.lt=void 0,this.ot=void 0,this.st=void 0,this.v=void 0,this.p=void 0,this.Xt=void 0,this.Qt=void 0,this.O=void 0,this.V=void 0,this.h=e,this.j=t,this.tt=n,this.ut=r,this.lt=new Ut(`ObservableObject.keys`),this.p=o(this.h)}_(e){return(this.j.get(e)??this.vt(e)??this.bt(e)).get()}vt(e){let t=this.O?.get(e);if(!t)return;this.O.delete(e),this.O.size===0&&(this.O=void 0);let n=t();return this.j.set(e,n),n}bt(e){let t=this.V?.get(e);if(!t)return;this.V.delete(e),this.V.size===0&&(this.V=void 0);let n=t();return this.j.set(e,n),n}M(e,t){let n=this.j.get(e)??this.vt(e)??this.bt(e);if(n instanceof _n)return n.set(t),!0;if(lt(this)){let n=A(this,{type:Jn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==F.UNCHANGED){let r=dt(this),i=r?{type:Jn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}return!0}Tt(e){return F.trackingDerivation&&!p(this.h,e)&&this.et(e),this.h[e]}Bt(e,t,n=!1){return p(this.h,e)?this.j.has(e)?this.M(e,t):n?Reflect.set(this.h,e,t):(this.h[e]=t,!0):this.u(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.ut,n)}et(e){if(!F.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new hn(e in this.h,y,`ObservableObject.key?`,!1),this.Qt.set(e,t)),t.get()}u(e,t,n,r=!1){return!0===n&&(n=this.ut),!1===n?this.l(e,t,r):n.u(this,e,t,r)}l(e,t,n=!1){try{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)){let n=A(this,{object:this.v||this.h,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:r}=n;t.value!==r&&(t=Nt({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else Ft(this.h,e,t);this.Yt(e,t.value)}finally{Ne()}return!0}S(e,t,n,r=!1){try{Me();let i=this.Dt(e);if(!i)return i;if(lt(this)){let n=A(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=St(e),o={configurable:!F.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else Ft(this.h,e,o);let s=new hn(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Ne()}return!0}m(e,t,n=!1){try{Me();let r=this.Dt(e);if(!r)return r;if(lt(this)&&!A(this,{object:this.v||this.h,name:e,type:`add`,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;let i=St(e),a={configurable:!F.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else Ft(this.h,e,a);this.j.set(e,new _n(t)),this.Yt(e,void 0)}finally{Ne()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(lt(this)&&!A(this,{object:this.v||this.h,name:e,type:sr}))return null;try{var n;Me();let r=dt(this),i=this.j.get(e),a;if(i||!r||(a=Pt(this.h,e)?.value),t){if(!Reflect.deleteProperty(this.h,e))return!1}else delete this.h[e];i&&(this.j.delete(e),i instanceof hn&&(a=i.rt),Ie(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&pt(this,{type:sr,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Ne()}return!0}Yt(e,t){var n;let r=dt(this);r&&r&&pt(this,r?{type:`add`,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,name:e,newValue:t}:null),(n=this.Qt)==null||(n=n.get(e))==null||n.set(!0),this.lt.reportChanged()}it(){return this.lt.reportObserved(),Vt(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let lr=l(`ObservableObjectAdministration`,cr),ur=It.toString,dr=globalThis.Iterator?.prototype||{};e.$mobx=M,e.FlowCancellationError=Bn,e.ObservableMap=tr,e.ObservableSet=ir,e.Reaction=wn,e._allowStateChanges=xe,e._allowStateChangesInsideComputed=Ve,e._allowStateReadsEnd=function(e){F.allowStateReads=e},e._allowStateReadsStart=function(e){let t=F.allowStateReads;return F.allowStateReads=e,t},e._autoAction=Fn,e._autoActionBound=Ln,e._endAction=be,e._getAdministration=Tt,e._getGlobalState=function(){return F},e._interceptReads=function(e,t,n){let r;return nr(e)||vt(e)||gn(e)?r=Tt(e):Ct(e)&&(r=Tt(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return F.trackingDerivation!==null},e._resetGlobalState=function(){let e=new xn;for(let t in e)bn.indexOf(t)===-1&&(F[t]=e[t]);F.allowStateChanges=!F.enforceActions},e._startAction=ye,e.action=Pn,e.actionBound=In,e.autorun=Ue,e.compareDefault=Gt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return Ot(e,t,1)},e.compareStructural=_,e.computed=ln,e.computedStruct=cn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((F.pendingReactions.length||F.inBatch||F.isRunningReactions)&&t(36),Cn=!0,Sn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),F=new xn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===zn?zn:n===`observed`;F.enforceActions=e,F.allowStateChanges=!0!==e&&e!==zn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(F[t]=!!e[t])}),F.allowStateReads=!F.observableRequiresReaction,e.reactionScheduler&&function(e){let t=En;En=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(Ct(e))return e[M].l(n,r);t(39)},e.entries=function(e){return Ct(e)?et(e).map(t=>[t,e[t]]):nr(e)?et(e).map(t=>[t,e.get(t)]):ar(e)?Array.from(e.entries()):vt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ke,e.flow=Un,e.flowBound=Wn,e.flowResult=function(e){return e},e.get=function(e,n){if(tt(e,n))return Ct(e)?e[M].Tt(n):nr(e)?e.get(n):vt(e)?e[n]:void t(11)},e.getAtom=wt,e.getDebugName=Et,e.getDependencyTree=function(e,t){return qe(wt(e,t))},e.getObserverTree=function(e,t){return Je(wt(e,t))},e.has=tt,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return ut(Tt(e,t),n)}(e,t,n):function(e,t){return ut(Tt(e),t)}(e,t)},e.isAction=He,e.isBoxedObservable=gn,e.isComputed=function(e){return Ze(e)},e.isComputedProp=function(e,t){return Ze(e,t)},e.isFlow=Xe,e.isFlowCancellationError=function(e){return e instanceof Bn},e.isObservable=$e,e.isObservableArray=vt,e.isObservableMap=nr,e.isObservableObject=Ct,e.isObservableProp=function(e,t){return Qe(e,t)},e.isObservableSet=ar,e.keys=et,e.makeAutoObservable=function(e,t,n){return o(e)?Ke(e,e,t,n):(Dt(()=>{let r=xt(e,n)[M];if(!e[Kn]){let t=Object.getPrototypeOf(e),n=new Set([...Vt(e),...Vt(t)]);n.delete(`constructor`),n.delete(M),c(t,Kn,n)}e[Kn].forEach(e=>mt(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return Dt(()=>{let r=xt(e,n)[M];Vt(t).forEach(e=>mt(r,e,t[e]))}),e},e.observable=an,e.observableDeep=nn,e.observableRef=en,e.observableShallow=tn,e.observableStruct=rn,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return rt(Tt(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Tt(e);if(vt(e))n&&t({observableKind:`array`,object:r.v,debugObjectName:r.ct.tt,type:`splice`,index:0,added:r.j.slice(),addedCount:r.j.length,removed:[],removedCount:0});else if(!nr(e)&&!ar(e)&&!Ct(e))return rt(r,t,n);return ft(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return Ge(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return Ge(`onBUO`,e,t,n)},e.onReactionError=function(e){return F.globalReactionErrorHandlers.push(e),()=>{let t=F.globalReactionErrorHandlers.indexOf(e);t>=0&&F.globalReactionErrorHandlers.splice(t,1)}},e.override=Kt,e.ownKeys=nt,e.reaction=function(e,t,n=Rt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=xe(!1,()=>e(h));t=f||!m(d,n),d=n}),(f&&n.fireImmediately||!f&&t)&&o(d,r,h),f=!1}var i;let a=n.name??`Reaction`,o=Pn(a,n.onError?(s=n.onError,c=t,function(){try{return c.apply(this,arguments)}catch(e){s.call(this,e)}}):t);var s,c;let l=!n.scheduler&&!n.delay,u=We(n),d,f=!0,p=!1,m=n.equals||Gt,h=new wn(a,()=>{f||l?r():p||(p=!0,u(r))},n.onError,n.requiresObservable);return n!=null&&(i=n.signal)!=null&&i.aborted||h.Y(),h.Z(n?.signal)},e.remove=function(e,n){Ct(e)?e[M].Dt(n):nr(e)||ar(e)?e.delete(n):vt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=Ve,e.set=function e(n,r,i){if(arguments.length===2&&!ar(n)){Me();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Ne()}return}Ct(n)?n[M].Bt(r,i):nr(n)?n.set(r,i):ar(n)?n.add(r):vt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),Me(),r>=n.length&&(n.length=r+1),n[r]=i,Ne()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return at(e,new Map)},e.transaction=ot,e.untracked=Ee,e.values=function(e){return Ct(e)?et(e).map(t=>e[t]):nr(e)?et(e).map(t=>e.get(t)):ar(e)?Array.from(e.values()):vt(e)?e.slice():void t(6)},e.when=function(e,t,n){return arguments.length===1||t&&typeof t==`object`?function(e,t){var n;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Nt(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=st(e,n,Nt({},t,{onError:a}));r=()=>{s(),a(Error(`WHEN_CANCELLED`))},i=()=>{s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)});return a.cancel=r,a}(e,t):st(e,t,n||{})}})),Bv=we((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t={0:`Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,1(e,t){return`Cannot apply '${e}' to '${t.toString()}': Field not found.`},5:`'keys()' can only be used on observable objects, arrays, sets and maps`,6:`'values()' can only be used on observable objects, arrays, sets and maps`,7:`'entries()' can only be used on observable objects, arrays and maps`,8:`'set()' can only be used on observable objects, arrays and maps`,9:`'remove()' can only be used on observable objects, arrays and maps`,10:`'has()' can only be used on observable objects, arrays and maps`,11:`'get()' can only be used on observable objects, arrays and maps`,12:`Invalid annotation`,13:`Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,14:`Intercept handlers should return nothing or a change object`,15:`Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,16:`Modification exception: the internal structure of an observable array was changed.`,19(e){return`Cannot initialize from classes that inherit from Map: `+e.constructor.name},20(e){return`Cannot initialize map from `+e},21(e){return`Cannot convert to map from '${e}'`},23:`It is not possible to get index atoms from arrays`,24(e){return`Cannot obtain administration from `+e},25(e,t){return`the entry '${e}' does not exist in the observable map '${t}'`},26:`please specify a property`,27(e,t){return`no observable property '${e.toString()}' found on the observable object '${t}'`},28(e){return`Cannot obtain atom from `+e},29:`Expecting some object`,30:`invalid action stack. did you forget to finish an action?`,31:`missing option for computed: get`,32(e,t){return`Cycle detected in computation ${e}: ${t}`},33(e){return`The setter of computed value '${e}' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?`},34(e){return`[ComputedValue '${e}'] It is not possible to assign a new value to a computed value.`},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:`isolateGlobalState should be called before MobX is running any reactions`,37(e){return`[mobx] \`observableArray.${e}()\` mutates the array in-place, which is not allowed inside a derivation. Use \`array.slice().${e}()\` instead`},38:`'ownKeys()' can only be used on observable objects`,39:`'defineProperty()' can only be used on observable objects`,40(e){return`Out of range: `+e},41(e){return`Cannot initialize set from `+e},42(e){return`Invalid index: '${e}'`},43(e,t,n){return`Cannot apply '${e}' to '${t}' (kind: ${n}):\n'${e}' can only be used on properties with a function value.`},44(e){return`'${e}' can only be used with 'makeObservable'`}};function n(e,...n){{let r=typeof e==`string`?e:t[e];throw typeof r==`function`&&(r=r.apply(null,n)),Error(`[MobX] ${r}`)}}let r=Object.assign,i=Object.getOwnPropertyDescriptor,a=Object.defineProperty,o=Object.prototype,s=[];Object.freeze(s);let c={};Object.freeze(c);let l=Object.toString();function u(){return++P.mobxGuid}function d(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}let f=()=>{};function p(e){return typeof e==`function`}function m(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function h(e){return typeof e==`object`&&!!e}function g(e){if(!h(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=T(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===l}function _(e){let t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function v(e,t,n){a(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function y(e,t,n){a(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function b(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return h(e)&&e[n]===!0}}function x(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function S(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function C(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function w(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let ee=Reflect.ownKeys;function te(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ne(e){return e===null?null:typeof e==`object`?``+e:e}function T(e,t){return o.hasOwnProperty.call(e,t)}let re=Object.getOwnPropertyDescriptors;function E(e,t){return!!(e&t)}function D(e,t,n){return n?e|=t:e&=~t,e}function ie(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let O=Symbol(`mobx administration`);var ae=class{constructor(e=`Atom@`+u()){this.name_=void 0,this.flags_=0,this.observers_=null,this.lastAccessedBy_=0,this.lowestObserverState_=-1,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}get isBeingObserved(){return E(this.flags_,1)}set isBeingObserved(e){this.flags_=D(this.flags_,1,e)}get isPendingUnobservation(){return E(this.flags_,2)}set isPendingUnobservation(e){this.flags_=D(this.flags_,2,e)}get diffValue(){return+!!E(this.flags_,4)}set diffValue(e){this.flags_=D(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return sn(this)}reportChanged(){nn(),cn(this),rn()}toString(){return this.name_}};let oe=b(`Atom`,ae);function se(e,t=f,n=f){let r=new ae(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function ce(e,t){return e===t}function le(e,t){return Mi(e,t)}function ue(e,t){return Mi(e,t,1)}let de=Object.is;function fe(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||yr(e)?e:Array.isArray(e)?A.array(e,{name:n}):g(e)?A.object(e,void 0,{name:n}):x(e)?A.map(e,{name:n}):C(e)?A.set(e,{name:n}):typeof e==`function`&&!Ln(e)&&!ur(e)?_(e)?or(e):Nn(n,e):e}function pe(e,t,r){if(e==null||wi(e)||ui(e)||mi(e)||yi(e))return e;if(Array.isArray(e))return A.array(e,{name:r,deep:!1});if(g(e))return A.object(e,void 0,{name:r,deep:!1});if(x(e))return A.map(e,{name:r,deep:!1});if(C(e))return A.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function me(e){return e}function he(e,t){return yr(e)&&n(`observable.struct should not be used with observable values`),Mi(e,t)?t:e}let ge=`override`,_e={annotationType_:ge,make_:ye,extend_:be};function ve(e){return e.annotationType_===ge}function ye(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),T(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function be(e,t,r,i){n(44,this.annotationType_)}function xe(e,t){return{annotationType_:e,options_:t,make_:Se,extend_:Ce}}function Se(e,t,n,r){var i;return(i=this.options_)!=null&&i.bound?this.extend_(e,t,n,!1)===null?0:1:r===e.target_?this.extend_(e,t,n,!1)===null?0:2:Ln(n.value)?1:(a(r,t,Ee(e,this,t,n,!1)),2)}function Ce(e,t,n,r){let i=Ee(e,this,t,n);return e.defineProperty_(t,i,r)}function we(e,t,r){ie(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>yt(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return Ln(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return Ln(t)||(t=c(t)),(l=s.options_)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),t}n(43,s.annotationType_,String(a),i)}function Te(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a function value.`)}function Ee(e,t,n,r,i=P.safeDescriptors){var a,o;Te(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:yt(t.options_?.name??n.toString(),s,t.options_?.autoAction??!1,(o=t.options_)!=null&&o.bound?e.proxy_??e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function k(e,t){return{annotationType_:e,options_:t,make_:De,extend_:Oe}}function De(e,t,n,r){var i;return r===e.target_?this.extend_(e,t,n,!1)===null?0:2:(i=this.options_)!=null&&i.bound&&(!T(e.target_,t)||!ur(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:ur(n.value)?1:(a(r,t,je(e,this,t,n,!1,!1)),2)}function Oe(e,t,n,r){let i=je(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function ke(e,t,n){var r;ie(n,[`method`]);let{name:i,addInitializer:a}=n;return ur(t)||(t=or(t)),(r=e.options_)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function Ae(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a generator function value.`)}function je(e,t,n,r,i,a=P.safeDescriptors){Ae(e,t,n,r);let{value:o}=r;return ur(o)||(o=or(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function Me(e,t){return{annotationType_:e,options_:t,make_:Ne,extend_:Pe}}function Ne(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Pe(e,t,n,i){return Ie(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Fe(e,t,n){ie(n,[`getter`]);let i=e,{name:a,addInitializer:o}=n,s;function c(e,n){let o=r({},i.options_,{get:t,context:e});return o.name||=`${n.name_}.${a.toString()}`,new Ot(o)}return o(function(){let e=R(this)[O],n=this,r=e.values_.get(a);r instanceof Ot&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[O],n=e.values_.get(a);if(n instanceof Ot&&n.derivation!==t){let t=s?.get(this);return t||(t=c(this,e),(s??=new WeakMap).set(this,t)),t.get()}return e.getObservablePropValue_(a)}}function Ie(e,{annotationType_:t},r,{get:i}){i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on getter(+setter) properties.`)}function Le(e,t){return{annotationType_:e,options_:t,make_:Re,extend_:ze}}function Re(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function ze(e,t,n,r){return Ve(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??fe,r)}function Be(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);ie(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=R(e)[O];return(n.lazyObservableKeys_??=new Map).set(o,()=>new Et(t,i.options_?.enhancer_??fe,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[O]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[O]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function Ve(e,{annotationType_:t},r,i){`value`in i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' cannot be used on getter/setter properties`)}let He=Ue();function Ue(e){return{annotationType_:`true`,options_:e,make_:Ke,extend_:qe}}let We=[He];function Ge(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return We[r]??(We[r]=Ue({deep:t,autoBind:n}))}function Ke(e,t,n,r){var i;if(n.get)return j.make_(e,t,n,r);if(n.set){let i=Ln(n.set)?n.set:yt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:P.safeDescriptors?e.isPlainObject_:!0,set:i})===null?0:2:(a(r,t,{configurable:!0,set:i}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(_(n.value)){var s;return((s=this.options_)!=null&&s.autoBind?sr:or).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Fn:Nn).make_(e,t,n,r)}let c=this.options_?.deep===!1?st:A;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),c.make_(e,t,n,r)}function qe(e,t,n,r){var i;return n.get?j.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:P.safeDescriptors?e.isPlainObject_:!0,set:yt(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),(this.options_?.deep===!1?st:A).extend_(e,t,n,r))}function Je(e,t){return r(function(r,i){if(i&&typeof i.kind==`string`)return t(e,r,i);n(`Invalid arguments for \`${e.annotationType_}\``)},e)}let Ye={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Ye);function Xe(e){return e||Ye}let Ze=Le(`observable`),Qe=Le(`observable.ref`,{enhancer_:me}),$e=Le(`observable.shallow`,{enhancer_:pe}),et=Le(`observable.struct`,{enhancer_:he});function tt(e){return Je(e,Be)}function nt(e){return e.deep===!0?fe:e.deep===!1?me:it(e.defaultDecorator)}function rt(e){return e?e.defaultDecorator??Ge(e):void 0}function it(e){return e?e.options_?.enhancer_??fe:fe}function at(e,t,n){return t&&typeof t.kind==`string`?Be(Ze,e,t):yr(e)?e:g(e)?A.object(e,t,n):Array.isArray(e)?A.array(e,t):x(e)?A.map(e,t):C(e)?A.set(e,t):typeof e==`object`&&e?e:A.box(e,t)}let ot={box(e,t){let n=Xe(t);return new Et(e,nt(n),n.name,!0,n.equals)},array(e,t){let n=Xe(t);return ii(e,nt(n),n.name)},map(e,t){let n=Xe(t);return new pi(e,nt(n),n.name)},set(e,t){let n=Xe(t);return new vi(e,nt(n),n.name)},object(e,t,n){return Ai(()=>Jn(Ur({},n),e,t))}},st=tt(Qe),ct=tt($e),lt=tt(Ze),ut=tt(et);var A=r(at,Ze,ot);let dt=`computed`;function ft(e){return Je(e,Fe)}let pt=Me(dt),mt=ft(Me(`computed.struct`,{equals:le})),j=function(e,t){if(t&&typeof t.kind==`string`)return Fe(pt,e,t);if(g(e))return ft(Me(dt,e));p(e)||n("First argument to `computed` should be an expression."),p(t)&&n("A setter as second argument is no longer supported, use `{ set: fn }` option instead");let r=g(t)?t:{};return r.get=e,r.name||=e.name||``,new Ot(r)};r(j,pt);let ht=0,gt=1,_t=i(()=>{},`name`)?.configurable??!1,vt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function yt(e,t,r=!1,i){p(t)||n("`action` can only be invoked on functions"),(typeof e!=`string`||!e)&&n(`actions should have valid names, got: '${e}'`);function o(){return bt(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),_t&&(vt.value=e,a(o,`name`,vt)),o}function bt(e,t,n,r,i){let a=xt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{St(a)}}function xt(e,t,n,r){let i=vn()&&!!e,a=0;i&&(a=Date.now(),bn({type:F,name:e,object:n,arguments:r?Array.from(r):s}));let o=P.trackingDerivation,c=!t||!o;nn();let l=P.allowStateChanges;c&&(Vt(),l=wt(!0));let u=P.allowStateReads;M(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:gt++,parentActionId_:ht};return ht=d.actionId_,d}function St(e){ht!==e.actionId_&&n(30),ht=e.parentActionId_,e.error_!==void 0&&(P.suppressReactionErrors=!0),Tt(e.prevAllowStateChanges_),Ut(e.prevAllowStateReads_),rn(),e.runAsAction_&&Ht(e.prevDerivation_),e.notifySpy_&&Sn({time:Date.now()-e.startTime_}),P.suppressReactionErrors=!1}function Ct(e,t){let n=wt(e);try{return t()}finally{Tt(n)}}function wt(e){let t=P.allowStateChanges;return P.allowStateChanges=e,t}function Tt(e){P.allowStateChanges=e}var Et=class extends ae{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=de){super(n),this.enhancer_=void 0,this.name_=void 0,this.equals_=void 0,this.hasUnreportedChange_=!1,this.interceptors_=void 0,this.changeListeners_=void 0,this.value_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,this.equals_=i,this.value_=t(e,void 0,n),r&&vn()&&yn({type:`create`,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:this.value_})}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){let t=this.value_;if(e=this.prepareNewValue_(e),e!==P.UNCHANGED){let n=vn();n&&bn({type:ti,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Sn()}}prepareNewValue_(e){if(Pt(this),Wr(this)){let t=Kr(this,{object:this,type:ti,newValue:e});if(!t)return P.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?P.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),qr(this)&&Yr(this,{type:ti,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.value_)}raw(){return this.value_}toJSON(){return this.get()}toString(){return`${this.name_}[${this.value_}]`}valueOf(){return ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Dt=b(`ObservableValue`,Et);var Ot=class{constructor(e){this.dependenciesState_=-1,this.observing_=[],this.newObserving_=null,this.observers_=null,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=0,this.unboundDepsCount_=0,this.value_=new At(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||n(31),this.derivation=e.get,this.name_=e.name||`ComputedValue@`+u(),e.set&&(this.setter_=yt(this.name_+`-setter`,e.set)),this.equals_=e.equals||de,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){un(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return E(this.flags_,1)}set isComputing(e){this.flags_=D(this.flags_,1,e)}get isRunningSetter(){return E(this.flags_,2)}set isRunningSetter(e){this.flags_=D(this.flags_,2,e)}get isBeingObserved(){return E(this.flags_,4)}set isBeingObserved(e){this.flags_=D(this.flags_,4,e)}get isPendingUnobservation(){return E(this.flags_,8)}set isPendingUnobservation(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),P.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Mt(this)&&(this.warnAboutUntrackedRead_(),nn(),this.value_=this.computeValue_(!1),rn());else{let e=this.isBeingObserved;if(sn(this),Mt(this)){let e=P.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(P.trackingContext=this),this.trackAndCompute()&&ln(this),P.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(on)}let e=this.value_;if(jt(e))throw e.cause;return e}set(e){if(this.setter_){this.isRunningSetter&&n(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter=!1}}else n(34,this.name_)}trackAndCompute(){let e=this.value_,t=this.dependenciesState_===-1,n=this.computeValue_(!0),r=t||jt(e)||jt(n)||!this.equals_(e,n);return r&&(this.value_=n,vn()&&yn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=wt(!1),n;if(e)n=It(this,this.derivation,this.scope_);else if(P.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new At(e)}return Tt(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(zt(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:P.computedRequiresReaction)&&console.warn(`[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`)}toString(){return`${this.name_}[${this.derivation.toString()}]`}valueOf(){return ne(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let kt=b(`ComputedValue`,Ot);var At=class{constructor(e){this.cause=void 0,this.cause=e}};function jt(e){return e instanceof At}function Mt(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=M(!0),n=Vt(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(kt(i)){if(P.disableErrorBoundaries)i.get();else try{i.get()}catch{return Ht(n),Ut(t),!0}if(e.dependenciesState_===2)return Ht(n),Ut(t),!0}}return Wt(e),Ht(n),Ut(t),!1}}}function Nt(){return P.trackingDerivation!==null}function Pt(e){let t=!!e.observers_&&e.observers_.size>0;!P.allowStateChanges&&(t||P.enforceActions===`always`)&&console.warn(`[MobX] `+(P.enforceActions?`Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: `:`Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: `)+e.name_)}function Ft(e){!P.allowStateReads&&P.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function It(e,t,n){let r=M(!0);Wt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++P.runId;let i=P.trackingDerivation;P.trackingDerivation=e,P.inBatch++;let a;if(P.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new At(e)}return P.inBatch--,P.trackingDerivation=i,Rt(e),Lt(e),Ut(r),a}function Lt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:P.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function Rt(e){let t=e.observing_,n=e.observing_=e.newObserving_,r=0,i=0,a=e.unboundDepsCount_;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.dependenciesState_>r&&(r=t.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&en(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,$t(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function zt(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)en(t[n],e);e.dependenciesState_=-1}function Bt(e){let t=Vt();try{return e()}finally{Ht(t)}}function Vt(){let e=P.trackingDerivation;return P.trackingDerivation=null,e}function Ht(e){P.trackingDerivation=e}function M(e){let t=P.allowStateReads;return P.allowStateReads=e,t}function Ut(e){P.allowStateReads=e}function Wt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Gt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Kt=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 qt=!0,N=!1,P=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(qt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(qt=!1),qt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Kt):(setTimeout(()=>{N||n(35)},1),new Kt)}();function Jt(){if((P.pendingReactions.length||P.inBatch||P.isRunningReactions)&&n(36),N=!0,qt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),P=new Kt}}function Yt(){return P}function Xt(){let e=new Kt;for(let t in e)Gt.indexOf(t)===-1&&(P[t]=e[t]);P.allowStateChanges=!P.enforceActions}function Zt(e){return!!e.observers_&&e.observers_.size>0}function Qt(e){return e.observers_??new Set}function $t(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function en(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&tn(e))}function tn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,P.pendingUnobservations.push(e))}function nn(){P.inBatch++}function rn(){--P.inBatch===0&&(mn(),!P.isRunningUnobservations&&P.pendingUnobservations.length>0&&an())}function an(){P.isRunningUnobservations=!0;try{let e=P.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,(!n.observers_||n.observers_.size===0)&&(n.observers_=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof Ot&&n.suspend_())}P.pendingUnobservations=[]}finally{P.isRunningUnobservations=!1}}function on(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(on))}function sn(e){Ft(e);let t=P.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&P.inBatch>0&&tn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&P.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function cn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&e.onBecomeStale_(),e.dependenciesState_=2}))}function ln(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(t=>{t.dependenciesState_===1?t.dependenciesState_=2:t.dependenciesState_===0&&(e.lowestObserverState_=0)}))}function un(e){var t;e.lowestObserverState_===0&&(e.lowestObserverState_=1,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&(e.dependenciesState_=1,e.onBecomeStale_())}))}var dn=class{constructor(e=`Reaction@`+u(),t,n,r){this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=-1,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.removeAbortListener_=void 0,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}get isDisposed(){return E(this.flags_,1)}set isDisposed(e){this.flags_=D(this.flags_,1,e)}get isScheduled(){return E(this.flags_,2)}set isScheduled(e){this.flags_=D(this.flags_,2,e)}get isTrackPending(){return E(this.flags_,4)}set isTrackPending(e){this.flags_=D(this.flags_,4,e)}get isRunning(){return E(this.flags_,8)}set isRunning(e){this.flags_=D(this.flags_,8,e)}get diffValue(){return+!!E(this.flags_,16)}set diffValue(e){this.flags_=D(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,P.pendingReactions.push(this),mn())}runReaction_(){if(!this.isDisposed){nn(),this.isScheduled=!1;let e=P.trackingContext;if(P.trackingContext=this,Mt(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&vn()&&yn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}P.trackingContext=e,rn()}}track(e){if(this.isDisposed)return;nn();let t=vn(),n;t&&(n=Date.now(),bn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=P.trackingContext;P.trackingContext=this;let i=It(this,e,void 0);P.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&zt(this),jt(i)&&this.reportExceptionInDerivation_(i.cause),t&&Sn({time:Date.now()-n}),rn()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(P.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;P.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),vn()&&yn({type:`error`,name:this.name_,message:t,error:``+e}),P.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(nn(),zt(this),rn())}}getDisposer_(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.removeAbortListener_=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[O]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function fn(e){return P.globalReactionErrorHandlers.push(e),()=>{let t=P.globalReactionErrorHandlers.indexOf(e);t>=0&&P.globalReactionErrorHandlers.splice(t,1)}}let pn=e=>e();function mn(){P.inBatch>0||P.isRunningReactions||pn(hn)}function hn(){P.isRunningReactions=!0;let e=P.pendingReactions,t=0;for(;e.length>0;){++t===100&&(console.error(`Reaction doesn't converge to a stable state after 100 iterations. Probably there is a cycle in the reactive function: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].runReaction_()}P.isRunningReactions=!1}let gn=b(`Reaction`,dn);function _n(e){let t=pn;pn=n=>e(()=>t(n))}function vn(){return!!P.spyListeners.length}function yn(e){if(!P.spyListeners.length)return;let t=P.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function bn(e){yn(r({},e,{spyReportStart:!0}))}let xn={type:`report-end`,spyReportEnd:!0};function Sn(e){yn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):xn)}function Cn(e){return P.spyListeners.push(e),d(()=>{P.spyListeners=P.spyListeners.filter(t=>t!==e)})}let F=`action`,wn=`autoAction`,Tn=`<unnamed action>`,En=xe(F),Dn=xe(`action.bound`,{bound:!0}),On=xe(wn,{autoAction:!0}),kn=xe(`autoAction.bound`,{autoAction:!0,bound:!0});function An(e){return Je(e,we)}function jn(e){return function(t,r){if(r&&typeof r.kind==`string`)return we(e?On:En,t,r);if(p(t))return yt(t.name||Tn,t,e);if(p(r))return yt(t,r,e);if(m(t))return An(xe(e?wn:F,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Mn=jn(!1);r(Mn,En);let Nn=jn(!0);r(Nn,On);let Pn=An(Dn),Fn=An(kn);function In(e){return bt(e.name||Tn,!1,e,this,void 0)}function Ln(e){return p(e)&&e.isMobxAction===!0}function Rn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),Ln(e)&&n(`Autorun does not accept actions since actions are untrackable`);let i=t?.name??(e.name||`Autorun@`+u()),a=!t.scheduler&&!t.delay,o;if(a)o=new dn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Bn(t),n=!1;o=new dn(i,()=>{n||(n=!0,e(()=>{n=!1,o.isDisposed||o.track(s)}))},t.onError,t.requiresObservable)}function s(){e(o)}return t!=null&&(r=t.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}let zn=e=>e();function Bn(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):zn}function Vn(e,t,r=c){var i;(!p(e)||!p(t))&&n(`First and second argument to reaction should be functions`),g(r)||n(`Third argument of reactions should be an object`);let a=r.name??`Reaction@`+u(),o=Mn(a,r.onError?Hn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Bn(r),d=!0,f=!1,m,h=r.equals||de,_=new dn(a,()=>{d||s?v():f||(f=!0,l(v))},r.onError,r.requiresObservable);function v(){if(f=!1,_.isDisposed)return;let t=!1,n=m;_.track(()=>{let n=Ct(!1,()=>e(_));t=d||!h(m,n),m=n}),(d&&r.fireImmediately||!d&&t)&&o(m,n,_),d=!1}return r!=null&&(i=r.signal)!=null&&i.aborted||_.schedule_(),_.getDisposer_(r?.signal)}function Hn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Un(e,t,n){return Gn(`onBO`,e,t,n)}function Wn(e,t,n){return Gn(`onBUO`,e,t,n)}function Gn(e,t,n,r){let i=typeof r==`function`?Di(t,n):Di(t),a=p(r)?r:n,o=`${e}L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){let e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}let Kn=`always`;function qn(e){e.isolateGlobalState===!0&&Jt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Kn?Kn:t===`observed`;P.enforceActions=e,P.allowStateChanges=!(e===!0||e===Kn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(P[t]=!!e[t])}),P.allowStateReads=!P.observableRequiresReaction,P.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&_n(e.reactionScheduler)}function Jn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),mi(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(yr(t)||yr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=re(t);return Ai(()=>{let t=R(e,i)[O];ee(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Yn(e,t){return Xn(Di(e,t))}function Xn(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=$n(e.observing_).map(Xn)),t}function Zn(e,t){return Qn(Di(e,t))}function Qn(e){let t={name:e.name_};return Zt(e)&&(t.observers=Array.from(Qt(e),Qn)),t}function $n(e){return Array.from(new Set(e))}let er=0;var tr=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function nr(e){return e instanceof tr}function rr(e){return Je(e,ke)}let ir=k(`flow`),ar=k(`flow.bound`,{bound:!0}),or=r(function(e,t){if(t&&typeof t.kind==`string`)return ke(ir,e,t);arguments.length!==1&&n(`Flow expects single argument with generator function`);let r=e,i=r.name||`<unnamed flow>`,a=function(){let e=this,t=arguments,n=++er,a=Mn(`${i} - runid: ${n} - init`,r).apply(e,t),o,s,c=new Promise(function(e,t){let r=0;o=t;function c(e){s=void 0;let o;try{o=Mn(`${i} - runid: ${n} - yield ${r++}`,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;let o;try{o=Mn(`${i} - runid: ${n} - yield ${r++}`,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(p(n?.then)){n.then(u,t);return}return n.done?e(n.value):(s=Promise.resolve(n.value),s.then(c,l))}c(void 0)});return c.cancel=Mn(`${i} - runid: ${n} - cancel`,function(){try{s&&cr(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),cr(t),o(new tr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},ir),sr=rr(ar);function cr(e){p(e.cancel)&&e.cancel()}function lr(e){return e}function ur(e){return e?.isMobXFlow===!0}function dr(e,t,r){let i;if(mi(e)||ui(e)||Dt(e))i=Oi(e);else if(wi(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=Oi(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 fr(e,t,n){return p(n)?mr(e,t,n):pr(e,t)}function pr(e,t){return Gr(Oi(e),t)}function mr(e,t,n){return Gr(Oi(e,t),n)}function hr(e,t){var n;if(t===void 0)return kt(e);if(wi(e)===!1)return!1;let r=e[O];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?kt(Di(e,t)):!1}function gr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):hr(e)}function _r(e,t){return m(t)?hr(e,t):n(`isComputed expected a property name as second argument`)}function vr(e,t){if(!e)return!1;if(t!==void 0){if(mi(e)||ui(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(wi(e)){var r,i;let n=e[O];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return wi(e)||!!e[O]||oe(e)||gn(e)||kt(e)}function yr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),vr(e)}function br(e,t){return m(t)?vr(e,t):n(`expected a property name as second argument`)}function xr(e){if(wi(e))return e[O].keys_();if(mi(e)||yi(e))return Array.from(e.keys());if(ui(e))return e.map((e,t)=>t);n(5)}function Sr(e){if(wi(e))return xr(e).map(t=>e[t]);if(mi(e))return xr(e).map(t=>e.get(t));if(yi(e))return Array.from(e.values());if(ui(e))return e.slice();n(6)}function Cr(e){if(wi(e))return xr(e).map(t=>[t,e[t]]);if(mi(e))return xr(e).map(t=>[t,e.get(t)]);if(yi(e))return Array.from(e.entries());if(ui(e))return e.map((e,t)=>[t,e]);n(7)}function wr(e,t,r){if(arguments.length===2&&!yi(e)){nn();let n=t;try{for(let t in n)wr(e,t,n[t])}finally{rn()}return}wi(e)?e[O].set_(t,r):mi(e)?e.set(t,r):yi(e)?e.add(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),nn(),t>=e.length&&(e.length=t+1),e[t]=r,rn()):n(8)}function Tr(e,t){wi(e)?e[O].delete_(t):mi(e)||yi(e)?e.delete(t):ui(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function Er(e,t){if(wi(e))return e[O].has_(t);if(mi(e)||yi(e))return e.has(t);if(ui(e))return t>=0&&t<e.length;n(10)}function Dr(e,t){if(Er(e,t)){if(wi(e))return e[O].get_(t);if(mi(e))return e.get(t);if(ui(e))return e[t];n(11)}}function Or(e,t,r){if(wi(e))return e[O].defineProperty_(t,r);n(39)}function kr(e){if(wi(e))return e[O].ownKeys_();n(38)}function Ar(e,t,n,r){return p(n)?Mr(e,t,n,r):jr(e,t,n)}function jr(e,t,r){let i=Oi(e);if(ui(e))r&&t({observableKind:`array`,object:i.proxy_,debugObjectName:i.atom_.name_,type:`splice`,index:0,added:i.values_.slice(),addedCount:i.values_.length,removed:[],removedCount:0});else if(mi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(yi(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(wi(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Nr(i,t,r);return Jr(i,t)}function Mr(e,t,n,r){return Nr(Oi(e,t),n,r)}function Nr(e,t,n){if(kt(e)){let r=!0,i;return Rn(()=>{let a=e.get();if(!r||n){let n=Vt();t({observableKind:`computed`,debugObjectName:e.name_,type:ti,object:e,newValue:a,oldValue:i}),Ht(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ti,newValue:e.value_,oldValue:void 0}),Jr(e,t)}function Pr(e,t,n){return e.set(t,n),n}function Fr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!yr(e))return e;if(Dt(e)||kt(e))return Fr(e.get(),t);if(t.has(e))return t.get(e);if(ui(e)){let n=Pr(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Fr(e,t)}),n}if(yi(e)){let n=Pr(t,e,new Set);return e.forEach(e=>{n.add(Fr(e,t))}),n}if(mi(e)){let n=Pr(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Fr(e,t))}),n}else{let n=Pr(t,e,{});return kr(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Fr(e[r],t))}),n}}function Ir(e,t){return t&&n(`toJS no longer supports options`),Fr(e,new Map)}function Lr(e,t=void 0){nn();try{return e.apply(t)}finally{rn()}}function Rr(e,t,n){return arguments.length===1||t&&typeof t==`object`?Br(e,t):zr(e,t,n||{})}function zr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[O].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=yt(n.name+`-effect`,t);var a=Rn(t=>{Ct(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function Br(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=zr(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 Vr(e){return e[O]}let Hr={has(e,t){return Vr(e).has_(t)},get(e,t){return Vr(e).get_(t)},set(e,t,n){return m(t)?Vr(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Vr(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Vr(e).defineProperty_(t,n)??!0},ownKeys(e){return Vr(e).ownKeys_()},preventExtensions(e){n(13)}};function Ur(e,t){var n;return e=R(e,t),(n=e[O]).proxy_??(n.proxy_=new Proxy(e,Hr))}function Wr(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function Gr(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 Kr(e,t){let r=Vt();try{let r=[...e.interceptors_||[]];for(let e=0,i=r.length;e<i&&(t=r[e](t),t&&!t.type&&n(14),t);e++);return t}finally{Ht(r)}}function qr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Jr(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 Yr(e,t){let n=Vt(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ht(n)}}function Xr(e,t,n){return Ai(()=>{let r=R(e,n)[O];ee(t).forEach(e=>$r(r,e,t[e]))}),e}let Zr=Symbol(`mobx-keys`);function Qr(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),wi(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Jn(e,e,t,r):(Ai(()=>{let n=R(e,r)[O];if(!e[Zr]){let t=Object.getPrototypeOf(e),n=new Set([...ee(e),...ee(t)]);n.delete(`constructor`),n.delete(O),v(t,Zr,n)}e[Zr].forEach(e=>$r(n,e,t&&e in t?t[e]:!0))}),e)}function $r(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;Ei(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)}Ti(e,r,t)}let ei=`splice`,ti=`update`,ni={get(e,t){let n=e[O];return t===O?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):T(ai,t)?ai[t]:e[t]},set(e,t,n){let r=e[O];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var ri=class{constructor(e=`ObservableArray@`+u(),t,n){this.owned_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=n,this.atom_=new ae(e),this.enhancer_=(n,r)=>t(n,r,e+`[..]`)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}dehanceValues_(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}getArrayLength_(){return this.atom_.reportObserved(),this.values_.length}setArrayLength_(e){(!Number.isInteger(e)||e<0)&&n(40,e);let t=this.values_.length;if(e!==t)if(e>t){let n=Array.from({length:e-t});this.spliceWithArray_(t,0,n)}else this.spliceWithArray_(e,t-e)}updateArrayLength_(e,t){e!==this.lastKnownLength_&&n(16),this.lastKnownLength_+=t}spliceWithArray_(e,t,n){Pt(this.atom_);let r=this.values_.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=s),Wr(this)){let r=Kr(this,{object:this.proxy_,type:ei,index:e,removedCount:t,added:n});if(!r)return s;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.enhancer_(e,void 0));{let e=n.length-t;this.updateArrayLength_(r,e)}let i=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,i),this.dehanceValues_(i)}spliceItemsIntoValues_(e,t,n){if(n.length<1e4)return this.values_.splice(e,t,...n);{let r=this.values_.slice(e,e+t),i=this.values_.slice(e+t);this.values_.length+=n.length-t;for(let t=0;t<n.length;t++)this.values_[e+t]=n[t];for(let t=0;t<i.length;t++)this.values_[e+n.length+t]=i[t];return r}}notifyArrayChildUpdate_(e,t,n){let r=!this.owned_&&vn(),i=qr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ti,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&bn(a),this.atom_.reportChanged(),i&&Yr(this,a),r&&Sn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&vn(),i=qr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:ei,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&bn(a),this.atom_.reportChanged(),i&&Yr(this,a),r&&Sn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Pt(this.atom_);let r=n[e];if(Wr(this)){let n=Kr(this,{type:ti,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 ii(e,t,n=`ObservableArray@`+u(),r=!1){return Ai(()=>{let i=new ri(n,t,r);y(i.values_,O,i);let a=new Proxy(i.values_,ni);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var ai={clear(){return this.splice(0)},replace(e){let t=this[O];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[O];switch(arguments.length){case 0:return[];case 1:return r.spliceWithArray_(e);case 2:return r.spliceWithArray_(e,t)}return r.spliceWithArray_(e,t,n)},spliceWithArray(e,t,n){return this[O].spliceWithArray_(e,t,n)},push(...e){let t=this[O];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[O].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[O];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return P.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){P.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[O],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};I(`at`,oi),I(`concat`,oi),I(`flat`,oi),I(`includes`,oi),I(`indexOf`,oi),I(`join`,oi),I(`lastIndexOf`,oi),I(`slice`,oi),I(`toString`,oi),I(`toLocaleString`,oi),I(`toSorted`,oi),I(`toSpliced`,oi),I(`with`,oi),I(`every`,si),I(`filter`,si),I(`find`,si),I(`findIndex`,si),I(`findLast`,si),I(`findLastIndex`,si),I(`flatMap`,si),I(`forEach`,si),I(`map`,si),I(`some`,si),I(`toReversed`,si),I(`reduce`,ci),I(`reduceRight`,ci);function I(e,t){typeof Array.prototype[e]==`function`&&(ai[e]=t(e))}function oi(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function si(e){return function(t,n){let r=this[O];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function ci(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}let li=b(`ObservableArrayAdministration`,ri);function ui(e){return h(e)&&li(e[O])}let di={},fi=`delete`;var pi=class{constructor(e,t=fe,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[O]=di,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,Ai(()=>{this.keysAtom_=se(`${this.name_}.keys()`),this.data_=new Map,this.hasMap_=new Map,e&&this.merge(e)})}has_(e){return this.data_.has(e)}has(e){if(!P.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new Et(this.has_(e),me,`${this.name_}.${te(e)}?`,!1);this.hasMap_.set(e,n),n.onBUOL=new Set([()=>this.hasMap_.delete(e)])}return t.get()}set(e,t){let n=this.has_(e);if(Wr(this)){let r=Kr(this,{type:n?ti:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this}delete(e){if(Pt(this.keysAtom_),Wr(this)&&!Kr(this,{type:fi,object:this,name:e}))return!1;if(this.has_(e)){let t=vn(),n=qr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:fi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&bn(r),Lr(()=>{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&&Yr(this,r),t&&Sn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=vn(),i=qr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ti,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&bn(a),n.setNewValue_(t),i&&Yr(this,a),r&&Sn()}}addValue_(e,t){Pt(this.keysAtom_),Lr(()=>{var n;let r=new Et(t,this.enhancer_,`${this.name_}.${te(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=vn(),r=qr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&bn(i),r&&Yr(this,i),n&&Sn()}get(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.keysAtom_.reportObserved(),this.data_.keys()}values(){let e=this,t=this.keys();return hi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return hi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return mi(e)&&(e=new Map(e)),Lr(()=>{g(e)?w(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):x(e)?(S(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){Lr(()=>{Bt(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return Lr(()=>{let t=gi(e),n=new Map,r=!1;for(let e of this.data_.keys())if(!t.has(e))if(this.delete(e))r=!0;else{let t=this.data_.get(e);n.set(e,t)}for(let[e,i]of t.entries()){let t=this.data_.has(e);if(this.set(e,i),this.data_.has(e)){let i=this.data_.get(e);n.set(e,i),t||(r=!0)}}if(!r)if(this.data_.size!==n.size)this.keysAtom_.reportChanged();else{let e=this.data_.keys(),t=n.keys(),r=e.next(),i=t.next();for(;!r.done;){if(r.value!==i.value){this.keysAtom_.reportChanged();break}r=e.next(),i=t.next()}}this.data_=n}),this}get size(){return this.keysAtom_.reportObserved(),this.data_.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},mi=b(`ObservableMap`,pi);function hi(e){return e[Symbol.toStringTag]=`MapIterator`,Ii(e)}function gi(e){if(x(e)||mi(e))return e;if(Array.isArray(e))return new Map(e);if(g(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}else return n(21,e)}let _i={};var vi=class{constructor(e,t=fe,n=`ObservableSet@`+u()){this.name_=void 0,this[O]=_i,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,this.enhancer_=(e,r)=>t(e,r,n),Ai(()=>{this.atom_=se(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){Lr(()=>{Bt(()=>{for(let e of this.data_.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.atom_.reportObserved(),this.data_.size}add(e){if(Pt(this.atom_),Wr(this)){let t=Kr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){Lr(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=vn(),n=qr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&bn(r),n&&Yr(this,r),t&&Sn()}return this}delete(e){if(Wr(this)&&!Kr(this,{type:fi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=vn(),n=qr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:fi,object:this,oldValue:e}:null;return t&&bn(r),Lr(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Yr(this,r),t&&Sn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return bi({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.atom_.reportObserved();let e=this,t=this.data_.values();return bi({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.dehanceValue_(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return yi(e)&&(e=new Set(e)),Array.isArray(e)||C(e)?Lr(()=>{let t=C(e)?e:new Set(e);if(t.size===0){this.clear();return}if(this.data_.size===0){t.forEach(e=>this.add(e));return}for(let e of this.data_.values())t.has(this.dehanceValue_(e))||this.delete(e);t.forEach(e=>this.add(e))}):e!=null&&n(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},yi=b(`ObservableSet`,vi);function bi(e){return e[Symbol.toStringTag]=`SetIterator`,Ii(e)}let xi=Object.create(null),Si=`remove`;var L=class{constructor(e,t=new Map,r,i=He){this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.lazyComputedKeys_=void 0,this.lazyObservableKeys_=void 0,this.target_=e,this.values_=t,this.name_=r,this.defaultAnnotation_=i,this.keysAtom_=new ae(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Ri(this.defaultAnnotation_)||n(`defaultAnnotation must be valid annotation`),this.appliedAnnotations_={}}getObservablePropValue_(e){return(this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e)).get()}materializeLazyComputed_(e){let t=this.lazyComputedKeys_?.get(e);if(!t)return;this.lazyComputedKeys_.delete(e),this.lazyComputedKeys_.size===0&&(this.lazyComputedKeys_=void 0);let n=t();return this.values_.set(e,n),n}materializeLazyObservable_(e){let t=this.lazyObservableKeys_?.get(e);if(!t)return;this.lazyObservableKeys_.delete(e),this.lazyObservableKeys_.size===0&&(this.lazyObservableKeys_=void 0);let n=t();return this.values_.set(e,n),n}setObservablePropValue_(e,t){let n=this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e);if(n instanceof Ot)return n.set(t),!0;if(Wr(this)){let n=Kr(this,{type:ti,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==P.UNCHANGED){let r=qr(this),i=vn(),a=r||i?{type:ti,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&bn(a),n.setNewValue_(t),r&&Yr(this,a),i&&Sn()}return!0}get_(e){return P.trackingDerivation&&!T(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return T(this.target_,e)?this.values_.has(e)?this.setObservablePropValue_(e,t):n?Reflect.set(this.target_,e,t):(this.target_[e]=t,!0):this.extend_(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,n)}has_(e){if(!P.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new Et(e in this.target_,me,`${this.name_}.${te(e)}?`,!1),this.pendingKeys_.set(e,t)),t.get()}extend_(e,t,n,r=!1){if(n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);Ei(this,n,e);let i=n.extend_(this,e,t,r);return i&&Ti(this,n,e),i}defineProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Wr(this)){let n=Kr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:i}=n;t.value!==i&&(t=r({},t,{value:i}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else a(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{rn()}return!0}defineObservableProperty_(e,t,n,r=!1){Pt(this.keysAtom_);try{nn();let i=this.delete_(e);if(!i)return i;if(Wr(this)){let n=Kr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=Ci(e),s={configurable:P.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,s))return!1}else a(this.target_,e,s);let c=new Et(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{rn()}return!0}defineComputedProperty_(e,t,n=!1){Pt(this.keysAtom_);try{nn();let r=this.delete_(e);if(!r)return r;if(Wr(this)&&!Kr(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=Ci(e),o={configurable:P.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,o))return!1}else a(this.target_,e,o);this.values_.set(e,new Ot(t)),this.notifyPropertyAddition_(e,void 0)}finally{rn()}return!0}delete_(e,t=!1){if(Pt(this.keysAtom_),!T(this.target_,e))return!0;if(Wr(this)&&!Kr(this,{object:this.proxy_||this.target_,name:e,type:Si}))return null;try{var n;nn();let r=qr(this),a=vn(),o=this.values_.get(e),s;if(!o&&(r||a)&&(s=i(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(delete this.appliedAnnotations_[e],o&&(this.values_.delete(e),o instanceof Et&&(s=o.value_),cn(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Si,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&bn(t),r&&Yr(this,t),a&&Sn()}}finally{rn()}return!0}notifyPropertyAddition_(e,t){var n;let r=qr(this),i=vn();if(r||i){let n=r||i?{type:`add`,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;i&&bn(n),r&&Yr(this,n),i&&Sn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),ee(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function R(e,t){if(t&&wi(e)&&n(`Options can't be provided for already observable objects.`),T(e,O))return Oi(e)instanceof L||n(`Cannot convert '${ki(e)}' into observable object:\nThe target is already observable of different type.\nExtending builtins is not supported.`),e;Object.isExtensible(e)||n(`Cannot make the designated object observable; it is not extensible`);let r=t?.name??`${g(e)?`ObservableObject`:e.constructor.name}@${u()}`;return v(e,O,new L(e,new Map,String(r),rt(t))),e}let z=b(`ObservableObjectAdministration`,L);function Ci(e){return xi[e]||(xi[e]={get(){return this[O].getObservablePropValue_(e)},set(t){return this[O].setObservablePropValue_(e,t)}})}function wi(e){return h(e)?z(e[O]):!1}function Ti(e,t,n){e.appliedAnnotations_[n]=t}function Ei(e,t,r){if(Ri(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!ve(t)&&T(e.appliedAnnotations_,r)){let i=`${e.name_}.${r.toString()}`,a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '${o}' to '${i}':\nThe field is already annotated with '${a}'.\nRe-annotating fields is not allowed.\nUse 'override' annotation for methods overridden by subclass.`)}}function Di(e,t){if(typeof e==`object`&&e){if(ui(e))return t!==void 0&&n(23),e[O].atom_;if(yi(e))return e.atom_;if(mi(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,ki(e)),r}if(wi(e)){if(!t)return n(26);let r=e[O],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,ki(e)),i}if(oe(e)||kt(e)||gn(e))return e}else if(p(e)&&gn(e[O]))return e[O];n(28)}function Oi(e,t){if(e||n(29),t!==void 0)return Oi(Di(e,t));if(oe(e)||kt(e)||gn(e)||mi(e)||yi(e))return e;if(e[O])return e[O];n(24,e)}function ki(e,t){let n;if(t!==void 0)n=Di(e,t);else if(Ln(e))return e.name;else n=wi(e)||mi(e)||yi(e)?Oi(e):Di(e);return n.name_}function Ai(e){let t=Vt(),n=wt(!0);nn();try{return e()}finally{rn(),Tt(n),Ht(t)}}let ji=o.toString;function Mi(e,t,n=-1){return Ni(e,t,n)}function Ni(e,t,n,r,i){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;let a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;let o=ji.call(e);if(o!==ji.call(t))return!1;switch(o){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++;break}e=Pi(e),t=Pi(t);let s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,r=t.constructor;if(n!==r&&!(p(n)&&n instanceof n&&p(r)&&r instanceof r)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];let c=r.length;for(;c--;)if(r[c]===e)return i[c]===t;if(r.push(e),i.push(t),s){if(c=e.length,c!==t.length)return!1;for(;c--;)if(!Ni(e[c],t[c],n-1,r,i))return!1}else{let a=Object.keys(e),o=a.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=a[s];if(!(T(t,o)&&Ni(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function Pi(e){return ui(e)?e.slice():x(e)||mi(e)||C(e)||yi(e)?Array.from(e.entries()):e}let Fi=globalThis.Iterator?.prototype||{};function Ii(e){return e[Symbol.iterator]=Li,r(Object.create(Fi),e)}function Li(){return this}function Ri(e){return e instanceof Object&&typeof e.annotationType_==`string`&&p(e.make_)&&p(e.extend_)}{let e=globalThis;[`Symbol`,`Map`,`Set`,`Proxy`].forEach(t=>{e[t]===void 0&&n(`MobX requires global '${t}' to be available or polyfilled`)})}typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Cn,extras:{getDebugName:ki},$mobx:O}),e.$mobx=O,e.FlowCancellationError=tr,e.ObservableMap=pi,e.ObservableSet=vi,e.Reaction=dn,e._allowStateChanges=Ct,e._allowStateChangesInsideComputed=In,e._allowStateReadsEnd=Ut,e._allowStateReadsStart=M,e._autoAction=Nn,e._autoActionBound=Fn,e._endAction=St,e._getAdministration=Oi,e._getGlobalState=Yt,e._interceptReads=dr,e._isComputingDerivation=Nt,e._resetGlobalState=Xt,e._startAction=xt,e.action=Mn,e.actionBound=Pn,e.autorun=Rn,e.compareDefault=de,e.compareIdentity=ce,e.compareShallow=ue,e.compareStructural=le,e.computed=j,e.computedStruct=mt,e.configure=qn,e.createAtom=se,e.defineProperty=Or,e.entries=Cr,e.extendObservable=Jn,e.flow=or,e.flowBound=sr,e.flowResult=lr,e.get=Dr,e.getAtom=Di,e.getDebugName=ki,e.getDependencyTree=Yn,e.getObserverTree=Zn,e.has=Er,e.intercept=fr,e.isAction=Ln,e.isBoxedObservable=Dt,e.isComputed=gr,e.isComputedProp=_r,e.isFlow=ur,e.isFlowCancellationError=nr,e.isObservable=yr,e.isObservableArray=ui,e.isObservableMap=mi,e.isObservableObject=wi,e.isObservableProp=br,e.isObservableSet=yi,e.keys=xr,e.makeAutoObservable=Qr,e.makeObservable=Xr,e.observable=A,e.observableDeep=lt,e.observableRef=st,e.observableShallow=ct,e.observableStruct=ut,e.observe=Ar,e.onBecomeObserved=Un,e.onBecomeUnobserved=Wn,e.onReactionError=fn,e.override=_e,e.ownKeys=kr,e.reaction=Vn,e.remove=Tr,e.runInAction=In,e.set=wr,e.spy=Cn,e.toJS=Ir,e.transaction=Lr,e.untracked=Bt,e.values=Sr,e.when=Rr})),Vv=we(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=zv():t.exports=Bv()}))();function Hv(e){if(Array.isArray(e))return Object.freeze(e.map(Hv));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]=Hv(r);return Object.freeze(t)}return e}function Uv(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 Wv(e){return typeof e==`string`?e:String(e)}function Gv(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 Kv(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 qv=class extends Error{constructor(e,t){super(t),this.variable=e}};function Jv(e){return e instanceof qv||e instanceof Error&&e.cause!==void 0&&Jv(e.cause)}var Yv=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?iy(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}},Xv=class extends Yv{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},Zv=class extends Yv{name=`EvalError`;kind=`EvalError`},Qv=class extends Zv{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=ay(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}},$v=class extends Zv{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}},ey=class extends Zv{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}},ty=class extends ey{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)}`}},ny=class extends Zv{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},ry=class extends Zv{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function iy(e,t){let n=e.split(`
|
|
58
58
|
`),r=t.line-1,i=[];if(r-1>=0&&r-1<n.length&&i.push({num:r,text:n[r-1]??``}),r>=0&&r<n.length&&i.push({num:r+1,text:n[r]??``}),r+1<n.length&&i.push({num:r+2,text:n[r+1]??``}),i.length===0)return``;let a=String(i[i.length-1]?.num??1).length,o=[];for(let e of i)if(o.push(` ${String(e.num).padStart(a,` `)} | ${e.text}`),e.num===t.line){let e=` ${` `.repeat(a)} | `,n=` `.repeat(Math.max(0,t.column-1));o.push(`${e}${n}^`)}return o.join(`
|
|
59
59
|
`)}function ay(e,t){if(t.length===0)return[];let n=t.map(t=>({name:t,dist:oy(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 oy(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 sy(e){throw Error(`unhandled node kind: ${JSON.stringify(e)}`)}const cy=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`]]),ly={left:`{{`,right:`}}`};var uy=class{src;leftDelim;rightDelim;offset=0;line=1;column=1;mode=`text`;pending;constructor(e,t=ly){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 Xv(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&&dy(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);dy(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);dy(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(;dy(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`;dy(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&&(py(e)||fy(e)&&py(this.src[this.offset+1]??``)||e===`.`&&py(this.src[this.offset+1]??``)))return this.readNumber(t);if(e===`.`)return this.readDotOrField(t);if(e!==void 0&&vy(e))return this.readIdentifier(t);throw this.err(`unexpected character ${JSON.stringify(e)}`,t,{found:e??`end of input`})}readQuotedString(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){let n=this.src[this.offset];if(n===`\\`){this.advanceBy(1),this.offset<this.src.length&&this.advanceBy(1);continue}if(n===`
|
|
60
60
|
`)throw this.err(`newline in interpreted string`,e,{found:`\\n`});if(n===`"`)return this.advanceBy(1),this.makeToken(`String`,this.src.slice(t,this.offset),e);this.advanceBy(1)}throw this.err(`unterminated string literal`,e,{expected:`"`,found:`end of input`})}readRawString(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){if(this.src[this.offset]==="`")return this.advanceBy(1),this.makeToken(`String`,this.src.slice(t,this.offset),e);this.advanceBy(1)}throw this.err(`unterminated raw string literal`,e,{expected:"`",found:`end of input`})}readChar(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){let n=this.src[this.offset];if(n===`\\`){this.advanceBy(1),this.offset<this.src.length&&this.advanceBy(1);continue}if(n===`
|
|
@@ -166,7 +166,7 @@ Config tooling:
|
|
|
166
166
|
running daemon; none spawn one.)
|
|
167
167
|
|
|
168
168
|
`,Hk=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`,Uk={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function Wk(e){let t=e[Uk.socket]??``,n=e[Uk.pane]??``;if(t===``||n===``)return null;let r=e[Uk.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const Gk=[`moves`,`can-move`,`still`];function Kk(e){let t=e.context_window?.current_usage;return t===null?`no`:t===void 0?`unknown`:`yes`}const qk=[`carried`,`missing`,`unanswered`];function Jk(e){let t=e.rate_limits;return t?.five_hour!=null||t?.seven_day!=null?`carried`:Kk(e)===`no`?`unanswered`:`missing`}function Yk(e){return{path:e.transcript_path,answered:Kk(e)===`yes`}}const Xk=[...Gk,`failed`,`drawing`],Zk=[`statusline`,`frames`],Qk=e=>e?.kind===`frames`?`frames`:`statusline`;var $k=class{seen=new Map;see(e,t,n,r){let i=Qk(t.client),a=JSON.stringify([e,i]),o=this.seen.get(a);o!==void 0&&o.order>r||(this.seen.delete(a),this.seen.set(a,{sessionId:e,said:{...t,role:i},at:n,order:r}),this.seen.size>64&&this.seen.delete(this.seen.keys().next().value))}list(e){return[...this.seen.values()].map(({said:t,at:n})=>({...t,ago:e-n}))}ofSession(e){return[...this.seen.values()].filter(t=>t.sessionId===e).map(e=>e.said)}};const eA={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`}}},tA=e=>eA[e];function nA(e){return tA(e).glyphs.kind===`bundled`}function rA(e){return tA(e).glyphs.kind===`configured`}const iA=e=>tA(e).label,aA=[{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 oA(e,t){let n=t.codePointAt(0);return aA.some(({since:t,from:r,to:i})=>r<=n&&n<=i&&e!==null&&lA(e,t)===!0)}const sA=Object.keys(eA);function cA(e){let t=/^\d+(?:\.\d+)*/.exec(e);return t===null?null:t[0].split(`.`).map(Number)}function lA(e,t){let n=cA(e),r=cA(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 uA(e){for(let t of sA){let n=tA(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 dA(e){let t=sA.find(t=>tA(t).term===e);return t===void 0?null:{name:t,version:null}}function fA(e){let t=uA(e.termtype)??dA(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 pA(e){let t=e.TERM_PROGRAM,n=sA.find(e=>tA(e).program===t),r=n===void 0?dA(e.TERM):{name:n,version:tA(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 mA(e){switch(e.kind){case`known`:return iA(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||null}}function hA(e){switch(e.kind){case`known`:return iA(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||`this terminal`}}function gA({name:e,version:t}){let n=tA(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=lA(t,n.since);return r===null?{kind:`unsaid`,since:n.since}:r?{kind:`draws`}:{kind:`older`,since:n.since,version:t}}const _A=sA.filter(e=>tA(e).links!==null).map(iA).join(`, `);function vA(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(!Ki(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||!Ki(r))break;if(`refreshInterval`in r)return{kind:`present`,refreshInterval:r.refreshInterval,from:e}}return{kind:`present`,refreshInterval:void 0,from:n.from}}function yA(e){return e.kind===`failed`?e:{kind:`ok`,value:e.value.find(e=>e.scope===`user`)?.env??{}}}const bA=[`drawn`,`boxes`],xA=1024*1024;function SA(e){switch(e.kind){case`claude-settings`:return`${e.kind} ${e.path.join(`.`)}=${JSON.stringify(e.value)} file=${JSON.stringify(e.file)}`;case`post-mortems-read`:return`${e.kind} through=${e.through}`}}function CA(e){let[t,...n]=e;return t===void 0?{ok:!0}:{ok:!1,reason:t,more:n}}const wA=Uk.truecolor;function TA(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 EA={name:`tmuxTruecolor`,label:`tmux truecolor`,takesMark:!1,probe:({tmux:e,claudeSettings:t})=>TA(e,(e,n)=>{if(!e.features.includes(`RGB`)||n.truecolor!==null)return{ok:!0};let r=yA(t.sources);if(r.kind===`failed`)return{ok:!1,reason:r.reason};let{userFile:i}=t.at,a=r.value[wA];return typeof a==`string`&&a!==``?{ok:!1,reason:`${wA} is set in ${i} — restart Claude Code to apply`}:{ok:!1,reason:`Claude Code renders the bar in 256 colours inside tmux`,fix:{kind:`claude-settings`,file:i,path:[`env`,wA],value:`1`}}})},DA={name:`utf8`,label:`UTF-8`,takesMark:!1,probe:({tmux:e})=>TA(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"})},OA={name:`termWidth`,label:`terminal width`,takesMark:!1,probe:({termCols:e})=>e===null?{ok:!1,reason:`no terminal width was measured (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}},kA={variable:`is never read`,action:`is never clicked`,helper:`is never called`,segment:`is in no preset`},AA={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(`
|
|
169
|
-
`).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return CA([...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${kA[e]}`)])}}},jA="re-run `cc-candybar install`";function MA(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:// — ${jA}`];let{app:t,missing:n}=e.value;return n.kind===`failed`?[`${t} opens cc-candybar://, but ${n.reason} — ${jA}`]:n.value.map(e=>`${e} is missing, and ${t} runs it — ${jA}`)}const NA={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}) — ${jA}`:`the URL handler runs cc-candybar ${e.handler}; the bar runs ${e.bar} — ${jA}`};case`lost`:return CA([...MA(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 PA({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 FA(e,t){return t===`frames`?`run \`node ${e.bundle} frames --lane <band|statusline|pane>\``:e.checkout===null?jA:`run \`just install-rust\` and point the statusLine command at ${e.checkout.root}/bin/cc-candybar-native`}function IA(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 — ${FA(e,`native`)}`];let{bundle:i,source:a}=PA(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} — ${FA(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 — ${FA(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 LA=`this daemon holds no render of this bar (it restarted since the bar was drawn, or has served 64 newer sessions)`,RA={name:`install`,label:`install`,takesMark:!1,probe:({install:e,askedBy: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===`click`?`${LA}, so which client draws it is unknown — run the doctor again once the bar has redrawn`:`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`}:CA([...new Set(i.flatMap(e=>IA(n,r,e)))])}};function zA({postMortems:e},t){return e.kind===`ok`&&t.kind===`ok`?e.value.filter(e=>t.value===null||on(e.identity,t.value)):[]}function BA(e,t){return e.kind===`failed`?t:t.filter(t=>t.pid!==e.value.pid)}const VA={name:`daemon`,label:`daemon`,takesMark:!1,probe:({daemon:{serving:e,processes:t,read:n}})=>{let r=[...n.kind===`failed`?[`which post-mortems were read could not be read: ${n.reason}`]:[],...t.kind===`failed`?[`the process table could not be read: ${t.reason}`]:[]],i=t.kind===`ok`?BA(e,t.value):[];if(e.kind===`failed`){let t=i.length>0?` — daemon ${i.map(e=>e.pid).join(`, `)} running`:``;return CA([`${e.reason}${t}`,...r])}let{pid:a,rss:o,rssLimit:s,postMortems:c}=e.value,l=zA(e.value,n),u=CA([...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}`]:[],...r,...i.map(e=>`daemon ${e.pid} (started ${e.started}, ${nn(e.rss)} MB${e.ppid===1?``:`, child of ${e.ppid}`}) runs beside the one serving the bar (${a}) — \`kill ${e.pid}\``),...sn(o,s)?[`the daemon holds ${nn(o)} MB of its ${nn(s)} MB limit — at the limit it records a post-mortem and restarts`]:[]]),d=l[0];return u.ok||d===void 0?u:{...u,fix:{kind:`post-mortems-read`,through:d.identity}}}},HA=`click 🩺 doctor in the bar's settings menu: if it runs, links work`;function UA(e,t){let n=mA(e);return t.kind===`ok`&&n!==null&&t.value.includes(n)?{kind:`draws`}:e.kind===`known`?gA(e.terminal):{kind:`unknown`}}function WA({identified:e,tmuxClient:t},n){let r=hA(e),i=UA(e,n),a=mA(e)===null?HA:`${HA}, 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: ${_A}`];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 GA={name:`links`,label:`links`,takesMark:!1,probe:({askedBy:e,terminal:t,clicked:n})=>{if(e===`click`)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 CA(WA(t,n))}}},KA=e=>e.filter(e=>e.role===`statusline`).map(e=>e.frame),qA={name:`effectRefresh`,label:`effect refresh`,takesMark:!1,probe:({frames:e,claudeSettings:t,askedBy:n})=>{let r=vA(t.sources);if(r.kind===`present`&&r.refreshInterval===1)return{ok:!0,note:`statusLine.refreshInterval is 1 in ${r.from.path}`};if(e.kind===`failed`)return{ok:!1,reason:e.reason};let i=KA(e.value),a=i.includes(`moves`)?`the bar moves (an effect, a fade, or an animated segment)`:i.includes(`can-move`)?`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)`:null;if(a===null)return i.includes(`still`)?{ok:!0}:{ok:!1,reason:`${i.length>0?i.includes(`drawing`)?`the bar's latest render has not finished`:`the bar's recent renders failed`:e.value.length>0?"only a `cc-candybar frames` display has drawn this bar, not Claude Code's statusline":n===`click`?LA:`no session of this Claude Code has drawn a statusline for this daemon in the last ${300/60} minutes`}, so whether it moves is unknown — run the doctor again once the bar has redrawn`};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`}) — the one that runs the bar comes from --settings, MDM or server-managed settings, which the doctor cannot read; set "refreshInterval": 1 beside its command there`};case`not-an-object`:return{ok:!1,reason:`${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`:{let{from:e,refreshInterval:t}=r,n=t===void 0?`${a}, but Claude Code redraws it only on events`:typeof t==`number`&&t>1?`${a}, but Claude Code redraws it only every ${t} s`:`${a}, but statusLine.refreshInterval is ${JSON.stringify(t)}, not a number of seconds Claude Code accepts (its minimum is 1)`;return e.scope===`managed`||e.scope===`project`?{ok:!1,reason:`${n} — its statusLine is in ${e.scope===`managed`?`managed settings`:`the project's checked-in settings`}, ${e.path}: set "refreshInterval": 1 there`}:{ok:!1,reason:`${n} (statusLine from ${e.path})`,fix:{kind:`claude-settings`,file:e.path,path:[`statusLine`,`refreshInterval`],value:1}}}}}},JA=e=>[...e].map(e=>`U+${e.codePointAt(0).toString(16).toUpperCase()}`).join(` `);function YA(e){switch(e.kind){case`unreported`:case`unasked`:return`this terminal`;case`unknown`:case`unnamed`:return hA(e);case`bundling`:case`unread`:case`configured`:return[iA(e.name),e.version].filter(e=>e!==null).join(` `)}}function XA(e){switch(e.kind){case`unreported`:case`unasked`:return null;case`unknown`:case`unnamed`:return mA(e);case`bundling`:case`unread`:return iA(e.name);case`configured`:{let t=iA(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 ZA(e){let t=XA(e.terminal);return t===null?void 0:{glyphs:e.glyphs,id:`${t}|${JA(e.glyphs)}`}}const QA={name:`nerdFont`,label:`Nerd Font`,takesMark:!0,probe:({nerdFont:e,marks:t})=>{if(e.kind===`none`)return{ok:!0};if(t.kind===`failed`)return{ok:!1,reason:`the mark book could not be read: ${t.reason}`};let n=ZA(e),r=e=>({ok:!1,reason:e,...n!==void 0&&{sighting:n}}),i=e.terminal,a=YA(i);switch(n===void 0?null:t.value.nerdFont?.[n.id]??null){case`drawn`:return{ok:!0};case`boxes`:return r(`${a} draws ${JA(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=eA[i.name].glyphs.since;if(e===null)return{ok:!0};let t=i.version===null?null:lA(i.version,e);if(t===!0)return{ok:!0};let n=iA(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 ${JA(n)} — set a Nerd Font as its font`)}}}};function $A(e){return e.join(`, `)}function ej(e){return`or set missingData: "ignore" on ${$A(e)}`}function tj(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;if(n.kind===`failed`)return[`${$A(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`?[`${$A(t)}: ${r} is not installed, so no pull request is ever shown — install it, ${ej(t)}`]:[`${$A(t)}: ${r} is not logged in to ${i} (${a.loggedOut}) — run \`${r} auth login --hostname ${i}\`, ${ej(t)}`]}function nj(e,t){if(e.kind===`unneeded`)return[];let{segments:n,fact:r}=e;return r.kind===`failed`?[`${$A(n)}: ${r.reason}`]:r.value.length===0?[t===`click`?`${$A(n)}: ${LA}, so whether Claude Code sends rate_limits is unseen — run the doctor again once the bar has redrawn`:`${$A(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`]:r.value.includes(`missing`)&&!r.value.includes(`carried`)?[`${$A(n)}: Claude Code sent no rate_limits — it sends them only to Claude.ai subscription sessions; on any other account, set missingData: "ignore" on ${$A(n)}`]:[]}function rj(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;switch(n.located.kind){case`ok`:return[];case`absent`:return[`${$A(t)}: memento is not installed (or is disabled) for ${n.claudeConfigDir} — install the memento plugin, ${ej(t)}`];case`failed`:return[`${$A(t)}: whether memento is installed could not be read: ${n.located.reason}`]}}const ij={name:`segmentData`,label:`segment data`,takesMark:!1,probe:({data:e,askedBy:t})=>CA([...tj(e.pullRequests),...nj(e.rateLimits,t),...rj(e.memento)])};function aj({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 ${xA/1024/1024} MiB of`} the transcript ${e} are not JSON objects — the bar skips them, so what it counts from them is missing`]}}}const oj=[AA,RA,VA,NA,GA,EA,DA,OA,qA,QA,ij,{name:`sessionData`,label:`session data`,takesMark:!1,probe:({transcripts:e,askedBy:t})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.length===0?{ok:!1,reason:t===`click`?`${LA}, so which transcript it reads is unknown — run the doctor again once the bar has redrawn`:`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`}:CA(e.value.flatMap(aj))}],sj=oj.filter(e=>e.takesMark);function cj(e){return oj.map(t=>({check:t,verdict:t.probe(e)}))}function lj(e){return oj.find(t=>t.name===e)}const uj=/^[^\s"=\\]+$/,dj=e=>uj.test(e)?e:JSON.stringify(e),fj=`${X}doctor.`;function pj(e){let t=`${fj}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`,sighting:`${t}sighting`}}function mj(e,t){let n=e.kind===`seen`?e.tmuxClient:null,r=e.kind===`seen`?mA(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 hj(e,t){let n=e.kind===`seen`?e.tmuxClient:null;return`cols=${t??`-`} clientUtf8=${n===null?`-`:n.utf8?`yes`:`no`}`}function gj(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}=PA(t,e);return`${e.client}/${n.kind}/${r.kind===`uncompared`?`-`:r.kind}`}).join(`,`)||`-`}`}function _j({serving:e,processes:t,read:n}){let r=t.kind===`failed`?`daemons=unread others=-`:`daemons=${t.value.length} others=${BA(e,t.value).map(e=>e.pid).join(`,`)||`-`}`;if(e.kind===`failed`)return`${r} rss=unasked postMortems=unasked`;let{rss:i,rssLimit:a,postMortems:o}=e.value,s=o.kind===`failed`||n.kind===`failed`?`unread`:`${zA(e.value,n).length}/${o.value.length}`;return`${r} rss=${nn(i)}/${nn(a)} postMortems=${s}`}function vj(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 yj(e){if(e.kind===`failed`)return`frames=failed`;let t=KA(e.value);return`frames=${Xk.map(e=>t.filter(t=>t===e).length).join(`/`)}`}function bj(e){let t=vA(e);switch(t.kind){case`unread`:return`statusLine=failed`;case`absent`:case`not-an-object`:return`statusLine=${t.kind}`;case`present`:return`statusLine=${dj(`${t.from.scope}:${t.refreshInterval===void 0?`-`:JSON.stringify(t.refreshInterval)}`)}`}}function xj(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 Sj(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=ZA(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 Cj(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function wj(e){return e.flatMap(({check:e,verdict:t})=>{let n=pj(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:t.note??``},{key:n.fixable,value:Xh},{key:n.sighting,value:``}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:Cj(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?Xh:Yh},{key:n.sighting,value:t.sighting?.glyphs??``}]})}const Tj={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function Ej(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(Tj).map(([t,n])=>[`${e}${t}`,n]))}}const Dj=`armed`,Oj=`disarmed`,kj=`.armed`,Aj=e=>e.endsWith(kj);function jj(e,t,n){let r=`${e}${kj}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${Dj}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:Dj},[a]:{set:r,to:Oj},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:Oj}},disarm:a}}const Mj=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function Nj(e){return typeof e==`string`&&Mj.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 Pj(e){let t=Nj(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const Fj=[`/compact`,`/model`],Ij=`/clear`;function Lj(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=jj(`${e}clear`,{arm:Ij,confirm:`${Ij} ✓ confirm`},[n]);return{template:Fj.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${lD} }}`,actions:{...Object.fromEntries(Fj.map(e=>[t(e),{slash:Pj(e)}])),...r.actions,[n]:{slash:Pj(Ij)}},variables:r.variables,disarm:r.disarm}}const Rj=Array.from({length:10},(e,t)=>(t+1)*1e5),zj=Rj[0],Bj=Rj[Rj.length-1];function Vj(e){let t;try{t=Vi(e)}catch(e){return z(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?L(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=zj&&n<=Bj?L(n):z(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${zj}–${Bj} tokens)`)}function Hj(e,t){let n=Math.min(t??Bj,Bj),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:Rj.filter(e=>e<r).at(-1)??0,higher:Rj.find(e=>e>r&&e<=n)??0}}function Uj(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${lD} }}{{ 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:Pj(`/autocompact auto`)},...Object.fromEntries(Rj.map(t=>[`${e}${t}`,{slash:Pj(`/autocompact ${t}`)}]))}}}const Wj=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 }}`,Gj=`${X}menu`,Kj=`open`,qj=`${X}edit`,Jj=`${X}toolbar`,Yj=Ej(X),Xj=`${X}commands`,Zj=Lj(`${Xj}.`),Qj=`${X}autocompact`,$j=Uj(`${Qj}.`,Wj),eM=e=>({kind:`segment`,name:e}),tM=`${X}tab`,nM=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],rM=e=>`${tM}.${e}`,iM=e=>`${rM(e)}.toggle`,aM=e=>({variable:tM,key:tM,member:e}),oM=`${X}save`,sM=`${X}preset.save`,cM=`${X}preset.delete`,lM=e=>`${X}${e}`,uM=e=>`${X}apply.${e}`,dM=e=>`${X}reset.${e}`,fM=`${X}themeDefault.save`,pM=`${X}themeDefault.differs`,mM=`${X}themeDefault.theme`,hM={when:`{{ .${pM} }}`,template:`{{ action "${fM}" (printf "⤓ default for %s" .${mM}) }} {{ swatch "${uM(`theme`)}" .${mM} }}`},gM=`${X}resetAll`,_M=`${Gj}.toggle`,vM={variable:Gj,key:Gj,member:Kj},yM=`${X}undo`,bM=`${X}back`,xM=`${bM}.step`,SM=`${X}navigation.back`,CM=bM,wM={template:`{{ if gt .${SM} 0 }}{{ action "${bM}" "◁" }}{{ else }}{{ fg (${Hk}) "◁" }}{{ end }}`},TM=`${X}redo`,EM=`${X}doctor`,DM=`${EM}.run`,OM=e=>`${EM}.fix.${e}`,kM=(e,t)=>`${EM}.mark.${e}.${t}`,AM=e=>`${EM}.${e}`,jM={drawn:`[✓ shapes]`,boxes:`[✗ boxes]`},MM=DD(`${X}pickers`),NM=`${X}gear`,PM=`gear`,FM=`${NM}.toggle`,IM={variable:MM,key:MM,member:PM},LM=DD(`${X}gearPickers`),RM=[{template:`{{ themePreview }}`}],zM={template:`{{ layoutPreview }}`},BM={preset:[zM,{when:`{{ not .preset.bundled }}`,template:`{{ action "${cM}" (printf "🚮 delete %s" .${io.preset.effectiveVar}) }}`}],style:RM,variation:[zM],shade:[zM]},VM=(e,t)=>`${X}list.${e}.${t}`,HM=e=>`${X}resettable.${e}`,UM=e=>e.length===0?`false`:`(or ${e.map(e=>`.${HM(e)}`).join(` `)})`,WM={preset:`door`,theme:`look`,style:`gear`,effect:`look`,variation:`gear`,shade:`gear`,endcaps:`look`,transitions:`look`,autoWrap:`layout`,padding:`layout`,updateNotice:`config`,experimentalBand:`config`,experimentalStatusline:`config`,experimentalPane:`config`},GM=e=>e===`gear`?WM.theme:e,KM=Object.keys(io).map(e=>{let t=io[e],n=jO(t.configKey),r=zD({label:t.label,domain:n},t.sessionKey,t.effectiveVar,uM(e),WM[e]===`gear`?LM:MM);return{...t,name:e,control:r,beneath:BM[e]??[]}}),qM=e=>KM.filter(t=>WM[t.name]===e),JM=e=>KM.filter(t=>GM(WM[t.name])===e),YM={theme:[vr(NM,IM,{kind:`container`,direction:`horizontal`,children:qM(`gear`).map(cN)},`drop`)]},XM=e=>qM(e).flatMap(e=>[cN(e),...YM[e.name]??[]]);new Set(KM.flatMap(e=>[e.sessionKey,e.configKey]));const ZM=jj(gM,{arm:`⟲`,confirm:`⟲ reset all?`},KM.map(e=>dM(e.name))),QM=[`unsaved`,`history.undo`,`history.redo`],$M=e=>`${X}${e}`,eN=$M(`unsaved`),tN=(e,t)=>({body:t,shown:`(gt .${$M(e)} 0)`}),nN=[tN(`unsaved`,`{{ action "${oM}" (printf "💾 save %d" .${eN}) }}`),tN(`history.undo`,`{{ action "${yM}" "↶" }}`),tN(`history.redo`,`{{ action "${TM}" "↷" }}`),{body:ZM.template,shown:`(or ${UM(KM.map(e=>e.name))} ${ZM.armed})`}],rN={when:`{{ or ${nN.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+nN.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},iN=[{step:ZM,place:`door`},{step:Zj,place:`session`}],aN=e=>e.map(e=>e.step.disarm),oN=aN(iN),sN=aN(iN.filter(e=>e.place!==`door`));function cN(e){let t=lM(e.name);return e.control.kind===`inline`?eM(t):vr(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[...e.control.list.rows,...e.beneath].map((t,n)=>eM(VM(e.name,n)))},`drop`)}function lN(e){return e===Gj}function uN(e){let t=eM(Gj);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[uN(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 dN(e){return fN(e)>0?e:uN(e)}function fN(e){let t=0;for(let n of __(e))n.kind===`segment`&&lN(n.name)&&(t+=1);return t}function pN(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&lN(e.name)||e.opens!==void 0&&pN(e.opens.body,!0):e.children.some(e=>pN(e,n))}const mN={session:{direction:`vertical`,content:[eM(Jj),{kind:`container`,direction:`horizontal`,children:[eM(Xj),eM(Qj)]}],after:[]},look:{direction:`horizontal`,content:[],after:[eM(fM)]},layout:{direction:`horizontal`,content:[eM(sM),eM(qj)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[eM(EM),...oj.map(e=>eM(AM(e.name)))],after:[]}},hN=e=>({kind:`container`,direction:mN[e].direction,children:[...mN[e].content,...XM(e),...mN[e].after]});function gN(e){return e.kind===`segment`?lN(e.name)?vr(e.name,vM,vN,`above`):e:bN(e)}function _N(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[eM(CM),...XM(`door`),eM(oM)]},{kind:`container`,direction:`horizontal`,children:nM.map(({member:e})=>vr(rM(e),aM(e),hN(e),`drop`))}]}}const vN=_N();function yN(e){let t=new Map;for(let e of __(vN))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=`${Gj}.fold.${fD(t)}`;return e.actions[i]={set:t,to:r.default},i})}function bN(e){return{...e,children:e.children.map(e=>gN(e))}}function xN(e){let t={variables:{[Gj]:wr(Gj,pr)},actions:{[_M]:Tr(Gj,Kj),[DM]:{doctor:`run`},[qj]:{do:[...yk]},...Yj.actions,...Zj.actions,...$j.actions,[oM]:{save:!0},[yM]:{undo:!0},[xM]:{back:!0},[bM]:{do:[xM,...oN]},[TM]:{redo:!0},[sM]:{preset:`save`},[fM]:{themeDefault:`save`},[cM]:{preset:`delete`,name:`{{ .${io.preset.effectiveVar} }}`}},segments:{[Gj]:{template:`{{ $door := ${Sr(Gj,Cr(e),Cr(`✖`))} }}{{ if ${br(vM)} }}{{ fg (keptOn (color "error") (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`},[Jj]:{template:Yj.template},[Xj]:{template:Zj.template,when:Zj.when},[Qj]:{template:$j.template,bg:$j.bg,when:$j.when},[CM]:wM,[oM]:rN,[fM]:hM,[sM]:{template:`{{ action "${sM}" "+ preset" }}`},[EM]:{template:`{{ action "${DM}" "🩺 doctor" }}`},[qj]:{template:`{{ action "${qj}" "✎ arrange" "✎ done" }}`}}};t.variables[pM]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[mM]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[SM]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of QM)t.variables[$M(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[tM]=wr(tM,`session`);for(let{member:e,label:n}of nM){t.actions[iM(e)]=Tr(tM,e),t.actions[rM(e)]={do:[iM(e),...sN]};let r=UM(JM(e).map(e=>e.name)),i=`(ternary ${Cr(` •`)} "" ${r})`,a=e=>`(print ${Cr(e)} ${i})`;t.segments[rM(e)]={template:`{{ ${Sr(rM(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,Zj.variables,ZM.variables),CN(t),SN(t),t.actions[Gj]={do:[_M,...oN,...yN(t)]},t}function SN(e){for(let t of oj){let n=pj(t.name),r=OM(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?bA:[];for(let n of i)e.actions[kM(t.name,n)]={doctor:`mark`,check:t.name,mark:n};let a=i.map(e=>` {{ action "${kM(t.name,e)}" "${jM[e]}" }}`).join(``);e.segments[AM(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} "${Yh}" }} {{ action "${r}" "[fix]" }}{{ end }}`+(a===``?``:`{{ if ne .${n.sighting} "" }} {{ .${n.sighting} }}${a}{{ end }}`)+`{{ end }}`}}}function CN(e){for(let t of KM){Object.assign(e.actions,t.control.actions);let n=dM(t.name);e.actions[n]={reset:t.configKey},e.variables[HM(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${HM(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[lM(t.name)]={template:`${t.control.template}${r}`},t.control.kind===`picker`&&[...t.control.list.rows.map(e=>({template:e})),...t.beneath].forEach((n,r)=>{e.segments[VM(t.name,r)]=n})}Object.assign(e.actions,ZM.actions),e.actions[FM]=Tr(MM,PM),e.segments[NM]={template:`{{ action "${FM}" "⚙" }}`}}function wN(e){let{variables:t,actions:n}=Ok();Object.assign(e.variables,t),Object.assign(e.actions,n)}function TN(e){let t=xN(e.globals.menuGlyph??`🍫`);wN(t);let n={...e.presets},r=[];for(let t of nv(e.presets)){let{node:i}=av(e,t),a=gN(dN(i));r.push(a),n[t]={...iv(e.presets,t),root:a}}let i=dD(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const EN=`${bD}live`,DN=[`☐ live`,`☑ live`],ON=`${bD}done`,kN=`${bD}cancel`,AN=`${bD}rewind`,jN=`${bD}changes`,MN=`(gt .${jN} 0)`,NN=`(or ${MN} (gt .${eN} 0))`,PN={variable:EN,key:EN,member:`open`};function FN(e){return`${bD}configuring.p${e}`}function IN(e){return`and ${br(Ck)} (not ${br(PN)}) (ne .${FN(e)} "true")`}function LN(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${gk} "${_r(e)}")`).join(` `)} false }}`}}function RN(e,t,n){return`{{ if ${IN(e)} }}${t}{{ else }}${n}{{ end }}`}const zN=`{{ and ${br(Ck)} .preset.customized }}`,BN=SD;function VN(e){return new Map([...uv(e),...UN(e)])}const HN=`${bD}addable`;function UN(e){return new Map([[HN,{members:Object.keys(e.segments).filter(e=>!BN(e)),library:{groups:fk.map(e=>({id:e,label:pk[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function WN(e,t,n){return n.segments[e]={template:t,when:wk,bg:Mk},{kind:`segment`,name:e}}function GN(e,t,n){let r=`${bD}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${Rm}`}) (action "${r}" "✖") }}`}function KN(e){return`{{ if ${br(Ck)} }}${e}{{ end }}`}function qN(e,t){return e.reduce((e,t)=>`{{ if and ${br(Ck)} ${br(t)} }}true{{ else }}${e}{{ end }}`,t)}function JN(e){return e.flatMap(e=>[...__(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function YN(e,t,n){return`${xk}${e}.${t}.${n}`}function XN(e,t,n,r){let i=p_(n),a=`${bD}${e.presetIdent}`,o=Sk(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=DD(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:pr},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:gk,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=YN(e.presetIdent,i,r),l=`${xk}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:L_(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=zD(LD(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 vr(d,f.list.ref,{kind:`container`,direction:`vertical`,children:p},`drop`)});return{term:`{{ action "${s}" "${Rk}" }}`,ref:{variable:gk,key:gk,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const ZN=`${bD}label:`;function QN(e){if(e.startsWith(ZN)){let t=e.slice(ZN.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function $N(e,t,n,r){let{artifacts:i}=n,a=p_(e),o=`${ZN}${a}:${e.name}`;i.segments[o]={template:`{{ "${_r(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=Object.fromEntries(M_.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...vr(o,r.ref,r.body,`drop`,qN([r.ref],`{{ ${IN(n.presetIdent)} }}`)),...Object.keys(s).length>0&&{settings:s},drafts:Object.fromEntries(M_.map(e=>[e,r.drafts[e]]))}}function eP(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${bD}${i}.insert.${t}`,s=`${bD}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:HN,anchor:n,relation:r};let c=TD(o),l=ED(s,o,void 0),u=kD(l),d=OD(l,c);return a.variables[l]=wr(l,pr),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=Tr(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${br({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${Rm}`}) $m }}{{ end }}`}}function tP(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!BN(e.name)),i=e=>tP(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=g_(o,i);if(BN(o.name)){n.push(s);continue}let c=p_(o),l=a===r?[eP(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=eP(t,u,c,`after`),f=GN(t,u,c),p=t.segments[o.name],m=XN(t,u,o,N_(p)),h=KN(f),g=KN(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>WN(e.host,e.template,t.artifacts)),{...$N(o,p,t,m),lead:h,trail:g},{...s,when:RN(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},WN(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:qN(JN(n),RN(t.presetIdent,`true`,e.when))}}}function nP(e,t,n,r,i,a,o){let s=`${bD}${t}.resetLayout`,c=`${bD}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:zN},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},rP(e,o)]}}function rP(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),rP(n,t)]}:{...e,children:[...e.children,t]}}function iP(e,t,n,r,i,a){let{node:o}=av(e,t),s={presetIdent:fD(t),rootKey:ak(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=tP(o,s);return n.variables[FN(s.presetIdent)]=LN(s.configured),nP(c,s.presetIdent,s.rootKey,n,r,i,a)}function aP(e){let t={variables:{},actions:{},segments:{}},n=Ak(`${bD}help`,Bk,[Ck],t);t.variables[EN]=wr(EN,pr),t.actions[EN]=Tr(EN,PN.member),t.segments[EN]={template:xr(EN,...DN),when:wk};let r={kind:`segment`,name:EN},i=n;t.variables[jN]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[ON]={do:[oM,...yk]},t.segments[ON]={template:`{{ if ${NN} }}{{ action "${ON}" "✓ save" }}{{ else }}{{ action "${ON}" "✓ done" }}{{ end }}`,when:wk},t.actions[AN]={rewind:!0},t.actions[kN]={do:[AN,...yk]},t.segments[kN]={template:`{{ action "${kN}" "↩ cancel" }}`,when:`{{ and ${br(Ck)} ${MN} }}`};let a=[{kind:`segment`,name:ON},{kind:`segment`,name:kN}],o={...e.presets},s=[];for(let n of nv(e.presets)){let c=iP(e,n,t,a,r,i);s.push(c),o[n]={...iv(e.presets,n),root:c}}let c=dD(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}function oP(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function sP(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 cP(e,t,n){let r=h_(e,new Set(n.map(m_).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const lP=/^-?\d+$/;function uP(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 dP(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!lP.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 fP(e,t,n){return r=>r?lP.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 pP(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=>!lP.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 mP(e){return e===`config`?`set-config`:`set-state`}function hP(e,t,n){return t.kind===`int`?dP(`menu page "${e}"`):t.kind===`range`?fP(t.min,t.max,`${n} stepper "${e}"`):uP(t.allowed,`${n} "${e}"`,mP(n))}function gP(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:pP(e,n,t)}))}function _P(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 gP(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,hP(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 vP(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};_P(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=_P(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const yP=vP({},`config`,EP);function bP(e,t){return yP.register(e,t)}function xP(e){return yP.gateFor(e)}function SP(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:fv(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:[oP({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[oP({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:fv(e.insertSegmentFrom,t).members.map(t=>oP({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function CP(e,t){let n=ek(e).get(t);return n===void 0?null:String(n)}function wP(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?lk(n.persist):null;e?.scope===`preset-root`&&t.add(ak(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function TP(e){let t=VN(e);return[...wP(e),...Object.values(e.actions).flatMap(e=>SP(e,t))]}function EP(e){return gP(TP(e),`config`)}function DP(e,t){return{globals:{...t.globals,...e.globals??{}},variables:{...t.variables,...e.variables??{}},segments:AP(t.segments,OP(t.segments,e.segments??{})),root:Q_(e.root??G_,t.root),actions:{...t.actions,...e.actions??{}},styles:{...t.styles,...e.styles??{}},presets:AP(t.presets,kP(t.presets,e.presets??{})),themeDefaults:AP(t.themeDefaults,e.themeDefaults??{}),editGlobals:{...t.editGlobals,...e.editGlobals??{}},helpers:{...t.helpers,...e.helpers??{}}}}function OP(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 kP(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 AP(e,t){return{...e,...Object.fromEntries(Object.entries(t).map(([t,n])=>[t,{...e[t],...n}]))}}function jP(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: ${w_.join(`, `)})`,line:Y(e.source,t.split(`.`))}),null):PP(e,`${t}.cache`,n.cache)}function MP(e){return{required:!0,json:FP(),parse:(t,n,r,i)=>jP(t,n,i,e)??void 0}}const NP={noun:`cache`,arms:{ttl:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&LP(n)?{ttl:n}:$D(e,t,`cache.ttl must be a duration string like "5s", "100ms", "2m", "1h"; got ${Z(n)}`)},watch_file:{json:{type:`string`,pattern:`^/`},parse:(e,t,n)=>{if(typeof n!=`string`)return $D(e,t,`cache.watch_file must be a path string, got ${Z(n)}`);let r=dO(`cache.watch_file`,n);return r===null?{watch_file:n}:$D(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}:$D(e,t,`cache.depends_on must be an array of variable-name strings, got ${Z(n)}`)},key:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&n!==``?{key:n}:$D(e,t,`cache.key must be a non-empty template string, got ${Z(n)}`)},never:{json:{const:!0},parse:(e,t,n)=>n===!0?{never:!0}:$D(e,t,`cache.never must be the literal boolean true, got ${Z(n)}`)}}};function PP(e,t,n){return eO(e,NP,t,n)}function FP(){return vO(NP)}const IP=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/;function LP(e){return IP.test(e)}function RP(e,t,n){if(n===void 0)return{};if(!KD(n))return e.issues.push({path:t,message:`${t} must be an object, got ${qD(n)}`,line:Y(e.source,t.split(`.`))}),{};let r={};for(let[i,a]of Object.entries(n)){let n=tO(e,uF,`${t}.${i}`,a);n!==null&&(r[i]=n)}return r}function zP(){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 ${qD(i)}`,line:Y(e.source,t.split(`.`))});return}return i}}}function BP(){return{required:!0,json:{enum:[...E_]},parse:(e,t,n,r)=>{let i=r.field;if(typeof i!=`string`||!E_.includes(i)){e.issues.push({path:`${t}.field`,message:`git field must be one of: ${E_.join(`, `)}, got ${JSON.stringify(i)}`,line:Y(e.source,[...t.split(`.`),`field`])});return}return i}}}function VP(){return{required:!1,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.type;return HD(e,t,r,i===`number`||i===`boolean`||i===`string`?i:`string`)}}}const HP={noun:`parse`,arms:{text:{json:{const:!0},parse:(e,t,n)=>n===!0?{text:!0}:$D(e,t,`parse.text must be the literal boolean true, got ${Z(n)}`)},regex:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`?UP(e,t,n):$D(e,t,`parse.regex must be a pattern string, got ${Z(n)}`)},json:{json:{const:!0},parse:(e,t,n)=>n===!0?{json:!0}:$D(e,t,`parse.json must be the literal boolean true, got ${Z(n)}`)}}};function UP(e,t,n){let r;try{new RegExp(n),r=RegExp(`${n}|`).exec(``).length-1}catch(n){return $D(e,t,`parse.regex is not a valid regular expression: ${n.message}`)}return r>=1?{regex:n}:$D(e,t,`parse.regex must contain a capture group — its group 1 is the value; got ${JSON.stringify(n)}`)}function WP(){return{required:!1,json:vO(HP),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:Y(e.source,[...t.split(`.`),`regex`])}),r.parse===void 0?void 0:eO(e,HP,`${t}.parse`,r.parse)??void 0)}}function GP(){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)=>KD(r.parse)&&`json`in r.parse?KP(e,t,r.default):UD(e,t,r,`default`)}}function KP(e,t,n){if(n!==void 0)return qP(n)?n:$D(e,`${t}.default`,`${t}.default must be a JSON value (a json-parsed source's document), got ${Z(n)}`)??void 0}function qP(e){return e!==null&&JP(e)}function JP(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(JP);let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&Object.values(e).every(JP)}default:return!1}}const YP={value:zP(),default:aO()},XP={path:uO(),type:pO([`string`,`number`,`boolean`]),default:VP()},ZP={name:uO(),default:aO()},QP={path:fO(),readMode:pO([`whole`,`first-line`]),parse:WP(),cache:MP(`file`),default:GP()},$P={command:uO(),parse:WP(),cache:MP(`shell`),default:GP()};function eF(e){return{cache:`${e}, so it takes no cache policy — delete the key`}}const tF={template:uO(),default:aO()},nF=eF(`a template variable recomputes whenever a variable it reads changes`),rF={layout:uO(),default:aO()},iF=eF(`a time variable reads the instant its render is drawn at`),aF={field:BP(),default:aO()},oF=eF(`a git variable is refreshed by the daemon's own watch on the repository`),sF={key:uO(),default:aO()},cF=`kind`;function lF(e,t,n={}){return{...nO(cF,e,t),parse:(r,i,a)=>{YD(r,n,i,a);let o=XD(r,t,i,a);return o===null?null:{kind:e,...o}}}}const uF={tag:cF,noun:`source kind`,memberNoun:`variable`,arms:{literal:lF(`literal`,YP),input:lF(`input`,XP),env:lF(`env`,ZP),file:lF(`file`,QP),shell:lF(`shell`,$P),template:lF(`template`,tF,nF),time:lF(`time`,rF,iF),git:lF(`git`,aF,oF),state:lF(`state`,sF)}};function dF(){return _O(uF)}function fF(){return{type:`object`,additionalProperties:dF()}}const pF=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 mF(e){let t=pF.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 hF=/^[A-Za-z_][A-Za-z0-9_]*$/,gF={pattern:hF.source},_F={anyOf:[{type:`boolean`},{type:`string`},{type:`integer`}]},vF={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`,...gF}}}]},default:_F}},yF=[`label`,`domain`,`default`],bF=[`min`,`max`,`step`,`atLeast`];function xF(e,t,n){e.issues.push({path:t,message:n,line:Y(e.source,t.split(`.`))})}function SF(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 xF(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 xF(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?xF(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(KD(n)){let{min:r,max:i,step:a=1,atLeast:o}=n;return Object.keys(n).filter(e=>!bF.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}}:xF(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 xF(e,t,`domain must be "bool", a list of words, or { min, max }, got ${Z(n)}`)}function CF(e,t,n){if(!KD(n))return xF(e,t,`${t} must be { label, domain, default }, got ${qD(n)}`);for(let r of Object.keys(n))yF.includes(r)||xF(e,`${t}.${r}`,`Unknown setting key "${r}". Expected one of: ${yF.join(`, `)}`);let{label:r}=n,i=typeof r==`string`&&r.length>0&&!/[\n\r]/.test(r);i||xF(e,`${t}.label`,`a setting needs a one-line, non-empty "label" — the name its control shows, spliced into a synthesized template string — got ${Z(r)}`);let a=SF(e,`${t}.domain`,n.domain);if(!i||a===void 0)return;let o={label:r,domain:a,default:n.default};return!wF(n.default)||!I_(o,n.default)?xF(e,`${t}.default`,`default must be ${B_(o)}, got ${Z(n.default)}`):o}function wF(e){return typeof e==`boolean`||typeof e==`string`||typeof e==`number`}const TF={theme:`its default for this segment is segments.<name>.palette, and a placement sets its own with settings: { ${A_}: "<theme>" }`,effect:`a placement follows the bar's effect, or sets its own with settings: { effect: "<effect>" }`};function EF(e){return M_.includes(e)}function DF(){return{required:!1,json:{type:`object`,propertyNames:{...gF,not:{enum:[...M_]}},additionalProperties:vF},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!KD(i))return xF(e,a,`${a} must be an object of name → { label, domain, default }, got ${qD(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i)){if(!hF.test(t)){xF(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(EF(t)){xF(e,`${a}.${t}`,`setting "${t}" is one every placement already has — ${TF[t]}`);continue}let r=CF(e,`${a}.${t}`,n);r!==void 0&&(o[t]=r)}return o}}}const OF=xD.map(e=>e.replace(/\./g,`\\.`)).join(`|`);function kF(){return{required:!1,json:{type:`string`,minLength:1,pattern:`^(?!${OF})[^:/]+$`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return typeof i==`string`&&i.length>0&&!/[:/]/.test(i)&&!SD(i)?i:xF(e,`${t}.${n}`,`a placement "id" must be a non-empty string without "/" or ":", outside the reserved ${xD.map(e=>`"${e}"`).join(`, `)} namespaces, got ${Z(i)}`)}}}function AF(){return{required:!1,json:{type:`object`,propertyNames:gF,additionalProperties:_F},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!KD(i))return xF(e,a,`a placement's "settings" must be an object of setting name → value, got ${qD(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i))wF(n)?o[t]=n:xF(e,`${a}.${t}`,`setting "${t}" must be a boolean, a word, or a number, got ${qD(n)}`);return o}}}function jF(e){return new Set(Object.keys(e.segments).filter(e=>!SD(e)))}function MF(e,t,n){if(t===void 0)return{};if(!KD(t))return e.issues.push({path:`segments`,message:`segments must be an object, got ${qD(t)}`,line:Y(e.source,[`segments`])}),{};let r={};for(let[i,a]of Object.entries(t)){let t=JD(e,n.has(i)?RF:LF,`segments.${i}`,a);t!==null&&(r[i]=t)}return r}function NF(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>r[n]===void 0?$D(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${mF(t.slice(9))}`)??void 0:VD(e,t,r,n)??void 0}}function PF(){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 ${Z(i)}`,line:Y(e.source,[...t.split(`.`),n])})}}}}function FF(){return{required:!1,json:fF(),parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return RP(e,`${t}.${n}`,i)}}}const IF={template:NF(),description:aO(),group:pO(dk),width:PF(),justify:pO(V_),truncate:pO(H_),bg:aO(),fg:aO(),when:aO(),palette:lO(),vars:FF(),settings:DF(),missingData:pO(D_)},LF={noun:`segment key`,fields:IF},RF={noun:`segment key`,fields:{...IF,template:aO()}},zF=`#/definitions/LayoutNode`,BF={kind:`container`,direction:`vertical`,children:[]};function VF(e){return{required:!0,json:{const:e},parse:()=>e}}function HF(){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 ${Z(i)}`,line:Y(e.source,[`root`])}),``)}}}function UF(){return{required:!0,json:{enum:[...d_]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&d_.includes(i)?i:(e.issues.push({path:`${t}.${n}`,message:`a container "direction" must be one of: ${d_.join(`, `)} (got ${JSON.stringify(i)})`,line:Y(e.source,[`root`])}),`vertical`)}}}function WF(e){return{required:!0,json:{type:`array`,items:{$ref:zF}},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 ${qD(a)}`,line:Y(t.source,[`root`])}),[])}}}const GF={noun:`layout-node key`,fields:{kind:VF(`segment`),name:HF(),when:aO(),id:kF(),settings:AF()}},KF=()=>pO(mm),qF={noun:`layout-node key`,fields:{kind:VF(`container`),direction:UF(),children:WF(rO(()=>QF)),when:aO(),distribution:KF()}};function JF(){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 ${Z(i)}`,line:Y(e.source,[`root`])}),``)}}}const YF={noun:`layout-node key`,fields:{seg:JF(),when:aO(),id:kF(),settings:AF()}},XF={noun:`layout-node key`,fields:{h:WF(rO(()=>QF)),when:aO(),distribution:KF()}},ZF={noun:`layout-node key`,fields:{v:WF(rO(()=>QF)),when:aO(),distribution:KF()}},QF=(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:Y(e.source,[`root`])}),BF):{kind:`segment`,name:n};if(!KD(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 ${qD(n)}`,line:Y(e.source,[`root`])}),BF;if(n.kind===`container`)return JD(e,qF,t,n)??BF;if(n.kind===`segment`)return JD(e,GF,t,n)??BF;if(n.kind===`cells`)return e.issues.push({path:t,message:`kind: "cells" is no longer supported — use the h-arm spelling instead:
|
|
169
|
+
`).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return CA([...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${kA[e]}`)])}}},jA="re-run `cc-candybar install`";function MA(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:// — ${jA}`];let{app:t,missing:n}=e.value;return n.kind===`failed`?[`${t} opens cc-candybar://, but ${n.reason} — ${jA}`]:n.value.map(e=>`${e} is missing, and ${t} runs it — ${jA}`)}const NA={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}) — ${jA}`:`the URL handler runs cc-candybar ${e.handler}; the bar runs ${e.bar} — ${jA}`};case`lost`:return CA([...MA(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 PA({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 FA(e,t){return t===`frames`?`run \`node ${e.bundle} frames --lane <band|statusline|pane>\``:e.checkout===null?jA:`run \`just install-rust\` and point the statusLine command at ${e.checkout.root}/bin/cc-candybar-native`}function IA(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 — ${FA(e,`native`)}`];let{bundle:i,source:a}=PA(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} — ${FA(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 — ${FA(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 LA=`this daemon holds no render of this bar (it restarted since the bar was drawn, or has served 64 newer sessions)`,RA={name:`install`,label:`install`,takesMark:!1,probe:({install:e,askedBy: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===`click`?`${LA}, so which client draws it is unknown — run the doctor again once the bar has redrawn`:`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`}:CA([...new Set(i.flatMap(e=>IA(n,r,e)))])}};function zA({postMortems:e},t){return e.kind===`ok`&&t.kind===`ok`?e.value.filter(e=>t.value===null||on(e.identity,t.value)):[]}function BA(e,t){return e.kind===`failed`?t:t.filter(t=>t.pid!==e.value.pid)}const VA={name:`daemon`,label:`daemon`,takesMark:!1,probe:({daemon:{serving:e,processes:t,read:n}})=>{let r=[...n.kind===`failed`?[`which post-mortems were read could not be read: ${n.reason}`]:[],...t.kind===`failed`?[`the process table could not be read: ${t.reason}`]:[]],i=t.kind===`ok`?BA(e,t.value):[];if(e.kind===`failed`){let t=i.length>0?` — daemon ${i.map(e=>e.pid).join(`, `)} running`:``;return CA([`${e.reason}${t}`,...r])}let{pid:a,rss:o,rssLimit:s,postMortems:c}=e.value,l=zA(e.value,n),u=CA([...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}`]:[],...r,...i.map(e=>`daemon ${e.pid} (started ${e.started}, ${nn(e.rss)} MB${e.ppid===1?``:`, child of ${e.ppid}`}) runs beside the one serving the bar (${a}) — \`kill ${e.pid}\``),...sn(o,s)?[`the daemon holds ${nn(o)} MB of its ${nn(s)} MB limit — at the limit it records a post-mortem and restarts`]:[]]),d=l[0];return u.ok||d===void 0?u:{...u,fix:{kind:`post-mortems-read`,through:d.identity}}}},HA=`click 🩺 doctor in the bar's settings menu: if it runs, links work`;function UA(e,t){let n=mA(e);return t.kind===`ok`&&n!==null&&t.value.includes(n)?{kind:`draws`}:e.kind===`known`?gA(e.terminal):{kind:`unknown`}}function WA({identified:e,tmuxClient:t},n){let r=hA(e),i=UA(e,n),a=mA(e)===null?HA:`${HA}, 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: ${_A}`];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 GA={name:`links`,label:`links`,takesMark:!1,probe:({askedBy:e,terminal:t,clicked:n})=>{if(e===`click`)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 CA(WA(t,n))}}},KA=e=>e.filter(e=>e.role===`statusline`).map(e=>e.frame),qA={name:`effectRefresh`,label:`effect refresh`,takesMark:!1,probe:({frames:e,claudeSettings:t,askedBy:n})=>{let r=vA(t.sources);if(r.kind===`present`&&r.refreshInterval===1)return{ok:!0,note:`statusLine.refreshInterval is 1 in ${r.from.path}`};if(e.kind===`failed`)return{ok:!1,reason:e.reason};let i=KA(e.value),a=i.includes(`moves`)?`the bar moves (an effect, a fade, or an animated segment)`:i.includes(`can-move`)?`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)`:null;if(a===null)return i.includes(`still`)?{ok:!0}:{ok:!1,reason:`${i.length>0?i.includes(`drawing`)?`the bar's latest render has not finished`:`the bar's recent renders failed`:e.value.length>0?"only a `cc-candybar frames` display has drawn this bar, not Claude Code's statusline":n===`click`?LA:`no session of this Claude Code has drawn a statusline for this daemon in the last ${300/60} minutes`}, so whether it moves is unknown — run the doctor again once the bar has redrawn`};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`}) — the one that runs the bar comes from --settings, MDM or server-managed settings, which the doctor cannot read; set "refreshInterval": 1 beside its command there`};case`not-an-object`:return{ok:!1,reason:`${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`:{let{from:e,refreshInterval:t}=r,n=t===void 0?`${a}, but Claude Code redraws it only on events`:typeof t==`number`&&t>1?`${a}, but Claude Code redraws it only every ${t} s`:`${a}, but statusLine.refreshInterval is ${JSON.stringify(t)}, not a number of seconds Claude Code accepts (its minimum is 1)`;return e.scope===`managed`||e.scope===`project`?{ok:!1,reason:`${n} — its statusLine is in ${e.scope===`managed`?`managed settings`:`the project's shared settings`}, ${e.path}: set "refreshInterval": 1 there`}:{ok:!1,reason:`${n} (statusLine from ${e.path})`,fix:{kind:`claude-settings`,file:e.path,path:[`statusLine`,`refreshInterval`],value:1}}}}}},JA=e=>[...e].map(e=>`U+${e.codePointAt(0).toString(16).toUpperCase()}`).join(` `);function YA(e){switch(e.kind){case`unreported`:case`unasked`:return`this terminal`;case`unknown`:case`unnamed`:return hA(e);case`bundling`:case`unread`:case`configured`:return[iA(e.name),e.version].filter(e=>e!==null).join(` `)}}function XA(e){switch(e.kind){case`unreported`:case`unasked`:return null;case`unknown`:case`unnamed`:return mA(e);case`bundling`:case`unread`:return iA(e.name);case`configured`:{let t=iA(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 ZA(e){let t=XA(e.terminal);return t===null?void 0:{glyphs:e.glyphs,id:`${t}|${JA(e.glyphs)}`}}const QA={name:`nerdFont`,label:`Nerd Font`,takesMark:!0,probe:({nerdFont:e,marks:t})=>{if(e.kind===`none`)return{ok:!0};if(t.kind===`failed`)return{ok:!1,reason:`the mark book could not be read: ${t.reason}`};let n=ZA(e),r=e=>({ok:!1,reason:e,...n!==void 0&&{sighting:n}}),i=e.terminal,a=YA(i);switch(n===void 0?null:t.value.nerdFont?.[n.id]??null){case`drawn`:return{ok:!0};case`boxes`:return r(`${a} draws ${JA(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=eA[i.name].glyphs.since;if(e===null)return{ok:!0};let t=i.version===null?null:lA(i.version,e);if(t===!0)return{ok:!0};let n=iA(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 ${JA(n)} — set a Nerd Font as its font`)}}}};function $A(e){return e.join(`, `)}function ej(e){return`or set missingData: "ignore" on ${$A(e)}`}function tj(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;if(n.kind===`failed`)return[`${$A(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`?[`${$A(t)}: ${r} is not installed, so no pull request is ever shown — install it, ${ej(t)}`]:[`${$A(t)}: ${r} is not logged in to ${i} (${a.loggedOut}) — run \`${r} auth login --hostname ${i}\`, ${ej(t)}`]}function nj(e,t){if(e.kind===`unneeded`)return[];let{segments:n,fact:r}=e;return r.kind===`failed`?[`${$A(n)}: ${r.reason}`]:r.value.length===0?[t===`click`?`${$A(n)}: ${LA}, so whether Claude Code sends rate_limits is unseen — run the doctor again once the bar has redrawn`:`${$A(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`]:r.value.includes(`missing`)&&!r.value.includes(`carried`)?[`${$A(n)}: Claude Code sent no rate_limits — it sends them only to Claude.ai subscription sessions; on any other account, set missingData: "ignore" on ${$A(n)}`]:[]}function rj(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;switch(n.located.kind){case`ok`:return[];case`absent`:return[`${$A(t)}: memento is not installed (or is disabled) for ${n.claudeConfigDir} — install the memento plugin, ${ej(t)}`];case`failed`:return[`${$A(t)}: whether memento is installed could not be read: ${n.located.reason}`]}}const ij={name:`segmentData`,label:`segment data`,takesMark:!1,probe:({data:e,askedBy:t})=>CA([...tj(e.pullRequests),...nj(e.rateLimits,t),...rj(e.memento)])};function aj({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 ${xA/1024/1024} MiB of`} the transcript ${e} are not JSON objects — the bar skips them, so what it counts from them is missing`]}}}const oj=[AA,RA,VA,NA,GA,EA,DA,OA,qA,QA,ij,{name:`sessionData`,label:`session data`,takesMark:!1,probe:({transcripts:e,askedBy:t})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.length===0?{ok:!1,reason:t===`click`?`${LA}, so which transcript it reads is unknown — run the doctor again once the bar has redrawn`:`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`}:CA(e.value.flatMap(aj))}],sj=oj.filter(e=>e.takesMark);function cj(e){return oj.map(t=>({check:t,verdict:t.probe(e)}))}function lj(e){return oj.find(t=>t.name===e)}const uj=/^[^\s"=\\]+$/,dj=e=>uj.test(e)?e:JSON.stringify(e),fj=`${X}doctor.`;function pj(e){let t=`${fj}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`,sighting:`${t}sighting`}}function mj(e,t){let n=e.kind===`seen`?e.tmuxClient:null,r=e.kind===`seen`?mA(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 hj(e,t){let n=e.kind===`seen`?e.tmuxClient:null;return`cols=${t??`-`} clientUtf8=${n===null?`-`:n.utf8?`yes`:`no`}`}function gj(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}=PA(t,e);return`${e.client}/${n.kind}/${r.kind===`uncompared`?`-`:r.kind}`}).join(`,`)||`-`}`}function _j({serving:e,processes:t,read:n}){let r=t.kind===`failed`?`daemons=unread others=-`:`daemons=${t.value.length} others=${BA(e,t.value).map(e=>e.pid).join(`,`)||`-`}`;if(e.kind===`failed`)return`${r} rss=unasked postMortems=unasked`;let{rss:i,rssLimit:a,postMortems:o}=e.value,s=o.kind===`failed`||n.kind===`failed`?`unread`:`${zA(e.value,n).length}/${o.value.length}`;return`${r} rss=${nn(i)}/${nn(a)} postMortems=${s}`}function vj(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 yj(e){if(e.kind===`failed`)return`frames=failed`;let t=KA(e.value);return`frames=${Xk.map(e=>t.filter(t=>t===e).length).join(`/`)}`}function bj(e){let t=vA(e);switch(t.kind){case`unread`:return`statusLine=failed`;case`absent`:case`not-an-object`:return`statusLine=${t.kind}`;case`present`:return`statusLine=${dj(`${t.from.scope}:${t.refreshInterval===void 0?`-`:JSON.stringify(t.refreshInterval)}`)}`}}function xj(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 Sj(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=ZA(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 Cj(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function wj(e){return e.flatMap(({check:e,verdict:t})=>{let n=pj(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:t.note??``},{key:n.fixable,value:Xh},{key:n.sighting,value:``}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:Cj(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?Xh:Yh},{key:n.sighting,value:t.sighting?.glyphs??``}]})}const Tj={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function Ej(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(Tj).map(([t,n])=>[`${e}${t}`,n]))}}const Dj=`armed`,Oj=`disarmed`,kj=`.armed`,Aj=e=>e.endsWith(kj);function jj(e,t,n){let r=`${e}${kj}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${Dj}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:Dj},[a]:{set:r,to:Oj},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:Oj}},disarm:a}}const Mj=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function Nj(e){return typeof e==`string`&&Mj.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 Pj(e){let t=Nj(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const Fj=[`/compact`,`/model`],Ij=`/clear`;function Lj(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=jj(`${e}clear`,{arm:Ij,confirm:`${Ij} ✓ confirm`},[n]);return{template:Fj.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${lD} }}`,actions:{...Object.fromEntries(Fj.map(e=>[t(e),{slash:Pj(e)}])),...r.actions,[n]:{slash:Pj(Ij)}},variables:r.variables,disarm:r.disarm}}const Rj=Array.from({length:10},(e,t)=>(t+1)*1e5),zj=Rj[0],Bj=Rj[Rj.length-1];function Vj(e){let t;try{t=Vi(e)}catch(e){return z(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?L(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=zj&&n<=Bj?L(n):z(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${zj}–${Bj} tokens)`)}function Hj(e,t){let n=Math.min(t??Bj,Bj),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:Rj.filter(e=>e<r).at(-1)??0,higher:Rj.find(e=>e>r&&e<=n)??0}}function Uj(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${lD} }}{{ 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:Pj(`/autocompact auto`)},...Object.fromEntries(Rj.map(t=>[`${e}${t}`,{slash:Pj(`/autocompact ${t}`)}]))}}}const Wj=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 }}`,Gj=`${X}menu`,Kj=`open`,qj=`${X}edit`,Jj=`${X}toolbar`,Yj=Ej(X),Xj=`${X}commands`,Zj=Lj(`${Xj}.`),Qj=`${X}autocompact`,$j=Uj(`${Qj}.`,Wj),eM=e=>({kind:`segment`,name:e}),tM=`${X}tab`,nM=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],rM=e=>`${tM}.${e}`,iM=e=>`${rM(e)}.toggle`,aM=e=>({variable:tM,key:tM,member:e}),oM=`${X}save`,sM=`${X}preset.save`,cM=`${X}preset.delete`,lM=e=>`${X}${e}`,uM=e=>`${X}apply.${e}`,dM=e=>`${X}reset.${e}`,fM=`${X}themeDefault.save`,pM=`${X}themeDefault.differs`,mM=`${X}themeDefault.theme`,hM={when:`{{ .${pM} }}`,template:`{{ action "${fM}" (printf "⤓ default for %s" .${mM}) }} {{ swatch "${uM(`theme`)}" .${mM} }}`},gM=`${X}resetAll`,_M=`${Gj}.toggle`,vM={variable:Gj,key:Gj,member:Kj},yM=`${X}undo`,bM=`${X}back`,xM=`${bM}.step`,SM=`${X}navigation.back`,CM=bM,wM={template:`{{ if gt .${SM} 0 }}{{ action "${bM}" "◁" }}{{ else }}{{ fg (${Hk}) "◁" }}{{ end }}`},TM=`${X}redo`,EM=`${X}doctor`,DM=`${EM}.run`,OM=e=>`${EM}.fix.${e}`,kM=(e,t)=>`${EM}.mark.${e}.${t}`,AM=e=>`${EM}.${e}`,jM={drawn:`[✓ shapes]`,boxes:`[✗ boxes]`},MM=DD(`${X}pickers`),NM=`${X}gear`,PM=`gear`,FM=`${NM}.toggle`,IM={variable:MM,key:MM,member:PM},LM=DD(`${X}gearPickers`),RM=[{template:`{{ themePreview }}`}],zM={template:`{{ layoutPreview }}`},BM={preset:[zM,{when:`{{ not .preset.bundled }}`,template:`{{ action "${cM}" (printf "🚮 delete %s" .${io.preset.effectiveVar}) }}`}],style:RM,variation:[zM],shade:[zM]},VM=(e,t)=>`${X}list.${e}.${t}`,HM=e=>`${X}resettable.${e}`,UM=e=>e.length===0?`false`:`(or ${e.map(e=>`.${HM(e)}`).join(` `)})`,WM={preset:`door`,theme:`look`,style:`gear`,effect:`look`,variation:`gear`,shade:`gear`,endcaps:`look`,transitions:`look`,autoWrap:`layout`,padding:`layout`,updateNotice:`config`,experimentalBand:`config`,experimentalStatusline:`config`,experimentalPane:`config`},GM=e=>e===`gear`?WM.theme:e,KM=Object.keys(io).map(e=>{let t=io[e],n=jO(t.configKey),r=zD({label:t.label,domain:n},t.sessionKey,t.effectiveVar,uM(e),WM[e]===`gear`?LM:MM);return{...t,name:e,control:r,beneath:BM[e]??[]}}),qM=e=>KM.filter(t=>WM[t.name]===e),JM=e=>KM.filter(t=>GM(WM[t.name])===e),YM={theme:[vr(NM,IM,{kind:`container`,direction:`horizontal`,children:qM(`gear`).map(cN)},`drop`)]},XM=e=>qM(e).flatMap(e=>[cN(e),...YM[e.name]??[]]);new Set(KM.flatMap(e=>[e.sessionKey,e.configKey]));const ZM=jj(gM,{arm:`⟲`,confirm:`⟲ reset all?`},KM.map(e=>dM(e.name))),QM=[`unsaved`,`history.undo`,`history.redo`],$M=e=>`${X}${e}`,eN=$M(`unsaved`),tN=(e,t)=>({body:t,shown:`(gt .${$M(e)} 0)`}),nN=[tN(`unsaved`,`{{ action "${oM}" (printf "💾 save %d" .${eN}) }}`),tN(`history.undo`,`{{ action "${yM}" "↶" }}`),tN(`history.redo`,`{{ action "${TM}" "↷" }}`),{body:ZM.template,shown:`(or ${UM(KM.map(e=>e.name))} ${ZM.armed})`}],rN={when:`{{ or ${nN.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+nN.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},iN=[{step:ZM,place:`door`},{step:Zj,place:`session`}],aN=e=>e.map(e=>e.step.disarm),oN=aN(iN),sN=aN(iN.filter(e=>e.place!==`door`));function cN(e){let t=lM(e.name);return e.control.kind===`inline`?eM(t):vr(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[...e.control.list.rows,...e.beneath].map((t,n)=>eM(VM(e.name,n)))},`drop`)}function lN(e){return e===Gj}function uN(e){let t=eM(Gj);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[uN(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 dN(e){return fN(e)>0?e:uN(e)}function fN(e){let t=0;for(let n of __(e))n.kind===`segment`&&lN(n.name)&&(t+=1);return t}function pN(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&lN(e.name)||e.opens!==void 0&&pN(e.opens.body,!0):e.children.some(e=>pN(e,n))}const mN={session:{direction:`vertical`,content:[eM(Jj),{kind:`container`,direction:`horizontal`,children:[eM(Xj),eM(Qj)]}],after:[]},look:{direction:`horizontal`,content:[],after:[eM(fM)]},layout:{direction:`horizontal`,content:[eM(sM),eM(qj)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[eM(EM),...oj.map(e=>eM(AM(e.name)))],after:[]}},hN=e=>({kind:`container`,direction:mN[e].direction,children:[...mN[e].content,...XM(e),...mN[e].after]});function gN(e){return e.kind===`segment`?lN(e.name)?vr(e.name,vM,vN,`above`):e:bN(e)}function _N(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[eM(CM),...XM(`door`),eM(oM)]},{kind:`container`,direction:`horizontal`,children:nM.map(({member:e})=>vr(rM(e),aM(e),hN(e),`drop`))}]}}const vN=_N();function yN(e){let t=new Map;for(let e of __(vN))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=`${Gj}.fold.${fD(t)}`;return e.actions[i]={set:t,to:r.default},i})}function bN(e){return{...e,children:e.children.map(e=>gN(e))}}function xN(e){let t={variables:{[Gj]:wr(Gj,pr)},actions:{[_M]:Tr(Gj,Kj),[DM]:{doctor:`run`},[qj]:{do:[...yk]},...Yj.actions,...Zj.actions,...$j.actions,[oM]:{save:!0},[yM]:{undo:!0},[xM]:{back:!0},[bM]:{do:[xM,...oN]},[TM]:{redo:!0},[sM]:{preset:`save`},[fM]:{themeDefault:`save`},[cM]:{preset:`delete`,name:`{{ .${io.preset.effectiveVar} }}`}},segments:{[Gj]:{template:`{{ $door := ${Sr(Gj,Cr(e),Cr(`✖`))} }}{{ if ${br(vM)} }}{{ fg (keptOn (color "error") (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`},[Jj]:{template:Yj.template},[Xj]:{template:Zj.template,when:Zj.when},[Qj]:{template:$j.template,bg:$j.bg,when:$j.when},[CM]:wM,[oM]:rN,[fM]:hM,[sM]:{template:`{{ action "${sM}" "+ preset" }}`},[EM]:{template:`{{ action "${DM}" "🩺 doctor" }}`},[qj]:{template:`{{ action "${qj}" "✎ arrange" "✎ done" }}`}}};t.variables[pM]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[mM]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[SM]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of QM)t.variables[$M(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[tM]=wr(tM,`session`);for(let{member:e,label:n}of nM){t.actions[iM(e)]=Tr(tM,e),t.actions[rM(e)]={do:[iM(e),...sN]};let r=UM(JM(e).map(e=>e.name)),i=`(ternary ${Cr(` •`)} "" ${r})`,a=e=>`(print ${Cr(e)} ${i})`;t.segments[rM(e)]={template:`{{ ${Sr(rM(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,Zj.variables,ZM.variables),CN(t),SN(t),t.actions[Gj]={do:[_M,...oN,...yN(t)]},t}function SN(e){for(let t of oj){let n=pj(t.name),r=OM(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?bA:[];for(let n of i)e.actions[kM(t.name,n)]={doctor:`mark`,check:t.name,mark:n};let a=i.map(e=>` {{ action "${kM(t.name,e)}" "${jM[e]}" }}`).join(``);e.segments[AM(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} "${Yh}" }} {{ action "${r}" "[fix]" }}{{ end }}`+(a===``?``:`{{ if ne .${n.sighting} "" }} {{ .${n.sighting} }}${a}{{ end }}`)+`{{ end }}`}}}function CN(e){for(let t of KM){Object.assign(e.actions,t.control.actions);let n=dM(t.name);e.actions[n]={reset:t.configKey},e.variables[HM(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${HM(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[lM(t.name)]={template:`${t.control.template}${r}`},t.control.kind===`picker`&&[...t.control.list.rows.map(e=>({template:e})),...t.beneath].forEach((n,r)=>{e.segments[VM(t.name,r)]=n})}Object.assign(e.actions,ZM.actions),e.actions[FM]=Tr(MM,PM),e.segments[NM]={template:`{{ action "${FM}" "⚙" }}`}}function wN(e){let{variables:t,actions:n}=Ok();Object.assign(e.variables,t),Object.assign(e.actions,n)}function TN(e){let t=xN(e.globals.menuGlyph??`🍫`);wN(t);let n={...e.presets},r=[];for(let t of nv(e.presets)){let{node:i}=av(e,t),a=gN(dN(i));r.push(a),n[t]={...iv(e.presets,t),root:a}}let i=dD(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const EN=`${bD}live`,DN=[`☐ live`,`☑ live`],ON=`${bD}done`,kN=`${bD}cancel`,AN=`${bD}rewind`,jN=`${bD}changes`,MN=`(gt .${jN} 0)`,NN=`(or ${MN} (gt .${eN} 0))`,PN={variable:EN,key:EN,member:`open`};function FN(e){return`${bD}configuring.p${e}`}function IN(e){return`and ${br(Ck)} (not ${br(PN)}) (ne .${FN(e)} "true")`}function LN(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${gk} "${_r(e)}")`).join(` `)} false }}`}}function RN(e,t,n){return`{{ if ${IN(e)} }}${t}{{ else }}${n}{{ end }}`}const zN=`{{ and ${br(Ck)} .preset.customized }}`,BN=SD;function VN(e){return new Map([...uv(e),...UN(e)])}const HN=`${bD}addable`;function UN(e){return new Map([[HN,{members:Object.keys(e.segments).filter(e=>!BN(e)),library:{groups:fk.map(e=>({id:e,label:pk[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function WN(e,t,n){return n.segments[e]={template:t,when:wk,bg:Mk},{kind:`segment`,name:e}}function GN(e,t,n){let r=`${bD}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${Rm}`}) (action "${r}" "✖") }}`}function KN(e){return`{{ if ${br(Ck)} }}${e}{{ end }}`}function qN(e,t){return e.reduce((e,t)=>`{{ if and ${br(Ck)} ${br(t)} }}true{{ else }}${e}{{ end }}`,t)}function JN(e){return e.flatMap(e=>[...__(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function YN(e,t,n){return`${xk}${e}.${t}.${n}`}function XN(e,t,n,r){let i=p_(n),a=`${bD}${e.presetIdent}`,o=Sk(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=DD(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:pr},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:gk,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=YN(e.presetIdent,i,r),l=`${xk}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:L_(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=zD(LD(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 vr(d,f.list.ref,{kind:`container`,direction:`vertical`,children:p},`drop`)});return{term:`{{ action "${s}" "${Rk}" }}`,ref:{variable:gk,key:gk,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const ZN=`${bD}label:`;function QN(e){if(e.startsWith(ZN)){let t=e.slice(ZN.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function $N(e,t,n,r){let{artifacts:i}=n,a=p_(e),o=`${ZN}${a}:${e.name}`;i.segments[o]={template:`{{ "${_r(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=Object.fromEntries(M_.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...vr(o,r.ref,r.body,`drop`,qN([r.ref],`{{ ${IN(n.presetIdent)} }}`)),...Object.keys(s).length>0&&{settings:s},drafts:Object.fromEntries(M_.map(e=>[e,r.drafts[e]]))}}function eP(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${bD}${i}.insert.${t}`,s=`${bD}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:HN,anchor:n,relation:r};let c=TD(o),l=ED(s,o,void 0),u=kD(l),d=OD(l,c);return a.variables[l]=wr(l,pr),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=Tr(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${br({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${Rm}`}) $m }}{{ end }}`}}function tP(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!BN(e.name)),i=e=>tP(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=g_(o,i);if(BN(o.name)){n.push(s);continue}let c=p_(o),l=a===r?[eP(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=eP(t,u,c,`after`),f=GN(t,u,c),p=t.segments[o.name],m=XN(t,u,o,N_(p)),h=KN(f),g=KN(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>WN(e.host,e.template,t.artifacts)),{...$N(o,p,t,m),lead:h,trail:g},{...s,when:RN(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},WN(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:qN(JN(n),RN(t.presetIdent,`true`,e.when))}}}function nP(e,t,n,r,i,a,o){let s=`${bD}${t}.resetLayout`,c=`${bD}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:zN},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},rP(e,o)]}}function rP(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),rP(n,t)]}:{...e,children:[...e.children,t]}}function iP(e,t,n,r,i,a){let{node:o}=av(e,t),s={presetIdent:fD(t),rootKey:ak(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=tP(o,s);return n.variables[FN(s.presetIdent)]=LN(s.configured),nP(c,s.presetIdent,s.rootKey,n,r,i,a)}function aP(e){let t={variables:{},actions:{},segments:{}},n=Ak(`${bD}help`,Bk,[Ck],t);t.variables[EN]=wr(EN,pr),t.actions[EN]=Tr(EN,PN.member),t.segments[EN]={template:xr(EN,...DN),when:wk};let r={kind:`segment`,name:EN},i=n;t.variables[jN]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[ON]={do:[oM,...yk]},t.segments[ON]={template:`{{ if ${NN} }}{{ action "${ON}" "✓ save" }}{{ else }}{{ action "${ON}" "✓ done" }}{{ end }}`,when:wk},t.actions[AN]={rewind:!0},t.actions[kN]={do:[AN,...yk]},t.segments[kN]={template:`{{ action "${kN}" "↩ cancel" }}`,when:`{{ and ${br(Ck)} ${MN} }}`};let a=[{kind:`segment`,name:ON},{kind:`segment`,name:kN}],o={...e.presets},s=[];for(let n of nv(e.presets)){let c=iP(e,n,t,a,r,i);s.push(c),o[n]={...iv(e.presets,n),root:c}}let c=dD(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}function oP(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function sP(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 cP(e,t,n){let r=h_(e,new Set(n.map(m_).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const lP=/^-?\d+$/;function uP(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 dP(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!lP.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 fP(e,t,n){return r=>r?lP.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 pP(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=>!lP.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 mP(e){return e===`config`?`set-config`:`set-state`}function hP(e,t,n){return t.kind===`int`?dP(`menu page "${e}"`):t.kind===`range`?fP(t.min,t.max,`${n} stepper "${e}"`):uP(t.allowed,`${n} "${e}"`,mP(n))}function gP(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:pP(e,n,t)}))}function _P(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 gP(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,hP(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 vP(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};_P(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=_P(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const yP=vP({},`config`,EP);function bP(e,t){return yP.register(e,t)}function xP(e){return yP.gateFor(e)}function SP(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:fv(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:[oP({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[oP({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:fv(e.insertSegmentFrom,t).members.map(t=>oP({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function CP(e,t){let n=ek(e).get(t);return n===void 0?null:String(n)}function wP(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?lk(n.persist):null;e?.scope===`preset-root`&&t.add(ak(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function TP(e){let t=VN(e);return[...wP(e),...Object.values(e.actions).flatMap(e=>SP(e,t))]}function EP(e){return gP(TP(e),`config`)}function DP(e,t){return{globals:{...t.globals,...e.globals??{}},variables:{...t.variables,...e.variables??{}},segments:AP(t.segments,OP(t.segments,e.segments??{})),root:Q_(e.root??G_,t.root),actions:{...t.actions,...e.actions??{}},styles:{...t.styles,...e.styles??{}},presets:AP(t.presets,kP(t.presets,e.presets??{})),themeDefaults:AP(t.themeDefaults,e.themeDefaults??{}),editGlobals:{...t.editGlobals,...e.editGlobals??{}},helpers:{...t.helpers,...e.helpers??{}}}}function OP(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 kP(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 AP(e,t){return{...e,...Object.fromEntries(Object.entries(t).map(([t,n])=>[t,{...e[t],...n}]))}}function jP(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: ${w_.join(`, `)})`,line:Y(e.source,t.split(`.`))}),null):PP(e,`${t}.cache`,n.cache)}function MP(e){return{required:!0,json:FP(),parse:(t,n,r,i)=>jP(t,n,i,e)??void 0}}const NP={noun:`cache`,arms:{ttl:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&LP(n)?{ttl:n}:$D(e,t,`cache.ttl must be a duration string like "5s", "100ms", "2m", "1h"; got ${Z(n)}`)},watch_file:{json:{type:`string`,pattern:`^/`},parse:(e,t,n)=>{if(typeof n!=`string`)return $D(e,t,`cache.watch_file must be a path string, got ${Z(n)}`);let r=dO(`cache.watch_file`,n);return r===null?{watch_file:n}:$D(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}:$D(e,t,`cache.depends_on must be an array of variable-name strings, got ${Z(n)}`)},key:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&n!==``?{key:n}:$D(e,t,`cache.key must be a non-empty template string, got ${Z(n)}`)},never:{json:{const:!0},parse:(e,t,n)=>n===!0?{never:!0}:$D(e,t,`cache.never must be the literal boolean true, got ${Z(n)}`)}}};function PP(e,t,n){return eO(e,NP,t,n)}function FP(){return vO(NP)}const IP=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/;function LP(e){return IP.test(e)}function RP(e,t,n){if(n===void 0)return{};if(!KD(n))return e.issues.push({path:t,message:`${t} must be an object, got ${qD(n)}`,line:Y(e.source,t.split(`.`))}),{};let r={};for(let[i,a]of Object.entries(n)){let n=tO(e,uF,`${t}.${i}`,a);n!==null&&(r[i]=n)}return r}function zP(){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 ${qD(i)}`,line:Y(e.source,t.split(`.`))});return}return i}}}function BP(){return{required:!0,json:{enum:[...E_]},parse:(e,t,n,r)=>{let i=r.field;if(typeof i!=`string`||!E_.includes(i)){e.issues.push({path:`${t}.field`,message:`git field must be one of: ${E_.join(`, `)}, got ${JSON.stringify(i)}`,line:Y(e.source,[...t.split(`.`),`field`])});return}return i}}}function VP(){return{required:!1,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.type;return HD(e,t,r,i===`number`||i===`boolean`||i===`string`?i:`string`)}}}const HP={noun:`parse`,arms:{text:{json:{const:!0},parse:(e,t,n)=>n===!0?{text:!0}:$D(e,t,`parse.text must be the literal boolean true, got ${Z(n)}`)},regex:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`?UP(e,t,n):$D(e,t,`parse.regex must be a pattern string, got ${Z(n)}`)},json:{json:{const:!0},parse:(e,t,n)=>n===!0?{json:!0}:$D(e,t,`parse.json must be the literal boolean true, got ${Z(n)}`)}}};function UP(e,t,n){let r;try{new RegExp(n),r=RegExp(`${n}|`).exec(``).length-1}catch(n){return $D(e,t,`parse.regex is not a valid regular expression: ${n.message}`)}return r>=1?{regex:n}:$D(e,t,`parse.regex must contain a capture group — its group 1 is the value; got ${JSON.stringify(n)}`)}function WP(){return{required:!1,json:vO(HP),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:Y(e.source,[...t.split(`.`),`regex`])}),r.parse===void 0?void 0:eO(e,HP,`${t}.parse`,r.parse)??void 0)}}function GP(){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)=>KD(r.parse)&&`json`in r.parse?KP(e,t,r.default):UD(e,t,r,`default`)}}function KP(e,t,n){if(n!==void 0)return qP(n)?n:$D(e,`${t}.default`,`${t}.default must be a JSON value (a json-parsed source's document), got ${Z(n)}`)??void 0}function qP(e){return e!==null&&JP(e)}function JP(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(JP);let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&Object.values(e).every(JP)}default:return!1}}const YP={value:zP(),default:aO()},XP={path:uO(),type:pO([`string`,`number`,`boolean`]),default:VP()},ZP={name:uO(),default:aO()},QP={path:fO(),readMode:pO([`whole`,`first-line`]),parse:WP(),cache:MP(`file`),default:GP()},$P={command:uO(),parse:WP(),cache:MP(`shell`),default:GP()};function eF(e){return{cache:`${e}, so it takes no cache policy — delete the key`}}const tF={template:uO(),default:aO()},nF=eF(`a template variable recomputes whenever a variable it reads changes`),rF={layout:uO(),default:aO()},iF=eF(`a time variable reads the instant its render is drawn at`),aF={field:BP(),default:aO()},oF=eF(`a git variable is refreshed by the daemon's own watch on the repository`),sF={key:uO(),default:aO()},cF=`kind`;function lF(e,t,n={}){return{...nO(cF,e,t),parse:(r,i,a)=>{YD(r,n,i,a);let o=XD(r,t,i,a);return o===null?null:{kind:e,...o}}}}const uF={tag:cF,noun:`source kind`,memberNoun:`variable`,arms:{literal:lF(`literal`,YP),input:lF(`input`,XP),env:lF(`env`,ZP),file:lF(`file`,QP),shell:lF(`shell`,$P),template:lF(`template`,tF,nF),time:lF(`time`,rF,iF),git:lF(`git`,aF,oF),state:lF(`state`,sF)}};function dF(){return _O(uF)}function fF(){return{type:`object`,additionalProperties:dF()}}const pF=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 mF(e){let t=pF.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 hF=/^[A-Za-z_][A-Za-z0-9_]*$/,gF={pattern:hF.source},_F={anyOf:[{type:`boolean`},{type:`string`},{type:`integer`}]},vF={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`,...gF}}}]},default:_F}},yF=[`label`,`domain`,`default`],bF=[`min`,`max`,`step`,`atLeast`];function xF(e,t,n){e.issues.push({path:t,message:n,line:Y(e.source,t.split(`.`))})}function SF(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 xF(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 xF(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?xF(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(KD(n)){let{min:r,max:i,step:a=1,atLeast:o}=n;return Object.keys(n).filter(e=>!bF.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}}:xF(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 xF(e,t,`domain must be "bool", a list of words, or { min, max }, got ${Z(n)}`)}function CF(e,t,n){if(!KD(n))return xF(e,t,`${t} must be { label, domain, default }, got ${qD(n)}`);for(let r of Object.keys(n))yF.includes(r)||xF(e,`${t}.${r}`,`Unknown setting key "${r}". Expected one of: ${yF.join(`, `)}`);let{label:r}=n,i=typeof r==`string`&&r.length>0&&!/[\n\r]/.test(r);i||xF(e,`${t}.label`,`a setting needs a one-line, non-empty "label" — the name its control shows, spliced into a synthesized template string — got ${Z(r)}`);let a=SF(e,`${t}.domain`,n.domain);if(!i||a===void 0)return;let o={label:r,domain:a,default:n.default};return!wF(n.default)||!I_(o,n.default)?xF(e,`${t}.default`,`default must be ${B_(o)}, got ${Z(n.default)}`):o}function wF(e){return typeof e==`boolean`||typeof e==`string`||typeof e==`number`}const TF={theme:`its default for this segment is segments.<name>.palette, and a placement sets its own with settings: { ${A_}: "<theme>" }`,effect:`a placement follows the bar's effect, or sets its own with settings: { effect: "<effect>" }`};function EF(e){return M_.includes(e)}function DF(){return{required:!1,json:{type:`object`,propertyNames:{...gF,not:{enum:[...M_]}},additionalProperties:vF},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!KD(i))return xF(e,a,`${a} must be an object of name → { label, domain, default }, got ${qD(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i)){if(!hF.test(t)){xF(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(EF(t)){xF(e,`${a}.${t}`,`setting "${t}" is one every placement already has — ${TF[t]}`);continue}let r=CF(e,`${a}.${t}`,n);r!==void 0&&(o[t]=r)}return o}}}const OF=xD.map(e=>e.replace(/\./g,`\\.`)).join(`|`);function kF(){return{required:!1,json:{type:`string`,minLength:1,pattern:`^(?!${OF})[^:/]+$`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return typeof i==`string`&&i.length>0&&!/[:/]/.test(i)&&!SD(i)?i:xF(e,`${t}.${n}`,`a placement "id" must be a non-empty string without "/" or ":", outside the reserved ${xD.map(e=>`"${e}"`).join(`, `)} namespaces, got ${Z(i)}`)}}}function AF(){return{required:!1,json:{type:`object`,propertyNames:gF,additionalProperties:_F},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!KD(i))return xF(e,a,`a placement's "settings" must be an object of setting name → value, got ${qD(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i))wF(n)?o[t]=n:xF(e,`${a}.${t}`,`setting "${t}" must be a boolean, a word, or a number, got ${qD(n)}`);return o}}}function jF(e){return new Set(Object.keys(e.segments).filter(e=>!SD(e)))}function MF(e,t,n){if(t===void 0)return{};if(!KD(t))return e.issues.push({path:`segments`,message:`segments must be an object, got ${qD(t)}`,line:Y(e.source,[`segments`])}),{};let r={};for(let[i,a]of Object.entries(t)){let t=JD(e,n.has(i)?RF:LF,`segments.${i}`,a);t!==null&&(r[i]=t)}return r}function NF(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>r[n]===void 0?$D(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${mF(t.slice(9))}`)??void 0:VD(e,t,r,n)??void 0}}function PF(){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 ${Z(i)}`,line:Y(e.source,[...t.split(`.`),n])})}}}}function FF(){return{required:!1,json:fF(),parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return RP(e,`${t}.${n}`,i)}}}const IF={template:NF(),description:aO(),group:pO(dk),width:PF(),justify:pO(V_),truncate:pO(H_),bg:aO(),fg:aO(),when:aO(),palette:lO(),vars:FF(),settings:DF(),missingData:pO(D_)},LF={noun:`segment key`,fields:IF},RF={noun:`segment key`,fields:{...IF,template:aO()}},zF=`#/definitions/LayoutNode`,BF={kind:`container`,direction:`vertical`,children:[]};function VF(e){return{required:!0,json:{const:e},parse:()=>e}}function HF(){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 ${Z(i)}`,line:Y(e.source,[`root`])}),``)}}}function UF(){return{required:!0,json:{enum:[...d_]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&d_.includes(i)?i:(e.issues.push({path:`${t}.${n}`,message:`a container "direction" must be one of: ${d_.join(`, `)} (got ${JSON.stringify(i)})`,line:Y(e.source,[`root`])}),`vertical`)}}}function WF(e){return{required:!0,json:{type:`array`,items:{$ref:zF}},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 ${qD(a)}`,line:Y(t.source,[`root`])}),[])}}}const GF={noun:`layout-node key`,fields:{kind:VF(`segment`),name:HF(),when:aO(),id:kF(),settings:AF()}},KF=()=>pO(mm),qF={noun:`layout-node key`,fields:{kind:VF(`container`),direction:UF(),children:WF(rO(()=>QF)),when:aO(),distribution:KF()}};function JF(){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 ${Z(i)}`,line:Y(e.source,[`root`])}),``)}}}const YF={noun:`layout-node key`,fields:{seg:JF(),when:aO(),id:kF(),settings:AF()}},XF={noun:`layout-node key`,fields:{h:WF(rO(()=>QF)),when:aO(),distribution:KF()}},ZF={noun:`layout-node key`,fields:{v:WF(rO(()=>QF)),when:aO(),distribution:KF()}},QF=(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:Y(e.source,[`root`])}),BF):{kind:`segment`,name:n};if(!KD(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 ${qD(n)}`,line:Y(e.source,[`root`])}),BF;if(n.kind===`container`)return JD(e,qF,t,n)??BF;if(n.kind===`segment`)return JD(e,GF,t,n)??BF;if(n.kind===`cells`)return e.issues.push({path:t,message:`kind: "cells" is no longer supported — use the h-arm spelling instead:
|
|
170
170
|
Old: { kind: "cells", segments: ["seg1", "seg2"] }
|
|
171
171
|
New: { h: ["seg1", "seg2"] }`,line:Y(e.source,[`root`])}),BF;if(n.kind===`group`){let r=JD(e,aI,t,n);return r===null?BF:(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}),sI(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:Y(e.source,[`root`])}),BF}if(a){let r=JD(e,YF,t,n);return r===null?BF:{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=JD(e,XF,t,n);return r===null?BF:{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=JD(e,ZF,t,n);return r===null?BF:{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:Y(e.source,[`root`])}),BF};function $F(){return{required:!0,json:{type:`object`,propertyNames:{pattern:U_.source},additionalProperties:{$ref:zF}},parse:(e,t,n,r)=>{let i=r[n];if(!KD(i))return e.issues.push({path:`${t}.${n}`,message:`"rows" must be an object of row name → layout node, got ${qD(i)}`,line:Y(e.source,[...t.split(`.`),n])}),{};let a={};for(let[r,o]of Object.entries(i)){if(!U_.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:Y(e.source,[...t.split(`.`),n,r])});continue}a[r]=QF(e,`${t}.${n}.${r}`,o)}return a}}}const eI={noun:`root key`,fields:{rows:$F(),when:aO(),distribution:KF()}};function tI(e,t,n){return KD(n)&&`rows`in n?JD(e,eI,t,n)??{rows:{}}:QF(e,t,n)}function nI(){return{required:!0,json:{type:`string`,pattern:U_.source},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`string`||!U_.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 "${pr}", got ${Z(i)}`,line:Y(e.source,[`root`])});return}return i}}}function rI(){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 ${Z(i)}`,line:Y(e.source,[`root`])});return}return i}}}}function iI(){return{required:!0,json:{type:`string`,pattern:`^[^\\n\\r]*$`},parse:(e,t,n,r)=>{let i=VD(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:Y(e.source,[...t.split(`.`),n])});return}return i}}}}const aI={noun:`layout-node key`,fields:{kind:VF(`group`),name:nI(),label:iI(),open:oO(),direction:pO(d_),key:rI(),bg:aO(),fg:aO(),when:aO(),distribution:KF(),children:WF(rO(()=>QF))}};function oI(e){return e.key??`groups.`+e.name}function sI(e){let t=vD+e.name;return vr(t,{variable:t,key:oI(e),member:e.name},{kind:`container`,direction:e.direction??`vertical`,children:e.children,...e.distribution!==void 0&&{distribution:e.distribution}},`drop`,e.when)}function cI(e,t,n){e.issues.push({path:t,message:n,line:Y(e.source,[`root`])})}function lI(e,t){wD(e,t,vD,`group nodes`);let n=e.groups;if(n.length===0)return;let r=new Set;for(let t of n)r.has(t.name)&&cI(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}.`)&&oI(t)===oI(r)&&cI(e,t.path,`group "${t.name}" shares key "${oI(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=oI(t);if(i.has(n)||i.set(n,pr),t.open===!0){let r=i.get(n);r!==`closed`&&cI(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=vD+e.name,r=oI(e),c=n.filter(t=>t!==e&&e.path.startsWith(t.path+`.`)).length,l=` `.repeat(c);a[t]=wr(r,i.get(r)),o[t]=Tr(r,e.name),s[t]={template:xr(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 uI=`menu`,dI=`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`,fI=e=>e.kind===`call`&&e.name===`dict`,pI=e=>e.kind===`literal`&&typeof e.value!=`object`,mI=e=>hr(``,e,2)===void 0;function hI(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&&fI(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(fI))return t(`whose options (dict …) is not its last argument — ${dI}`);if(i!==void 0&&a===void 0&&!pI(i)&&mI(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=hr(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${dI}`);let c=a===void 0?{}:MS(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=ND(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=CD(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 "${DD(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 gI(e){let t=Vb({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===uI).map(hI)}catch{return`parse-failed`}}function _I(e){let t=Vb({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(uI)}catch{return!1}}function vI(e,t,n){e.issues.push({path:t,message:n,line:Y(e.source,[`root`])})}function yI(e,t){wD(e,t,yD,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))_I(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:Y(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`&&_I(i)&&vI(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 __(X_(t.root)))typeof n.when==`string`&&_I(n.when)&&vI(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||!_I(r))continue;let n=gI(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:bI(r.apply);n!==void 0&&vI(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function bI(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(TD(e)===`closed`)return`whose apply action is named "${pr}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function xI(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 nv(e.presets)){let a=new Map,s=new Map;for(let c of __(av(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,gI(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=p_(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||bI(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=TD(i),f=ED(u,i,l.key),p=kD(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=OD(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]=Tr(f,d),n[f]=wr(f,pr),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 SI=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`ceiling`,`slash`,`do`];function CI(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function wI(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function TI(e,t){if(t===void 0)return{};if(!KD(t))return Q(e,`actions`,`actions must be an object, got ${qD(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=EI(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Q(e,t,n){e.issues.push({path:t,message:n,line:Y(e.source,t.split(`.`))})}function EI(e,t,n){if(!KD(n))return Q(e,t,`${t} must be an action object, got ${qD(n)}`),null;if(`persistWhen`in n)return Q(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=SI.filter(e=>e in n);return r.length===1?DI[r[0]](e,t,n):(Q(e,t,`action must declare exactly one of: ${SI.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const DI={set:(e,t,n)=>sL(e,t,n,`set`,rL),persist:(e,t,n)=>sL(e,t,n,`persist`,iL),copy:OI(`copy`),open:OI(`open`),reset:kI,undo:jI(`undo`),redo:jI(`redo`),back:jI(`back`),rewind:jI(`rewind`),save:jI(`save`),preset:MI,themeDefault:NI,doctor:FI,ceiling:II,slash:LI,do:RI};function OI(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=VD(t,n,r,e);return i===null?null:{[e]:i}}}function kI(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=zI(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 AI={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 jI(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Q(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${AI[e]}), got ${Z(r[e])}`),null)}}function MI(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Q(e,`${t}.preset`,`preset must be "save" or "delete", got ${Z(r)}`),null;if(r===`save`)return{preset:`save`};let a=VD(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function NI(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(Q(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${Z(n.themeDefault)}`),null)}const PI={run:[`doctor`],fix:[`doctor`,`check`],mark:[`doctor`,`check`,`mark`]};function FI(e,t,n){let r=n.doctor,i=typeof r==`string`&&Object.hasOwn(PI,r),a=i?PI[r]:[...new Set(Object.values(PI).flat())];for(let r of Object.keys(n))a.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${a.join(`, `)}`);if(!i)return Q(e,`${t}.doctor`,`doctor must be ${Object.keys(PI).map(e=>`"${e}"`).join(`, `)}, got ${Z(r)}`),null;if(r===`run`)return{doctor:`run`};let o=n.check,s=r===`mark`?sj:oj;if(typeof o!=`string`||!s.some(e=>e.name===o))return Q(e,`${t}.check`,`doctor ${r} must name a check (have: ${s.map(e=>e.name).join(`, `)}), got ${Z(o)}`),null;if(r===`fix`)return{doctor:`fix`,check:o};let c=n.mark;return bA.includes(c)?{doctor:`mark`,check:o,mark:c}:(Q(e,`${t}.mark`,`doctor mark must be ${bA.map(e=>`"${e}"`).join(` or `)}, got ${Z(c)}`),null)}function II(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Q(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${Z(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Q(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${Z(a)}`),null):{ceiling:`set`,to:a}}function LI(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=Nj(n.slash);return r.kind===`refused`?(Q(e,`${t}.slash`,r.reason),null):{slash:r.line}}function RI(e,t,n){for(let r of Object.keys(n))r!==`do`&&Q(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===``)?(Q(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 ${Z(r)}`),null):{do:r}}function zI(e,t,n,r,i,a){let o=VD(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Q(e,s,i),null):o.includes(`/`)?(Q(e,s,a(o)),null):o}const BI={set:`the SessionState key to write`,persist:`the config globals field to write`};function VI(e,t,n,r){let i=BI[r],a=zI(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 HI(e){return e===`set`?`set-state`:`set-config`}const UI={to:cL(`set`)},WI={to:cL(`persist`)},GI={from:lL(`set`)},KI={from:lL(`persist`)},qI={min:mL(),max:mL(),by:mL()},JI={int:dL()},YI={cycle:uL(`set`)},XI={cycle:uL(`persist`)},ZI={removeSegment:fL(`removeSegment`)},QI={insertSegment:fL(`insertSegment`),anchor:fL(`anchor`),relation:pL()},$I={insertSegmentFrom:lL(`persist`),anchor:fL(`anchor`),relation:pL()},eL={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},tL={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function nL(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>XD(e,t,n,r),c=mO(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?iO(s,...n):s}}const rL=[nL(`set`,UI),nL(`set`,GI),nL(`set`,qI,[eL,tL]),nL(`set`,JI),nL(`set`,YI)],iL=[nL(`persist`,WI),nL(`persist`,KI),nL(`persist`,qI,[eL,tL]),nL(`persist`,XI),nL(`persist`,ZI),nL(`persist`,QI,[],[`insertSegment`]),nL(`persist`,$I,[],[`insertSegmentFrom`])];function aL(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 oL(e){let t=aL(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 sL(e,t,n,r,i){let a=VI(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Q(e,t,`${oL(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)||Q(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 cL(e){let t=HI(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>zI(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 lL(e){let t=HI(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===``){Q(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){Q(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===``)){Q(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){Q(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){Q(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Q(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${Z(o)}`)}}}function uL(e){let t=HI(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`)){Q(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${qD(o)}`);return}let c=o;if(c.length<2){Q(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){Q(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Q(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){Q(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function dL(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Q(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${Z(r[n])}`);return}return!0}}}function fL(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=VD(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Q(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Q(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 pL(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Q(e,`${t}.${n}`,`relation must be "before" or "after", got ${Z(i)}`);return}return i}}}function mL(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Q(e,`${t}.${n}`,`${n} must be an integer, got ${Z(i)}`);return}return i}}}function hL(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const gL={noun:`style key`,fields:{hueShift:cO(),chromaScale:cO({min:0}),lightnessScale:cO(),lightnessShift:cO()}};function _L(e,t){if(!KD(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${qD(t)}`,line:Y(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:Y(e.source,[`styles`,r])});continue}if(zh(r)){e.issues.push({path:`styles.${r}`,message:hL(`styles.${r}`,r,`globals.endcaps`),line:Y(e.source,[`styles`,r])});continue}let t=JD(e,gL,`styles.${r}`,i);t!==null&&(n[r]={...Js,...t})}return n}const vL={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:tI(e,`${t}.${n}`,r[n])},globals:{required:!1,json:qO(),parse:(e,t,n,r)=>r[n]===void 0?void 0:KO(e,`${t}.${n}`,r[n])}}};function yL(e,t){if(!KD(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${qD(t)}`,line:Y(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:Y(e.source,[`presets`,r])});continue}let t=JD(e,vL,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function bL(e,t){if(t===void 0)return{};if(!KD(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${qD(t)}`,line:Y(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 ${Z(i)}`,line:Y(e.source,[`helpers`,r])});continue}n[r]=i}return n}const xL=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 SL(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 CL(e){let t=xL.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${SL(t)}`}function wL(e){let t=xL.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${SL(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function TL(e,t){let n=new Map;for(let e of Object.keys(t)){let t=fD(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:Y(e.source,[`presets`])})}function EL(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||xh(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:zh(i)?hL(r,i,a):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:Y(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:Y(e.source,[`globals`,`preset`])}),TL(e,t.presets);let i=Fv(t);for(let t of i.names)t!==`settings`&&!t.startsWith(kL)||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:Y(e.source,[`variables`,t])});let a=(t,n,r)=>{fN(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${Gj}" ${fN(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}),pN(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${Gj}" 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 __(t)){if(e.kind!==`segment`)continue;let t=p_(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=h_(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||f_[e.direction]===`cell`))}let s=(n,r)=>{for(let[a,o]of Z_(n,r)){let n=Y(e.source,o.split(`.`));if(a.when!==void 0&&(VL(e,`${o}.when`,a.when,i,{line:n}),BL(e,`${o}.when`,a.when,n)),a.kind===`segment`){if(lN(a.name)){(a.id!==void 0||a.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${Gj}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${Gj}"`,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${mF(a.name)}`,line:n}),LL(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`,Y_(t.root)]]);for(let e of nv(t.presets)){let{node:n,path:r}=av(t,e);c.set(r,n)}for(let[t,n]of c)a(n,t,Y(e.source,t.split(`.`)));JL(e,t,i,()=>!0)}const DL=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function OL(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=Y(e.source,[`actions`,n,r]);if(!nv(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${nv(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(`, `)})${mF(i)}`,line:c})},p=new Set(m_(av(t,a).node)),m=(r,i)=>{!pF.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${mF(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 kL=`settings.`;function AL(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>kL+e)])}}function jL(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:Y(e.source,[`segments`,t,`settings`,n])})},a=PL(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of F_(n,NL(n)))i(e,`the defaults do not stand together: ${t}`)}function ML(e){return PL(e).length>0||F_(e,NL(e)).length>0}function NL(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function PL(e){let t=t=>P_(FL(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||P_(FL(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${IL(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 FL(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function IL(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&P_(n)!==void 0).map(([e])=>e)}function LL(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=N_(a),s=`${r}: placement "${p_(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(`, `)})`:I_(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?fh(a):``}, but it must be ${B_(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])=>I_(o[e],t))||ML(o)))for(let{message:t}of F_(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function RL(e,t,n,r,i){n.kind===`template`&&VL(e,`${t}.template`,n.template,r,{segCtx:i}),T_(n)&&`key`in n.cache&&VL(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function zL(e,t,n,r,i){if(!(!T_(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:Y(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function BL(e,t,n,r){try{mk.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function VL(e,t,n,r,i){for(let[a,o]of Dv(n,r.helpers)){if(Pv(a,r))continue;if(a.startsWith(kL)){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??Y(e.source,t.split(`.`))});continue}if(o!==null){HL(e,o,`Template references unknown variable ".${a}"${wL(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&Pv(n,r)?` (segment-local vars are namespaced — write ".${n}")`:wL(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??Y(e.source,t.split(`.`))})}}function HL(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:Y(e.source,[`helpers`,t])})}function UL(e,t,n,r,i){let a=n.set,o=jO(io[r].configKey),s=`${a} takes ${ID(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:Y(e.source,[`actions`,t,`min`])});return}let c=KL(n,i);if(c===GL){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:Y(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!FD(o,e.value,i));if(l.length!==0){if(a===io.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>zh(e.value)))){let r=io.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:hL(`actions.${t}.to`,n.to,`set: "${r}", to`),line:Y(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:Y(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<=WL?r.join(`, `):`${r.slice(0,WL).join(`, `)} and ${r.length-WL} 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:Y(e.source,[`actions`,t,n])})}}}const WL=3,GL=Symbol(`any integer`);function KL(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?fv(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)}]:GL}function qL(e,t){return Object.entries(e).filter(([e])=>t(e))}function JL(e,t,n,r){let i=VN(t),a=dv(i);for(let[n,o]of qL(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 ${mv(r,i)}`,line:Y(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;so.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:Y(e.source,[`actions`,n,`set`])});let s=fo.get(o.set);s!==void 0&&UL(e,n,o,s,i)}for(let[n,i]of qL(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&&wI(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:Y(e.source,[`actions`,n,`do`])})});for(let[n,i]of qL(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=lk(r);if(o===null){let t=ZO(r);e.issues.push({path:`actions.${n}.${a}`,message:t===void 0?`actions.${n}: "${r}" is not a config globals field (have: ${QO().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:Y(e.source,[`actions`,n,a])});continue}let s=DL.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:Y(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){OL(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!nv(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: ${nv(t.presets).join(`, `)})`,line:Y(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${fh(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:Y(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(`, `)})${mF(o.segment)}`,line:Y(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:Y(e.source,[`actions`,n,a])})}}for(let[i,a]of qL(t.variables,r)){RL(e,`variables.${i}`,a,n);let t=CL(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:Y(e.source,[`variables`,i])})}for(let[i,a]of qL(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))RL(e,`segments.${i}.vars.${t}`,r,n,i);let r=N_(a);jL(e,i,r);let o=AL(n,r);for(let n of[`template`,`bg`,`fg`,`when`]){let s=a[n];if(typeof s==`string`){VL(e,`segments.${i}.${n}`,s,o,{segCtx:i,settings:r});for(let{name:r,site:a,via:o}of jv(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){HL(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${i}.${n}`,message:`${n} references unknown action "${r}"${s}`,line:Y(e.source,[`segments`,i,n])})}}}}for(let[i,a]of qL(t.variables,r))zL(e,`variables.${i}`,a,n);for(let[i,a]of qL(t.segments,r))if(a.vars)for(let[t,r]of Object.entries(a.vars))zL(e,`segments.${i}.vars.${t}`,r,n,i)}function YL(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=XL(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:Y(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function XL(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 Dv(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),T_(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 ZL(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?w.homedir()+e.slice(1):e}function QL(e,t){return v.resolve(e,ZL(t))}function $L(e,t){return typeof t==`string`&&t!==``?QL(e,t):void 0}function eR(e){return`plugin ${e.path} was not loaded: ${e.reason}`}const tR=new Set([`data`,`segments`,`helpers`,`actions`]),nR=`plugin.json5`,rR=/^[a-z][a-z0-9_]*$/;function iR(e){let t=v.basename(v.dirname(e));return rR.test(t)?t:void 0}const aR=`plugins.`;function oR(e){return`${aR}${e}.data`}function sR(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,reason:cR(e)}}}function cR(e){return e instanceof pD?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 lR(e,t){return e.map(e=>QL(v.dirname(t),e))}function uR(e,t,n,r){let i=new Map;return e.reduce((e,n)=>{let a=iR(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(v.basename(n)!==`plugin.json5`){let t=`a plugin is a folder holding its ${nR}, and the folder's name is the plugin's: move this file to <dir>/<name>/${nR} and list that`;return o(t,a===void 0?e.config:pR(fR(e.config,a),a,{path:n,plugin:a,reason:t}))}if(a===void 0)return o(`its folder "${v.basename(v.dirname(n))}" is not a plugin name (one matching ${rR}: 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=fR(e.config,a),u=sR(()=>{let i=s.readFileSync(n,`utf-8`),o=DP(yR(n,a,{source:i,json:Nr.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,pR(l,a,d))},{config:n.config,rendering:n.rendering,loaded:[],dropped:[]})}function dR(e){let t=`${aR}${e}.`;return e=>e.startsWith(t)}function fR(e,t){let n=dR(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 pR(e,t,n){return{...e,variables:{...e.variables,[oR(t)]:{kind:`dropped`,reason:eR(n),definition:n.path}}}}function mR(e){return e.startsWith(`plugins.`)?e.slice(8).split(`.`)[0]:void 0}function hR(e,t){let n=new Set([...Object.keys(e.config.variables),...Object.keys(e.config.segments)].map(mR)),r=[...t,...e.dropped].filter(e=>e.plugin===void 0).map(e=>({definition:e.path,notice:eR(e)}));return t=>{let i=mR(t);if(i===void 0)return[];let a=e.config.variables[oR(i)];return a?.kind===`dropped`?[{definition:a.definition,notice:a.reason}]:n.has(i)?[]:r}}function gR(e,t){let n=nv(e.presets).flatMap(t=>[...__(av(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,_R(e,t.map(e=>e.notice),n.filter(t=>t.name===e))])),a=t=>{let n=mR(t),r=n===void 0?void 0:e.variables[oR(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=>jv(t,e.helpers).map(e=>e.name)),...c],e.actions),d=l(s.flatMap(t=>[...Nv(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:`{{ .${oR(mR(e)??``)} }}`}]))},helpers:{...e.helpers,...Object.fromEntries(d.map(([e,t])=>[e,`{{ fail ${JSON.stringify(t.notice)} }}`]))}},reached:f}}function _R(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,vR(e,t)]));return{template:`{{ ${JSON.stringify(r)} }}`,bg:`error`,description:`stands in for a segment whose plugin did not load`,settings:a}}function vR(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 yR(e,t,{source:n,json:r},{checkout:i}){let a=[],o=()=>{throw new pD(e,a)};if(!KD(r))return a.push({path:``,message:`a plugin definition must be an object, got ${qD(r)}`}),o();for(let e of Object.keys(r))tR.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: ${[...tR].join(`, `)}`});let s=TR(r.data,e,i,a);if(KD(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(hh()),groups:[]},l=RP(c,`data`,{[oR(t)]:{kind:`file`,path:s,parse:{json:!0},cache:{watch_file:s},default:{}}});for(let[e,t]of Object.entries(r.segments))if(!(!KD(t)||!KD(t.vars)))for(let[n,r]of Object.entries(t.vars)){let t=KD(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:xR(t,CR(t,MF(c,r.segments,new Set))),helpers:xR(t,bL(c,r.helpers)),actions:xR(t,wR(t,TI(c,r.actions)))};for(let[e,t]of bR(u))try{mk.parse(t)}catch(t){a.push({path:e,message:`Template parse error in ${e}: ${t.message}`})}return a.length>0&&o(),u}function*bR(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 xR(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[`${aR}${e}.${t}`,n]))}function SR(e,t){return`${aR}${e}.${t}`}function CR(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:SR(e,n.key)}:n]))}]))}function wR(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,`set`in n?{...n,set:SR(e,n.set)}:n]))}function TR(e,t,n,r){if(typeof e==`string`&&e!==``)return QL(v.dirname(t),e);if(KD(e)&&Object.keys(e).length===1&&typeof e.checkout==`string`&&e.checkout!==``){let t=e.checkout;if(v.isAbsolute(t)||t.startsWith(`~`)||v.normalize(t).split(v.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 v.resolve(n.root,t)}if(KD(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 ER(e){let t=[...[...(process.env.XDG_DATA_DIRS||kR()).split(`:`).filter(e=>e!==``)].reverse().map(e=>v.join(e,`cc-candybar`,`plugins`)),DR(),...e===null?[]:[v.join(e,OR)]];return t.filter((e,n)=>t.lastIndexOf(e)===n)}function DR(){let e=process.env.XDG_DATA_HOME||v.join(w.homedir(),`.local`,`share`);return v.join(e,`cc-candybar`,`plugins`)}const OR=v.join(`.cc-candybar`,`plugins`);function kR(){let e=`/usr/local/share:/usr/share`;return process.platform===`darwin`?`${v.join(process.env.HOMEBREW_PREFIX||`/opt/homebrew`,`share`)}:${e}`:e}function AR(e){let t=ER(e),n=new Map,r=[],i=[];for(let e of t){let t=jR(e);if(`error`in t){r.push(t);continue}for(let r of t.folders)n.delete(r),n.set(r,v.join(e,r,nR));for(let n of t.files)i.push({path:v.join(e,n),plugin:void 0,reason:`a plugin is a folder holding its ${nR}: move this file to ${v.join(e,`<name>`,nR)}`})}return{roots:t,definitions:[...n.values()],unchecked:r,strays:i}}function jR(e){try{let t=s.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()||MR(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 MR(e,t){if(!t.isSymbolicLink())return!1;try{return s.statSync(v.join(e,t.name)).isDirectory()}catch{return!0}}const NR=[`json5`,`json`];function PR(e){try{return s.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function FR(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?NR.map(t=>v.join(e,`.cc-candybar.${t}`)):[],...NR.map(e=>v.join(r,`.cc-candybar.${e}`)),...NR.map(e=>`${IR()}.${e}`)])]}function IR(){let e=process.env.XDG_CONFIG_HOME??v.join(w.homedir(),`.config`);return v.join(e,`cc-candybar`,`config`)}function LR(e,t,n){let r=[],i=new Map;for(let a of FR(e,t,n)){let e=PR(a);if(e===`absent`)continue;if(e!==`present`){r.push(e);continue}let t=v.join(s.realpathSync(v.dirname(a)),v.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:RR(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 RR(e){let t=IR();return e.find(e=>NR.some(n=>e===`${t}.${n}`))??`${t}.${NR[0]}`}function zR(e,t,n){let r=LR(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 BR(e){return VR(e).join(`
|
|
172
172
|
`)||null}function VR(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 HR(e,t){let n=FR(e,t).filter(e=>PR(e)===`present`),r=new Map;for(let e of n){let t=v.dirname(e),n=v.basename(e).replace(/\.(json5|json)$/,``),i=v.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 UR(e,t,n,r){return e===null?{...$R,config:DP($R.raw,t)}:GR(e,s.readFileSync(e,`utf-8`),t,n,r)}const WR={projectDir:null,checkout:null,beneath:{dropped:[],rendering:new Map}};function GR(e,t,n,r,i){let a=nz(e,t,i,(t,a)=>{let o=uR(lR(t,e),r,{config:n,rendering:r.beneath.rendering},(t,n,r)=>ZR(t,n,r,e,i)),s=hR(o,r.beneath.dropped);return{inherited:new Set([...jF(o.config),...a.filter(e=>s(e).length>0)]),layer:{plugins:o,owning:s}}}),{plugins:o,owning:s}=a.layer,c=gR(DP(a.raw,o.config),s);return{source:t,raw:a.raw,warnings:[...a.warnings,...o.dropped.map(eR)],plugins:{loaded:o.loaded,dropped:o.dropped,reached:c.reached,rendering:o.rendering},config:c.config}}const KR=new WeakMap;function qR(e,t,n,r){let i=JSON.stringify([[...r??[]].sort(),e.map(e=>[e,YR(e)])]),a=KR.get(n)??new Map;KR.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=uR(e,t,{config:n,rendering:new Map},(e,t,n)=>ZR(e,t,n,`<installed plugins>`,r));return a.set(o,{key:i,layer:c}),c}function JR(e,t,n){return uR(e,{projectDir:null,checkout:n},{config:t,rendering:new Map},(e,t,n)=>ZR(e,t,n,`<plugin install>`,void 0)).dropped}function YR(e){try{let t=s.statSync(e);return`${t.ino}:${t.size}:${t.mtimeMs}`}catch(e){return e.code??`unreadable`}}function XR(e,t,n,r,i=e=>s.readFileSync(e,`utf-8`),a){let o={projectDir:r.projectDir,checkout:r.cwd===null?null:WT(r.cwd)},c=AR(o.projectDir),l=qR(c.definitions,o,t,a),u={...l,dropped:[...l.dropped,...c.strays]};n.warned(c.unchecked.map(e=>`Plugin folder could not be listed: ${e.path} — ${e.error}`));let d=u.config,f=[];for(let t of e){n.entered(t);let e=f.at(-1)?.plugins,r=GR(t,i(t),f.at(-1)?.config??d,{...o,beneath:{dropped:[...u.dropped,...f.flatMap(e=>e.plugins.dropped)],rendering:e?.rendering??u.rendering}},a);n.warned(r.warnings),f.push({...r,path:t})}let p=new Set(f.flatMap(e=>[...e.plugins.reached])),m=e=>p.has(e.path),h=u.dropped.filter(m),g=u.dropped.filter(e=>!m(e));n.warned(h.map(eR));let _={checkout:o.checkout,roots:c.roots,loaded:u.loaded,dropped:h,unreached:g,reached:p,rendering:f.at(-1)?.plugins.rendering??u.rendering},v=f.at(-1);if(v===void 0)return{layers:f,base:d,installed:_,config:ez(UR(null,d,WR),`<default>`,a)};try{return{layers:f,base:d,installed:_,config:ez(v,v.path,a)}}catch(e){for(let e of f.slice(0,-1))n.entered(e.path),ez(e,e.path,a);throw n.entered(v.path),e}}function ZR(e,t,n,r,i){if(n){ez(QR(e),r,i);return}let a=dR(t),o=[],s={source:``,issues:o,allowedPalettes:new Set,groups:[]};if(JL(s,e,Fv(e),a),YL(s,e,a),o.length>0)throw new pD(r,o)}function QR(e){return{config:e,raw:{root:e.root,presets:e.presets},source:``}}const $R={raw:{},source:``,warnings:[],plugins:{loaded:[],dropped:[],reached:new Set,rendering:new Map}};function ez({config:e,raw:t,source:n},r=`<config>`,i=new Set(hh())){let a=[],o={source:n,issues:a,allowedPalettes:i,groups:[]};if(EL(o,e,t),YL(o,e),a.length>0)throw new pD(r,a);let s=xI(e,a);if(a.length>0)throw new pD(r,a);return aP(TN(s))}function tz(e,t,n=new Set(hh()),r=rz){return nz(e,t,n,()=>({inherited:r,layer:null})).raw}function nz(e,t,n,r){let i=iz(e,t),a=gD(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(hh()),groups:[]};if(!KD(i))throw new pD(e,[{path:``,message:`Config root must be an object, got ${qD(i)}`}],o);let{inherited:l,layer:u}=r(i.plugins===void 0?[]:sz({...c,issues:[]},i.plugins)??[],KD(i.segments)?Object.keys(i.segments):[]),d=az(c,i,l);if(s.length>0)throw new pD(e,s,o);return{raw:d,warnings:o,layer:u}}const rz=new Set;function iz(e,t){try{return Nr.default.parse(t)}catch(t){let n=t;throw new pD(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function az(e,t,n){for(let n of Object.keys(t))oz.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...oz].join(`, `)}`,line:Y(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=GO(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=RP(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=MF(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.
|