@promptctl/cc-candybar 1.74.0 → 1.74.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 +3 -3
  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
- `,Bh=`preset.customized`,Vh=`{{ and ${Fo(ph)} .${Bh} }}`,Hh=Js;function Uh(e){return`${Gs}addable.${e}`}function Wh(e){let t=Object.keys(e.segments).filter(e=>!Hh(e)),n=new Map;for(let r of Ch(e.presets)){let{node:i}=Eh(e,r),a=bh(i);n.set(Uh(r),{members:t.filter(e=>!a.has(e))})}return n}function Gh(e,t,n,r){let i=`${Gs}${e}.remove.${Hs(n)}`,a=`${Gs}${e}.removeSeg.${Hs(n)}`;return r.actions[i]={persist:t,removeSegment:n},r.segments[a]={template:`{{ action "${i}" "-" }}`,when:mh},{kind:`segment`,name:a}}function Kh(e,t,n,r,i,a,o){let s=`${Gs}${e}.insert.${n}`,c=`${Gs}${e}.insertSeg.${n}`;o.actions[s]={persist:t,insertSegmentFrom:r,anchor:i,relation:a};let l=Gm(s),u=Km(c,s,void 0),d=Ym(u),f=Jm(u,l);return o.variables[u]=Lo(u,Oo),o.variables[d]={kind:`state`,key:d,default:`0`},o.actions[f]=Ro(u,l),o.actions[d]={set:d,int:!0},o.segments[c]={template:`{{ menu "${s}" "+" "✕" }}`,when:mh},{kind:`segment`,name:c}}function qh(e,t,n,r,i,a){let o=[],s=e.children.reduce((e,t,n)=>t.kind===`segment`&&!Hh(t.name)?n:e,-1),c=e=>qh(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=ja(u,c);if(Hh(u.name)){o.push(d);continue}let f=[Kh(t,n,String(a.n++),r,u.name,`before`,i),d,Gh(t,n,u.name,i),...l===s?[Kh(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 Jh(e,t,n,r,i,a){let o=`${Gs}${n}.resetLayout`,s=`${Gs}${n}.customized`;i.actions[o]={reset:r},i.ensured[Bh]={kind:`input`,path:Bh,type:`boolean`,default:!1};let c=Mo(t);return i.segments[s]={template:`{{ action "${o}" "↺ ${c} customized" }}`,when:Vh},{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:s},Yh(e,a)]}}function Yh(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),Yh(n,t)]}:{...e,children:[...e.children,t]}}function Xh(e,t,n,r){let{node:i}=Eh(e,t),a=Ah(t),o=Uh(t),s=Hs(t);return Jh(qh(i,s,a,o,n,{n:0}),t,s,a,n,r)}function Zh(e){if(!(`edit.toggle`in e.actions))return e;let t={variables:{},ensured:{},actions:{},segments:{}},n=Ph(`${Gs}help`,Lh,[ph],t),r={...e.presets};for(let i of Ch(e.presets)){let a=Xh(e,i,t,n);r[i]={...Th(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 Qh={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function $h(e){let t=e[Qh.socket]??``,n=e[Qh.pane]??``;if(t===``||n===``)return null;let r=e[Qh.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const eg=Qh.truecolor,tg=[{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[eg];return typeof n==`string`&&n!==``?{ok:!1,reason:`${eg} 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:eg,value:`1`}}}}}}];function ng(e){return tg.map(t=>({check:t,verdict:t.probe(e)}))}function rg(e){return tg.find(t=>t.name===e)}function ig(e){let t=`settings.doctor.${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function ag(e){return e.flatMap(({check:e,verdict:t})=>{let n=ig(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:Ni}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:t.reason},{key:n.fixable,value:t.fix===void 0?Ni:H}]})}const og={copySession:{copy:`{{ .session.id }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`}};function sg(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}`,actions:Object.fromEntries(Object.entries(og).map(([t,n])=>[`${e}${t}`,n]))}}const cg=`${Ks}menu`,lg=fh,ug=`${Ks}edit`,dg=`${Ks}close`,fg=`${Ks}toolbar`,pg=sg(Ks),mg=`${Ks}persist`,hg=`${Ks}config`,gg=mg,_g={variable:cg,key:cg,member:lg},vg={variable:hg,key:hg,member:lg},yg=`${Ks}tools`,bg={variable:yg,key:yg,member:lg},xg=`${Ks}doctor`,Sg=`${xg}.run`,Cg=e=>`${xg}.fix.${e}`,wg=e=>`${xg}.${e}`,Tg=`${Ks}help.persist`,Eg=`${Ks}pickers`,Dg=[{name:`preset`,sessionKey:`preset`,configKey:`preset`,effectiveVar:`preset.effective`,glyph:`▦`,domain:`presets`}],Og=[{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`}],kg={name:`wrap`,sessionKey:`autoWrap`,configKey:`autoWrap`},Ag={name:`padding`,sessionKey:`padding`,configKey:`padding`},jg=`${Ks}${kg.name}`,Mg=`${Ks}${Ag.name}`,Ng=[...Dg,...Og];new Set([...Ng,kg,Ag].flatMap(e=>[e.sessionKey,e.configKey]));const Pg=e=>`${Ks}${e}`,Fg=e=>`${Ks}apply.${e}`,Ig=e=>`${Ks}reset.${e}`;function Lg(e){return e===cg}function Rg(e){let t={kind:`segment`,name:cg};if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[Rg(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function zg(e){return Bg(e)>0?e:Rg(e)}function Bg(e){let t=0;for(let n of Ma(e))n.kind===`segment`&&Lg(n.name)&&(t+=1);return t}function Vg(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&Lg(e.name)||e.opens!==void 0&&Vg(e.opens.body,!0):e.children.some(e=>Vg(e,n))}function Hg(e,t){return e.kind===`segment`?Lg(e.name)?No(e.name,_g,{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:fg},{kind:`segment`,name:mg},t,...Dg.map(e=>({kind:`segment`,name:Pg(e.name)})),No(hg,vg,{kind:`container`,direction:`horizontal`,children:[...Og.map(e=>({kind:`segment`,name:Pg(e.name)})),{kind:`segment`,name:jg},{kind:`segment`,name:Mg}]},`drop`),No(yg,bg,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:xg},...tg.map(e=>({kind:`segment`,name:wg(e.name)}))]},`drop`),{kind:`segment`,name:ug}]},`inline`):e:Ug(e,t)}function Ug(e,t){return{...e,children:e.children.map(e=>Hg(e,t))}}function Wg(e,t,n,r){let i=Gm(t),a=Km(e,t,r),o=Ym(a);n.variables[a]=Lo(a,Oo),n.variables[o]={kind:`state`,key:o,default:`0`},n.actions[Jm(a,i)]=Ro(a,i),n.actions[o]={set:o,int:!0}}function Gg(e){let t={variables:{[cg]:Lo(cg,Oo)},actions:{[cg]:Ro(cg,lg),[hg]:Ro(hg,lg),[yg]:Ro(yg,lg),[Sg]:{doctor:`run`},[dg]:{set:_g.key,to:Oo},[ug]:{do:[dh,dg]},...pg.actions,[mg]:{set:gg,cycle:[Ni,H]}},segments:{[cg]:{template:Io(cg,e,`❌`)},[fg]:{template:pg.template},[mg]:{template:`{{ action "${mg}" "☐ persist?" "☑ persist?" }}`},[hg]:{template:Io(hg,`⚙ config ▸`,`⚙ config ▾`)},[yg]:{template:Io(yg,`🧰 tools ▸`,`🧰 tools ▾`)},[xg]:{template:`{{ action "${Sg}" "🩺 doctor" }}`},[jg]:{template:`{{ action "${Fg(`wrap`)}" "wrap: on" "wrap: off" }} {{ action "${Ig(`wrap`)}" "↺" }}`},[Mg]:{template:`{{ action "${Fg(`padding`)}.down" "◀" }} padding {{ .padding.effective }} {{ action "${Fg(`padding`)}.up" "▶" }} {{ action "${Ig(`padding`)}" "↺" }}`},[ug]:{template:`{{ action "${ug}" "✎ edit" "✎ done" }}`}}};return t.variables[gg]={kind:`state`,key:gg,default:Ni},t.variables[hg]=Lo(hg,Oo),t.variables[yg]=Lo(yg,Oo),qg(t),Kg(t),{artifacts:t,help:Ph(Tg,Rh,[_g],t)}}function Kg(e){for(let t of tg){let n=ig(t.name),r=Cg(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[wg(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${H}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function qg(e){for(let t of Ng){let n=Pg(t.name),r=Fg(t.name);e.segments[n]={template:`${t.glyph} {{ .${t.effectiveVar} }} {{ menu "${r}" "▸" "▾" (dict "key" "${Eg}" "closeOnPick" true) }} {{ action "${Ig(t.name)}" "↺" }}`},e.actions[r]={set:t.sessionKey,persist:t.configKey,persistWhen:gg,from:t.domain},e.actions[Ig(t.name)]={reset:t.configKey},Wg(n,r,e,Eg)}e.actions[Fg(kg.name)]={set:kg.sessionKey,persist:kg.configKey,persistWhen:gg,cycle:[...Pi]},e.actions[Ig(kg.name)]={reset:kg.configKey};for(let t of[-1,1])e.actions[`${Fg(Ag.name)}.${t<0?`down`:`up`}`]={set:Ag.sessionKey,persist:Ag.configKey,persistWhen:gg,...Fi,by:t};e.actions[Ig(Ag.name)]={reset:Ag.configKey}}function Jg(e){e.variables[uh]=Lo(uh,Oo),e.actions[dh]=Ro(uh,fh)}const Yg=`session.id`;function Xg(e){return Object.prototype.hasOwnProperty.call(e.variables,Yg)}function Zg(e){if(!Xg(e))return e;let{artifacts:t,help:n}=Gg(e.globals.menuGlyph??`🍫`);Jg(t);let r={...e.presets};for(let t of Ch(e.presets)){let{node:i}=Eh(e,t);r[t]={...Th(e.presets,t),root:Hg(zg(i),n)}}return{...e,variables:{...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:r}}const Qg=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`doctor`,`do`],$g=`persistWhen`;function e_(e){return $g in e}function t_(e){return e_(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 n_(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function r_(e){return`set`in e}function i_(e){return`persist`in e}function a_(e){return`reset`in e}function o_(e){return`undo`in e}function s_(e){return`redo`in e}function c_(e){return`doctor`in e}function l_(e,t){if(t===void 0)return{};if(!Ka(t))return J(e,`actions`,`actions must be an object, got ${qa(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=u_(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function J(e,t,n){e.issues.push({path:t,message:n,line:W(e.source,t.split(`.`))})}function u_(e,t,n){if(!Ka(n))return J(e,t,`${t} must be an action object, got ${qa(n)}`),null;if(`persistWhen`in n)return U_(e,t,n,`dual`,B_);let r=Qg.filter(e=>e in n);return r.length===1?d_[r[0]](e,t,n):(J(e,t,`action must declare exactly one of: ${Qg.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const d_={set:(e,t,n)=>U_(e,t,n,`set`,R_),persist:(e,t,n)=>U_(e,t,n,`persist`,z_),copy:f_(`copy`),open:f_(`open`),reset:p_,undo:m_(`undo`),redo:m_(`redo`),doctor:h_,do:g_};function f_(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=Va(t,n,r,e);return i===null?null:{[e]:i}}}function p_(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=__(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 m_(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 ${G(r[e])}`),null)}}function h_(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 ${G(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||rg(a)===void 0?(J(e,`${t}.check`,`doctor fix must name a check (have: ${tg.map(e=>e.name).join(`, `)}), got ${G(a)}`),null):{doctor:`fix`,check:a}}function g_(e,t,n){for(let r of Object.keys(n))r!==`do`&&J(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(J(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${G(r)}`),null):{do:r}}function __(e,t,n,r,i,a){let o=Va(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 v_={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`],[$g,`the SessionState key whose boolean value chooses the destination`]]};function y_(e,t,n,r){let i={},a=v_[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=__(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 b_(e){return e===`set`?`set-state`:e===`persist`?`set-config`:`set-state/set-config`}const x_={to:W_(`set`)},S_={to:W_(`persist`)},C_={from:G_(`set`)},w_={from:G_(`persist`)},T_={min:X_(),max:X_(),by:X_()},E_={int:q_()},D_={cycle:K_(`set`)},O_={to:W_(`dual`)},k_={from:G_(`dual`)},A_={cycle:K_(`dual`)},j_={cycle:K_(`persist`)},M_={removeSegment:J_(`removeSegment`)},N_={insertSegment:J_(`insertSegment`),anchor:J_(`anchor`),relation:Y_()},P_={insertSegmentFrom:G_(`persist`),anchor:J_(`anchor`),relation:Y_()},F_={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},I_={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function L_(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=v_[e].map(([e])=>e),s=(e,n,r)=>Ya(e,t,n,r),c=uo(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?ro(s,...n):s}}const R_=[L_(`set`,x_),L_(`set`,C_),L_(`set`,T_,[F_,I_]),L_(`set`,E_),L_(`set`,D_)],z_=[L_(`persist`,S_),L_(`persist`,w_),L_(`persist`,T_,[F_,I_]),L_(`persist`,j_),L_(`persist`,M_),L_(`persist`,N_,[],[`insertSegment`]),L_(`persist`,P_,[],[`insertSegmentFrom`])],B_=[L_(`dual`,O_),L_(`dual`,k_),L_(`dual`,T_,[F_,I_]),L_(`dual`,A_)];function V_(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 H_(e){let t=V_(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 U_(e,t,n,r,i){let a=y_(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return J(e,t,`${H_(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 W_(e){let t=b_(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>__(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 G_(e){let t=b_(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 ${G(o)}`)}}}function K_(e){let t=b_(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 ${qa(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 q_(){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 ${G(r[n])}`);return}return!0}}}function J_(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Va(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 Y_(){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 ${G(i)}`);return}return i}}}function X_(){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 ${G(i)}`);return}return i}}}const Z_={noun:`look key`,fields:{hueShift:oo(),chromaScale:oo({min:0}),lightnessScale:oo(),lightnessShift:oo()}};function Q_(e,t){if(!Ka(t))return e.issues.push({path:`looks`,message:`looks must be an object mapping look names to adaptation objects, got ${qa(t)}`,line:W(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:W(e.source,[`looks`,r])});continue}let t=Ja(e,Z_,`looks.${r}`,i);t!==null&&(n[r]={...vn,...t})}return n}const $_={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:Qc(e,`${t}.${n}`,r[n])},globals:{required:!1,json:$o(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Qo(e,`${t}.${n}`,r[n])}}};function ev(e,t){if(!Ka(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${qa(t)}`,line:W(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:W(e.source,[`presets`,r])});continue}let t=Ja(e,$_,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function tv(e,t){if(t===void 0)return{};if(!Ka(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${qa(t)}`,line:W(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 ${G(i)}`,line:W(e.source,[`helpers`,r])});continue}n[r]=i}return n}const nv=new Map,rv=new Map;function iv(e){let t=av(e);if(t===null)throw Error(`Palette "${e}" (resolved "${mi(e)}") did not resolve in the theme registry — allowed names and the registry are inconsistent`);return t}function av(e){let t=mi(e),n=nv.get(t);if(n!==void 0)return n;let r=Wn(t);return r===null?null:(nv.set(t,r),r)}function ov(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=rv.get(n);if(r!==void 0)return r;let i=Qn(e,t);return rv.set(n,i),i}function sv(e){let t=av(e);return t===null?null:{kind:`decided`,name:e,value:t}}function cv(e,t){let n=sv(e);return n===null?(t(`globals.palette rendered "${hi}": "${e}" names no installed theme`),uv()):n}function lv(e,t,n){return Si(e,t,n,uv(),sv)}function uv(){return sv(hi)}function dv(e){return Ci(lv(void 0,null,e),()=>hi,uv).value}const fv=new Map;function pv(e,t,n){fv.set(e,{permanent:!0,resolve:t,paletteOf:n})}pv(`themes`,()=>vi(),e=>iv(e)),pv(`styles`,()=>Oi),pv(`charsets`,()=>ji),pv(`colorCompatibilities`,()=>Mi);function mv(e){return new Map([[`looks`,{members:Object.keys(e.looks),paletteOf:(t,n)=>ov(n,e.looks[t])}],[`presets`,{members:Ch(e.presets)}]])}function hv(e){return[...new Set([...fv.keys(),...e.keys()])]}function gv(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=fv.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(`unknown option domain "${e}" (have: ${hv(t).join(`, `)})`)}const _v=/{{([\s\S]*?)}}/g,vv=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g,yv=/(?<![A-Za-z0-9_)])\.([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*)/g;function bv(e){let t=new Set,n;for(_v.lastIndex=0;(n=_v.exec(e))!==null;){let e=n[1].replace(vv,``),r;for(yv.lastIndex=0;(r=yv.exec(e))!==null;)t.add(r[1])}return t}const xv=/\baction\s+$/;function Sv(e){let t=new Set;_v.lastIndex=0;let n;for(;(n=_v.exec(e))!==null;){let e=n[1],r=0,i;for(vv.lastIndex=0;(i=vv.exec(e))!==null;)xv.test(e.slice(r,i.index))&&t.add(i[0].slice(1,-1)),r=i.index+i[0].length}return t}const Cv=/\b(picker|menu)\s+$/;function wv(e){let t=new Set;_v.lastIndex=0;let n;for(;(n=_v.exec(e))!==null;){let e=n[1],r=0,i=0,a;for(vv.lastIndex=0;(a=vv.exec(e))!==null;){let n=Cv.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 Tv(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 Ev={gitTaculous:`gitaculous`};function Dv(e,t){let n=new Map;for(let e of Object.keys(t)){let t=Hs(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:W(e.source,[`presets`])})}function Ov(e,t){t.globals.look!==void 0&&!xi(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:W(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:W(e.source,[`globals`,`preset`])}),Dv(e,t.presets);let n=mv(t);for(let[r,i]of Object.entries(t.actions))!(`set`in i)||!(`from`in i)||typeof i.from!=`string`||hv(n).includes(i.from)||e.issues.push({path:`actions.${r}.from`,message:`actions.${r} from: references unknown option domain "${i.from}" (have: ${hv(n).join(`, `)})`,line:W(e.source,[`actions`,r,`from`])});for(let[n,r]of Object.entries(t.actions)){if(!e_(r))continue;let i=r[$g];Nv(t,i)||e.issues.push({path:`actions.${n}.${$g}`,message:`actions.${n} ${$g}: "${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:W(e.source,[`actions`,n,$g])})}for(let[n,r]of Object.entries(t.actions))`do`in r&&r.do.forEach((i,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,i)?t.actions[i]:void 0,s=o===void 0?`references unknown action "${i}"`:`do`in o?`"${i}" is itself a do action — list its members here instead`:r.do.indexOf(i)===a?a>0&&n_(o)?`"${i}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${i}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:W(e.source,[`actions`,n,`do`])})});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=jh(i);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a config globals field (have: ${rs().join(`, `)}), a "segments.<name>.palette" target, or a "presets.<name>.root" target`,line:W(e.source,[`actions`,n,a])});continue}let s=kv.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:W(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){Av(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:W(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:W(e.source,[`actions`,n,a])})}}let r=Fv(t),i=Xg(t),a=Object.entries(t.segments).filter(([,e])=>sh(e.template)).map(([e])=>e),o=(t,n,r)=>{Bg(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${cg}" ${Bg(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}),Vg(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${cg}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r});let i=new Map;for(let e of Ma(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 Ma(n))if(s.when!==void 0&&zv(e,`${a}.when`,s.when,r,{line:o}),s.kind===`segment`){if(Lg(s.name)){i||e.issues.push({path:a,message:`${a} places the global settings menu anchor "${cg}", but this config declares no "${Yg}" variable — the menu is a click surface and every click composes a URL from "${Yg}", so it is not synthesized for a config without it. Declare a "${Yg}" 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=Ev[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=Bv(e.source);s(So(t.root),c,W(e.source,[c]));for(let[n,r]of Object.entries(t.presets)){if(r.root===void 0)continue;let t=`presets.${n}.root`,i=W(e.source,[`presets`,n,`root`]);s(Co(r.root),t,i)}let l=new Map([[`root`,So(t.root)]]);for(let e of Ch(t.presets)){let{node:n,path:r}=Eh(t,e);l.set(r,n)}for(let[t,n]of l)o(n,t,W(e.source,t.split(`.`)));for(let[n,i]of Object.entries(t.variables))Lv(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))Lv(e,`segments.${n}.vars.${t}`,a,r,n);for(let a of[`template`,`bg`,`fg`,`when`]){let o=i[a];if(typeof o==`string`){zv(e,`segments.${n}.${a}`,o,r,{segCtx:n});for(let r of Sv(o))Object.prototype.hasOwnProperty.call(t.actions,r)||e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}"`,line:W(e.source,[`segments`,n,a])});for(let r of wv(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:W(e.source,[`segments`,n,a])})}}}for(let[n,i]of Object.entries(t.variables))Rv(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))Rv(e,`segments.${n}.vars.${t}`,a,r,n);(Mv(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:W(e.source,[`variables`])})}const kv=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function Av(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=W(e.source,[`actions`,n,r]);if(!Ch(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${Ch(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 jv(e){return[...Object.values(e.variables),...Object.values(e.segments).flatMap(e=>Object.values(e.vars??{}))].filter(e=>e.kind===`state`)}function Mv(e){return jv(e).length>0}function Nv(e,t){return jv(e).some(e=>e.kind===`state`&&e.key===t)}function Pv(e){return Object.values(e.actions).some(e=>r_(e)||i_(e)||a_(e)||o_(e)||s_(e)||c_(e))}function Fv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),Iv(r)&&n.add(e)};for(let[t,n]of Object.entries(e.variables))r(t,n);for(let[t,n]of Object.entries(e.segments))for(let[e,i]of Object.entries(n.vars??{}))r(`${t}.${e}`,i);return{names:t,documents:n}}function Iv(e){return(e.kind===`shell`||e.kind===`file`)&&Pa(e.parse)===`json`}function Lv(e,t,n,r,i){n.kind===`template`&&zv(e,`${t}.template`,n.template,r,{segCtx:i}),Ia(n)&&n.cache&&`key`in n.cache&&zv(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function Rv(e,t,n,r,i){if(Ia(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:W(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function zv(e,t,n,r,i){for(let a of bv(n)){if(Tv(a,r))continue;let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,o=n!==void 0&&Tv(n,r)?` (segment-local vars are namespaced — write ".${n}")`:``;e.issues.push({path:t,message:`Template references unknown variable ".${a}"${o}`,line:i?.line??W(e.source,t.split(`.`))})}}function Bv(e){try{let t=Xe.default.parse(e);if(Ka(t)&&`root`in t)return`root`}catch{}return`layout`}function Vv(e,t){let{graph:n,nodeInfo:r}=Hv(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:W(e.source,o?.linePathParts??[`variables`,i])}),!0}if(t===0&&o(s))return!0}return i.set(t,2),a.pop(),!1}}function Hv(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 bv(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),Ia(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 Uv=[`json5`,`json`];function Wv(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function Gv(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?f.homedir()+e.slice(1):e}function Kv(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Uv.map(t=>c.join(e,`.cc-candybar.${t}`)):[],...Uv.map(e=>c.join(r,`.cc-candybar.${e}`)),...Uv.map(e=>`${qv()}.${e}`)])]}function qv(){let e=process.env.XDG_CONFIG_HOME??c.join(f.homedir(),`.config`);return c.join(e,`cc-candybar`,`config`)}function Jv(e,t,n){let r=[];for(let i of Kv(e,t,n)){let e=Wv(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 Yv(e,t,n){let r=Jv(e,t,n);return r.kind===`default`?`${qv()}.${Uv[0]}`:r.path}function Xv(e){return Zv(e).join(`
118
+ `,Bh=`preset.customized`,Vh=`{{ and ${Fo(ph)} .${Bh} }}`,Hh=Js;function Uh(e){return`${Gs}addable.${e}`}function Wh(e){let t=Object.keys(e.segments).filter(e=>!Hh(e)),n=new Map;for(let r of Ch(e.presets)){let{node:i}=Eh(e,r),a=bh(i);n.set(Uh(r),{members:t.filter(e=>!a.has(e))})}return n}function Gh(e,t,n,r){let i=`${Gs}${e}.remove.${Hs(n)}`,a=`${Gs}${e}.removeSeg.${Hs(n)}`;return r.actions[i]={persist:t,removeSegment:n},r.segments[a]={template:`{{ action "${i}" "-" }}`,when:mh},{kind:`segment`,name:a}}function Kh(e,t,n,r,i,a,o){let s=`${Gs}${e}.insert.${n}`,c=`${Gs}${e}.insertSeg.${n}`;o.actions[s]={persist:t,insertSegmentFrom:r,anchor:i,relation:a};let l=Gm(s),u=Km(c,s,void 0),d=Ym(u),f=Jm(u,l);return o.variables[u]=Lo(u,Oo),o.variables[d]={kind:`state`,key:d,default:`0`},o.actions[f]=Ro(u,l),o.actions[d]={set:d,int:!0},o.segments[c]={template:`{{ menu "${s}" "+" "✕" }}`,when:mh},{kind:`segment`,name:c}}function qh(e,t,n,r,i,a){let o=[],s=e.children.reduce((e,t,n)=>t.kind===`segment`&&!Hh(t.name)?n:e,-1),c=e=>qh(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=ja(u,c);if(Hh(u.name)){o.push(d);continue}let f=[Kh(t,n,String(a.n++),r,u.name,`before`,i),d,Gh(t,n,u.name,i),...l===s?[Kh(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 Jh(e,t,n,r,i,a){let o=`${Gs}${n}.resetLayout`,s=`${Gs}${n}.customized`;i.actions[o]={reset:r},i.ensured[Bh]={kind:`input`,path:Bh,type:`boolean`,default:!1};let c=Mo(t);return i.segments[s]={template:`{{ action "${o}" "↺ ${c} customized" }}`,when:Vh},{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:s},Yh(e,a)]}}function Yh(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),Yh(n,t)]}:{...e,children:[...e.children,t]}}function Xh(e,t,n,r){let{node:i}=Eh(e,t),a=Ah(t),o=Uh(t),s=Hs(t);return Jh(qh(i,s,a,o,n,{n:0}),t,s,a,n,r)}function Zh(e){if(!(`edit.toggle`in e.actions))return e;let t={variables:{},ensured:{},actions:{},segments:{}},n=Ph(`${Gs}help`,Lh,[ph],t),r={...e.presets};for(let i of Ch(e.presets)){let a=Xh(e,i,t,n);r[i]={...Th(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 Qh={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function $h(e){let t=e[Qh.socket]??``,n=e[Qh.pane]??``;if(t===``||n===``)return null;let r=e[Qh.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const eg=Qh.truecolor,tg=[{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[eg];return typeof n==`string`&&n!==``?{ok:!1,reason:`${eg} 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:eg,value:`1`}}}}}}];function ng(e){return tg.map(t=>({check:t,verdict:t.probe(e)}))}function rg(e){return tg.find(t=>t.name===e)}function ig(e){let t=`settings.doctor.${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function ag(e){return e.flatMap(({check:e,verdict:t})=>{let n=ig(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:Ni}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:t.reason},{key:n.fixable,value:t.fix===void 0?Ni:H}]})}const og={copySession:{copy:`{{ .session.id }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`}};function sg(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}`,actions:Object.fromEntries(Object.entries(og).map(([t,n])=>[`${e}${t}`,n]))}}const cg=`${Ks}menu`,lg=fh,ug=`${Ks}edit`,dg=`${Ks}close`,fg=`${Ks}toolbar`,pg=sg(Ks),mg=`${Ks}persist`,hg=`${Ks}config`,gg=mg,_g={variable:cg,key:cg,member:lg},vg={variable:hg,key:hg,member:lg},yg=`${Ks}tools`,bg={variable:yg,key:yg,member:lg},xg=`${Ks}doctor`,Sg=`${xg}.run`,Cg=e=>`${xg}.fix.${e}`,wg=e=>`${xg}.${e}`,Tg=`${Ks}help.persist`,Eg=`${Ks}pickers`,Dg=[{name:`preset`,sessionKey:`preset`,configKey:`preset`,effectiveVar:`preset.effective`,glyph:`▦`,domain:`presets`}],Og=[{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`}],kg={name:`wrap`,sessionKey:`autoWrap`,configKey:`autoWrap`},Ag={name:`padding`,sessionKey:`padding`,configKey:`padding`},jg=`${Ks}${kg.name}`,Mg=`${Ks}${Ag.name}`,Ng=[...Dg,...Og];new Set([...Ng,kg,Ag].flatMap(e=>[e.sessionKey,e.configKey]));const Pg=e=>`${Ks}${e}`,Fg=e=>`${Ks}apply.${e}`,Ig=e=>`${Ks}reset.${e}`;function Lg(e){return e===cg}function Rg(e){let t={kind:`segment`,name:cg};if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[Rg(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function zg(e){return Bg(e)>0?e:Rg(e)}function Bg(e){let t=0;for(let n of Ma(e))n.kind===`segment`&&Lg(n.name)&&(t+=1);return t}function Vg(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&Lg(e.name)||e.opens!==void 0&&Vg(e.opens.body,!0):e.children.some(e=>Vg(e,n))}function Hg(e,t){return e.kind===`segment`?Lg(e.name)?No(e.name,_g,{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:fg},{kind:`segment`,name:mg},t,...Dg.map(e=>({kind:`segment`,name:Pg(e.name)})),No(hg,vg,{kind:`container`,direction:`horizontal`,children:[...Og.map(e=>({kind:`segment`,name:Pg(e.name)})),{kind:`segment`,name:jg},{kind:`segment`,name:Mg}]},`drop`),No(yg,bg,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:xg},...tg.map(e=>({kind:`segment`,name:wg(e.name)}))]},`drop`),{kind:`segment`,name:ug}]},`inline`):e:Ug(e,t)}function Ug(e,t){return{...e,children:e.children.map(e=>Hg(e,t))}}function Wg(e,t,n,r){let i=Gm(t),a=Km(e,t,r),o=Ym(a);n.variables[a]=Lo(a,Oo),n.variables[o]={kind:`state`,key:o,default:`0`},n.actions[Jm(a,i)]=Ro(a,i),n.actions[o]={set:o,int:!0}}function Gg(e){let t={variables:{[cg]:Lo(cg,Oo)},actions:{[cg]:Ro(cg,lg),[hg]:Ro(hg,lg),[yg]:Ro(yg,lg),[Sg]:{doctor:`run`},[dg]:{set:_g.key,to:Oo},[ug]:{do:[dh,dg]},...pg.actions,[mg]:{set:gg,cycle:[Ni,H]}},segments:{[cg]:{template:Io(cg,e,`❌`)},[fg]:{template:pg.template},[mg]:{template:`{{ action "${mg}" "☐ persist?" "☑ persist?" }}`},[hg]:{template:Io(hg,`⚙ config ▸`,`⚙ config ▾`)},[yg]:{template:Io(yg,`🧰 tools ▸`,`🧰 tools ▾`)},[xg]:{template:`{{ action "${Sg}" "🩺 doctor" }}`},[jg]:{template:`{{ action "${Fg(`wrap`)}" "wrap: on" "wrap: off" }} {{ action "${Ig(`wrap`)}" "↺" }}`},[Mg]:{template:`{{ action "${Fg(`padding`)}.down" "◀" }} padding {{ .padding.effective }} {{ action "${Fg(`padding`)}.up" "▶" }} {{ action "${Ig(`padding`)}" "↺" }}`},[ug]:{template:`{{ action "${ug}" "✎ edit" "✎ done" }}`}}};return t.variables[gg]={kind:`state`,key:gg,default:Ni},t.variables[hg]=Lo(hg,Oo),t.variables[yg]=Lo(yg,Oo),qg(t),Kg(t),{artifacts:t,help:Ph(Tg,Rh,[_g],t)}}function Kg(e){for(let t of tg){let n=ig(t.name),r=Cg(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[wg(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${H}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function qg(e){for(let t of Ng){let n=Pg(t.name),r=Fg(t.name);e.segments[n]={template:`${t.glyph} {{ .${t.effectiveVar} }} {{ menu "${r}" "▸" "▾" (dict "key" "${Eg}") }} {{ action "${Ig(t.name)}" "↺" }}`},e.actions[r]={set:t.sessionKey,persist:t.configKey,persistWhen:gg,from:t.domain},e.actions[Ig(t.name)]={reset:t.configKey},Wg(n,r,e,Eg)}e.actions[Fg(kg.name)]={set:kg.sessionKey,persist:kg.configKey,persistWhen:gg,cycle:[...Pi]},e.actions[Ig(kg.name)]={reset:kg.configKey};for(let t of[-1,1])e.actions[`${Fg(Ag.name)}.${t<0?`down`:`up`}`]={set:Ag.sessionKey,persist:Ag.configKey,persistWhen:gg,...Fi,by:t};e.actions[Ig(Ag.name)]={reset:Ag.configKey}}function Jg(e){e.variables[uh]=Lo(uh,Oo),e.actions[dh]=Ro(uh,fh)}const Yg=`session.id`;function Xg(e){return Object.prototype.hasOwnProperty.call(e.variables,Yg)}function Zg(e){if(!Xg(e))return e;let{artifacts:t,help:n}=Gg(e.globals.menuGlyph??`🍫`);Jg(t);let r={...e.presets};for(let t of Ch(e.presets)){let{node:i}=Eh(e,t);r[t]={...Th(e.presets,t),root:Hg(zg(i),n)}}return{...e,variables:{...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:r}}const Qg=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`doctor`,`do`],$g=`persistWhen`;function e_(e){return $g in e}function t_(e){return e_(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 n_(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function r_(e){return`set`in e}function i_(e){return`persist`in e}function a_(e){return`reset`in e}function o_(e){return`undo`in e}function s_(e){return`redo`in e}function c_(e){return`doctor`in e}function l_(e,t){if(t===void 0)return{};if(!Ka(t))return J(e,`actions`,`actions must be an object, got ${qa(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=u_(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function J(e,t,n){e.issues.push({path:t,message:n,line:W(e.source,t.split(`.`))})}function u_(e,t,n){if(!Ka(n))return J(e,t,`${t} must be an action object, got ${qa(n)}`),null;if(`persistWhen`in n)return U_(e,t,n,`dual`,B_);let r=Qg.filter(e=>e in n);return r.length===1?d_[r[0]](e,t,n):(J(e,t,`action must declare exactly one of: ${Qg.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const d_={set:(e,t,n)=>U_(e,t,n,`set`,R_),persist:(e,t,n)=>U_(e,t,n,`persist`,z_),copy:f_(`copy`),open:f_(`open`),reset:p_,undo:m_(`undo`),redo:m_(`redo`),doctor:h_,do:g_};function f_(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=Va(t,n,r,e);return i===null?null:{[e]:i}}}function p_(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=__(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 m_(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 ${G(r[e])}`),null)}}function h_(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 ${G(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||rg(a)===void 0?(J(e,`${t}.check`,`doctor fix must name a check (have: ${tg.map(e=>e.name).join(`, `)}), got ${G(a)}`),null):{doctor:`fix`,check:a}}function g_(e,t,n){for(let r of Object.keys(n))r!==`do`&&J(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(J(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${G(r)}`),null):{do:r}}function __(e,t,n,r,i,a){let o=Va(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 v_={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`],[$g,`the SessionState key whose boolean value chooses the destination`]]};function y_(e,t,n,r){let i={},a=v_[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=__(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 b_(e){return e===`set`?`set-state`:e===`persist`?`set-config`:`set-state/set-config`}const x_={to:W_(`set`)},S_={to:W_(`persist`)},C_={from:G_(`set`)},w_={from:G_(`persist`)},T_={min:X_(),max:X_(),by:X_()},E_={int:q_()},D_={cycle:K_(`set`)},O_={to:W_(`dual`)},k_={from:G_(`dual`)},A_={cycle:K_(`dual`)},j_={cycle:K_(`persist`)},M_={removeSegment:J_(`removeSegment`)},N_={insertSegment:J_(`insertSegment`),anchor:J_(`anchor`),relation:Y_()},P_={insertSegmentFrom:G_(`persist`),anchor:J_(`anchor`),relation:Y_()},F_={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},I_={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function L_(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=v_[e].map(([e])=>e),s=(e,n,r)=>Ya(e,t,n,r),c=uo(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?ro(s,...n):s}}const R_=[L_(`set`,x_),L_(`set`,C_),L_(`set`,T_,[F_,I_]),L_(`set`,E_),L_(`set`,D_)],z_=[L_(`persist`,S_),L_(`persist`,w_),L_(`persist`,T_,[F_,I_]),L_(`persist`,j_),L_(`persist`,M_),L_(`persist`,N_,[],[`insertSegment`]),L_(`persist`,P_,[],[`insertSegmentFrom`])],B_=[L_(`dual`,O_),L_(`dual`,k_),L_(`dual`,T_,[F_,I_]),L_(`dual`,A_)];function V_(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 H_(e){let t=V_(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 U_(e,t,n,r,i){let a=y_(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return J(e,t,`${H_(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 W_(e){let t=b_(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>__(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 G_(e){let t=b_(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 ${G(o)}`)}}}function K_(e){let t=b_(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 ${qa(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 q_(){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 ${G(r[n])}`);return}return!0}}}function J_(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Va(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 Y_(){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 ${G(i)}`);return}return i}}}function X_(){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 ${G(i)}`);return}return i}}}const Z_={noun:`look key`,fields:{hueShift:oo(),chromaScale:oo({min:0}),lightnessScale:oo(),lightnessShift:oo()}};function Q_(e,t){if(!Ka(t))return e.issues.push({path:`looks`,message:`looks must be an object mapping look names to adaptation objects, got ${qa(t)}`,line:W(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:W(e.source,[`looks`,r])});continue}let t=Ja(e,Z_,`looks.${r}`,i);t!==null&&(n[r]={...vn,...t})}return n}const $_={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:Qc(e,`${t}.${n}`,r[n])},globals:{required:!1,json:$o(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Qo(e,`${t}.${n}`,r[n])}}};function ev(e,t){if(!Ka(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${qa(t)}`,line:W(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:W(e.source,[`presets`,r])});continue}let t=Ja(e,$_,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function tv(e,t){if(t===void 0)return{};if(!Ka(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${qa(t)}`,line:W(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 ${G(i)}`,line:W(e.source,[`helpers`,r])});continue}n[r]=i}return n}const nv=new Map,rv=new Map;function iv(e){let t=av(e);if(t===null)throw Error(`Palette "${e}" (resolved "${mi(e)}") did not resolve in the theme registry — allowed names and the registry are inconsistent`);return t}function av(e){let t=mi(e),n=nv.get(t);if(n!==void 0)return n;let r=Wn(t);return r===null?null:(nv.set(t,r),r)}function ov(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=rv.get(n);if(r!==void 0)return r;let i=Qn(e,t);return rv.set(n,i),i}function sv(e){let t=av(e);return t===null?null:{kind:`decided`,name:e,value:t}}function cv(e,t){let n=sv(e);return n===null?(t(`globals.palette rendered "${hi}": "${e}" names no installed theme`),uv()):n}function lv(e,t,n){return Si(e,t,n,uv(),sv)}function uv(){return sv(hi)}function dv(e){return Ci(lv(void 0,null,e),()=>hi,uv).value}const fv=new Map;function pv(e,t,n){fv.set(e,{permanent:!0,resolve:t,paletteOf:n})}pv(`themes`,()=>vi(),e=>iv(e)),pv(`styles`,()=>Oi),pv(`charsets`,()=>ji),pv(`colorCompatibilities`,()=>Mi);function mv(e){return new Map([[`looks`,{members:Object.keys(e.looks),paletteOf:(t,n)=>ov(n,e.looks[t])}],[`presets`,{members:Ch(e.presets)}]])}function hv(e){return[...new Set([...fv.keys(),...e.keys()])]}function gv(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=fv.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(`unknown option domain "${e}" (have: ${hv(t).join(`, `)})`)}const _v=/{{([\s\S]*?)}}/g,vv=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g,yv=/(?<![A-Za-z0-9_)])\.([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*)/g;function bv(e){let t=new Set,n;for(_v.lastIndex=0;(n=_v.exec(e))!==null;){let e=n[1].replace(vv,``),r;for(yv.lastIndex=0;(r=yv.exec(e))!==null;)t.add(r[1])}return t}const xv=/\baction\s+$/;function Sv(e){let t=new Set;_v.lastIndex=0;let n;for(;(n=_v.exec(e))!==null;){let e=n[1],r=0,i;for(vv.lastIndex=0;(i=vv.exec(e))!==null;)xv.test(e.slice(r,i.index))&&t.add(i[0].slice(1,-1)),r=i.index+i[0].length}return t}const Cv=/\b(picker|menu)\s+$/;function wv(e){let t=new Set;_v.lastIndex=0;let n;for(;(n=_v.exec(e))!==null;){let e=n[1],r=0,i=0,a;for(vv.lastIndex=0;(a=vv.exec(e))!==null;){let n=Cv.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 Tv(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 Ev={gitTaculous:`gitaculous`};function Dv(e,t){let n=new Map;for(let e of Object.keys(t)){let t=Hs(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:W(e.source,[`presets`])})}function Ov(e,t){t.globals.look!==void 0&&!xi(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:W(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:W(e.source,[`globals`,`preset`])}),Dv(e,t.presets);let n=mv(t);for(let[r,i]of Object.entries(t.actions))!(`set`in i)||!(`from`in i)||typeof i.from!=`string`||hv(n).includes(i.from)||e.issues.push({path:`actions.${r}.from`,message:`actions.${r} from: references unknown option domain "${i.from}" (have: ${hv(n).join(`, `)})`,line:W(e.source,[`actions`,r,`from`])});for(let[n,r]of Object.entries(t.actions)){if(!e_(r))continue;let i=r[$g];Nv(t,i)||e.issues.push({path:`actions.${n}.${$g}`,message:`actions.${n} ${$g}: "${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:W(e.source,[`actions`,n,$g])})}for(let[n,r]of Object.entries(t.actions))`do`in r&&r.do.forEach((i,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,i)?t.actions[i]:void 0,s=o===void 0?`references unknown action "${i}"`:`do`in o?`"${i}" is itself a do action — list its members here instead`:r.do.indexOf(i)===a?a>0&&n_(o)?`"${i}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${i}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:W(e.source,[`actions`,n,`do`])})});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=jh(i);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a config globals field (have: ${rs().join(`, `)}), a "segments.<name>.palette" target, or a "presets.<name>.root" target`,line:W(e.source,[`actions`,n,a])});continue}let s=kv.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:W(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){Av(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:W(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:W(e.source,[`actions`,n,a])})}}let r=Fv(t),i=Xg(t),a=Object.entries(t.segments).filter(([,e])=>sh(e.template)).map(([e])=>e),o=(t,n,r)=>{Bg(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${cg}" ${Bg(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}),Vg(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${cg}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r});let i=new Map;for(let e of Ma(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 Ma(n))if(s.when!==void 0&&zv(e,`${a}.when`,s.when,r,{line:o}),s.kind===`segment`){if(Lg(s.name)){i||e.issues.push({path:a,message:`${a} places the global settings menu anchor "${cg}", but this config declares no "${Yg}" variable — the menu is a click surface and every click composes a URL from "${Yg}", so it is not synthesized for a config without it. Declare a "${Yg}" 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=Ev[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=Bv(e.source);s(So(t.root),c,W(e.source,[c]));for(let[n,r]of Object.entries(t.presets)){if(r.root===void 0)continue;let t=`presets.${n}.root`,i=W(e.source,[`presets`,n,`root`]);s(Co(r.root),t,i)}let l=new Map([[`root`,So(t.root)]]);for(let e of Ch(t.presets)){let{node:n,path:r}=Eh(t,e);l.set(r,n)}for(let[t,n]of l)o(n,t,W(e.source,t.split(`.`)));for(let[n,i]of Object.entries(t.variables))Lv(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))Lv(e,`segments.${n}.vars.${t}`,a,r,n);for(let a of[`template`,`bg`,`fg`,`when`]){let o=i[a];if(typeof o==`string`){zv(e,`segments.${n}.${a}`,o,r,{segCtx:n});for(let r of Sv(o))Object.prototype.hasOwnProperty.call(t.actions,r)||e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}"`,line:W(e.source,[`segments`,n,a])});for(let r of wv(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:W(e.source,[`segments`,n,a])})}}}for(let[n,i]of Object.entries(t.variables))Rv(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))Rv(e,`segments.${n}.vars.${t}`,a,r,n);(Mv(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:W(e.source,[`variables`])})}const kv=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function Av(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=W(e.source,[`actions`,n,r]);if(!Ch(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${Ch(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 jv(e){return[...Object.values(e.variables),...Object.values(e.segments).flatMap(e=>Object.values(e.vars??{}))].filter(e=>e.kind===`state`)}function Mv(e){return jv(e).length>0}function Nv(e,t){return jv(e).some(e=>e.kind===`state`&&e.key===t)}function Pv(e){return Object.values(e.actions).some(e=>r_(e)||i_(e)||a_(e)||o_(e)||s_(e)||c_(e))}function Fv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),Iv(r)&&n.add(e)};for(let[t,n]of Object.entries(e.variables))r(t,n);for(let[t,n]of Object.entries(e.segments))for(let[e,i]of Object.entries(n.vars??{}))r(`${t}.${e}`,i);return{names:t,documents:n}}function Iv(e){return(e.kind===`shell`||e.kind===`file`)&&Pa(e.parse)===`json`}function Lv(e,t,n,r,i){n.kind===`template`&&zv(e,`${t}.template`,n.template,r,{segCtx:i}),Ia(n)&&n.cache&&`key`in n.cache&&zv(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function Rv(e,t,n,r,i){if(Ia(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:W(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function zv(e,t,n,r,i){for(let a of bv(n)){if(Tv(a,r))continue;let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,o=n!==void 0&&Tv(n,r)?` (segment-local vars are namespaced — write ".${n}")`:``;e.issues.push({path:t,message:`Template references unknown variable ".${a}"${o}`,line:i?.line??W(e.source,t.split(`.`))})}}function Bv(e){try{let t=Xe.default.parse(e);if(Ka(t)&&`root`in t)return`root`}catch{}return`layout`}function Vv(e,t){let{graph:n,nodeInfo:r}=Hv(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:W(e.source,o?.linePathParts??[`variables`,i])}),!0}if(t===0&&o(s))return!0}return i.set(t,2),a.pop(),!1}}function Hv(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 bv(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),Ia(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 Uv=[`json5`,`json`];function Wv(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function Gv(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?f.homedir()+e.slice(1):e}function Kv(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Uv.map(t=>c.join(e,`.cc-candybar.${t}`)):[],...Uv.map(e=>c.join(r,`.cc-candybar.${e}`)),...Uv.map(e=>`${qv()}.${e}`)])]}function qv(){let e=process.env.XDG_CONFIG_HOME??c.join(f.homedir(),`.config`);return c.join(e,`cc-candybar`,`config`)}function Jv(e,t,n){let r=[];for(let i of Kv(e,t,n)){let e=Wv(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 Yv(e,t,n){let r=Jv(e,t,n);return r.kind===`default`?`${qv()}.${Uv[0]}`:r.path}function Xv(e){return Zv(e).join(`
119
119
  `)||null}function Zv(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 Qv(e,t){let n=Kv(e,t).filter(e=>Wv(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 $v(e,t,n){let r=e===null?ey:ty(e,t,n);return{...r,config:Eo(r.raw,t)}}const ey={raw:{},source:``,warnings:[]};function ty(e,t,n){let i=r.readFileSync(e,`utf-8`);return{source:i,...iy(e,i,n,Zs(t))}}function ny(e,t=`<config>`,n=``,r=new Set(vi())){let i=[],a={source:n,issues:i,allowedPalettes:r,groups:[]};if(Ov(a,e),Vv(a,e),i.length>0)throw new Ta(t,i);return Zh(Zg(e))}function ry(e,t,n=new Set(vi()),r=ay){return iy(e,t,n,r).raw}function iy(e,t,n,r){let i=oy(e,t),a=Oa(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(vi()),groups:[]};if(!Ka(i))throw new Ta(e,[{path:``,message:`Config root must be an object, got ${qa(i)}`}],o);let l=sy(c,i,r);if(s.length>0)throw new Ta(e,s,o);return{raw:l,warnings:o}}const ay=new Set;function oy(e,t){try{return Xe.default.parse(t)}catch(t){let n=t;throw new Ta(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function sy(e,t,n){for(let n of Object.keys(t))cy.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...cy].join(`, `)}`,line:W(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=Zo(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=_s(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=Qs(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:W(e.source,[`layout`])}),t.root!==void 0&&(r.root=Qc(e,`root`,t.root)),t.actions!==void 0&&(r.actions=l_(e,t.actions)),t.looks!==void 0&&(r.looks=Q_(e,t.looks)),t.presets!==void 0&&(r.presets=ev(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=es(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=tv(e,t.helpers)),ol(e,r),lh(e,r),_h(e,r),Xs(e,r,Ks,`the global settings menu`),r}const cy=new Set([`globals`,`variables`,`segments`,`layout`,`root`,`actions`,`looks`,`presets`,`editGlobals`,`helpers`]);function ly(e){let t=py(e.termCols),n=py(e.termRows),r=my(e.ssh),i=dy(e.tmux),a=uy(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 uy(e){return typeof e==`string`&&e!==``?Gv(e):void 0}function dy(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 fy=1e4;function py(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>fy?fy:t}function my(e){return typeof e==`boolean`?e:void 0}var hy=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function gy(e){let t=Buffer.from(JSON.stringify(e),`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function _y(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 hy(`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 hy(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function vy(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=_y(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(gy(t))})}async function yy(e,t,n){let r=null;try{r=await wy(Ne(),t.connectMs);let i=await vy(r,{v:3,...e},t.budgetMs);return Sy(e.kind,i,n)}catch(e){return Cy(e)}finally{r&&r.destroy()}}function by(e,t){return typeof e==`string`?e:t}function xy(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function Sy(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=by(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:xy(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 Cy(e){if(e instanceof hy||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 wy(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 Ty(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 Ey={connectMs:50,budgetMs:150},Dy={connectMs:50,budgetMs:200};function Oy(e){let t=e.output;return typeof t==`string`?t:void 0}function ky(e,t,n,r){return yy({kind:`render`,hookData:e,args:t,cwd:n,...r},Ey,Oy)}function Ay(e,t){return yy({kind:`click`,verb:e,value:t},Dy,Oy)}let jy=null;function My(e){if(jy!==null)return jy;r.mkdirSync(c.dirname(e),{recursive:!0});try{jy=r.statSync(e).size}catch{jy=0}return jy}function Ny(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{}jy=0}function Y(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=Ge(),t=My(e);r.appendFileSync(e,n),jy=t+Buffer.byteLength(n,`utf8`),jy>=5242880&&Ny(e)}catch(e){jy=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 Fy(e,t){return e===`darwin`?[Iy(`footprint`,[`-p`,String(t)]),Iy(`vmmap`,[`--summary`,String(t)])]:e===`linux`?[Ly(`/proc/self/smaps_rollup`),Ly(`/proc/self/status`)]:[]}function Iy(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=Ee({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}`}${Ry(n.stderr)}`}}}}function Ly(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 Ry(e){let t=e.split(`
124
124
  `).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const zy=`CC_CANDYBAR_RSS_LIMIT_MB`;function By(e){let t=e[zy];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${zy} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function Vy(e){return By(e)*2}const Hy=1024*1024;function Uy(e){return By(e)*Hy}const Wy={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function Gy(e,t,n){let{prefix:r,suffix:i}=Wy[t];return c.join(e,`${r}${n}${i}`)}function Ky(e){for(let t of Object.keys(Wy)){let{prefix:n,suffix:r}=Wy[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function qy(e){let t=e.rssLimitBytes??512*Hy,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 Jy(e.log,`memory report`,()=>{let t=Gy(e.snapshotDir,`memoryReport`,o);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),Jy(e.log,`heap snapshot`,()=>{let t=Gy(e.snapshotDir,`heapSnapshot`,o);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),Jy(e.log,`artifact rotation`,()=>{Xy(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 Jy(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function Yy(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=Ky(t);if(n===null)return t;let{prefix:r,suffix:i}=Wy[n];return t.slice(r.length,t.length-i.length)}function Xy(e,t,n){let r=new Map;for(let t of e){let e=Yy(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 Zy(e,t,n={}){let i=Me();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(Fy(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=>Ky(e)!==null).map(e=>c.join(i,e))}catch{return[]}},removeFile:e=>r.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function Qy(e={}){if(mb()!==null)return;let n=e.spawn??hb,r=db();if(r.kind===`contended`){let e=eb();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),$y(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),$y(n);return}try{$y(n)}finally{pb()}}function $y(e){sb()&&tb(e)}function eb(){try{let e=r.statSync(Ve());return Date.now()-e.mtimeMs}catch{return null}}function tb(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 nb(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function rb(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function ib(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 ab(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 ob(){try{r.unlinkSync(Ue())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function sb(){let e=He(),n=Ue(),r=ib(n),i=nb(cb(e),rb(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`),lb(e),ab(n,Math.min(r+1,5)),!0)}function cb(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function lb(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 ub=null;function db(){let e=Ve();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 ub={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(!fb(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 fb(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function pb(){if(!ub)return;let{fd:e,path:t}=ub;ub=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function mb(){try{return r.mkdirSync(Me(),{recursive:!0}),null}catch(e){return`mkdir ${Me()}: ${e.message}`}}function hb(){let e=t.execPath,n=t.argv[1];return n?De({bin:e,args:[`--max-old-space-size=${Vy(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const gb=`cc-candybar`,_b=`dispatch`,vb=`set-state`,yb=`step-state`,bb=`copy`,xb=`open-vscode`,Sb=`toolbar-toggle`,Cb=`show-config-error`,wb=`show-config-warning`,Tb=`set-config`,Eb=`step-config`,Db=`reset-config`,Ob=`apply-layout-op`,kb=`undo`,Ab=`redo`,jb=`apply-update`,Mb=`doctor-run`,Nb=`doctor-fix`;function Pb(e){return e.map(encodeURIComponent).join(`/`)}function Fb(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function Ib(e){return`${gb}://${_b}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${Pb(e.args)}`)}`).join(`&`)}`}function Lb(e){return new y(e).getAll(`e`).map(Bb)}function Rb(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&zb(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function zb(e,t){if(e.verb!==`set-state`||t.verb!==`set-state`)return;let[n,r]=[Bb(e.value),Bb(t.value)];return n.verb===r.verb?{verb:vb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function Bb(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const Vb=`1.74.0`;function Hb(){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 Ub(e,t){return e?.kind===`ok`?e.value:t}const Wb=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Gb(e){let t=Wb.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 Kb(e){return e.join(`.`)}function qb([e,t,n],[r,i,a]){return e-r||t-i||n-a}const Jb=`@promptctl/cc-candybar`;async function Yb(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`?Gb(n.latest):Z}catch(e){return Q(e instanceof Error?e.message:String(e))}}function Xb(e,t){let n=Gb(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=qb(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 Zb(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${Kb(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${Kb(t.installed)} is newer than the registry's latest release (${Kb(t.latest)}): an unpublished build.\n`};case`stale`:{let n=Kb(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${Kb(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 Qb=`CCCandybarURLHandler`,$b=[],ex={"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 tx(e){return/^[A-Za-z0-9_./=,:-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function nx(e,t){return[e,...t].map(tx).join(` `)}function rx(){return c.join(f.homedir(),`Applications`,`${Qb}.app`)}function ix(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function ax(){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 ox(){return c.join(ax(),`bin`,`cc-candybar`)}function sx(){return c.join(ax(),`dist`,`index.mjs`)}function cx(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 nb(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function rb(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function ib(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 ab(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 ob(){try{r.unlinkSync(Ue())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function sb(){let e=He(),n=Ue(),r=ib(n),i=nb(cb(e),rb(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`),lb(e),ab(n,Math.min(r+1,5)),!0)}function cb(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function lb(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 ub=null;function db(){let e=Ve();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 ub={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(!fb(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 fb(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function pb(){if(!ub)return;let{fd:e,path:t}=ub;ub=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function mb(){try{return r.mkdirSync(Me(),{recursive:!0}),null}catch(e){return`mkdir ${Me()}: ${e.message}`}}function hb(){let e=t.execPath,n=t.argv[1];return n?De({bin:e,args:[`--max-old-space-size=${Vy(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const gb=`cc-candybar`,_b=`dispatch`,vb=`set-state`,yb=`step-state`,bb=`copy`,xb=`open-vscode`,Sb=`toolbar-toggle`,Cb=`show-config-error`,wb=`show-config-warning`,Tb=`set-config`,Eb=`step-config`,Db=`reset-config`,Ob=`apply-layout-op`,kb=`undo`,Ab=`redo`,jb=`apply-update`,Mb=`doctor-run`,Nb=`doctor-fix`;function Pb(e){return e.map(encodeURIComponent).join(`/`)}function Fb(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function Ib(e){return`${gb}://${_b}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${Pb(e.args)}`)}`).join(`&`)}`}function Lb(e){return new y(e).getAll(`e`).map(Bb)}function Rb(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&zb(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function zb(e,t){if(e.verb!==`set-state`||t.verb!==`set-state`)return;let[n,r]=[Bb(e.value),Bb(t.value)];return n.verb===r.verb?{verb:vb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function Bb(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const Vb=`1.74.1`;function Hb(){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 Ub(e,t){return e?.kind===`ok`?e.value:t}const Wb=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Gb(e){let t=Wb.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 Kb(e){return e.join(`.`)}function qb([e,t,n],[r,i,a]){return e-r||t-i||n-a}const Jb=`@promptctl/cc-candybar`;async function Yb(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`?Gb(n.latest):Z}catch(e){return Q(e instanceof Error?e.message:String(e))}}function Xb(e,t){let n=Gb(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=qb(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 Zb(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${Kb(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${Kb(t.installed)} is newer than the registry's latest release (${Kb(t.latest)}): an unpublished build.\n`};case`stale`:{let n=Kb(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${Kb(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 Qb=`CCCandybarURLHandler`,$b=[],ex={"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 tx(e){return/^[A-Za-z0-9_./=,:-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function nx(e,t){return[e,...t].map(tx).join(` `)}function rx(){return c.join(f.homedir(),`Applications`,`${Qb}.app`)}function ix(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function ax(){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 ox(){return c.join(ax(),`bin`,`cc-candybar`)}function sx(){return c.join(ax(),`dist`,`index.mjs`)}function cx(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 lx(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 ux(t){let n=ex[`${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 dx(e,t){c.resolve(e)!==c.resolve(t)&&r.copyFileSync(e,t)}function fx(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 ${Jb}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{r.closeSync(t)}}function px(){let e=lx(process.argv[1]);if(!r.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let t=ux(e);if(!r.existsSync(t.sourcePath))throw Error(`install: render entry not found at ${t.sourcePath}. Reinstall the package.`);r.mkdirSync(c.dirname(sx()),{recursive:!0}),r.mkdirSync(c.dirname(ox()),{recursive:!0}),dx(e,sx()),dx(t.sourcePath,ox()),r.chmodSync(ox(),493),r.rmSync(c.join(ax(),`url-handler.mjs`),{force:!0});let n=fx(ox());return process.stdout.write(`Staged cc-candybar v${Vb} runtime at ${ax()}\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:ox(),distPath:sx(),entryKind:n}}function mx(){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>${gb}</string>`,` </array>`,` </dict>`,`</array>`].join(`
127
127
  `)}]}function hx(e){let t=rx();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=Ee({bin:`/usr/bin/osacompile`,args:[`-o`,t,`-e`,cx(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 mx())Ee({bin:`/usr/bin/plutil`,args:[`-remove`,e,i],category:`install.plutil`});for(let{key:e,xml:t}of mx()){let n=Ee({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 ${gb}:// with Launch Services\n`);let a=Ee({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(`✓ ${Qb}.app installed and registered.\n`),process.stdout.write(` Test: open '${gb}://hello-world' && pbpaste\n`)}function gx(){ix(),hx(px().distPath)}function _x(e,t=gb){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:bb,value:r}:{verb:decodeURIComponent(r.slice(0,i)),value:r.slice(i+1)}}async function vx(e){e||(process.stderr.write(`url-handle: missing URL argument.
128
128
  `),process.exit(1));let t;try{t=_x(e)}catch(e){process.stderr.write(`url-handle: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}let n=await Ay(t.verb,t.value);n.kind===`ok`&&process.exit(0),n.kind===`transient`&&(Qy(),process.stderr.write(`url-handle: daemon unavailable (${n.cause}: ${n.message})\n`),process.exit(1)),process.stderr.write(yx(n)+`
@@ -133,7 +133,7 @@ Config tooling:
133
133
  `))throw Error(`renderStripCells: rich-js strip output did not end its last line`);return i.slice(0,-1)}function aS(e){return Math.min(20,e??20)}const oS={heading:`ERROR`,glyph:`⚠`,colors:Qx},sS={heading:`WARNING`,glyph:`⚠`,colors:$x},cS={heading:`UPDATE`,glyph:`⬆`,colors:$x};function lS(e,t){return{text:qx(e),link:t}}function uS(e,t,n){let[r,...i]=[dS(e,oS,Cb),t,dS(n,sS,wb)].flat();return r===void 0?null:{channels:[r,...i]}}function dS(e,t,n){let r=Ib([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>lS(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function fS(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
134
134
  `)}function pS(e,t,n,r){if(t===null)return e;let i=mS(r),a=t.channels.flatMap(e=>hS(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[gS(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
135
135
  `);return e?`${l}\n${e}`:l}function mS(e){return{style:`plain`,separator:``,width:e.width,wrap:!0,padding:0,charset:`unicode`,colorCompatibility:e.colorCompatibility}}function hS(e,t){let n=new B({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=Rt(Math.max(2,t.width-1)),i=(e,t)=>new Jr(`${e} `,{style:t,end:``,noWrap:!0});return e.lines.flatMap((a,o)=>iS([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=>Ht(e,r)).map(e=>i(e,t))})],t).split(`
136
- `))}function gS(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new B({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new Jr(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: ${qx(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(qx(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=Jr.fromFragments([...d,...p]).truncate(r.width);return m.noWrap=!0,iS([m],r)}const _S=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function vS(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function yS(e,t){return r.readdirSync(t).filter(_S).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?yS(e,i):[[c.relative(e,i).split(c.sep).join(`/`),vS(i,a)]]})}function bS(e){let t=C.createHash(`sha256`);for(let[n,r]of yS(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const xS=e=>e.slice(0,7);function SS(e){return c.dirname(c.dirname(e))}function CS(){return{version:Vb,digest:`efad99cb99a1fa0cbb7e378802275a7f95bea60c81985832ff95b459c890739a`}}function wS(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 TS(e,t){try{let n=SS(b(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=bS(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:wS(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 ES=/^-?\d+$/;function DS(e,t,n){return e===void 0?t:Math.max(t,Math.min(n,e))}function OS(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 kS(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!ES.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 AS(e,t,n){return r=>r?ES.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 jS(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=>!ES.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:DS(r[0].seed,t,i)}}return{kind:`int`}}function MS(e){return e===`config`?`set-config`:`set-state`}function NS(e,t,n){return t.kind===`int`?kS(`menu page "${e}"`):t.kind===`range`?AS(t.min,t.max,`${n} stepper "${e}"`):OS(t.allowed,`${n} "${e}"`,MS(n))}function PS(e,t,n){return NS(e,jS(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:jS(e,n,t)}))}function IS(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=PS(e,a.specs,t)}else{let r=[i];n.set(e,{permanent:!1,kind:i.kind,validator:PS(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=PS(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=jS(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 LS=IS({},`config`);function RS(){return LS.listKeys()}function zS(e,t){return LS.validate(e,t)}function BS(e){return LS.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:gv(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:[vh({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[vh({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:gv(e.insertSegmentFrom,n).members.map(t=>vh({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max,seed:DS(t.get(e.persist),e.min,e.max)}}]:[]}function HS(e){return as(e.globals)}function US(e){let t=new Set;for(let n of GS(e)){let e=`persist`in n?n.persist:`reset`in n?n.reset:null;if(e===null)continue;let r=jh(e);r?.scope===`preset-root`&&t.add(r.preset)}return[...t].map(e=>({key:Ah(e),spec:{kind:`allow-list`,allowed:[]}}))}function WS(e){let t=HS(e),n=new Map([...mv(e),...Wh(e)]);return[...US(e),...GS(e).flatMap(e=>VS(e,t,n))]}function GS(e){return Object.values(e.actions).flatMap(t_)}function KS(e){return FS(WS(e),`config`)}function qS(e,t){return LS.register(e,t)}const JS=vi(),YS=new Set(JS),XS=new Set(Oi),ZS=e=>e?YS.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${JS.join(`, `)})`}:{ok:!1,reason:`theme name is required`},QS=e=>e?XS.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown style "${e}" (have: ${Oi.join(`, `)})`}:{ok:!1,reason:`style name is required`},$S=new Set([`1`,`true`]),eC=new Set([`0`,`false`]),tC=IS({style:QS,theme:ZS,"toolbar-expanded":e=>$S.has(e)?{ok:!0,value:`1`}:eC.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}});function nC(){return tC.listKeys()}function rC(e,t){return tC.register(e,t)}function iC(e,t){return tC.validate(e,t)}function aC(e){return tC.rangeParamsFor(e)}function oC(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:gv(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:DS(t.get(e.set),e.min,e.max)}}]:[]}function sC(e){let t=new Set(tC.listBaselineKeys());return e.filter(e=>e.spec.kind!==`allow-list`||!t.has(e.key))}function cC(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 as(e.globals))t.set(n,r);return t}function lC(e){let t=cC(e),n=mv(e);return sC(Object.values(e.actions).flatMap(t_).flatMap(e=>oC(e,t,n)))}function uC(e){return FS(lC(e))}const dC=`update.dismissed`,fC=`updateNotice`;function pC(e){return e.kind===`source`?e.newer.digest:Kb(e.newer)}const mC=e=>`${e.version} [${xS(e.digest)}]`;function hC(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:mC(e.newer),running:mC(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:Kb(e.newer),running:Kb(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${Jb}@${Kb(e.newer)}`,`install`]}}}}const gC={kind:`idle`},_C={kind:`running`};function vC(e,t,n){if(e===null)return[];let r=pC(e);if(!n.enabled||n.dismissed===r)return[];let i=hC(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(`
136
+ `))}function gS(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new B({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new Jr(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: ${qx(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(qx(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=Jr.fromFragments([...d,...p]).truncate(r.width);return m.noWrap=!0,iS([m],r)}const _S=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function vS(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function yS(e,t){return r.readdirSync(t).filter(_S).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?yS(e,i):[[c.relative(e,i).split(c.sep).join(`/`),vS(i,a)]]})}function bS(e){let t=C.createHash(`sha256`);for(let[n,r]of yS(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const xS=e=>e.slice(0,7);function SS(e){return c.dirname(c.dirname(e))}function CS(){return{version:Vb,digest:`50b716ee234c3d65cd28f6963dbadf1fe715e1873ff2501a2d4da8fa0c0f1a63`}}function wS(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 TS(e,t){try{let n=SS(b(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=bS(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:wS(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 ES=/^-?\d+$/;function DS(e,t,n){return e===void 0?t:Math.max(t,Math.min(n,e))}function OS(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 kS(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!ES.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 AS(e,t,n){return r=>r?ES.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 jS(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=>!ES.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:DS(r[0].seed,t,i)}}return{kind:`int`}}function MS(e){return e===`config`?`set-config`:`set-state`}function NS(e,t,n){return t.kind===`int`?kS(`menu page "${e}"`):t.kind===`range`?AS(t.min,t.max,`${n} stepper "${e}"`):OS(t.allowed,`${n} "${e}"`,MS(n))}function PS(e,t,n){return NS(e,jS(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:jS(e,n,t)}))}function IS(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=PS(e,a.specs,t)}else{let r=[i];n.set(e,{permanent:!1,kind:i.kind,validator:PS(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=PS(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=jS(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 LS=IS({},`config`);function RS(){return LS.listKeys()}function zS(e,t){return LS.validate(e,t)}function BS(e){return LS.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:gv(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:[vh({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[vh({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:gv(e.insertSegmentFrom,n).members.map(t=>vh({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max,seed:DS(t.get(e.persist),e.min,e.max)}}]:[]}function HS(e){return as(e.globals)}function US(e){let t=new Set;for(let n of GS(e)){let e=`persist`in n?n.persist:`reset`in n?n.reset:null;if(e===null)continue;let r=jh(e);r?.scope===`preset-root`&&t.add(r.preset)}return[...t].map(e=>({key:Ah(e),spec:{kind:`allow-list`,allowed:[]}}))}function WS(e){let t=HS(e),n=new Map([...mv(e),...Wh(e)]);return[...US(e),...GS(e).flatMap(e=>VS(e,t,n))]}function GS(e){return Object.values(e.actions).flatMap(t_)}function KS(e){return FS(WS(e),`config`)}function qS(e,t){return LS.register(e,t)}const JS=vi(),YS=new Set(JS),XS=new Set(Oi),ZS=e=>e?YS.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${JS.join(`, `)})`}:{ok:!1,reason:`theme name is required`},QS=e=>e?XS.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown style "${e}" (have: ${Oi.join(`, `)})`}:{ok:!1,reason:`style name is required`},$S=new Set([`1`,`true`]),eC=new Set([`0`,`false`]),tC=IS({style:QS,theme:ZS,"toolbar-expanded":e=>$S.has(e)?{ok:!0,value:`1`}:eC.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}});function nC(){return tC.listKeys()}function rC(e,t){return tC.register(e,t)}function iC(e,t){return tC.validate(e,t)}function aC(e){return tC.rangeParamsFor(e)}function oC(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:gv(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:DS(t.get(e.set),e.min,e.max)}}]:[]}function sC(e){let t=new Set(tC.listBaselineKeys());return e.filter(e=>e.spec.kind!==`allow-list`||!t.has(e.key))}function cC(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 as(e.globals))t.set(n,r);return t}function lC(e){let t=cC(e),n=mv(e);return sC(Object.values(e.actions).flatMap(t_).flatMap(e=>oC(e,t,n)))}function uC(e){return FS(lC(e))}const dC=`update.dismissed`,fC=`updateNotice`;function pC(e){return e.kind===`source`?e.newer.digest:Kb(e.newer)}const mC=e=>`${e.version} [${xS(e.digest)}]`;function hC(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:mC(e.newer),running:mC(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:Kb(e.newer),running:Kb(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${Jb}@${Kb(e.newer)}`,`install`]}}}}const gC={kind:`idle`},_C={kind:`running`};function vC(e,t,n){if(e===null)return[];let r=pC(e);if(!n.enabled||n.dismissed===r)return[];let i=hC(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(`
137
137
  `),c=Ib([{verb:wb,args:[s]}]),l=t.kind===`running`?lS(`[${i.busy}]`,c):lS(`[${i.act}]`,Ib([{verb:jb,args:[n.sessionId]}]));return[{severity:cS,message:s,lines:[[lS(a,c),l,lS(`[dismiss]`,Ib([{verb:vb,args:[n.sessionId,dC,r]}])),lS(`[disable]`,Ib([{verb:Tb,args:[n.sessionId,fC,`false`]}]))],...o.map(e=>[lS(e,c)])]}]}function yC(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 bC(e){switch(e.kind){case`current`:return[`info`,`build: current ${mC(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${mC(e.source)}, running ${mC(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function xC(e){switch(e.kind){case`current`:return[`info`,`release: current ${Kb(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${Kb(e.latest)}, running ${Kb(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${Kb(e.installed)}, latest ${Kb(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function SC(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const CC=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function wC(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=CC(e.stderr)??e.error??CC(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function TC(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=gC,d=null,f=SC(s),p=SC(s),m=()=>yC(c,l);function h(){let e=m(),t=e===null?null:pC(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:rC(dC,{kind:`allow-list`,allowed:[t]})})}function g(){c=TS(t,CS),f(bC(c)),h()}async function _(){l=Xb(Vb,await Yb(Jb,a,i)),p(xC(l)),h()}return{arm(){qS(fC,{kind:`allow-list`,allowed:[`false`]}),g(),setInterval(g,n).unref(),c.kind===`not-source-checkout`&&(_(),setInterval(()=>void _(),r).unref())},notice:e=>vC(m(),u,e),act(){let e=m();if(e===null)throw new $(`apply-update: nothing newer is known to apply`);let t=hC(e);if(u.kind===`running`)throw new $(`apply-update: already ${t.busy}`);u=_C,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),Te({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=gC,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=wC(n);u={kind:`failed`,identity:pC(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}function EC(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??DC(t.stderr)].filter(Boolean).join(`, `)}`)}function DC(e){return e.trim().split(`
138
138
  `,1)[0]??``}function OC(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?Z:X(n)}function kC(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?X(t):Z}const AC=/^[A-Za-z]:[\\/]/;function jC(e){let t=e.trim();if(AC.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 MC(e){return jC(e)?.host||null}function NC(e){let t=MC(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}function PC(e){let t=new Map;for(let n of e.split(`
139
139
  `)){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=>BC(e)!==null)??e.urls[0]??null}function IC(e){return e.find(e=>e.name===`origin`)??e[0]??null}function LC(e){let t=IC(e);return t?FC(t):null}function RC(e){let t=IC(e);return t?t.urls.find(e=>NC(e)!==null)??FC(t):null}function zC(e){let t=(jC(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function BC(e){let t=jC(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=LC(e);return t===null?null:BC(t)}function HC(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??DC(t.stderr)].filter(Boolean).join(`, `)}`)}function UC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function WC(e){let t=`detached`,n=Z,r=Z,i=Z,a=0,o=0,s=0,c=0;for(let l of e.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptctl/cc-candybar",
3
- "version": "1.74.0",
3
+ "version": "1.74.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.74.0",
94
- "@promptctl/cc-candybar-darwin-x64": "1.74.0",
95
- "@promptctl/cc-candybar-linux-x64": "1.74.0",
96
- "@promptctl/cc-candybar-linux-arm64": "1.74.0"
93
+ "@promptctl/cc-candybar-darwin-arm64": "1.74.1",
94
+ "@promptctl/cc-candybar-darwin-x64": "1.74.1",
95
+ "@promptctl/cc-candybar-linux-x64": "1.74.1",
96
+ "@promptctl/cc-candybar-linux-arm64": "1.74.1"
97
97
  }
98
98
  }