@promptctl/cc-candybar 1.71.0 → 1.71.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +4 -4
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -115,14 +115,14 @@ Config tooling:
115
115
  config [--json] The effective merged config. (All three query the
116
116
  running daemon; none spawn one.)
117
117
 
118
- `,Eh=`preset.customized`,Dh=`{{ and ${vc($m)} .${Eh} }}`,Oh=ws;function kh(e){return`${xs}addable.${e}`}function Ah(e){let t=Object.keys(e.segments).filter(e=>!Oh(e)),n=new Map;for(let r of lh(e.presets)){let{node:i}=fh(e,r),a=oh(i);n.set(kh(r),{members:t.filter(e=>!a.has(e))})}return n}function jh(e,t,n,r){let i=`${xs}${e}.remove.${vs(n)}`,a=`${xs}${e}.removeSeg.${vs(n)}`;return r.actions[i]={persist:t,removeSegment:n},r.segments[a]={template:`{{ action "${i}" "-" }}`,when:eh},{kind:`segment`,name:a}}function Mh(e,t,n,r,i,a,o){let s=`${xs}${e}.insert.${n}`,c=`${xs}${e}.insertSeg.${n}`;o.actions[s]={persist:t,insertSegmentFrom:r,anchor:i,relation:a};let l=jm(s),u=Mm(c,s,void 0),d=Fm(u),f=Pm(u,l);return o.variables[u]=bc(u,fc),o.variables[d]={kind:`state`,key:d,default:`0`},o.actions[f]=xc(u,l),o.actions[d]={set:d,int:!0},o.segments[c]={template:`{{ menu "${s}" "+" "✕" }}`,when:eh},{kind:`segment`,name:c}}function Nh(e,t,n,r,i,a){let o=[],s=e.children.reduce((e,t,n)=>t.kind===`segment`&&!Oh(t.name)?n:e,-1),c=e=>Nh(e,t,n,r,i,a);for(let[l,u]of e.children.entries()){if(u.kind===`container`){o.push(c(u));continue}let d=Ca(u,c);if(Oh(u.name)){o.push(d);continue}let f=[Mh(t,n,String(a.n++),r,u.name,`before`,i),d,jh(t,n,u.name,i),...l===s?[Mh(t,n,String(a.n++),r,u.name,`after`,i)]:[]];o.push(...e.direction===`vertical`?[{kind:`container`,direction:`horizontal`,children:f,...u.when!==void 0&&{when:u.when}}]:f)}return{...e,children:o}}function Ph(e,t,n,r,i,a){let o=`${xs}${n}.resetLayout`,s=`${xs}${n}.customized`;i.actions[o]={reset:r},i.ensured[Eh]={kind:`input`,path:Eh,type:`boolean`,default:!1};let c=hc(t);return i.segments[s]={template:`{{ action "${o}" "↺ ${c} customized" }}`,when:Dh},{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:s},Fh(e,a)],...e.when!==void 0&&{when:e.when}}}function Fh(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),Fh(n,t)]}:{...e,children:[...e.children,t]}}function Ih(e,t,n,r){let{node:i}=fh(e,t),a=gh(t),o=kh(t),s=vs(t);return Ph(Nh(i,s,a,o,n,{n:0}),t,s,a,n,r)}function Lh(e){if(!(`edit.toggle`in e.actions))return e;let t={variables:{},ensured:{},actions:{},segments:{}},n=bh(`${xs}help`,Ch,[$m],t),r={...e.presets};for(let i of lh(e.presets)){let a=Ih(e,i,t,n);r[i]={...dh(e.presets,i),root:a}}return{...e,variables:{...t.ensured,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:r}}const Rh={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function zh(e){let t=e[Rh.socket]??``,n=e[Rh.pane]??``;if(t===``||n===``)return null;let r=e[Rh.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const Bh=Rh.truecolor,Vh=[{name:`tmuxTruecolor`,label:`tmux truecolor`,probe:({tmux:e,claudeSettingsEnv: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`:{if(e.termfeatures.kind===`failed`)return{ok:!1,reason:`tmux could not be asked: ${e.termfeatures.reason}`};if(!e.termfeatures.value.includes(`RGB`)||e.hint.truecolor!==null)return{ok:!0};let n=t[Bh];return typeof n==`string`&&n!==``?{ok:!1,reason:`${Bh} is set in ~/.claude/settings.json — restart Claude Code to apply`}:{ok:!1,reason:`Claude Code renders the bar in 256 colours inside tmux`,fix:{kind:`claude-settings-env`,name:Bh,value:`1`}}}}}}];function Hh(e){return Vh.map(t=>({check:t,verdict:t.probe(e)}))}function Uh(e){return Vh.find(t=>t.name===e)}function Wh(e){let t=`settings.doctor.${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function Gh(e){return e.flatMap(({check:e,verdict:t})=>{let n=Wh(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:Ti}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:t.reason},{key:n.fixable,value:t.fix===void 0?Ti:wi}]})}const Kh=`${Ss}menu`,qh=Qm,Jh=`${Ss}edit`,Yh=`${Ss}persist`,Xh=`${Ss}config`,Zh=Yh,Qh={variable:Kh,member:qh},$h={variable:Xh,member:qh},eg=`${Ss}tools`,tg={variable:eg,member:qh},ng=`${Ss}doctor`,rg=`${ng}.run`,ig=e=>`${ng}.fix.${e}`,ag=e=>`${ng}.${e}`,og=`${Ss}help.persist`,sg={bg:`{{ color "accent" }}`,fg:`{{ contrastOn (bgOf) }}`},cg=`${Ss}pickers`,lg=[{name:`preset`,sessionKey:`preset`,configKey:`preset`,effectiveVar:`preset.effective`,glyph:`▦`,domain:`presets`}],ug=[{name:`theme`,sessionKey:`theme`,configKey:`palette`,effectiveVar:`theme.effective`,glyph:`🎨`,domain:`themes`},{name:`look`,sessionKey:`look`,configKey:`look`,effectiveVar:`look.effective`,glyph:`◐`,domain:`looks`},{name:`style`,sessionKey:`style`,configKey:`style`,effectiveVar:`style.effective`,glyph:`✦`,domain:`styles`}],dg={name:`wrap`,sessionKey:`autoWrap`,configKey:`autoWrap`},fg={name:`padding`,sessionKey:`padding`,configKey:`padding`},pg=`${Ss}${dg.name}`,mg=`${Ss}${fg.name}`,hg=[...lg,...ug];new Set([...hg,dg,fg].flatMap(e=>[e.sessionKey,e.configKey]));const gg=e=>`${Ss}${e}`,_g=e=>`${Ss}apply.${e}`,vg=e=>`${Ss}reset.${e}`;function yg(e){return e===Kh}function bg(e){let t={kind:`segment`,name:Kh};if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[t,e],...e.when!==void 0&&{when:e.when}};let[n,...r]=e.children;return e.direction===`vertical`&&n!==void 0&&n.when===void 0?{...e,children:[bg(n),...r]}:{...e,children:[t,...e.children]}}function xg(e){return Sg(e)>0?e:bg(e)}function Sg(e){let t=0;for(let n of wa(e))n.kind===`segment`&&yg(n.name)&&(t+=1);return t}function Cg(e,t){return e.kind===`segment`?yg(e.name)?gc(e.name,Qh,{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:Yh},t,...lg.map(e=>({kind:`segment`,name:gg(e.name)})),gc(Xh,$h,{kind:`container`,direction:`horizontal`,children:[...ug.map(e=>({kind:`segment`,name:gg(e.name)})),{kind:`segment`,name:pg},{kind:`segment`,name:mg}]}),gc(eg,tg,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:ng},...Vh.map(e=>({kind:`segment`,name:ag(e.name)}))]}),{kind:`segment`,name:Jh}]},e.when):Ca(e,e=>wg(e,t)):wg(e,t)}function wg(e,t){return{...e,children:e.children.map(e=>Cg(e,t))}}function Tg(e,t,n,r){let i=jm(t),a=Mm(e,t,r),o=Fm(a);n.variables[a]=bc(a,fc),n.variables[o]={kind:`state`,key:o,default:`0`},n.actions[Pm(a,i)]=xc(a,i),n.actions[o]={set:o,int:!0}}function Eg(){let e={variables:{[Kh]:bc(Kh,fc)},actions:{[Kh]:xc(Kh,qh),[Xh]:xc(Xh,qh),[eg]:xc(eg,qh),[rg]:{doctor:`run`},[Yh]:{set:Zh,cycle:[Ti,wi]}},segments:{[Kh]:{template:yc(Kh,`☰`,`✕`),...sg},[Yh]:{template:`{{ action "${Yh}" "☐ persist?" "☑ persist?" }}`},[Xh]:{template:yc(Xh,`⚙ config ▸`,`⚙ config ▾`)},[eg]:{template:yc(eg,`🧰 tools ▸`,`🧰 tools ▾`)},[ng]:{template:`{{ action "${rg}" "🩺 doctor" }}`},[pg]:{template:`{{ action "${_g(`wrap`)}" "wrap: on" "wrap: off" }} {{ action "${vg(`wrap`)}" "↺" }}`},[mg]:{template:`{{ action "${_g(`padding`)}.down" "◀" }} padding {{ .padding.effective }} {{ action "${_g(`padding`)}.up" "▶" }} {{ action "${vg(`padding`)}" "↺" }}`},[Jh]:{template:`{{ action "${Zm}" "✎ edit" "✎ done" }}`}}};return e.variables[Zh]={kind:`state`,key:Zh,default:Ti},e.variables[Xh]=bc(Xh,fc),e.variables[eg]=bc(eg,fc),Og(e),Dg(e),{artifacts:e,help:bh(og,wh,[Qh],e)}}function Dg(e){for(let t of Vh){let n=Wh(t.name),r=ig(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},e.segments[ag(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${wi}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function Og(e){for(let t of hg){let n=gg(t.name),r=_g(t.name);e.segments[n]={template:`${t.glyph} {{ .${t.effectiveVar} }} {{ menu "${r}" "▸" "▾" (dict "key" "${cg}" "closeOnPick" true) }} {{ action "${vg(t.name)}" "↺" }}`},e.actions[r]={set:t.sessionKey,persist:t.configKey,persistWhen:Zh,from:t.domain},e.actions[vg(t.name)]={reset:t.configKey},Tg(n,r,e,cg)}e.actions[_g(dg.name)]={set:dg.sessionKey,persist:dg.configKey,persistWhen:Zh,cycle:[...Ei]},e.actions[vg(dg.name)]={reset:dg.configKey};for(let t of[-1,1])e.actions[`${_g(fg.name)}.${t<0?`down`:`up`}`]={set:fg.sessionKey,persist:fg.configKey,persistWhen:Zh,...Di,by:t};e.actions[vg(fg.name)]={reset:fg.configKey}}function kg(e){e.variables[Xm]=bc(Xm,fc),e.actions[Zm]=xc(Xm,Qm)}const Ag=`session.id`;function jg(e){return Object.prototype.hasOwnProperty.call(e.variables,Ag)}function Mg(e){if(!jg(e))return e;let{artifacts:t,help:n}=Eg();kg(t);let r={...e.presets};for(let t of lh(e.presets)){let{node:i}=fh(e,t);r[t]={...dh(e.presets,t),root:Cg(xg(i),n)}}return{...e,variables:{...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:r}}const Ng=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`doctor`],Pg=`persistWhen`;function Fg(e){return Pg in e}function Ig(e){return Fg(e)?`to`in e?[{set:e.set,to:e.to},{persist:e.persist,to:e.to}]:`from`in e?[{set:e.set,from:e.from},{persist:e.persist,from:e.from}]:`cycle`in e?[{set:e.set,cycle:e.cycle},{persist:e.persist,cycle:e.cycle}]:[{set:e.set,min:e.min,max:e.max,by:e.by},{persist:e.persist,min:e.min,max:e.max,by:e.by}]:[e]}function Lg(e){return`set`in e}function Rg(e){return`persist`in e}function zg(e){return`reset`in e}function Bg(e){return`undo`in e}function Vg(e){return`redo`in e}function Hg(e){return`doctor`in e}function Ug(e,t){if(t===void 0)return{};if(!Ra(t))return J(e,`actions`,`actions must be an object, got ${za(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=Wg(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function J(e,t,n){e.issues.push({path:t,message:n,line:G(e.source,t.split(`.`))})}function Wg(e,t,n){if(!Ra(n))return J(e,t,`${t} must be an action object, got ${za(n)}`),null;if(`persistWhen`in n)return S_(e,t,n,`dual`,y_);let r=Ng.filter(e=>e in n);return r.length===1?Gg[r[0]](e,t,n):(J(e,t,`action must declare exactly one of: ${Ng.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const Gg={set:(e,t,n)=>S_(e,t,n,`set`,__),persist:(e,t,n)=>S_(e,t,n,`persist`,v_),copy:Kg(`copy`),open:Kg(`open`),reset:qg,undo:Jg(`undo`),redo:Jg(`redo`),doctor:Yg};function Kg(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&J(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=Na(t,n,r,e);return i===null?null:{[e]:i}}}function qg(e,t,n){for(let r of Object.keys(n))r!==`reset`&&J(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=Xg(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}}function Jg(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&J(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(J(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — it steps the history of the session's config file), got ${Ba(r[e])}`),null)}}function Yg(e,t,n){let r=n.doctor,i=r===`run`?[`doctor`]:[`doctor`,`check`];for(let r of Object.keys(n))i.includes(r)||J(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${i.join(`, `)}`);if(r!==`run`&&r!==`fix`)return J(e,`${t}.doctor`,`doctor must be "run" or "fix", got ${Ba(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||Uh(a)===void 0?(J(e,`${t}.check`,`doctor fix must name a check (have: ${Vh.map(e=>e.name).join(`, `)}), got ${Ba(a)}`),null):{doctor:`fix`,check:a}}function Xg(e,t,n,r,i,a){let o=Na(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(J(e,s,i),null):o.includes(`/`)?(J(e,s,a(o)),null):o}const Zg={set:[[`set`,`the SessionState key to write`]],persist:[[`persist`,`the config globals field to write`]],dual:[[`set`,`the SessionState key written while persistWhen is off`],[`persist`,`the config globals field written while persistWhen is on`],[Pg,`the SessionState key whose boolean value chooses the destination`]]};function Qg(e,t,n,r){let i={},a=Zg[r],o=!0;for(let[r,s]of a){if(!(r in n)){J(e,t,`${r} is required here (${s}) — a dual-destination action declares ${a.map(([e])=>e).join(`, `)} together, plus one value source`),o=!1;continue}let c=Xg(e,t,r,n,`${r} key must be non-empty (${s})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);if(c===null){o=!1;continue}i[r]=c}return o?i:null}function $g(e){return e===`set`?`set-state`:e===`persist`?`set-config`:`set-state/set-config`}const e_={to:C_(`set`)},t_={to:C_(`persist`)},n_={from:w_(`set`)},r_={from:w_(`persist`)},i_={min:k_(),max:k_(),by:k_()},a_={int:E_()},o_={cycle:T_(`set`)},s_={to:C_(`dual`)},c_={from:w_(`dual`)},l_={cycle:T_(`dual`)},u_={cycle:T_(`persist`)},d_={removeSegment:D_(`removeSegment`)},f_={insertSegment:D_(`insertSegment`),anchor:D_(`anchor`),relation:O_()},p_={insertSegmentFrom:w_(`persist`),anchor:D_(`anchor`),relation:O_()},m_={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},h_={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function g_(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=Zg[e].map(([e])=>e),s=(e,n,r)=>Ha(e,t,n,r),c=ro(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?Xa(s,...n):s}}const __=[g_(`set`,e_),g_(`set`,n_),g_(`set`,i_,[m_,h_]),g_(`set`,a_),g_(`set`,o_)],v_=[g_(`persist`,t_),g_(`persist`,r_),g_(`persist`,i_,[m_,h_]),g_(`persist`,u_),g_(`persist`,d_),g_(`persist`,f_,[],[`insertSegment`]),g_(`persist`,p_,[],[`insertSegmentFrom`])],y_=[g_(`dual`,s_),g_(`dual`,c_),g_(`dual`,i_,[m_,h_]),g_(`dual`,l_)];function b_(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"styles"/"looks", 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 x_(e){let t=b_(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 S_(e,t,n,r,i){let a=Qg(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return J(e,t,`${x_(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)||J(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 C_(e){let t=$g(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>Xg(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 w_(e){let t=$g(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===``){J(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){J(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===``)){J(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){J(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){J(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}J(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${Ba(o)}`)}}}function T_(e){let t=$g(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`)){J(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${za(o)}`);return}let c=o;if(c.length<2){J(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){J(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){J(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){J(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function E_(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){J(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${Ba(r[n])}`);return}return!0}}}function D_(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Na(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){J(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){J(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 O_(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){J(e,`${t}.${n}`,`relation must be "before" or "after", got ${Ba(i)}`);return}return i}}}function k_(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){J(e,`${t}.${n}`,`${n} must be an integer, got ${Ba(i)}`);return}return i}}}const A_={noun:`look key`,fields:{hueShift:$a(),chromaScale:$a({min:0}),lightnessScale:$a(),lightnessShift:$a()}};function j_(e,t){if(!Ra(t))return e.issues.push({path:`looks`,message:`looks must be an object mapping look names to adaptation objects, got ${za(t)}`,line:G(e.source,[`looks`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`looks.${r}`,message:`look name ${JSON.stringify(r)} must be non-empty and slash-free — a look picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:G(e.source,[`looks`,r])});continue}let t=Va(e,A_,`looks.${r}`,i);t!==null&&(n[r]={...gn,...t})}return n}const M_={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:Rc(e,`${t}.${n}`,r[n])},globals:{required:!1,json:ko(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Oo(e,`${t}.${n}`,r[n])}}};function N_(e,t){if(!Ra(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${za(t)}`,line:G(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:G(e.source,[`presets`,r])});continue}let t=Va(e,M_,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function P_(e,t){if(t===void 0)return{};if(!Ra(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${za(t)}`,line:G(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 ${Ba(i)}`,line:G(e.source,[`helpers`,r])});continue}n[r]=i}return n}const F_=new Map,I_=new Map;function L_(e){let t=R_(e);if(t===null)throw Error(`Palette "${e}" (resolved "${ai(e)}") did not resolve in the theme registry — allowed names and the registry are inconsistent`);return t}function R_(e){let t=ai(e),n=F_.get(t);if(n!==void 0)return n;let r=Kn(t);return r===null?null:(F_.set(t,r),r)}function z_(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=I_.get(n);if(r!==void 0)return r;let i=tr(e,t);return I_.set(n,i),i}function B_(e){let t=R_(e);return t===null?null:{kind:`decided`,name:e,value:t}}function V_(e,t){let n=B_(e);return n===null?(t(`globals.palette rendered "${oi}": "${e}" names no installed theme`),B_(oi)):n}function H_(e,t,n){return pi(e,t,n,B_(oi),B_)}function U_(){return B_(oi)}function W_(e){return mi(H_(void 0,null,e),()=>oi,U_).value}const G_=new Map;function K_(e,t,n){G_.set(e,{permanent:!0,resolve:t,paletteOf:n})}K_(`themes`,()=>li(),e=>L_(e)),K_(`styles`,()=>yi),K_(`charsets`,()=>Si),K_(`colorCompatibilities`,()=>Ci);function q_(e){return new Map([[`looks`,{members:Object.keys(e.looks),paletteOf:(t,n)=>z_(n,e.looks[t])}],[`presets`,{members:lh(e.presets)}]])}function J_(e){return[...new Set([...G_.keys(),...e.keys()])]}function Y_(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=G_.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(`unknown option domain "${e}" (have: ${J_(t).join(`, `)})`)}const X_=/{{([\s\S]*?)}}/g,Z_=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g,Q_=/(?<![A-Za-z0-9_)])\.([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*)/g;function $_(e){let t=new Set,n;for(X_.lastIndex=0;(n=X_.exec(e))!==null;){let e=n[1].replace(Z_,``),r;for(Q_.lastIndex=0;(r=Q_.exec(e))!==null;)t.add(r[1])}return t}const ev=/\baction\s+$/;function tv(e){let t=new Set;X_.lastIndex=0;let n;for(;(n=X_.exec(e))!==null;){let e=n[1],r=0,i;for(Z_.lastIndex=0;(i=Z_.exec(e))!==null;)ev.test(e.slice(r,i.index))&&t.add(i[0].slice(1,-1)),r=i.index+i[0].length}return t}const nv=/\b(picker|menu)\s+$/;function rv(e){let t=new Set;X_.lastIndex=0;let n;for(;(n=X_.exec(e))!==null;){let e=n[1],r=0,i=0,a;for(Z_.lastIndex=0;(a=Z_.exec(e))!==null;){let n=nv.exec(e.slice(r,a.index));n!==null&&(i=n[1]===`picker`?2:1),i>0&&(t.add(a[0].slice(1,-1)),i--),r=a.index+a[0].length}}return t}function iv(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}const av={gitTaculous:`gitaculous`};function ov(e,t){let n=new Map;for(let e of Object.keys(t)){let t=vs(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:G(e.source,[`presets`])})}function sv(e,t){t.globals.look!==void 0&&!fi(t.globals.look)&&!Object.prototype.hasOwnProperty.call(t.looks,t.globals.look)&&e.issues.push({path:`globals.look`,message:`globals.look "${t.globals.look}" does not match any declared look (have: ${Object.keys(t.looks).join(`, `)})`,line:G(e.source,[`globals`,`look`])}),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:G(e.source,[`globals`,`preset`])}),ov(e,t.presets);let n=q_(t);for(let[r,i]of Object.entries(t.actions))!(`set`in i)||!(`from`in i)||typeof i.from!=`string`||J_(n).includes(i.from)||e.issues.push({path:`actions.${r}.from`,message:`actions.${r} from: references unknown option domain "${i.from}" (have: ${J_(n).join(`, `)})`,line:G(e.source,[`actions`,r,`from`])});for(let[n,r]of Object.entries(t.actions)){if(!Fg(r))continue;let i=r[Pg];fv(t,i)||e.issues.push({path:`actions.${n}.${Pg}`,message:`actions.${n} ${Pg}: "${i}" is not a declared state key — a dual action's selector must name a { kind: "state", key: "${i}" } variable, or the destination can never change`,line:G(e.source,[`actions`,n,Pg])})}for(let[n,r]of Object.entries(t.actions)){let i=`persist`in r?r.persist:`reset`in r?r.reset:null;if(i===null)continue;let a=`persist`in r?`persist`:`reset`,o=_h(i);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a config globals field (have: ${No().join(`, `)}), a "segments.<name>.palette" target, or a "presets.<name>.root" target`,line:G(e.source,[`actions`,n,a])});continue}let s=cv.filter(e=>e in r);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){lv(e,t,n,a,i,o.preset,r);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}: "${i}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})`,line:G(e.source,[`actions`,n,a])});continue}`min`in r&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:G(e.source,[`actions`,n,a])})}}let r=mv(t),i=jg(t),a=Object.entries(t.segments).filter(([,e])=>qm(e.template)).map(([e])=>e),o=(t,n,r)=>{Sg(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${Kh}" ${Sg(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});let i=new Map;for(let e of wa(t))e.kind===`segment`&&i.set(e.name,(i.get(e.name)??0)+1);for(let t of a)(i.get(t)??0)>1&&e.issues.push({path:n,message:`segment "${t}" hosts a {{ menu }} and is placed in the layout more than once — a menu's open-state is keyed by segment name, so the copies would share one state (clicking one would toggle both). Give each placement its own named segment.`,line:r})},s=(n,a,o)=>{for(let s of wa(n))if(s.when!==void 0&&vv(e,`${a}.when`,s.when,r,{line:o}),s.kind===`segment`){if(yg(s.name)){i||e.issues.push({path:a,message:`${a} places the global settings menu anchor "${Kh}", but this config declares no "${Ag}" variable — the menu is a click surface and every click composes a URL from "${Ag}", so it is not synthesized for a config without it. Declare a "${Ag}" variable (any config merged onto the bundled default inherits one) or remove the anchor placement.`,line:o});continue}if(!Object.prototype.hasOwnProperty.call(t.segments,s.name)){let t=av[s.name],n=t===void 0?``:` (the built-in segment "${s.name}" was renamed to "${t}" — update this reference)`;e.issues.push({path:a,message:`${a} entry "${s.name}" does not match any declared segment${n}`,line:o})}}},c=yv(e.source);s(ho(t.root),c,G(e.source,[c]));for(let[n,r]of Object.entries(t.presets)){if(r.root===void 0)continue;let t=`presets.${n}.root`,i=G(e.source,[`presets`,n,`root`]);s(go(r.root),t,i)}let l=new Map([[`root`,ho(t.root)]]);for(let e of lh(t.presets)){let{node:n,path:r}=fh(t,e);l.set(r,n)}for(let[t,n]of l)o(n,t,G(e.source,t.split(`.`)));for(let[n,i]of Object.entries(t.variables))gv(e,`variables.${n}`,i,r);for(let[n,i]of Object.entries(t.segments)){if(i.vars)for(let[t,a]of Object.entries(i.vars))gv(e,`segments.${n}.vars.${t}`,a,r,n);for(let a of[`template`,`bg`,`fg`,`when`]){let o=i[a];if(typeof o==`string`){vv(e,`segments.${n}.${a}`,o,r,{segCtx:n});for(let r of tv(o))Object.prototype.hasOwnProperty.call(t.actions,r)||e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}"`,line:G(e.source,[`segments`,n,a])});for(let r of rv(o))Object.prototype.hasOwnProperty.call(t.actions,r)||e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}" (in a picker or menu)`,line:G(e.source,[`segments`,n,a])})}}}for(let[n,i]of Object.entries(t.variables))_v(e,`variables.${n}`,i,r);for(let[n,i]of Object.entries(t.segments))if(i.vars)for(let[t,a]of Object.entries(i.vars))_v(e,`segments.${n}.vars.${t}`,a,r,n);(dv(t)||pv(t))&&!Object.prototype.hasOwnProperty.call(t.variables,`session.id`)&&e.issues.push({path:`variables.session.id`,message:`state reads and action set-writes require a global "session.id" variable (segment-local declarations do not satisfy this — declareState/set-state both read the global box; conventionally { kind: "input", path: "session_id" })`,line:G(e.source,[`variables`])})}const cv=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function lv(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=G(e.source,[`actions`,n,r]);if(!lh(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${lh(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=e=>!Object.prototype.hasOwnProperty.call(t.segments,e);l&&`removeSegment`in o&&f(o.removeSegment)&&e.issues.push({path:s,message:`actions.${n}: removeSegment "${o.removeSegment}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c}),u&&`insertSegment`in o&&(f(o.insertSegment)&&e.issues.push({path:s,message:`actions.${n}: insertSegment "${o.insertSegment}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c}),f(o.anchor)&&e.issues.push({path:s,message:`actions.${n}: anchor "${o.anchor}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c})),d&&`insertSegmentFrom`in o&&f(o.anchor)&&e.issues.push({path:s,message:`actions.${n}: anchor "${o.anchor}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c})}function uv(e){return[...Object.values(e.variables),...Object.values(e.segments).flatMap(e=>Object.values(e.vars??{}))].filter(e=>e.kind===`state`)}function dv(e){return uv(e).length>0}function fv(e,t){return uv(e).some(e=>e.kind===`state`&&e.key===t)}function pv(e){return Object.values(e.actions).some(e=>Lg(e)||Rg(e)||zg(e)||Bg(e)||Vg(e)||Hg(e))}function mv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),hv(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}}function hv(e){return(e.kind===`shell`||e.kind===`file`)&&Ea(e.parse)===`json`}function gv(e,t,n,r,i){n.kind===`template`&&vv(e,`${t}.template`,n.template,r,{segCtx:i}),Oa(n)&&n.cache&&`key`in n.cache&&vv(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function _v(e,t,n,r,i){if(Oa(n)&&n.cache&&`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:G(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function vv(e,t,n,r,i){for(let a of $_(n)){if(iv(a,r))continue;let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,o=n!==void 0&&iv(n,r)?` (segment-local vars are namespaced — write ".${n}")`:``;e.issues.push({path:t,message:`Template references unknown variable ".${a}"${o}`,line:i?.line??G(e.source,t.split(`.`))})}}function yv(e){try{let t=Ze.default.parse(e);if(Ra(t)&&`root`in t)return`root`}catch{}return`layout`}function bv(e,t){let{graph:n,nodeInfo:r}=xv(t),i=new Map,a=[];for(let e of n.keys())i.set(e,0);for(let e of n.keys())if(i.get(e)===0&&o(e))return;function o(t){i.set(t,1),a.push(t);for(let s of n.get(t)??[]){let t=i.get(s);if(t===1){let t=a.indexOf(s),n=[...a.slice(t),s],i=n[0],o=r.get(i);return e.issues.push({path:o?.declarationPath??`variables.${i}`,message:`Dependency cycle: ${n.join(` → `)}`,line:G(e.source,o?.linePathParts??[`variables`,i])}),!0}if(t===0&&o(s))return!0}return i.set(t,2),a.pop(),!1}}function xv(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=(e,n)=>{for(let i of $_(n)){if(t.has(i)){r.get(e).add(i);continue}let n=i.split(`.`)[0];n!==i&&t.has(n)&&r.get(e).add(n)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),Oa(n)&&(n.cache&&`key`in n.cache&&i(e,n.cache.key),n.cache&&`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}}const Sv=[`json5`,`json`];function Cv(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function wv(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?f.homedir()+e.slice(1):e}function Tv(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Sv.map(t=>c.join(e,`.cc-candybar.${t}`)):[],...Sv.map(e=>c.join(r,`.cc-candybar.${e}`)),...Sv.map(e=>`${Ev()}.${e}`)])]}function Ev(){let e=process.env.XDG_CONFIG_HOME??c.join(f.homedir(),`.config`);return c.join(e,`cc-candybar`,`config`)}function Dv(e,t,n){let r=[];for(let i of Tv(e,t,n)){let e=Cv(i);if(e===`present`)return{kind:`file`,path:i,unchecked:r};e!==`absent`&&r.push(e)}if(n===void 0)return{kind:`default`,unchecked:r};let[i]=r;return i===void 0?{kind:`missing`,path:n}:{kind:`unreadable`,...i}}function Ov(e,t,n){let r=Dv(e,t,n);return r.kind===`default`?`${Ev()}.${Sv[0]}`:r.path}function kv(e){return Av(e).join(`
118
+ `,Eh=`preset.customized`,Dh=`{{ and ${vc($m)} .${Eh} }}`,Oh=ws;function kh(e){return`${xs}addable.${e}`}function Ah(e){let t=Object.keys(e.segments).filter(e=>!Oh(e)),n=new Map;for(let r of lh(e.presets)){let{node:i}=fh(e,r),a=oh(i);n.set(kh(r),{members:t.filter(e=>!a.has(e))})}return n}function jh(e,t,n,r){let i=`${xs}${e}.remove.${vs(n)}`,a=`${xs}${e}.removeSeg.${vs(n)}`;return r.actions[i]={persist:t,removeSegment:n},r.segments[a]={template:`{{ action "${i}" "-" }}`,when:eh},{kind:`segment`,name:a}}function Mh(e,t,n,r,i,a,o){let s=`${xs}${e}.insert.${n}`,c=`${xs}${e}.insertSeg.${n}`;o.actions[s]={persist:t,insertSegmentFrom:r,anchor:i,relation:a};let l=jm(s),u=Mm(c,s,void 0),d=Fm(u),f=Pm(u,l);return o.variables[u]=bc(u,fc),o.variables[d]={kind:`state`,key:d,default:`0`},o.actions[f]=xc(u,l),o.actions[d]={set:d,int:!0},o.segments[c]={template:`{{ menu "${s}" "+" "✕" }}`,when:eh},{kind:`segment`,name:c}}function Nh(e,t,n,r,i,a){let o=[],s=e.children.reduce((e,t,n)=>t.kind===`segment`&&!Oh(t.name)?n:e,-1),c=e=>Nh(e,t,n,r,i,a);for(let[l,u]of e.children.entries()){if(u.kind===`container`){o.push(c(u));continue}let d=Ca(u,c);if(Oh(u.name)){o.push(d);continue}let f=[Mh(t,n,String(a.n++),r,u.name,`before`,i),d,jh(t,n,u.name,i),...l===s?[Mh(t,n,String(a.n++),r,u.name,`after`,i)]:[]];o.push(...e.direction===`vertical`?[{kind:`container`,direction:`horizontal`,children:f,...u.when!==void 0&&{when:u.when}}]:f)}return{...e,children:o}}function Ph(e,t,n,r,i,a){let o=`${xs}${n}.resetLayout`,s=`${xs}${n}.customized`;i.actions[o]={reset:r},i.ensured[Eh]={kind:`input`,path:Eh,type:`boolean`,default:!1};let c=hc(t);return i.segments[s]={template:`{{ action "${o}" "↺ ${c} customized" }}`,when:Dh},{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:s},Fh(e,a)],...e.when!==void 0&&{when:e.when}}}function Fh(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),Fh(n,t)]}:{...e,children:[...e.children,t]}}function Ih(e,t,n,r){let{node:i}=fh(e,t),a=gh(t),o=kh(t),s=vs(t);return Ph(Nh(i,s,a,o,n,{n:0}),t,s,a,n,r)}function Lh(e){if(!(`edit.toggle`in e.actions))return e;let t={variables:{},ensured:{},actions:{},segments:{}},n=bh(`${xs}help`,Ch,[$m],t),r={...e.presets};for(let i of lh(e.presets)){let a=Ih(e,i,t,n);r[i]={...dh(e.presets,i),root:a}}return{...e,variables:{...t.ensured,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:r}}const Rh={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function zh(e){let t=e[Rh.socket]??``,n=e[Rh.pane]??``;if(t===``||n===``)return null;let r=e[Rh.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const Bh=Rh.truecolor,Vh=[{name:`tmuxTruecolor`,label:`tmux truecolor`,probe:({tmux:e,claudeSettingsEnv: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`:{if(e.termfeatures.kind===`failed`)return{ok:!1,reason:`tmux could not be asked: ${e.termfeatures.reason}`};if(!e.termfeatures.value.includes(`RGB`)||e.hint.truecolor!==null)return{ok:!0};let n=t[Bh];return typeof n==`string`&&n!==``?{ok:!1,reason:`${Bh} is set in ~/.claude/settings.json — restart Claude Code to apply`}:{ok:!1,reason:`Claude Code renders the bar in 256 colours inside tmux`,fix:{kind:`claude-settings-env`,name:Bh,value:`1`}}}}}}];function Hh(e){return Vh.map(t=>({check:t,verdict:t.probe(e)}))}function Uh(e){return Vh.find(t=>t.name===e)}function Wh(e){let t=`settings.doctor.${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function Gh(e){return e.flatMap(({check:e,verdict:t})=>{let n=Wh(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:Ti}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:t.reason},{key:n.fixable,value:t.fix===void 0?Ti:wi}]})}const Kh=`${Ss}menu`,qh=Qm,Jh=`${Ss}edit`,Yh=`${Ss}persist`,Xh=`${Ss}config`,Zh=Yh,Qh={variable:Kh,member:qh},$h={variable:Xh,member:qh},eg=`${Ss}tools`,tg={variable:eg,member:qh},ng=`${Ss}doctor`,rg=`${ng}.run`,ig=e=>`${ng}.fix.${e}`,ag=e=>`${ng}.${e}`,og=`${Ss}help.persist`,sg={bg:`{{ color "accent" }}`,fg:`{{ contrastOn (bgOf) }}`},cg=`${Ss}pickers`,lg=[{name:`preset`,sessionKey:`preset`,configKey:`preset`,effectiveVar:`preset.effective`,glyph:`▦`,domain:`presets`}],ug=[{name:`theme`,sessionKey:`theme`,configKey:`palette`,effectiveVar:`theme.effective`,glyph:`🎨`,domain:`themes`},{name:`look`,sessionKey:`look`,configKey:`look`,effectiveVar:`look.effective`,glyph:`◐`,domain:`looks`},{name:`style`,sessionKey:`style`,configKey:`style`,effectiveVar:`style.effective`,glyph:`✦`,domain:`styles`}],dg={name:`wrap`,sessionKey:`autoWrap`,configKey:`autoWrap`},fg={name:`padding`,sessionKey:`padding`,configKey:`padding`},pg=`${Ss}${dg.name}`,mg=`${Ss}${fg.name}`,hg=[...lg,...ug];new Set([...hg,dg,fg].flatMap(e=>[e.sessionKey,e.configKey]));const gg=e=>`${Ss}${e}`,_g=e=>`${Ss}apply.${e}`,vg=e=>`${Ss}reset.${e}`;function yg(e){return e===Kh}function bg(e){let t={kind:`segment`,name:Kh};if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[t,e],...e.when!==void 0&&{when:e.when}};let[n,...r]=e.children;return e.direction===`vertical`&&n!==void 0&&n.when===void 0?{...e,children:[bg(n),...r]}:{...e,children:[t,...e.children]}}function xg(e){return Sg(e)>0?e:bg(e)}function Sg(e){let t=0;for(let n of wa(e))n.kind===`segment`&&yg(n.name)&&(t+=1);return t}function Cg(e,t){return e.kind===`segment`?yg(e.name)?gc(e.name,Qh,{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:Yh},t,...lg.map(e=>({kind:`segment`,name:gg(e.name)})),gc(Xh,$h,{kind:`container`,direction:`horizontal`,children:[...ug.map(e=>({kind:`segment`,name:gg(e.name)})),{kind:`segment`,name:pg},{kind:`segment`,name:mg}]}),gc(eg,tg,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:ng},...Vh.map(e=>({kind:`segment`,name:ag(e.name)}))]}),{kind:`segment`,name:Jh}]},e.when):Ca(e,e=>wg(e,t)):wg(e,t)}function wg(e,t){return{...e,children:e.children.map(e=>Cg(e,t))}}function Tg(e,t,n,r){let i=jm(t),a=Mm(e,t,r),o=Fm(a);n.variables[a]=bc(a,fc),n.variables[o]={kind:`state`,key:o,default:`0`},n.actions[Pm(a,i)]=xc(a,i),n.actions[o]={set:o,int:!0}}function Eg(){let e={variables:{[Kh]:bc(Kh,fc)},actions:{[Kh]:xc(Kh,qh),[Xh]:xc(Xh,qh),[eg]:xc(eg,qh),[rg]:{doctor:`run`},[Yh]:{set:Zh,cycle:[Ti,wi]}},segments:{[Kh]:{template:yc(Kh,`☰`,`✕`),...sg},[Yh]:{template:`{{ action "${Yh}" "☐ persist?" "☑ persist?" }}`},[Xh]:{template:yc(Xh,`⚙ config ▸`,`⚙ config ▾`)},[eg]:{template:yc(eg,`🧰 tools ▸`,`🧰 tools ▾`)},[ng]:{template:`{{ action "${rg}" "🩺 doctor" }}`},[pg]:{template:`{{ action "${_g(`wrap`)}" "wrap: on" "wrap: off" }} {{ action "${vg(`wrap`)}" "↺" }}`},[mg]:{template:`{{ action "${_g(`padding`)}.down" "◀" }} padding {{ .padding.effective }} {{ action "${_g(`padding`)}.up" "▶" }} {{ action "${vg(`padding`)}" "↺" }}`},[Jh]:{template:`{{ action "${Zm}" "✎ edit" "✎ done" }}`}}};return e.variables[Zh]={kind:`state`,key:Zh,default:Ti},e.variables[Xh]=bc(Xh,fc),e.variables[eg]=bc(eg,fc),Og(e),Dg(e),{artifacts:e,help:bh(og,wh,[Qh],e)}}function Dg(e){for(let t of Vh){let n=Wh(t.name),r=ig(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},e.segments[ag(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${wi}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function Og(e){for(let t of hg){let n=gg(t.name),r=_g(t.name);e.segments[n]={template:`${t.glyph} {{ .${t.effectiveVar} }} {{ menu "${r}" "▸" "▾" (dict "key" "${cg}" "closeOnPick" true) }} {{ action "${vg(t.name)}" "↺" }}`},e.actions[r]={set:t.sessionKey,persist:t.configKey,persistWhen:Zh,from:t.domain},e.actions[vg(t.name)]={reset:t.configKey},Tg(n,r,e,cg)}e.actions[_g(dg.name)]={set:dg.sessionKey,persist:dg.configKey,persistWhen:Zh,cycle:[...Ei]},e.actions[vg(dg.name)]={reset:dg.configKey};for(let t of[-1,1])e.actions[`${_g(fg.name)}.${t<0?`down`:`up`}`]={set:fg.sessionKey,persist:fg.configKey,persistWhen:Zh,...Di,by:t};e.actions[vg(fg.name)]={reset:fg.configKey}}function kg(e){e.variables[Xm]=bc(Xm,fc),e.actions[Zm]=xc(Xm,Qm)}const Ag=`session.id`;function jg(e){return Object.prototype.hasOwnProperty.call(e.variables,Ag)}function Mg(e){if(!jg(e))return e;let{artifacts:t,help:n}=Eg();kg(t);let r={...e.presets};for(let t of lh(e.presets)){let{node:i}=fh(e,t);r[t]={...dh(e.presets,t),root:Cg(xg(i),n)}}return{...e,variables:{...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:r}}const Ng=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`doctor`],Pg=`persistWhen`;function Fg(e){return Pg in e}function Ig(e){return Fg(e)?`to`in e?[{set:e.set,to:e.to},{persist:e.persist,to:e.to}]:`from`in e?[{set:e.set,from:e.from},{persist:e.persist,from:e.from}]:`cycle`in e?[{set:e.set,cycle:e.cycle},{persist:e.persist,cycle:e.cycle}]:[{set:e.set,min:e.min,max:e.max,by:e.by},{persist:e.persist,min:e.min,max:e.max,by:e.by}]:[e]}function Lg(e){return`set`in e}function Rg(e){return`persist`in e}function zg(e){return`reset`in e}function Bg(e){return`undo`in e}function Vg(e){return`redo`in e}function Hg(e){return`doctor`in e}function Ug(e,t){if(t===void 0)return{};if(!Ra(t))return J(e,`actions`,`actions must be an object, got ${za(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=Wg(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function J(e,t,n){e.issues.push({path:t,message:n,line:G(e.source,t.split(`.`))})}function Wg(e,t,n){if(!Ra(n))return J(e,t,`${t} must be an action object, got ${za(n)}`),null;if(`persistWhen`in n)return S_(e,t,n,`dual`,y_);let r=Ng.filter(e=>e in n);return r.length===1?Gg[r[0]](e,t,n):(J(e,t,`action must declare exactly one of: ${Ng.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const Gg={set:(e,t,n)=>S_(e,t,n,`set`,__),persist:(e,t,n)=>S_(e,t,n,`persist`,v_),copy:Kg(`copy`),open:Kg(`open`),reset:qg,undo:Jg(`undo`),redo:Jg(`redo`),doctor:Yg};function Kg(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&J(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=Na(t,n,r,e);return i===null?null:{[e]:i}}}function qg(e,t,n){for(let r of Object.keys(n))r!==`reset`&&J(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=Xg(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}}function Jg(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&J(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(J(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — it steps the history of the session's config file), got ${Ba(r[e])}`),null)}}function Yg(e,t,n){let r=n.doctor,i=r===`run`?[`doctor`]:[`doctor`,`check`];for(let r of Object.keys(n))i.includes(r)||J(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${i.join(`, `)}`);if(r!==`run`&&r!==`fix`)return J(e,`${t}.doctor`,`doctor must be "run" or "fix", got ${Ba(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||Uh(a)===void 0?(J(e,`${t}.check`,`doctor fix must name a check (have: ${Vh.map(e=>e.name).join(`, `)}), got ${Ba(a)}`),null):{doctor:`fix`,check:a}}function Xg(e,t,n,r,i,a){let o=Na(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(J(e,s,i),null):o.includes(`/`)?(J(e,s,a(o)),null):o}const Zg={set:[[`set`,`the SessionState key to write`]],persist:[[`persist`,`the config globals field to write`]],dual:[[`set`,`the SessionState key written while persistWhen is off`],[`persist`,`the config globals field written while persistWhen is on`],[Pg,`the SessionState key whose boolean value chooses the destination`]]};function Qg(e,t,n,r){let i={},a=Zg[r],o=!0;for(let[r,s]of a){if(!(r in n)){J(e,t,`${r} is required here (${s}) — a dual-destination action declares ${a.map(([e])=>e).join(`, `)} together, plus one value source`),o=!1;continue}let c=Xg(e,t,r,n,`${r} key must be non-empty (${s})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);if(c===null){o=!1;continue}i[r]=c}return o?i:null}function $g(e){return e===`set`?`set-state`:e===`persist`?`set-config`:`set-state/set-config`}const e_={to:C_(`set`)},t_={to:C_(`persist`)},n_={from:w_(`set`)},r_={from:w_(`persist`)},i_={min:k_(),max:k_(),by:k_()},a_={int:E_()},o_={cycle:T_(`set`)},s_={to:C_(`dual`)},c_={from:w_(`dual`)},l_={cycle:T_(`dual`)},u_={cycle:T_(`persist`)},d_={removeSegment:D_(`removeSegment`)},f_={insertSegment:D_(`insertSegment`),anchor:D_(`anchor`),relation:O_()},p_={insertSegmentFrom:w_(`persist`),anchor:D_(`anchor`),relation:O_()},m_={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},h_={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function g_(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=Zg[e].map(([e])=>e),s=(e,n,r)=>Ha(e,t,n,r),c=ro(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?Xa(s,...n):s}}const __=[g_(`set`,e_),g_(`set`,n_),g_(`set`,i_,[m_,h_]),g_(`set`,a_),g_(`set`,o_)],v_=[g_(`persist`,t_),g_(`persist`,r_),g_(`persist`,i_,[m_,h_]),g_(`persist`,u_),g_(`persist`,d_),g_(`persist`,f_,[],[`insertSegment`]),g_(`persist`,p_,[],[`insertSegmentFrom`])],y_=[g_(`dual`,s_),g_(`dual`,c_),g_(`dual`,i_,[m_,h_]),g_(`dual`,l_)];function b_(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"styles"/"looks", 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 x_(e){let t=b_(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 S_(e,t,n,r,i){let a=Qg(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return J(e,t,`${x_(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)||J(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 C_(e){let t=$g(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>Xg(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 w_(e){let t=$g(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===``){J(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){J(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===``)){J(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){J(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){J(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}J(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${Ba(o)}`)}}}function T_(e){let t=$g(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`)){J(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${za(o)}`);return}let c=o;if(c.length<2){J(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){J(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){J(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){J(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function E_(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){J(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${Ba(r[n])}`);return}return!0}}}function D_(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Na(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){J(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){J(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 O_(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){J(e,`${t}.${n}`,`relation must be "before" or "after", got ${Ba(i)}`);return}return i}}}function k_(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){J(e,`${t}.${n}`,`${n} must be an integer, got ${Ba(i)}`);return}return i}}}const A_={noun:`look key`,fields:{hueShift:$a(),chromaScale:$a({min:0}),lightnessScale:$a(),lightnessShift:$a()}};function j_(e,t){if(!Ra(t))return e.issues.push({path:`looks`,message:`looks must be an object mapping look names to adaptation objects, got ${za(t)}`,line:G(e.source,[`looks`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`looks.${r}`,message:`look name ${JSON.stringify(r)} must be non-empty and slash-free — a look picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:G(e.source,[`looks`,r])});continue}let t=Va(e,A_,`looks.${r}`,i);t!==null&&(n[r]={...gn,...t})}return n}const M_={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:Rc(e,`${t}.${n}`,r[n])},globals:{required:!1,json:ko(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Oo(e,`${t}.${n}`,r[n])}}};function N_(e,t){if(!Ra(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${za(t)}`,line:G(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:G(e.source,[`presets`,r])});continue}let t=Va(e,M_,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function P_(e,t){if(t===void 0)return{};if(!Ra(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${za(t)}`,line:G(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 ${Ba(i)}`,line:G(e.source,[`helpers`,r])});continue}n[r]=i}return n}const F_=new Map,I_=new Map;function L_(e){let t=R_(e);if(t===null)throw Error(`Palette "${e}" (resolved "${ai(e)}") did not resolve in the theme registry — allowed names and the registry are inconsistent`);return t}function R_(e){let t=ai(e),n=F_.get(t);if(n!==void 0)return n;let r=Kn(t);return r===null?null:(F_.set(t,r),r)}function z_(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=I_.get(n);if(r!==void 0)return r;let i=tr(e,t);return I_.set(n,i),i}function B_(e){let t=R_(e);return t===null?null:{kind:`decided`,name:e,value:t}}function V_(e,t){let n=B_(e);return n===null?(t(`globals.palette rendered "${oi}": "${e}" names no installed theme`),U_()):n}function H_(e,t,n){return pi(e,t,n,U_(),B_)}function U_(){return B_(oi)}function W_(e){return mi(H_(void 0,null,e),()=>oi,U_).value}const G_=new Map;function K_(e,t,n){G_.set(e,{permanent:!0,resolve:t,paletteOf:n})}K_(`themes`,()=>li(),e=>L_(e)),K_(`styles`,()=>yi),K_(`charsets`,()=>Si),K_(`colorCompatibilities`,()=>Ci);function q_(e){return new Map([[`looks`,{members:Object.keys(e.looks),paletteOf:(t,n)=>z_(n,e.looks[t])}],[`presets`,{members:lh(e.presets)}]])}function J_(e){return[...new Set([...G_.keys(),...e.keys()])]}function Y_(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=G_.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(`unknown option domain "${e}" (have: ${J_(t).join(`, `)})`)}const X_=/{{([\s\S]*?)}}/g,Z_=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g,Q_=/(?<![A-Za-z0-9_)])\.([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*)/g;function $_(e){let t=new Set,n;for(X_.lastIndex=0;(n=X_.exec(e))!==null;){let e=n[1].replace(Z_,``),r;for(Q_.lastIndex=0;(r=Q_.exec(e))!==null;)t.add(r[1])}return t}const ev=/\baction\s+$/;function tv(e){let t=new Set;X_.lastIndex=0;let n;for(;(n=X_.exec(e))!==null;){let e=n[1],r=0,i;for(Z_.lastIndex=0;(i=Z_.exec(e))!==null;)ev.test(e.slice(r,i.index))&&t.add(i[0].slice(1,-1)),r=i.index+i[0].length}return t}const nv=/\b(picker|menu)\s+$/;function rv(e){let t=new Set;X_.lastIndex=0;let n;for(;(n=X_.exec(e))!==null;){let e=n[1],r=0,i=0,a;for(Z_.lastIndex=0;(a=Z_.exec(e))!==null;){let n=nv.exec(e.slice(r,a.index));n!==null&&(i=n[1]===`picker`?2:1),i>0&&(t.add(a[0].slice(1,-1)),i--),r=a.index+a[0].length}}return t}function iv(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}const av={gitTaculous:`gitaculous`};function ov(e,t){let n=new Map;for(let e of Object.keys(t)){let t=vs(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:G(e.source,[`presets`])})}function sv(e,t){t.globals.look!==void 0&&!fi(t.globals.look)&&!Object.prototype.hasOwnProperty.call(t.looks,t.globals.look)&&e.issues.push({path:`globals.look`,message:`globals.look "${t.globals.look}" does not match any declared look (have: ${Object.keys(t.looks).join(`, `)})`,line:G(e.source,[`globals`,`look`])}),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:G(e.source,[`globals`,`preset`])}),ov(e,t.presets);let n=q_(t);for(let[r,i]of Object.entries(t.actions))!(`set`in i)||!(`from`in i)||typeof i.from!=`string`||J_(n).includes(i.from)||e.issues.push({path:`actions.${r}.from`,message:`actions.${r} from: references unknown option domain "${i.from}" (have: ${J_(n).join(`, `)})`,line:G(e.source,[`actions`,r,`from`])});for(let[n,r]of Object.entries(t.actions)){if(!Fg(r))continue;let i=r[Pg];fv(t,i)||e.issues.push({path:`actions.${n}.${Pg}`,message:`actions.${n} ${Pg}: "${i}" is not a declared state key — a dual action's selector must name a { kind: "state", key: "${i}" } variable, or the destination can never change`,line:G(e.source,[`actions`,n,Pg])})}for(let[n,r]of Object.entries(t.actions)){let i=`persist`in r?r.persist:`reset`in r?r.reset:null;if(i===null)continue;let a=`persist`in r?`persist`:`reset`,o=_h(i);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a config globals field (have: ${No().join(`, `)}), a "segments.<name>.palette" target, or a "presets.<name>.root" target`,line:G(e.source,[`actions`,n,a])});continue}let s=cv.filter(e=>e in r);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){lv(e,t,n,a,i,o.preset,r);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}: "${i}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})`,line:G(e.source,[`actions`,n,a])});continue}`min`in r&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:G(e.source,[`actions`,n,a])})}}let r=mv(t),i=jg(t),a=Object.entries(t.segments).filter(([,e])=>qm(e.template)).map(([e])=>e),o=(t,n,r)=>{Sg(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${Kh}" ${Sg(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});let i=new Map;for(let e of wa(t))e.kind===`segment`&&i.set(e.name,(i.get(e.name)??0)+1);for(let t of a)(i.get(t)??0)>1&&e.issues.push({path:n,message:`segment "${t}" hosts a {{ menu }} and is placed in the layout more than once — a menu's open-state is keyed by segment name, so the copies would share one state (clicking one would toggle both). Give each placement its own named segment.`,line:r})},s=(n,a,o)=>{for(let s of wa(n))if(s.when!==void 0&&vv(e,`${a}.when`,s.when,r,{line:o}),s.kind===`segment`){if(yg(s.name)){i||e.issues.push({path:a,message:`${a} places the global settings menu anchor "${Kh}", but this config declares no "${Ag}" variable — the menu is a click surface and every click composes a URL from "${Ag}", so it is not synthesized for a config without it. Declare a "${Ag}" variable (any config merged onto the bundled default inherits one) or remove the anchor placement.`,line:o});continue}if(!Object.prototype.hasOwnProperty.call(t.segments,s.name)){let t=av[s.name],n=t===void 0?``:` (the built-in segment "${s.name}" was renamed to "${t}" — update this reference)`;e.issues.push({path:a,message:`${a} entry "${s.name}" does not match any declared segment${n}`,line:o})}}},c=yv(e.source);s(ho(t.root),c,G(e.source,[c]));for(let[n,r]of Object.entries(t.presets)){if(r.root===void 0)continue;let t=`presets.${n}.root`,i=G(e.source,[`presets`,n,`root`]);s(go(r.root),t,i)}let l=new Map([[`root`,ho(t.root)]]);for(let e of lh(t.presets)){let{node:n,path:r}=fh(t,e);l.set(r,n)}for(let[t,n]of l)o(n,t,G(e.source,t.split(`.`)));for(let[n,i]of Object.entries(t.variables))gv(e,`variables.${n}`,i,r);for(let[n,i]of Object.entries(t.segments)){if(i.vars)for(let[t,a]of Object.entries(i.vars))gv(e,`segments.${n}.vars.${t}`,a,r,n);for(let a of[`template`,`bg`,`fg`,`when`]){let o=i[a];if(typeof o==`string`){vv(e,`segments.${n}.${a}`,o,r,{segCtx:n});for(let r of tv(o))Object.prototype.hasOwnProperty.call(t.actions,r)||e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}"`,line:G(e.source,[`segments`,n,a])});for(let r of rv(o))Object.prototype.hasOwnProperty.call(t.actions,r)||e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}" (in a picker or menu)`,line:G(e.source,[`segments`,n,a])})}}}for(let[n,i]of Object.entries(t.variables))_v(e,`variables.${n}`,i,r);for(let[n,i]of Object.entries(t.segments))if(i.vars)for(let[t,a]of Object.entries(i.vars))_v(e,`segments.${n}.vars.${t}`,a,r,n);(dv(t)||pv(t))&&!Object.prototype.hasOwnProperty.call(t.variables,`session.id`)&&e.issues.push({path:`variables.session.id`,message:`state reads and action set-writes require a global "session.id" variable (segment-local declarations do not satisfy this — declareState/set-state both read the global box; conventionally { kind: "input", path: "session_id" })`,line:G(e.source,[`variables`])})}const cv=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function lv(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=G(e.source,[`actions`,n,r]);if(!lh(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${lh(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=e=>!Object.prototype.hasOwnProperty.call(t.segments,e);l&&`removeSegment`in o&&f(o.removeSegment)&&e.issues.push({path:s,message:`actions.${n}: removeSegment "${o.removeSegment}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c}),u&&`insertSegment`in o&&(f(o.insertSegment)&&e.issues.push({path:s,message:`actions.${n}: insertSegment "${o.insertSegment}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c}),f(o.anchor)&&e.issues.push({path:s,message:`actions.${n}: anchor "${o.anchor}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c})),d&&`insertSegmentFrom`in o&&f(o.anchor)&&e.issues.push({path:s,message:`actions.${n}: anchor "${o.anchor}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})`,line:c})}function uv(e){return[...Object.values(e.variables),...Object.values(e.segments).flatMap(e=>Object.values(e.vars??{}))].filter(e=>e.kind===`state`)}function dv(e){return uv(e).length>0}function fv(e,t){return uv(e).some(e=>e.kind===`state`&&e.key===t)}function pv(e){return Object.values(e.actions).some(e=>Lg(e)||Rg(e)||zg(e)||Bg(e)||Vg(e)||Hg(e))}function mv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),hv(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}}function hv(e){return(e.kind===`shell`||e.kind===`file`)&&Ea(e.parse)===`json`}function gv(e,t,n,r,i){n.kind===`template`&&vv(e,`${t}.template`,n.template,r,{segCtx:i}),Oa(n)&&n.cache&&`key`in n.cache&&vv(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function _v(e,t,n,r,i){if(Oa(n)&&n.cache&&`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:G(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function vv(e,t,n,r,i){for(let a of $_(n)){if(iv(a,r))continue;let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,o=n!==void 0&&iv(n,r)?` (segment-local vars are namespaced — write ".${n}")`:``;e.issues.push({path:t,message:`Template references unknown variable ".${a}"${o}`,line:i?.line??G(e.source,t.split(`.`))})}}function yv(e){try{let t=Ze.default.parse(e);if(Ra(t)&&`root`in t)return`root`}catch{}return`layout`}function bv(e,t){let{graph:n,nodeInfo:r}=xv(t),i=new Map,a=[];for(let e of n.keys())i.set(e,0);for(let e of n.keys())if(i.get(e)===0&&o(e))return;function o(t){i.set(t,1),a.push(t);for(let s of n.get(t)??[]){let t=i.get(s);if(t===1){let t=a.indexOf(s),n=[...a.slice(t),s],i=n[0],o=r.get(i);return e.issues.push({path:o?.declarationPath??`variables.${i}`,message:`Dependency cycle: ${n.join(` → `)}`,line:G(e.source,o?.linePathParts??[`variables`,i])}),!0}if(t===0&&o(s))return!0}return i.set(t,2),a.pop(),!1}}function xv(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=(e,n)=>{for(let i of $_(n)){if(t.has(i)){r.get(e).add(i);continue}let n=i.split(`.`)[0];n!==i&&t.has(n)&&r.get(e).add(n)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),Oa(n)&&(n.cache&&`key`in n.cache&&i(e,n.cache.key),n.cache&&`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}}const Sv=[`json5`,`json`];function Cv(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function wv(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?f.homedir()+e.slice(1):e}function Tv(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Sv.map(t=>c.join(e,`.cc-candybar.${t}`)):[],...Sv.map(e=>c.join(r,`.cc-candybar.${e}`)),...Sv.map(e=>`${Ev()}.${e}`)])]}function Ev(){let e=process.env.XDG_CONFIG_HOME??c.join(f.homedir(),`.config`);return c.join(e,`cc-candybar`,`config`)}function Dv(e,t,n){let r=[];for(let i of Tv(e,t,n)){let e=Cv(i);if(e===`present`)return{kind:`file`,path:i,unchecked:r};e!==`absent`&&r.push(e)}if(n===void 0)return{kind:`default`,unchecked:r};let[i]=r;return i===void 0?{kind:`missing`,path:n}:{kind:`unreadable`,...i}}function Ov(e,t,n){let r=Dv(e,t,n);return r.kind===`default`?`${Ev()}.${Sv[0]}`:r.path}function kv(e){return Av(e).join(`
119
119
  `)||null}function Av(e){switch(e.kind){case`file`:case`default`: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 jv(e,t){let n=Tv(e,t).filter(e=>Cv(e)===`present`),r=new Map;for(let e of n){let t=c.dirname(e),n=c.basename(e).replace(/\.(json5|json)$/,``),i=c.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 Mv(e,t,n){let r=e===null?Nv:Pv(e,t,n);return{...r,config:yo(r.raw,t)}}const Nv={raw:{},source:``,warnings:[]};function Pv(e,t,n){let i=r.readFileSync(e,`utf-8`);return{source:i,...Lv(e,i,n,Ds(t))}}function Fv(e,t=`<config>`,n=``,r=new Set(li())){let i=[],a={source:n,issues:i,allowedPalettes:r,groups:[]};if(sv(a,e),bv(a,e),i.length>0)throw new _a(t,i);return Lh(Mg(e))}function Iv(e,t,n=new Set(li()),r=Rv){return Lv(e,t,n,r).raw}function Lv(e,t,n,r){let i=zv(e,t),a=ba(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(li()),groups:[]};if(!Ra(i))throw new _a(e,[{path:``,message:`Config root must be an object, got ${za(i)}`}],o);let l=Bv(c,i,r);if(s.length>0)throw new _a(e,s,o);return{raw:l,warnings:o}}const Rv=new Set;function zv(e,t){try{return Ze.default.parse(t)}catch(t){let n=t;throw new _a(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function Bv(e,t,n){for(let n of Object.keys(t))Vv.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...Vv].join(`, `)}`,line:G(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=Do(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=qo(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=Os(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.
120
120
  Replace: layout: [["seg1", "seg2"], ["seg3"]]
121
121
  With: root: { v: [{ h: ["seg1", "seg2"] }, "seg3"] }
122
122
  Single-row example: root: { h: ["seg1", "seg2"] }`,line:G(e.source,[`layout`])}),t.root!==void 0&&(r.root=Rc(e,`root`,t.root)),t.actions!==void 0&&(r.actions=Ug(e,t.actions)),t.looks!==void 0&&(r.looks=j_(e,t.looks)),t.presets!==void 0&&(r.presets=N_(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=Ao(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=P_(e,t.helpers)),Kc(e,r),Ym(e,r),rh(e,r),Es(e,r,Ss,`the global settings menu`),r}const Vv=new Set([`globals`,`variables`,`segments`,`layout`,`root`,`actions`,`looks`,`presets`,`editGlobals`,`helpers`]);function Hv(e){let t=Kv(e.termCols),n=Kv(e.termRows),r=qv(e.ssh),i=Wv(e.tmux),a=Uv(e.configEnv);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}}}function Uv(e){return typeof e==`string`&&e!==``?wv(e):void 0}function Wv(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 Gv=1e4;function Kv(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>Gv?Gv:t}function qv(e){return typeof e==`boolean`?e:void 0}var Jv=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Yv(e){let t=Buffer.from(JSON.stringify(e),`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Xv(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 Jv(`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 Jv(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Zv(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=Xv(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(Yv(t))})}async function Qv(e,t,n){let r=null;try{r=await ry(Pe(),t.connectMs);let i=await Zv(r,{v:3,...e},t.budgetMs);return ty(e.kind,i,n)}catch(e){return ny(e)}finally{r&&r.destroy()}}function $v(e,t){return typeof e==`string`?e:t}function ey(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function ty(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=$v(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:ey(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};default:return{kind:`permanent`,cause:`malformed_response`,message:`unknown error code: ${String(r.code)}`}}}function ny(e){if(e instanceof Jv||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 ry(e,t){return new Promise((n,r)=>{let i=g.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 iy(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`malformed_response`:return`daemon error (${e.cause}): ${e.message}`}}const ay={connectMs:50,budgetMs:150},oy={connectMs:50,budgetMs:200};function sy(e){let t=e.output;return typeof t==`string`?t:void 0}function cy(e,t,n,r){return Qv({kind:`render`,hookData:e,args:t,cwd:n,...r},ay,sy)}function ly(e,t){return Qv({kind:`click`,verb:e,value:t},oy,sy)}let uy=null;function dy(e){if(uy!==null)return uy;r.mkdirSync(c.dirname(e),{recursive:!0});try{uy=r.statSync(e).size}catch{uy=0}return uy}function fy(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,i=`${e}.${t+1}`;try{r.renameSync(n,i)}catch{}}try{r.renameSync(e,`${e}.1`)}catch{}uy=0}function Y(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=Ke(),t=dy(e);r.appendFileSync(e,n),uy=t+Buffer.byteLength(n,`utf8`),uy>=5242880&&fy(e)}catch(e){uy=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}function py(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(`
123
123
  `)}function my(e,t){return e===`darwin`?[hy(`footprint`,[`-p`,String(t)]),hy(`vmmap`,[`--summary`,String(t)])]:e===`linux`?[gy(`/proc/self/smaps_rollup`),gy(`/proc/self/status`)]:[]}function hy(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=De({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}`}${_y(n.stderr)}`}}}}function gy(e){return{name:e,read:()=>{try{let t=r.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 _y(e){let t=e.split(`
124
124
  `).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const vy=`CC_CANDYBAR_RSS_LIMIT_MB`;function yy(e){let t=e[vy];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${vy} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function by(e){return yy(e)*2}const xy=1024*1024;function Sy(e){return yy(e)*xy}const Cy={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function wy(e,t,n){let{prefix:r,suffix:i}=Cy[t];return c.join(e,`${r}${n}${i}`)}function Ty(e){for(let t of Object.keys(Cy)){let{prefix:n,suffix:r}=Cy[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function Ey(e){let t=e.rssLimitBytes??512*xy,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 Dy(e.log,`memory report`,()=>{let t=wy(e.snapshotDir,`memoryReport`,o);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),Dy(e.log,`heap snapshot`,()=>{let t=wy(e.snapshotDir,`heapSnapshot`,o);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),Dy(e.log,`artifact rotation`,()=>{ky(e.listArtifacts(),n,e.removeFile)}),e.shutdown(0),!0}function a(){let{rss:n,heapTotal:r}=e.memoryBytes();return n>t*.75?`rss ${n} approaching limit ${t} (v8 heap ${r})`:null}function o(e=6e4){let t=setInterval(()=>{i()},e);return t.unref(),{disarm:()=>clearInterval(t)}}return{checkRss:i,describeNextRestart:a,arm:o}}function Dy(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function Oy(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=Ty(t);if(n===null)return t;let{prefix:r,suffix:i}=Cy[n];return t.slice(r.length,t.length-i.length)}function ky(e,t,n){let r=new Map;for(let t of e){let e=Oy(t),n=r.get(e);n===void 0?r.set(e,[t]):n.push(t)}let i=[...r.keys()].sort((e,t)=>t.localeCompare(e));for(let e of i.slice(t))for(let t of r.get(e)??[])try{n(t)}catch{}}function Ay(e,t,n={}){let i=Ne();return{now:()=>Date.now(),pid:process.pid,snapshotDir:i,log:Y,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},captureMemoryReport:()=>py(my(process.platform,process.pid)),writeMemoryReport:(e,t)=>r.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>_.writeHeapSnapshot(e),listArtifacts:()=>{try{return r.readdirSync(i).filter(e=>Ty(e)!==null).map(e=>c.join(i,e))}catch{return[]}},removeFile:e=>r.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function jy(e={}){if(qy()!==null)return;let n=e.spawn??Jy,r=Wy();if(r.kind===`contended`){let e=Ny();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),My(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),My(n);return}try{My(n)}finally{Ky()}}function My(e){By()&&Py(e)}function Ny(){try{let e=r.statSync(He());return Date.now()-e.mtimeMs}catch{return null}}function Py(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
125
- `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function Fy(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function Iy(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function Ly(e){try{let t=r.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function Ry(e,n){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function zy(){try{r.unlinkSync(We())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function By(){let e=Ue(),n=We(),r=Ly(n),i=Fy(Vy(e),Iy(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`),Hy(e),Ry(n,Math.min(r+1,5)),!0)}function Vy(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function Hy(e){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.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 Uy=null;function Wy(){let e=He();for(let n=0;n<2;n++){try{let n=r.openSync(e,`wx`,384);try{r.writeSync(n,JSON.stringify({pid:t.pid,ts:Date.now()}))}catch{}return Uy={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(!Gy(e))return{kind:`contended`};try{r.unlinkSync(e)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function Gy(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function Ky(){if(!Uy)return;let{fd:e,path:t}=Uy;Uy=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function qy(){try{return r.mkdirSync(Ne(),{recursive:!0}),null}catch(e){return`mkdir ${Ne()}: ${e.message}`}}function Jy(){let e=t.execPath,n=t.argv[1];return n?Oe({bin:e,args:[`--max-old-space-size=${by(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const Yy=`cc-candybar`,Xy=`dispatch`,Zy=`set-state`,Qy=`step-state`,$y=`copy`,eb=`open-vscode`,tb=`toolbar-toggle`,nb=`show-config-error`,rb=`show-config-warning`,ib=`set-config`,ab=`step-config`,ob=`reset-config`,sb=`apply-layout-op`,cb=`undo`,lb=`redo`,ub=`apply-update`,db=`doctor-run`,fb=`doctor-fix`;function pb(e){return e.map(encodeURIComponent).join(`/`)}function mb(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function hb(e){return`${Yy}://${Xy}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${pb(e.args)}`)}`).join(`&`)}`}function gb(e){return new y(e).getAll(`e`).map(_b)}function _b(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const vb=`1.71.0`;function yb(){return c.join(f.homedir(),`.claude`,`settings.json`)}function X(e){return{kind:`ok`,value:e}}const Z={kind:`absent`};function Q(e){return{kind:`failed`,reason:e}}function bb(e,t){return e?.kind===`ok`?e.value:t}const xb=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Sb(e){let t=xb.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 Cb(e){return e.join(`.`)}function wb([e,t,n],[r,i,a]){return e-r||t-i||n-a}const Tb=`@promptctl/cc-candybar`;async function Eb(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 Q(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?Sb(n.latest):Z}catch(e){return Q(e instanceof Error?e.message:String(e))}}function Db(e,t){let n=Sb(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=wb(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 Ob(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${Cb(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${Cb(t.installed)} is newer than the registry's latest release (${Cb(t.latest)}): an unpublished build.\n`};case`stale`:{let n=Cb(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${Cb(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 kb=`CCCandybarURLHandler`,Ab=[],jb={"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 Mb(e){return/^[A-Za-z0-9_./=,:-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function Nb(e,t){return[e,...t].map(Mb).join(` `)}function Pb(){return c.join(f.homedir(),`Applications`,`${kb}.app`)}function Fb(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function Ib(){if(process.platform===`darwin`)return c.join(f.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??c.join(f.homedir(),`.local`,`share`);return c.join(e,`cc-candybar`)}function Lb(){return c.join(Ib(),`bin`,`cc-candybar`)}function Rb(){return c.join(Ib(),`dist`,`index.mjs`)}function zb(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(`
125
+ `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function Fy(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function Iy(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function Ly(e){try{let t=r.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function Ry(e,n){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function zy(){try{r.unlinkSync(We())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function By(){let e=Ue(),n=We(),r=Ly(n),i=Fy(Vy(e),Iy(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`),Hy(e),Ry(n,Math.min(r+1,5)),!0)}function Vy(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function Hy(e){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.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 Uy=null;function Wy(){let e=He();for(let n=0;n<2;n++){try{let n=r.openSync(e,`wx`,384);try{r.writeSync(n,JSON.stringify({pid:t.pid,ts:Date.now()}))}catch{}return Uy={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(!Gy(e))return{kind:`contended`};try{r.unlinkSync(e)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function Gy(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function Ky(){if(!Uy)return;let{fd:e,path:t}=Uy;Uy=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function qy(){try{return r.mkdirSync(Ne(),{recursive:!0}),null}catch(e){return`mkdir ${Ne()}: ${e.message}`}}function Jy(){let e=t.execPath,n=t.argv[1];return n?Oe({bin:e,args:[`--max-old-space-size=${by(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const Yy=`cc-candybar`,Xy=`dispatch`,Zy=`set-state`,Qy=`step-state`,$y=`copy`,eb=`open-vscode`,tb=`toolbar-toggle`,nb=`show-config-error`,rb=`show-config-warning`,ib=`set-config`,ab=`step-config`,ob=`reset-config`,sb=`apply-layout-op`,cb=`undo`,lb=`redo`,ub=`apply-update`,db=`doctor-run`,fb=`doctor-fix`;function pb(e){return e.map(encodeURIComponent).join(`/`)}function mb(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function hb(e){return`${Yy}://${Xy}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${pb(e.args)}`)}`).join(`&`)}`}function gb(e){return new y(e).getAll(`e`).map(_b)}function _b(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const vb=`1.71.1`;function yb(){return c.join(f.homedir(),`.claude`,`settings.json`)}function X(e){return{kind:`ok`,value:e}}const Z={kind:`absent`};function Q(e){return{kind:`failed`,reason:e}}function bb(e,t){return e?.kind===`ok`?e.value:t}const xb=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Sb(e){let t=xb.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 Cb(e){return e.join(`.`)}function wb([e,t,n],[r,i,a]){return e-r||t-i||n-a}const Tb=`@promptctl/cc-candybar`;async function Eb(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 Q(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?Sb(n.latest):Z}catch(e){return Q(e instanceof Error?e.message:String(e))}}function Db(e,t){let n=Sb(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=wb(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 Ob(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${Cb(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${Cb(t.installed)} is newer than the registry's latest release (${Cb(t.latest)}): an unpublished build.\n`};case`stale`:{let n=Cb(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${Cb(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 kb=`CCCandybarURLHandler`,Ab=[],jb={"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 Mb(e){return/^[A-Za-z0-9_./=,:-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function Nb(e,t){return[e,...t].map(Mb).join(` `)}function Pb(){return c.join(f.homedir(),`Applications`,`${kb}.app`)}function Fb(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function Ib(){if(process.platform===`darwin`)return c.join(f.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??c.join(f.homedir(),`.local`,`share`);return c.join(e,`cc-candybar`)}function Lb(){return c.join(Ib(),`bin`,`cc-candybar`)}function Rb(){return c.join(Ib(),`dist`,`index.mjs`)}function zb(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(`
126
126
  `)}function Bb(e){if(!e)throw Error(`install: process.argv[1] not set`);return e.endsWith(`.mjs`)||e.endsWith(`.js`)?e:c.resolve(c.dirname(e),`..`,`dist`,`index.mjs`)}function Vb(t){let n=jb[`${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:c.resolve(c.dirname(t),`..`,`bin`,`cc-candybar`)}}function Hb(e,t){c.resolve(e)!==c.resolve(t)&&r.copyFileSync(e,t)}function Ub(e){let t=r.openSync(e,`r`);try{let n=Buffer.alloc(2),i=r.readSync(t,n,0,2,0);if(i<2)throw Error(`install: staged render entry at ${e} is truncated (${i} byte(s)). Re-run: pnpm dlx ${Tb}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{r.closeSync(t)}}function Wb(){let e=Bb(process.argv[1]);if(!r.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let t=Vb(e);if(!r.existsSync(t.sourcePath))throw Error(`install: render entry not found at ${t.sourcePath}. Reinstall the package.`);r.mkdirSync(c.dirname(Rb()),{recursive:!0}),r.mkdirSync(c.dirname(Lb()),{recursive:!0}),Hb(e,Rb()),Hb(t.sourcePath,Lb()),r.chmodSync(Lb(),493),r.rmSync(c.join(Ib(),`url-handler.mjs`),{force:!0});let n=Ub(Lb());return process.stdout.write(`Staged cc-candybar v${vb} runtime at ${Ib()}\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:Lb(),distPath:Rb(),entryKind:n}}function Gb(){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>${Yy}</string>`,` </array>`,` </dict>`,`</array>`].join(`
127
127
  `)}]}function Kb(e){let t=Pb();r.mkdirSync(c.dirname(t),{recursive:!0}),r.existsSync(t)&&r.rmSync(t,{recursive:!0,force:!0}),process.stdout.write(`Building ${t}\n`);let n=De({bin:`/usr/bin/osacompile`,args:[`-o`,t,`-e`,zb(process.execPath,e)],category:`install.osacompile`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`osacompile failed (${n.reason})`);let i=c.join(t,`Contents`,`Info.plist`);for(let{key:e}of Gb())De({bin:`/usr/bin/plutil`,args:[`-remove`,e,i],category:`install.plutil`});for(let{key:e,xml:t}of Gb()){let n=De({bin:`/usr/bin/plutil`,args:[`-insert`,e,`-xml`,t,i],category:`install.plutil`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`plutil -insert ${e} failed (${n.reason})`)}process.stdout.write(`Registering ${Yy}:// with Launch Services\n`);let a=De({bin:`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister`,args:[`-f`,t],category:`install.lsregister`});if(!a.ok)throw process.stderr.write(a.stderr),Error(`lsregister failed (${a.reason})`);process.stdout.write(`✓ ${kb}.app installed and registered.\n`),process.stdout.write(` Test: open '${Yy}://hello-world' && pbpaste\n`)}function qb(){Fb(),Kb(Wb().distPath)}function Jb(e,t=Yy){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:$y,value:r}:{verb:decodeURIComponent(r.slice(0,i)),value:r.slice(i+1)}}async function Yb(e){e||(process.stderr.write(`url-handle: missing URL argument.
128
128
  `),process.exit(1));let t;try{t=Jb(e)}catch(e){process.stderr.write(`url-handle: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}let n=await ly(t.verb,t.value);n.kind===`ok`&&process.exit(0),n.kind===`transient`&&(jy(),process.stderr.write(`url-handle: daemon unavailable (${n.cause}: ${n.message})\n`),process.exit(1)),process.stderr.write(Xb(n)+`
@@ -135,7 +135,7 @@ Config tooling:
135
135
  `)?r.slice(0,-1):r}return Vr(new jr([...e],n),{colorSystem:t.colorCompatibility})}function Ix(e){return Math.min(20,e??20)}const Lx={heading:`ERROR`,glyph:`⚠`,colors:kx},Rx={heading:`WARNING`,glyph:`⚠`,colors:Ax},zx={heading:`UPDATE`,glyph:`⬆`,colors:Ax};function Bx(e,t){return{text:wx(e),link:t}}function Vx(e,t,n){let[r,...i]=[Hx(e,Lx,nb),t,Hx(n,Rx,rb)].flat();return r===void 0?null:{channels:[r,...i]}}function Hx(e,t,n){let r=hb([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>Bx(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function Ux(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
136
136
  `)}function Wx(e,t,n,r){if(t===null)return e;let i=Gx(r),a=t.channels.flatMap(e=>Kx(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[qx(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
137
137
  `);return e?`${l}\n${e}`:l}function Gx(e){return{style:`plain`,separator:``,width:e.width,wrap:!0,padding:0,charset:`unicode`,colorCompatibility:e.colorCompatibility}}function Kx(e,t){let n=new H({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=A(Math.max(2,t.width-1)),i=(e,t)=>new Ar(`${e} `,{style:t,end:``,noWrap:!0});return e.lines.flatMap((a,o)=>Fx([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=>Vt(e,r)).map(e=>i(e,t))})],t).split(`
138
- `))}function qx(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new H({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new Ar(e,{style:t,end:``,noWrap:!0}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(x(a.path).href)):c(`full text unavailable: ${wx(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(wx(o),s.withLink(x(o).href))],d=[c(`↳ `,s),...l,...u.slice(0,-1)],f=d.reduce((e,t)=>e+t.cellLength,0),p=u.slice(-1).map(e=>e.truncate(Math.max(1,r.width-f),{mode:`middle`})),m=Ar.fromFragments([...d,...p]).truncate(r.width,{overflow:`ellipsis`});return m.noWrap=!0,Fx([m],r)}const Jx=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Yx(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function Xx(e,t){return r.readdirSync(t).filter(Jx).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?Xx(e,i):[[c.relative(e,i).split(c.sep).join(`/`),Yx(i,a)]]})}function Zx(e){let t=C.createHash(`sha256`);for(let[n,r]of Xx(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const Qx=e=>e.slice(0,7);function $x(e){return c.dirname(c.dirname(e))}function eS(){return{version:vb,digest:`9e93d3272d4865300e11b6828d14bfc52e227c8dc410a4bf74eec910cd5c1085`}}function tS(e){let t=JSON.parse(r.readFileSync(c.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${c.join(e,`package.json`)} has no version string`);return n}function nS(e,t){try{let n=$x(b(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=Zx(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:tS(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const rS=/^-?\d+$/;function iS(e,t,n){return e===void 0?t:Math.max(t,Math.min(n,e))}function aS(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 oS(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!rS.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 sS(e,t,n){return r=>r?rS.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 cS(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=>!rS.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,seed:iS(r[0].seed,t,i)}}return{kind:`int`}}function lS(e){return e===`config`?`set-config`:`set-state`}function uS(e,t,n){return t.kind===`int`?oS(`menu page "${e}"`):t.kind===`range`?sS(t.min,t.max,`${n} stepper "${e}"`):aS(t.allowed,`${n} "${e}"`,lS(n))}function dS(e,t,n){return uS(e,cS(e,t,n),n)}function fS(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:cS(e,n,t)}))}function pS(e,t=`state`){let n=new Map(Object.entries(e).map(([e,t])=>[e,{validator:t,permanent:!0}]));function r(){let e=[];for(let[t,r]of n)r.permanent&&e.push(t);return e}return{register(e,i){if(!e)throw Error(`register: key is required`);if(e.includes(`/`))throw Error(`register: key "${e}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);let a=n.get(e);if(a){if(a.permanent)throw Error(`register: key "${e}" is a built-in ${t} key and cannot be re-claimed (built-in keys: ${[...r()].join(`, `)})`);if(a.kind!==i.kind)throw Error(`register: key "${e}" is already a ${a.kind} ${t} key; cannot also register it as ${i.kind}. A ${t} key has one key shape — a menu page index (int) and a button allow-list cannot share a key.`);a.specs.push(i),a.validator=dS(e,a.specs,t)}else{let r=[i];n.set(e,{permanent:!1,kind:i.kind,validator:dS(e,r,t),specs:r})}let o=!0;return()=>{if(!o)return;o=!1;let r=n.get(e);if(!r||r.permanent)return;let a=r.specs.indexOf(i);a>=0&&r.specs.splice(a,1),r.specs.length===0?n.delete(e):r.validator=dS(e,r.specs,t)}},validate(e,r){let i=n.get(e);return i?i.validator(r):{ok:!1,reason:`unknown ${t} key "${e}" (have: ${[...n.keys()].join(`, `)})`}},listKeys(){return[...n.keys()]},listBaselineKeys(){return r()},rangeParamsFor(e){let r=n.get(e);if(!r||r.permanent||r.kind!==`range`)return null;let i=cS(e,r.specs,t);if(i.kind!==`range`)throw Error(`rangeParamsFor: key "${e}" holds range specs but the merge produced a ${i.kind} spec — the entry-kind invariant is broken.`);return{min:i.min,max:i.max,seed:i.seed}}}}const mS=pS({},`config`);function hS(){return mS.listKeys()}function gS(e,t){return mS.validate(e,t)}function _S(e){return mS.rangeParamsFor(e)}function vS(e,t,n){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:Y_(e.from,n).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:[ih({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[ih({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Y_(e.insertSegmentFrom,n).members.map(t=>ih({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max,seed:iS(t.get(e.persist),e.min,e.max)}}]:[]}function yS(e){return Fo(e.globals)}function bS(e){let t=new Set;for(let n of SS(e)){let e=`persist`in n?n.persist:`reset`in n?n.reset:null;if(e===null)continue;let r=_h(e);r?.scope===`preset-root`&&t.add(r.preset)}return[...t].map(e=>({key:gh(e),spec:{kind:`allow-list`,allowed:[]}}))}function xS(e){let t=yS(e),n=new Map([...q_(e),...Ah(e)]);return[...bS(e),...SS(e).flatMap(e=>vS(e,t,n))]}function SS(e){return Object.values(e.actions).flatMap(Ig)}function CS(e){return fS(xS(e),`config`)}function wS(e,t){return mS.register(e,t)}const TS=li(),ES=new Set(TS),DS=new Set(yi),OS=e=>e?ES.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${TS.join(`, `)})`}:{ok:!1,reason:`theme name is required`},kS=e=>e?DS.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown style "${e}" (have: ${yi.join(`, `)})`}:{ok:!1,reason:`style name is required`},AS=new Set([`1`,`true`]),jS=new Set([`0`,`false`]),MS=pS({style:kS,theme:OS,"toolbar-expanded":e=>AS.has(e)?{ok:!0,value:`1`}:jS.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}});function NS(){return MS.listKeys()}function PS(e,t){return MS.register(e,t)}function FS(e,t){return MS.validate(e,t)}function IS(e){return MS.rangeParamsFor(e)}function LS(e,t,n){return`set`in e?`to`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:Y_(e.from,n).members}}]:`int`in e?[{key:e.set,spec:{kind:`int`}}]:`cycle`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:e.cycle}}]:[{key:e.set,spec:{kind:`range`,min:e.min,max:e.max,seed:iS(t.get(e.set),e.min,e.max)}}]:[]}function RS(e){let t=new Set(MS.listBaselineKeys());return e.filter(e=>e.spec.kind!==`allow-list`||!t.has(e.key))}function zS(e){let t=new Map,n=/^-?\d+$/;for(let r of Object.values(e.variables)){if(r.kind!==`state`)continue;let e=r.default;e!==void 0&&n.test(e)&&t.set(r.key,parseInt(e,10))}for(let[n,r]of Fo(e.globals))t.set(n,r);return t}function BS(e){let t=zS(e),n=q_(e);return RS(Object.values(e.actions).flatMap(Ig).flatMap(e=>LS(e,t,n)))}function VS(e){return fS(BS(e))}const HS=`update.dismissed`,US=`updateNotice`;function WS(e){return e.kind===`source`?e.newer.digest:Cb(e.newer)}const GS=e=>`${e.version} [${Qx(e.digest)}]`;function KS(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:GS(e.newer),running:GS(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:Cb(e.newer),running:Cb(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${Tb}@${Cb(e.newer)}`,`install`]}}}}const qS={kind:`idle`},JS={kind:`running`};function YS(e,t,n){if(e===null)return[];let r=WS(e);if(!n.enabled||n.dismissed===r)return[];let i=KS(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[`${i.act} failed: ${t.reason}`]:[],s=[a,...o].join(`
138
+ `))}function qx(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new H({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new Ar(e,{style:t,end:``,noWrap:!0}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(x(a.path).href)):c(`full text unavailable: ${wx(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(wx(o),s.withLink(x(o).href))],d=[c(`↳ `,s),...l,...u.slice(0,-1)],f=d.reduce((e,t)=>e+t.cellLength,0),p=u.slice(-1).map(e=>e.truncate(Math.max(1,r.width-f),{mode:`middle`})),m=Ar.fromFragments([...d,...p]).truncate(r.width,{overflow:`ellipsis`});return m.noWrap=!0,Fx([m],r)}const Jx=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Yx(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function Xx(e,t){return r.readdirSync(t).filter(Jx).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?Xx(e,i):[[c.relative(e,i).split(c.sep).join(`/`),Yx(i,a)]]})}function Zx(e){let t=C.createHash(`sha256`);for(let[n,r]of Xx(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const Qx=e=>e.slice(0,7);function $x(e){return c.dirname(c.dirname(e))}function eS(){return{version:vb,digest:`6ac8f6d634cf87cc230ec22b9926b73212896c4eb4ac9c2f9f8c6bc595ec3575`}}function tS(e){let t=JSON.parse(r.readFileSync(c.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${c.join(e,`package.json`)} has no version string`);return n}function nS(e,t){try{let n=$x(b(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=Zx(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:tS(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const rS=/^-?\d+$/;function iS(e,t,n){return e===void 0?t:Math.max(t,Math.min(n,e))}function aS(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 oS(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!rS.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 sS(e,t,n){return r=>r?rS.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 cS(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=>!rS.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,seed:iS(r[0].seed,t,i)}}return{kind:`int`}}function lS(e){return e===`config`?`set-config`:`set-state`}function uS(e,t,n){return t.kind===`int`?oS(`menu page "${e}"`):t.kind===`range`?sS(t.min,t.max,`${n} stepper "${e}"`):aS(t.allowed,`${n} "${e}"`,lS(n))}function dS(e,t,n){return uS(e,cS(e,t,n),n)}function fS(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:cS(e,n,t)}))}function pS(e,t=`state`){let n=new Map(Object.entries(e).map(([e,t])=>[e,{validator:t,permanent:!0}]));function r(){let e=[];for(let[t,r]of n)r.permanent&&e.push(t);return e}return{register(e,i){if(!e)throw Error(`register: key is required`);if(e.includes(`/`))throw Error(`register: key "${e}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);let a=n.get(e);if(a){if(a.permanent)throw Error(`register: key "${e}" is a built-in ${t} key and cannot be re-claimed (built-in keys: ${[...r()].join(`, `)})`);if(a.kind!==i.kind)throw Error(`register: key "${e}" is already a ${a.kind} ${t} key; cannot also register it as ${i.kind}. A ${t} key has one key shape — a menu page index (int) and a button allow-list cannot share a key.`);a.specs.push(i),a.validator=dS(e,a.specs,t)}else{let r=[i];n.set(e,{permanent:!1,kind:i.kind,validator:dS(e,r,t),specs:r})}let o=!0;return()=>{if(!o)return;o=!1;let r=n.get(e);if(!r||r.permanent)return;let a=r.specs.indexOf(i);a>=0&&r.specs.splice(a,1),r.specs.length===0?n.delete(e):r.validator=dS(e,r.specs,t)}},validate(e,r){let i=n.get(e);return i?i.validator(r):{ok:!1,reason:`unknown ${t} key "${e}" (have: ${[...n.keys()].join(`, `)})`}},listKeys(){return[...n.keys()]},listBaselineKeys(){return r()},rangeParamsFor(e){let r=n.get(e);if(!r||r.permanent||r.kind!==`range`)return null;let i=cS(e,r.specs,t);if(i.kind!==`range`)throw Error(`rangeParamsFor: key "${e}" holds range specs but the merge produced a ${i.kind} spec — the entry-kind invariant is broken.`);return{min:i.min,max:i.max,seed:i.seed}}}}const mS=pS({},`config`);function hS(){return mS.listKeys()}function gS(e,t){return mS.validate(e,t)}function _S(e){return mS.rangeParamsFor(e)}function vS(e,t,n){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:Y_(e.from,n).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:[ih({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[ih({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Y_(e.insertSegmentFrom,n).members.map(t=>ih({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max,seed:iS(t.get(e.persist),e.min,e.max)}}]:[]}function yS(e){return Fo(e.globals)}function bS(e){let t=new Set;for(let n of SS(e)){let e=`persist`in n?n.persist:`reset`in n?n.reset:null;if(e===null)continue;let r=_h(e);r?.scope===`preset-root`&&t.add(r.preset)}return[...t].map(e=>({key:gh(e),spec:{kind:`allow-list`,allowed:[]}}))}function xS(e){let t=yS(e),n=new Map([...q_(e),...Ah(e)]);return[...bS(e),...SS(e).flatMap(e=>vS(e,t,n))]}function SS(e){return Object.values(e.actions).flatMap(Ig)}function CS(e){return fS(xS(e),`config`)}function wS(e,t){return mS.register(e,t)}const TS=li(),ES=new Set(TS),DS=new Set(yi),OS=e=>e?ES.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${TS.join(`, `)})`}:{ok:!1,reason:`theme name is required`},kS=e=>e?DS.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown style "${e}" (have: ${yi.join(`, `)})`}:{ok:!1,reason:`style name is required`},AS=new Set([`1`,`true`]),jS=new Set([`0`,`false`]),MS=pS({style:kS,theme:OS,"toolbar-expanded":e=>AS.has(e)?{ok:!0,value:`1`}:jS.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}});function NS(){return MS.listKeys()}function PS(e,t){return MS.register(e,t)}function FS(e,t){return MS.validate(e,t)}function IS(e){return MS.rangeParamsFor(e)}function LS(e,t,n){return`set`in e?`to`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:Y_(e.from,n).members}}]:`int`in e?[{key:e.set,spec:{kind:`int`}}]:`cycle`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:e.cycle}}]:[{key:e.set,spec:{kind:`range`,min:e.min,max:e.max,seed:iS(t.get(e.set),e.min,e.max)}}]:[]}function RS(e){let t=new Set(MS.listBaselineKeys());return e.filter(e=>e.spec.kind!==`allow-list`||!t.has(e.key))}function zS(e){let t=new Map,n=/^-?\d+$/;for(let r of Object.values(e.variables)){if(r.kind!==`state`)continue;let e=r.default;e!==void 0&&n.test(e)&&t.set(r.key,parseInt(e,10))}for(let[n,r]of Fo(e.globals))t.set(n,r);return t}function BS(e){let t=zS(e),n=q_(e);return RS(Object.values(e.actions).flatMap(Ig).flatMap(e=>LS(e,t,n)))}function VS(e){return fS(BS(e))}const HS=`update.dismissed`,US=`updateNotice`;function WS(e){return e.kind===`source`?e.newer.digest:Cb(e.newer)}const GS=e=>`${e.version} [${Qx(e.digest)}]`;function KS(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:GS(e.newer),running:GS(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:Cb(e.newer),running:Cb(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${Tb}@${Cb(e.newer)}`,`install`]}}}}const qS={kind:`idle`},JS={kind:`running`};function YS(e,t,n){if(e===null)return[];let r=WS(e);if(!n.enabled||n.dismissed===r)return[];let i=KS(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[`${i.act} failed: ${t.reason}`]:[],s=[a,...o].join(`
139
139
  `),c=hb([{verb:rb,args:[s]}]),l=t.kind===`running`?Bx(`[${i.busy}]`,c):Bx(`[${i.act}]`,hb([{verb:ub,args:[n.sessionId]}]));return[{severity:zx,message:s,lines:[[Bx(a,c),l,Bx(`[dismiss]`,hb([{verb:Zy,args:[n.sessionId,HS,r]}])),Bx(`[disable]`,hb([{verb:ib,args:[n.sessionId,US,`false`]}]))],...o.map(e=>[Bx(e,c)])]}]}function XS(e,t){return e.kind===`stale`?{kind:`source`,root:e.root,newer:e.source,running:e.running}:e.kind===`not-source-checkout`&&t!==null&&t.kind===`stale`?{kind:`release`,newer:t.latest,running:t.installed}:null}function ZS(e){switch(e.kind){case`current`:return[`info`,`build: current ${GS(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${GS(e.source)}, running ${GS(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function QS(e){switch(e.kind){case`current`:return[`info`,`release: current ${Cb(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${Cb(e.latest)}, running ${Cb(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${Cb(e.installed)}, latest ${Cb(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function $S(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const eC=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function tC(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=eC(e.stderr)??e.error??eC(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function nC(e){let{entryUrl:t,intervalMs:n,releaseIntervalMs:r,registryUrl:i,fetchImpl:a,onApplied:o,log:s}=e,c={kind:`unchecked`,reason:`not sampled yet`},l=null,u=qS,d=null,f=$S(s),p=$S(s),m=()=>XS(c,l);function h(){let e=m(),t=e===null?null:WS(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:PS(HS,{kind:`allow-list`,allowed:[t]})})}function g(){c=nS(t,eS),f(ZS(c)),h()}async function _(){l=Db(vb,await Eb(Tb,a,i)),p(QS(l)),h()}return{arm(){wS(US,{kind:`allow-list`,allowed:[`false`]}),g(),setInterval(g,n).unref(),c.kind===`not-source-checkout`&&(_(),setInterval(()=>void _(),r).unref())},notice:e=>YS(m(),u,e),act(){let e=m();if(e===null)throw new $(`apply-update: nothing newer is known to apply`);let t=KS(e);if(u.kind===`running`)throw new $(`apply-update: already ${t.busy}`);u=JS,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),Ee({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=qS,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=tC(n);u={kind:`failed`,identity:WS(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}function rC(e,t,n){return t.ok?X(t.stdout):t.reason===`non-zero`&&n===`absent`||t.reason===`non-zero`&&n===t.exitCode?Z:Q(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??iC(t.stderr)].filter(Boolean).join(`, `)}`)}function iC(e){return e.trim().split(`
140
140
  `,1)[0]??``}function aC(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?Z:X(n)}function oC(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?X(t):Z}const sC=/^[A-Za-z]:[\\/]/;function cC(e){let t=e.trim();if(sC.test(t))return null;let n=t.match(/^(?:[^@/]+@)?(\[[^\]]+\]):(.*)$/)??t.match(/^(?:[^@/:]+@)?([^/:]+):(?!\/\/)(.*)$/),r=n?`ssh://${n[1]}/${n[2].replace(/^\/+/,``)}`:t,i;try{i=new URL(r)}catch{return null}return{scheme:i.protocol.replace(/:$/,``),host:i.hostname.toLowerCase(),port:i.port,path:i.pathname.replace(/^\/+/,``).replace(/\/+$/,``)}}function lC(e){return cC(e)?.host||null}function uC(e){let t=lC(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}function dC(e){let t=new Map;for(let n of e.split(`
141
141
  `)){let e=n.match(/^remote\.(.+)\.url\s+(\S.*)$/);if(!e)continue;let r=t.get(e[1])??[];r.push(e[2].trim()),t.set(e[1],r)}return[...t].map(([e,t])=>({name:e,urls:t}))}function fC(e){return e.urls.find(e=>_C(e)!==null)??e.urls[0]??null}function pC(e){return e.find(e=>e.name===`origin`)??e[0]??null}function mC(e){let t=pC(e);return t?fC(t):null}function hC(e){let t=pC(e);return t?t.urls.find(e=>uC(e)!==null)??fC(t):null}function gC(e){let t=(cC(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function _C(e){let t=cC(e);if(!t)return null;let n=t.scheme===`https`?{scheme:`https`,port:t.port}:t.scheme===`http`?{scheme:`http`,port:t.port}:t.scheme===`ssh`||t.scheme===`git`?{scheme:`https`,port:``}:null;if(!n||!t.host)return null;let r=t.path.replace(/\.git$/,``);if(!r)return null;let i=n.port?`${t.host}:${n.port}`:t.host;return`${n.scheme}://${i}/${r}`}function vC(e){let t=mC(e);return t===null?null:_C(t)}function yC(e,t,n,r){return t.ok?r(t.stdout):t.reason===`spawn-error`&&/ENOENT/i.test(t.error??``)||t.reason===`non-zero`&&n.test(t.stderr)?Z:Q(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??iC(t.stderr)].filter(Boolean).join(`, `)}`)}function bC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xC(e){let t=`detached`,n=Z,r=Z,i=Z,a=0,o=0,s=0,c=0;for(let l of e.split(`
@@ -196,7 +196,7 @@ Use 'override' annotation for methods overridden by subclass.`)}}var na=ca(0),ra
196
196
  `)+`
197
197
  `}function pj(e){return e===null?`config: DSL not active
198
198
  `:JSON.stringify(e,null,2)+`
199
- `}function mj(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function hj(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function gj(){let e=vj();return e===null?null:r.readFileSync(e,`utf-8`)}function _j(){let e;try{e=gj()}catch(e){t.stderr.write(`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`),t.exit(2)}e===null&&(t.stderr.write("schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n"),t.exit(2)),t.stdout.write(e),t.exit(0)}function vj(){let e=c.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let i=c.dirname(c.resolve(n));for(;;){let t=c.join(i,e);if(r.existsSync(t))return t;let n=c.dirname(i);if(n===i)return null;i=n}}function yj(e){let t=e.CC_CANDYBAR_CONFIG??``;return t===``?void 0:t}const bj=5e3;function xj(e){let t=`/home/tester`,n=Math.floor(Date.now()/1e3);return{hook_event_name:`Status`,session_id:`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`,version:`1.15.0`,home:t,cwd:`${t}/code/cc-candybar/src`,transcript_path:`${t}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},workspace:{current_dir:`${t}/code/cc-candybar/src`,project_dir:`${t}/code/cc-candybar`},git:{repoName:`cc-candybar`,repoUrl:`https://github.com/promptctl/cc-candybar`,branch:`main`,sha:`abc1234`,ahead:2,behind:1,staged:3,unstaged:2,untracked:1,conflicts:0,upstream:`origin/main`,stash:1,status:`dirty`,operation:`rebase`,timeSinceCommit:780},session:{cost:.39,tokens:241400},today:{cost:12.5,tokens:34e5},context:{totalTokens:48487,contextLeft:24},metrics:{lastResponseTime:8.2,responseTime:4.2,sessionDuration:930,messageCount:8,linesAdded:512,linesRemoved:88},block:{nativeUtilization:63,resetsAt:n+2*3600},weekly:{percentage:21,resetsAt:n+5*86400},cache:{expiresAt:n+900},tmux:{session:`work`},host:{name:`tester-box`,user:`tester`,ssh:!0},preset:{effective:e.preset,customized:e.presetCustomized},style:{effective:e.style},charset:{effective:e.charset},colorCompatibility:{effective:e.colorCompatibility},autoWrap:{effective:e.autoWrap},padding:{effective:e.padding}}}function Sj(e,t){let n=Dv(e,e),r=kv(n);return r!==null&&t.push(r),n.kind===`file`?n.path:null}async function Cj(e,n=t.cwd()){let i=[],a=e===void 0?Sj(n,i):c.resolve(wv(e));if(e!==void 0&&a!==null){let e;try{e=r.statSync(a,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:a,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:a,message:`not a file`}}let o=jv(n,n);o!==null&&i.push(o);try{return{kind:`clean`,configPath:a,warnings:i,rendered:await wj(a,n,i)}}catch(e){let t=e;return a!==null&&typeof t==`object`&&t&&typeof t.code==`string`&&t.path===a&&typeof t.message==`string`?{kind:`unreadable`,path:a,message:t.message}:(e instanceof _a&&i.push(...e.warnings),{kind:`fatal`,configPath:a,message:e instanceof _a||e instanceof Error?e.message:String(e),warnings:i})}}async function wj(e,t,n){let{config:r,source:i,warnings:a}=Mv(e,Qw);n.push(...a);let o=Fv(r,e??`<default>`,i),s=new zD,c=new vE(s,o.globals.default_empty_value??``,void 0,new XD);try{let e=DD(o,c,{cwd:t});n.push(...e.loadWarnings);let r=await c.settled(bj);r.length>0&&n.push(`source${r.length===1?``:`s`} still running after ${bj} ms, rendered with fallback values: ${r.join(`, `)}`),VS(o);let i=ww(o,()=>null,()=>!1),a=t=>{let n=new Map;return{rendered:jD(o,e,s,c,xj(t),{style:t.style,separator:t.separator,width:200,colorCompatibility:t.colorCompatibility,wrap:t.autoWrap,padding:t.padding,charset:t.charset},{onSegmentError:(e,t)=>n.set(e,t),onRenderWarning:e=>n.set(`globals.palette`,e)},{theme:t.theme,look:t.look,preset:t.preset}),segmentErrors:n}},l=a(i),u=a({...i,presetCustomized:!0}),d=[...[...l.segmentErrors].map(([e,t])=>`segment "${e}": ${t}`),...[...u.segmentErrors].filter(([e])=>!l.segmentErrors.has(e)).map(([e,t])=>`segment "${e}": ${t} (under .preset.customized = true)`)];if(d.length>0)throw Error(`config renders with ${d.length} segment error${d.length===1?``:`s`} (the daemon would render ⚠ error cells):\n`+d.map(e=>` ${e}`).join(`
199
+ `}function mj(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function hj(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function gj(){let e=vj();return e===null?null:r.readFileSync(e,`utf-8`)}function _j(){let e;try{e=gj()}catch(e){t.stderr.write(`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`),t.exit(2)}e===null&&(t.stderr.write("schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n"),t.exit(2)),t.stdout.write(e),t.exit(0)}function vj(){let e=c.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let i=c.dirname(c.resolve(n));for(;;){let t=c.join(i,e);if(r.existsSync(t))return t;let n=c.dirname(i);if(n===i)return null;i=n}}function yj(e){let t=e.CC_CANDYBAR_CONFIG??``;return t===``?void 0:t}const bj=5e3;function xj(e){let t=`/home/tester`,n=Math.floor(Date.now()/1e3);return{hook_event_name:`Status`,session_id:`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`,version:`1.15.0`,home:t,cwd:`${t}/code/cc-candybar/src`,transcript_path:`${t}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},workspace:{current_dir:`${t}/code/cc-candybar/src`,project_dir:`${t}/code/cc-candybar`},git:{repoName:`cc-candybar`,repoUrl:`https://github.com/promptctl/cc-candybar`,branch:`main`,sha:`abc1234`,ahead:2,behind:1,staged:3,unstaged:2,untracked:1,conflicts:0,upstream:`origin/main`,stash:1,status:`dirty`,operation:`rebase`,timeSinceCommit:780},session:{cost:.39,tokens:241400},today:{cost:12.5,tokens:34e5},context:{totalTokens:48487,contextLeft:24},metrics:{lastResponseTime:8.2,responseTime:4.2,sessionDuration:930,messageCount:8,linesAdded:512,linesRemoved:88},block:{nativeUtilization:63,resetsAt:n+2*3600},weekly:{percentage:21,resetsAt:n+5*86400},cache:{expiresAt:n+900},tmux:{session:`work`},host:{name:`tester-box`,user:`tester`,ssh:!0},preset:{effective:e.preset,customized:e.presetCustomized},style:{effective:e.style},charset:{effective:e.charset},colorCompatibility:{effective:e.colorCompatibility},autoWrap:{effective:e.autoWrap},padding:{effective:e.padding}}}function Sj(e,t){let n=Dv(e,e),r=kv(n);return r!==null&&t.push(r),n.kind===`file`?n.path:null}async function Cj(e,n=t.cwd()){let i=[],a=e===void 0?Sj(n,i):c.resolve(wv(e));if(e!==void 0&&a!==null){let e;try{e=r.statSync(a,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:a,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:a,message:`not a file`}}let o=jv(n,n);o!==null&&i.push(o);try{return{kind:`clean`,configPath:a,warnings:i,rendered:await wj(a,n,i)}}catch(e){let t=e;return a!==null&&typeof t==`object`&&t&&typeof t.code==`string`&&t.path===a&&typeof t.message==`string`?{kind:`unreadable`,path:a,message:t.message}:(e instanceof _a&&i.push(...e.warnings),{kind:`fatal`,configPath:a,message:e instanceof _a||e instanceof Error?e.message:String(e),warnings:i})}}async function wj(e,t,n){let{config:r,source:i,warnings:a}=Mv(e,Qw);n.push(...a);let o=Fv(r,e??`<default>`,i),s=new zD,c=new vE(s,o.globals.default_empty_value??``,void 0,new XD);try{let e=DD(o,c,{cwd:t});n.push(...e.loadWarnings);let r=await c.settled(bj);r.length>0&&n.push(`source${r.length===1?``:`s`} still running after ${bj} ms, rendered with fallback values: ${r.join(`, `)}`),VS(o);let i=ww(o,()=>null,()=>!1),a=t=>{let n=new Map;return{rendered:jD(o,e,s,c,xj(t),{style:t.style,separator:t.separator,width:200,colorCompatibility:t.colorCompatibility,wrap:t.autoWrap,padding:t.padding,charset:t.charset},{onSegmentError:(e,t)=>n.set(`segment "${e}"`,t),onRenderWarning:e=>n.set(`globals.palette`,e)},{theme:t.theme,look:t.look,preset:t.preset}),failures:n}},l=a(i),u=a({...i,presetCustomized:!0}),d=[...[...l.failures].map(([e,t])=>`${e}: ${t}`),...[...u.failures].filter(([e])=>!l.failures.has(e)).map(([e,t])=>`${e}: ${t} (under .preset.customized = true)`)];if(d.length>0)throw Error(`config renders with ${d.length} render error${d.length===1?``:`s`} (the daemon would show them on the bar):\n`+d.map(e=>` ${e}`).join(`
200
200
  `));return l.rendered}finally{c.dispose()}}function Tj(e){return e.map(e=>`warning: ${e}\n`).join(``)}function Ej(e,t=!1){switch(e.kind){case`clean`:return{stdout:`✓ ${e.configPath??`bundled default (no config file found)`}: config OK${e.warnings.length>0?` (${e.warnings.length} warning${e.warnings.length===1?``:`s`})`:``}\n`+(t?`${e.rendered}\n`:``),stderr:Tj(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:Tj(e.warnings)+`✗ ${e.configPath??`<default>`}\n${e.message}\n`,code:1};case`unreadable`:return{stdout:``,stderr:`check: cannot read ${e.path}: ${e.message}\n`,code:2}}}const Dj=`--render`,Oj=`Usage: cc-candybar check [${Dj}] [config-file]\n`;function kj(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==Dj);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${Oj}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${Oj}`}:{kind:`run`,target:n[0],render:t.includes(Dj)}}async function Aj(e){let n=kj(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:Ej(await Cj(n.target??yj(t.env)),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const jj=`${Dx}${Ex}`;function Mj(e){return`${jj}⚠ cc-candybar: ${Nj(e)}\n`}function Nj(e){switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:return`daemon rejected request: ${Tx(e.message,60)}`;case`render_failed`:return`render failed: ${Tx(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${Tx(e.message,60)}`}}function Pj(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
201
201
  `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:Mj(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}function Fj(e,t){if(e!==void 0&&/^\+?\d+$/.test(e)){let t=Number(e);if(t>0&&t<=4294967295)return t}if(t&&t>0)return t}function Ij({check:e,verdict:t}){return t.ok?`✓ ${e.label}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:` (fix: click ☰ 🧰 tools ▸ 🩺 doctor, then [fix] on the bar)`}\n`}function Lj(e,t){let n;try{n=XO(e,zh(t))}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let r=Hh(n);return{stdout:r.map(Ij).join(``),stderr:``,code:+!r.every(e=>e.verdict.ok)}}function Rj(e){e.length>0&&(t.stderr.write(`doctor: takes no arguments
202
202
  Usage: cc-candybar doctor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptctl/cc-candybar",
3
- "version": "1.71.0",
3
+ "version": "1.71.1",
4
4
  "description": "Statusline renderer for Claude Code — a JSON5-configurable DSL with daemon-cached data sources, byte-clean palette-aware composition, and OSC8 click verbs.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -90,9 +90,9 @@
90
90
  "mobx": "^6.15.0"
91
91
  },
92
92
  "optionalDependencies": {
93
- "@promptctl/cc-candybar-darwin-arm64": "1.71.0",
94
- "@promptctl/cc-candybar-darwin-x64": "1.71.0",
95
- "@promptctl/cc-candybar-linux-x64": "1.71.0",
96
- "@promptctl/cc-candybar-linux-arm64": "1.71.0"
93
+ "@promptctl/cc-candybar-darwin-arm64": "1.71.1",
94
+ "@promptctl/cc-candybar-darwin-x64": "1.71.1",
95
+ "@promptctl/cc-candybar-linux-x64": "1.71.1",
96
+ "@promptctl/cc-candybar-linux-arm64": "1.71.1"
97
97
  }
98
98
  }