ccdeck 3.43.0 → 3.43.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.
- package/dist/web/assets/{BrowserWatchModal-BPws0psH.js → BrowserWatchModal-1On-pA6T.js} +1 -1
- package/dist/web/assets/{RadioPanel-CDl7ZImm.js → RadioPanel-DkXAgxKR.js} +1 -1
- package/dist/web/assets/{TrafficRadar-D1hp6BgZ.js → TrafficRadar-DWilzdA3.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-DPcdpBpI.js → UsageHistoryModal-BW9jTi6E.js} +1 -1
- package/dist/web/assets/{app-9p127oSR.js → app-ByCusSHX.js} +5 -5
- package/dist/web/assets/{index-Bkx27-wy.js → index-CzIBjYsB.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/release-notes.json +2 -1
- package/src/server/cswap-auto-choice.mjs +13 -6
- package/src/server/cswap-auto-loop.mjs +16 -1
|
@@ -81,7 +81,7 @@ ${e.sessionTitle}`:e.sessionTitle:e.cwd,d=y1(e),h=y.useRef(null),f=y.useRef(null
|
|
|
81
81
|
spend on this card also covers:
|
|
82
82
|
${d.join(`
|
|
83
83
|
`)}`:su(e.model,e.effort)),N=w1(e.sessionName,e.sessionTitle),S=qf(e),E=S?S.key:null,C=X7(E),I=S!=null&&!C,R=(S==null?void 0:S.kind)==="recap",$=Qz(e);return a.jsxs("div",{className:t,style:{"--session-hue":r},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(Bo,{type:"target",position:Oe.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(W9,{state:e.state}),a.jsx("span",{className:"label",title:c,children:e.label}),e.restoredFromLog&&a.jsx("span",{className:"synth-tag",title:e.provider==="claude"?"Restored from Claude’s busy-session registry after verifying the process identity. Earlier tool history is partial.":"Restored from a log with no recorded ending. Process status is not confirmed.",children:"restored"}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),S&&E&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":R?"Claude Code's recap":`Session note: ${Oa(S.kind)}`,"aria-expanded":I,title:R?I?"Hide the recap":"Show Claude Code's recap":I?"Hide this note":"Show what this session is doing",onClick:O=>{O.stopPropagation(),Y7(E)},children:a.jsx(Gh,{recap:R})})]}),a.jsx("div",{className:"head-right",children:i&&e.onOpenContext&&a.jsx(D7,{currentContextTokens:o,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),a.jsxs("div",{className:"sub",title:p7(e),children:[a.jsxs("span",{className:"sub-details",ref:h,children:[k.kind&&a.jsx("span",{children:Ff(e)}),e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:f7(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"&&a.jsxs("span",{className:"sub-folder",ref:f,children:[k.kind?"· ":"",e.cwdBasename]}),e.model?a.jsxs("span",{className:"model-chip","data-family":Of(e.model),title:v,children:[Pf(e.model,k.effort?e.effort:void 0),d.length>0?` +${d.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),a.jsxs("span",{className:"time",title:e.synthetic?`The deck joined this session after it began, so it has run at least this long — first seen ${new Date(e.startedAt).toLocaleTimeString()}`:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:[e.synthetic?"≥ ":"",a.jsx(U9,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&N.face&&a.jsx("div",{className:"session-name",title:N.tooltip,children:N.face}),e.waiting&&a.jsx(H9,{waiting:e.waiting}),(()=>{const O=ZO(e);return O?a.jsxs("div",{className:"approval-blind-row",title:O.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:O.label})]}):null})(),(()=>{const O=bu(e.plan);return O&&e.plan?a.jsx(B9,{plan:O,items:e.plan.items}):null})(),(e.tools.length>0||(((U=e.outputs)==null?void 0:U.length)??0)>0)&&a.jsx(z9,{tools:e.tools,outputs:e.outputs}),a.jsxs("div",{className:"meta",children:[a.jsxs("span",{children:[a.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),s>0&&a.jsxs("span",{className:"failed-meta",title:`${s} tool ${s===1?"call":"calls"} returned an error`,children:[a.jsx("b",{children:s})," err"]}),n>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:n})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&a.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[a.jsx("b",{children:gt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),($==null?void 0:$.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:$.tt,children:Kr}),($==null?void 0:$.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:$.tt,children:a.jsxs("b",{children:[Xe($.total),$.floor?"+":""]})})]}),a.jsx(q9,{data:e,title:e.kind==="root"?N.face:void 0}),a.jsx(Bo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}const F9=y.memo(D9);function B9({plan:e,items:t}){return a.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:$O(t),children:[a.jsx("span",{className:"plan-meter","aria-hidden":!0,style:{"--plan-done":e.done/e.total}}),a.jsxs("span",{className:"plan-count",children:[e.done,"/",e.total]}),a.jsx("span",{className:"plan-step",children:e.allDone||!e.current?"done":a.jsxs(a.Fragment,{children:[e.next&&a.jsx("span",{className:"plan-next",children:"next: "}),e.current]})})]})}function q9({data:e,title:t}){const n=e.kind==="root"&&Mn(e.waiting),s=r9(e,e.branch,{sayWaiting:zh,describeCall:r=>({name:k1(r.name).label,subject:R9(r.name,r.input)})});return a.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":s?"":void 0,"aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsx(y3,{kind:qk(e.state)}),a.jsx("span",{className:"lod-name",children:e.label}),s&&a.jsx("span",{className:"lod-inline","data-tone":s.tone,children:s.short}),n&&a.jsx(j1,{})]}),t&&a.jsx("div",{className:"lod-title",children:t}),s&&a.jsxs("div",{className:"lod-signal","data-tone":s.tone,children:[a.jsx("span",{className:"lod-long",children:s.long}),a.jsx("span",{className:"lod-short",children:s.short})]})]})}function U9({start:e,end:t}){const n=Go(1e3);return a.jsx(a.Fragment,{children:cl(e,t,n)})}function W9({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:il(e)})}function H9({waiting:e}){const t=Go(1e3),n=Mn(e),s=ll(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
|
|
84
|
-
Blocked for ${cl(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:zh(e)}),a.jsx("b",{children:cl(e.since,void 0,t)})]})}function z9({tools:e,outputs:t}){const n=Go(1e3),{counts:s,title:r}=L9(e,t,n),o=Eg/Ji;return a.jsxs("div",{className:"tool-spark-row",title:r,children:[a.jsx("svg",{className:"tool-spark",width:Eg,height:_h,viewBox:`0 0 ${Eg} ${_h}`,"aria-hidden":!0,children:s.map((i,c)=>{const d=P9(i),h=c===Ji-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:_h-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function V9({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}const N1="agent-dag.single-key-shortcuts";function x3(e){return e!=="0"}function v3(e){return e.length===1}function b3(e,t){return!t&&v3(e)}function gn(e,t,n){return n?`${e} (${t})`:e}let Io=null;const Cc=new Set;function k3(){for(const e of Cc)e()}function Wk(){return Io===null&&(Io=x3(Ve(N1))),Io}function G9(e){Io!==e&&(Io=e,ze(N1,e?"1":"0"),k3())}function xE(e){if(e.key!==N1)return;const t=x3(e.newValue);t!==Io&&(Io=t,k3())}function K9(e){var t;return Cc.add(e),Cc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",xE)),()=>{var n;Cc.delete(e),Cc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",xE))}}function Kh(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const vE=99;function Y9(e){const t=Math.max(0,Math.floor(e));return t>vE?`${vE}+`:String(t)}const X9="Pause the canvas";function Z9(e){const t=e.singleKeys??!0;if(!e.paused)return gn("Pause live updates — events keep arriving and are applied when you resume","Space",t);const n=Math.max(0,Math.floor(e.dropped??0));return n>0?gn(`The pause is full — ${Kh(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?gn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):gn(`${Kh(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function J9(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const j3="paused · full",Q9=(e,t)=>t>0?j3:e>0?`paused · ${Y9(e)}`:"paused";function eV(e){const t=Math.max(0,Math.floor(e.dropped??0)),n=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:Q9(e.held,t),widest:j3,title:gn(t>0?`Connected — the pause is full at ${Kh(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${Kh(e.held)} held until you resume`:"Connected — updates held until you resume","Space",n)}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function Ln(){return y.useSyncExternalStore(K9,Wk,Wk)}const tV=e=>e.transform[2]>=e.maxZoom,nV=e=>e.transform[2]<=e.minZoom;function sV({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:r,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=ml(),h=tt(tV),f=tt(nV),p=Ln();return a.jsxs(mH,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(is,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(is,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(is,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(is,{"data-group-start":"",onClick:r,title:Z9({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":X9,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(is,{onClick:o,title:gn("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(is,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:gn("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(is,{"data-group-start":"",onClick:()=>c(m=>!m),title:p?gn("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const rV="modulepreload",aV=function(e){return"/"+e},bE={},Nu=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){let i=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=i(n.map(h=>{if(h=aV(h),h in bE)return;bE[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":rV,f||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),f)return new Promise((w,j)=>{m.addEventListener("load",w),m.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return r.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},kE="agent-dag.fm-custom-stations",jE="agent-dag.fm-muted",Hk="custom:",oV=/^UC[A-Za-z0-9_-]{22}$/,iV=/^[A-Za-z0-9_-]{11}$/,N3=/^[A-Za-z0-9_-]{1,80}$/,lV=/\.(mp3|aac|ogg)$/i,cV=/\.m3u8$/i,uV=2048,S3=80;function dl(e){return`${Hk}${e}`}function Hf(e){if(!e.startsWith(Hk))return null;const t=e.slice(Hk.length);return N3.test(t)?t:null}function NE(e){return Hf(e)??e}function S1(e){var i,c;const t=e.trim();if(t.length>uV)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const s=n.toString(),r=n.hostname.toLowerCase();if(r==="youtube.com"||r==="www.youtube.com"||r==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&oV.test(d))return{kind:"youtube-channel",url:s,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:s,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(iV.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return cV.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:lV.test(n.pathname)?{kind:"direct-audio",url:s,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:s,format:"audio"}}function dV(e){return e==="1"}function hV(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,s=[];for(const r of t){if(!r||typeof r!="object")continue;const o=typeof r.id=="string"?r.id:"",i=typeof r.name=="string"?r.name.trim():"",c=typeof r.url=="string"?r.url.trim():"",d=S1(c);if(!N3.test(o)||n.has(o)||!i||i.length>S3||!d)continue;n.add(o);const h=_3(r.radio);s.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return s}function fV(e,t,n){const s=Hf(e??"");return s&&t.some(r=>r.id===s)?dl(s):n(e)}function pV(e,t){return e===dl(t)?"claude-fm":e}function _3(e){if(!e||typeof e!="object")return null;const t=e,n=(r,o)=>typeof t[r]=="string"?t[r].slice(0,o):"",s=(r,o)=>typeof t[r]=="number"&&Number.isFinite(t[r])&&Math.abs(t[r])<=o?t[r]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:s("lat",90),lon:s("lon",180)}}const zk="https://www.youtube-nocookie.com";function mV(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${zk}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function Mi(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function gV(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const yV=[1],wV=[0,2],xV=[2,5,100,101,150,153];function vV(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:s}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const r=typeof s=="number"?s:Number(s==null?void 0:s.errorCode);return Number.isFinite(r)?{kind:"error",code:r}:null}if(n==="onStateChange"||n==="infoDelivery"){const r=typeof s=="number"?s:s==null?void 0:s.playerState;return typeof r!="number"||!Number.isFinite(r)?null:yV.includes(r)?{kind:"playing",playing:!0}:r===3?{kind:"buffering"}:wV.includes(r)?{kind:"playing",playing:!1}:null}return null}const wc=new Set;let SE="";function _E(e){const t=new Date().toISOString().slice(0,10);if(t!==SE&&(wc.clear(),SE=t),!wc.has(e)){wc.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&wc.delete(e)}catch{wc.delete(e)}}}const EE=864e5,bV=6e4;function nn(e,t=!0){y.useEffect(()=>{if(!t)return;_E(e);let n;const s=()=>{n=setTimeout(()=>{_E(e),s()},EE-Date.now()%EE+bV)};return s(),()=>clearTimeout(n)},[e,t])}const kV={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function jV({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:r,playRequest:o,customStation:i,onAvailabilityChange:c}){var q;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(!1),[j,b]=y.useState(!1),[k,v]=y.useState(!1);nn("claude-fm",j);const N=y.useRef(o),S=y.useRef(null),E=y.useRef(null),C=y.useRef(void 0),I=y.useRef(null),R=y.useCallback(()=>{var D;clearTimeout(C.current),(D=E.current)==null||D.destroy(),E.current=null;const A=S.current;A&&(A.pause(),A.removeAttribute("src"),A.load(),S.current=null)},[]),$=y.useCallback(A=>{var D,P;(P=(D=I.current)==null?void 0:D.contentWindow)==null||P.postMessage(A,zk)},[]),L=y.useRef(n);L.current=n;const U=y.useRef(s);U.current=s;const O=y.useCallback((A,D,P)=>{R();const K=new Audio;K.preload="none",K.volume=L.current/100,K.muted=U.current,S.current=K,w(!0),b(!1),v(!1);let G=!1;const W=()=>S.current===K,H=()=>{clearTimeout(C.current),R(),w(!1),b(!1),v(!1)},F=()=>{W()&&(H(),p(!0),c==null||c(P,!0))},B=V=>{if(W()&&!(V instanceof DOMException&&V.name==="AbortError")){if(V instanceof DOMException&&V.name==="NotAllowedError"){H();return}F()}};C.current=setTimeout(()=>{W()&&!G&&F()},15e3),K.addEventListener("playing",()=>{W()&&(clearTimeout(C.current),G=!0,b(!0),v(!1),c==null||c(P,!1))});const Z=()=>{W()&&(b(!1),v(G),clearTimeout(C.current),C.current=setTimeout(()=>{W()&&F()},15e3))};K.addEventListener("waiting",Z),K.addEventListener("stalled",Z),K.addEventListener("ended",()=>{W()&&H()}),K.addEventListener("error",F,{once:!0}),D&&!K.canPlayType("application/vnd.apple.mpegurl")?Nu(async()=>{const{default:V}=await import("./hls-BFpXDghs.js");return{default:V}},[]).then(({default:V})=>{if(!W())return;if(!V.isSupported()){F();return}const X=new V;E.current=X,X.on(V.Events.ERROR,(Y,J)=>{J.fatal&&F()}),X.on(V.Events.MEDIA_ATTACHED,()=>X.loadSource(A)),X.on(V.Events.MANIFEST_PARSED,()=>{K.play().catch(B)}),X.attachMedia(K)},F):(K.src=A,K.play().catch(B))},[c,R]);y.useEffect(()=>{m&&($(Mi("setVolume",[n])),$(Mi(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,$]),y.useEffect(()=>{var H;let A=!0;const D=e??fetch,P=N.current!==o;if(N.current=o,h(null),p(!1),v(!1),w(P),b(!1),R(),!t){w(!1),b(!1);return}const K=i&&dl(i.id)===r?S1(i.url):null;if(K){if(K.kind==="direct-audio"){const F=K.format==="hls"||((H=i==null?void 0:i.radio)==null?void 0:H.hls)===!0;return h({live:!0,channel:"",audio:K.url,hls:F}),c==null||c(r,!1),P&&O(K.url,F,r),()=>{A=!1}}return D(`/api/fm-station?url=${encodeURIComponent(K.url)}`).then(F=>F.ok?F.json():null).then(F=>{A&&(F!=null&&F.channel||F!=null&&F.video?(h({live:!0,channel:F.channel??"",video:F.video??void 0}),c==null||c(r,!1)):(p(!0),w(!1),b(!1),v(!1),c==null||c(r,!0)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),v(!1),c==null||c(r,!0))}),()=>{A=!1}}if(Hf(r))return p(!0),c==null||c(r,!0),()=>{A=!1};const G=r,W=kV[G];if(W)D(W).then(F=>F.ok?F.json():null).then(F=>{A&&(F!=null&&F.video&&h({live:!0,channel:"",video:F.video}),F!=null&&F.video||(p(!0),w(!1),b(!1)),c==null||c(r,!(F!=null&&F.video)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))});else if(G!=="claude-fm"){const F=G.replace("lofi-","");D(`/api/lofi-girl?station=${encodeURIComponent(F)}`).then(B=>B.ok?B.json():null).then(B=>{A&&(B!=null&&B.video&&h({live:!0,channel:"",video:B.video}),B!=null&&B.video||(p(!0),w(!1),b(!1)),c==null||c(r,!(B!=null&&B.video)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))})}else D("/api/claude-fm").then(F=>F.ok?F.json():null).then(F=>{if(!A)return;const B=!!(F!=null&&F.live&&(F!=null&&F.channel));B&&h({live:!0,channel:F.channel}),B||(p(!0),w(!1),b(!1)),c==null||c(r,!B)}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))});return()=>{A=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(q=i==null?void 0:i.radio)==null?void 0:q.hls,t,e,c,o,r,O,R]),y.useEffect(()=>()=>R(),[R]),y.useEffect(()=>{if(!m||d!=null&&d.audio)return;let A;const D=()=>{clearTimeout(A),A=void 0,w(!1),b(!1),v(!1),p(!0),c==null||c(r,!0)},P=()=>{A??(A=setTimeout(D,15e3))};P();const K=G=>{var H;if(G.origin!==zk||G.source!==((H=I.current)==null?void 0:H.contentWindow))return;const W=vV(G.data);if(W){if(W.kind==="ready"){$(Mi("setVolume",[L.current])),$(Mi(U.current?"mute":"unMute")),$(Mi("playVideo"));return}if(W.kind==="blocked"){clearTimeout(A),A=void 0,w(!1),b(!1),v(!1);return}if(W.kind==="buffering"){b(!1),v(!0),P();return}if(W.kind==="playing"){clearTimeout(A),A=void 0,b(W.playing),v(!1),W.playing||w(!1);return}xV.includes(W.code)&&D()}};return window.addEventListener("message",K),()=>{clearTimeout(A),window.removeEventListener("message",K)}},[m,d==null?void 0:d.audio,o,c,$,r]);const M=y.useCallback(()=>{if(d){if(d.audio){if(m){R(),w(!1),b(!1),v(!1);return}O(d.audio,d.hls===!0,r);return}if(!m){w(!0),b(!1),v(!1);return}$(Mi("pauseVideo")),w(!1),b(!1),v(!1)}},[d,m,j,r,$,O,R]);return y.useMemo(()=>({probe:d,dead:f,armed:m,playing:j,buffering:k,frame:I,say:$,press:M}),[d,f,m,j,k,$,M])}const CE="agent-dag.radio-favorites",TE="agent-dag.radio-recent",RE="agent-dag.radio-catalogue";function NV(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const s=n,r=typeof s.id=="string"?s.id:"",o=typeof s.name=="string"?s.name.trim().slice(0,80):"",i=typeof s.url=="string"?S1(s.url):null,c=_3(s.radio??s);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(r)||!o||!c||!i||i.kind!=="direct-audio"||t.has(r)?[]:(t.add(r),[{id:r,name:o,url:i.url,radio:c}])})}function AE(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function SV(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function Cwe(e,t,n=Math.random){const s=e.filter(r=>r.id!==t);return s.length?s[Math.min(s.length-1,Math.floor(Math.max(0,n())*s.length))]:null}function Twe(e,t,n){if(!e.length)return null;const s=e.findIndex(o=>o.id===t),r=e[s<0?n===1?0:e.length-1:(s+n+e.length)%e.length];return r.id===t?null:r}function E3(e,t,n){const s=e.findIndex(r=>r.id===t);for(let r=1;r<=e.length;r++){const o=e[(s+r)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function Rwe(e,t){if(!e.length)return null;const n=[...e].sort((r,o)=>r.id.localeCompare(o.id));let s=0;for(const r of t)s=Math.imul(s,31)+r.charCodeAt(0)>>>0;return n[s%n.length]}function Awe(e,t,n,s,r){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!s||e.radio.tags.toLowerCase().includes(s.toLowerCase()))&&(!r||e.radio.language.toLowerCase().includes(r.toLowerCase()))}function _V(){const[e,t]=y.useState(()=>AE(Ve(CE))),[n,s]=y.useState(()=>AE(Ve(TE))),[r,o]=y.useState(()=>{try{return NV(JSON.parse(Ve(RE)??"[]"))}catch{return[]}});y.useEffect(()=>{ze(CE,JSON.stringify(e))},[e]),y.useEffect(()=>{ze(TE,JSON.stringify(n))},[n]);const i=y.useCallback(h=>s(f=>SV(f,h)),[]),c=y.useCallback(h=>t(f=>f.includes(h)?f.filter(p=>p!==h):[...f,h].slice(-100)),[]),d=y.useCallback(h=>{o(h),ze(RE,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:r,remember:i,toggleFavorite:c,updateCatalogue:d}}function EV(e,t,n,s){const r=E3(e,t,n);if(!r)return()=>{};const o=setTimeout(()=>{n.add(t),s(r)},1e3);return()=>clearTimeout(o)}const zf=148,ME=6e3,CV=16e3,C3=46,$a=34;function TV(e,t,n=zf){let s=-Math.round(t()*n);if(Math.abs(s-e)<$a){const r=e-$a>=-n?-$a:$a;s=Math.max(-n,Math.min(0,Math.round(e+r)))}return{to:s,ms:Math.round(Math.abs(s-e)*C3)}}function RV(e){return Math.round(ME+e()*(CV-ME))}const $E=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function AV(e){const t=$E.reduce((s,r)=>s+r.weight,0);let n=e()*t;for(const s of $E)if(n-=s.weight,n<0)return s.kind;return"stroll"}const MV=720,$V=260,IV=620,LV=220,IE=520,T3=1600,LE=7e3,OV=15e3,OE=6e3,PV=14e3;function $i(e,t,n=zf){let s=-Math.round(t()*n);if(Math.abs(s-e)<$a){const r=e-$a>=-n?-$a:$a;s=Math.max(-n,Math.min(0,Math.round(e+r)))}return s}const Gt=(e,t)=>Math.round(Math.abs(t-e)*C3),DV=120,nh=0;function FV(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:Gt(e,t)},{x:t,prop:n({}),act:"stoop",ms:MV},{x:nh,prop:n({held:!0}),act:"carry",ms:Gt(t,nh)},{x:nh,prop:n({held:!0}),act:"windup",ms:$V},{x:nh,prop:n({held:!0,leaving:!0}),act:"toss",ms:IV}]}function BV(e,t){const n=t>e?1:-1,s=t-n*Math.min(15,Math.abs(t-e)),r=(o={})=>({kind:"ball",at:t,...o});return[{x:s,prop:r(),act:"walk",ms:Gt(e,s)},{x:s,prop:r(),act:"windup",ms:LV,facing:n>0?"right":"left"},{x:s,prop:r({leaving:!0}),act:"kick",ms:IE,facing:n>0?"right":"left"},{x:s,prop:r({leaving:!0}),act:"stand",ms:T3-IE}]}const R3=640;function qV(e,t,n){const s=Math.max(-70,Math.min(-20,t)),r={x:s,prop:null,facing:"left"};return[{x:s,prop:null,act:"walk",ms:Gt(e,s)},{...r,act:"sit",ms:600},{...r,act:"cast",ms:900},{...r,act:"fish",ms:6e3+Math.round(n()*4e3)},{...r,act:"reel",ms:1200},{...r,act:"stow",ms:500},{...r,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Gt(s,0)}]}function UV(e,t,n){const s=Math.max(-110,Math.min(-30,t)),r={x:s,prop:null};return[{...r,act:"walk",ms:Gt(e,s)},{...r,act:"skip-ready",ms:500},{...r,act:"skip",ms:R3*(6+Math.floor(n()*5))},{...r,act:"skip-rest",ms:600},{...r,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Gt(s,0)}]}function WV(e,t,n){return[{x:t,prop:null,act:"walk",ms:Gt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(OE+n()*(PV-OE))},{x:t,prop:null,act:"stand",ms:400}]}function HV(e,t,n){t=Math.max(-110,Math.min(0,t));const s=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Gt(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(LE+n()*(OV-LE))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Cg(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const zV=1500,VV=e=>Math.round(1e3*Math.sqrt(2*e/zV)),GV=115,KV=e=>Math.round(e/GV*1e3),YV=620,XV=200,ZV=760,JV=600,QV=240;function eG(e,t,n){const r=-(t.ledgeSpan??zf),o=VV(t.ledgeH),i=KV(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:r,act:"walk",prop:null,ms:Gt(e,r)},{x:r,act:"peer",prop:null,ms:YV},{x:r,act:"fall",prop:null,ms:o,place:"floor"},{x:r,act:"land",prop:null,ms:XV,place:"floor"},{x:h,act:"walk",prop:null,ms:Gt(r,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Gt(h,f),place:"floor",floorFrac:d},{x:r,act:"walk",prop:null,ms:Gt(f,r),place:"floor"},{x:r,act:"lasso",prop:null,ms:ZV,place:"floor"},{x:r,act:"rope-throw",prop:null,ms:JV,place:"floor"},{x:r,act:"rope-catch",prop:null,ms:QV,place:"floor"},{x:r,act:"climb",prop:null,ms:i},{x:r,act:"pull-up",prop:null,ms:480}]}function tG(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??zf;switch(AV(t)){case"tidy":return FV(e,$i(e,t,s));case"kick":return BV(e,$i(e,t,s));case"sit":return WV(e,$i(e,t,s),t);case"watch":return HV(e,$i(e,t,s),t);case"fish":return qV(e,$i(e,t,s),t);case"skip":return UV(e,$i(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return eG(e,n,t)}}const o=TV(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const nG=420;function sG(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(nG,Math.max(0,s))}const rG=260,aG=200;function oG(e,t,n){const s=(f,p=Gt(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[s(t)];const r=Math.min(e,t);if(Math.max(e,t)<=n.left||r>=n.right)return[s(t)];const i=t>e,c=i?n.left:n.right,d=i?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[s(c,Gt(e,c)),{...h,x:c,act:"mount",ms:rG},{...h,x:d,act:"walk",ms:Gt(c,d)},{x:d,prop:null,act:"dismount",ms:aG,place:"floor"},{x:t,prop:null,act:"walk",ms:Gt(d,t),place:"floor"}]}const A3=["bob","sway","groove"],PE=9e3,iG=16e3,M3=1e3,lG=.08;function cG(e,t){const n=A3.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],r=(t()*2-1)*lG;return{dance:s,beatMs:Math.round(M3*(1+r))}}function uG(e){return Math.round(PE+e()*(iG-PE))}const _1=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],DE=18,dG=_1.length,$3="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",I3="M12 9H14V6H13V3H11V2H9V4H12Z",E1=new Set(["a","c","p"]);function Ga(e=_1){const t=[];return e.forEach((n,s)=>{let r=0;for(;r<n.length;){const o=n[r];if(o==="."){r+=1;continue}let i=1;for(;r+i<n.length&&n[r+i]===o;)i+=1;t.push({x:r,y:s,w:i,cell:o}),r+=i}}),t}const hG=[".xx.","xxxx",".xx."],fG=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],pG=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],Tg={litter:hG,ball:fG,scope:pG},mG=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],gG=3,yG=-1,Vk=11,FE=9;function BE(e){let t=null,n=null,s=0,r=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(r=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},s))},d=()=>{e.hidden&&t!==null?(s=Math.max(0,s-(performance.now()-r)),i()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(i(),n=h,s=Math.max(0,f),c())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",d)}}}function wG(e,t,n){const[s,r]=y.useState(0),[o,i]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,m]=y.useState({x:0,drop:0}),[w,j]=y.useState("ledge"),[b,k]=y.useState("left"),[v,N]=y.useState(0),S=y.useRef(null),[E,C]=y.useState(()=>document.hidden);y.useEffect(()=>{const M=new Set,q=()=>{var A;if(document.hidden){for(const D of((A=S.current)==null?void 0:A.getAnimations({subtree:!0}))??[])if(D.playState==="running"||D.pending){const P=D.currentTime;D.pause(),P!==null&&(D.currentTime=P),M.add(D)}}else{for(const D of M)D.playState==="paused"&&D.play();M.clear()}C(document.hidden)};return q(),document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[e,t]);const[I,R]=y.useState(null),[$,L]=y.useState(M3),[U,O]=y.useState(()=>{var M;return((M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var A;const M=(A=window.matchMedia)==null?void 0:A.call(window,"(prefers-reduced-motion: reduce)");if(!M)return;const q=()=>O(M.matches);return q(),M.addEventListener("change",q),()=>M.removeEventListener("change",q)},[]),y.useEffect(()=>{var J;if(!e||t||U)return;const M=BE(document);let q=0;r(ee=>q=ee);let A=null,D=0,P=0;const K=ee=>{var re,pe;const[ne,...le]=ee;if(!ne){A=null,d(null),f(null),V();return}d(ne.act),f(ne.prop),j(ne.place??"ledge"),N(ne.riser??0);const de=q,ue=B(ne);if(ne.act==="kick"){const ye=(pe=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:pe.getBoundingClientRect();ye&&m({x:sG(ye.x,Cg(ne,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-ye.y+24)})}P=ne.act==="walk"?Math.max(Gt(de,ue),DV):ne.ms,ne.act==="carry"&&(P=Gt(de,ue)),i(P),k(ye=>Cg({...ne,x:ue},de,ye)),r(ue),q=ue,A=ne,D=Date.now(),M.schedule(()=>K(le),P)},G=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite"),le=ee==null?void 0:ee.parentElement;if(!ee||!ne||!le)return null;const de=ee.getBoundingClientRect(),ue=le.getBoundingClientRect(),re=ue.right-de.right,pe=ue.width-re*2-ne.offsetWidth;return pe>0?pe:null},W=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!ne?0:Math.max(0,ee.getBoundingClientRect().width-ne.offsetWidth)},H=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-walker"),le=G();if(!ee||!ne||le==null)return;const de=ee.getBoundingClientRect().bottom-ne.getBoundingClientRect().bottom;if(de>0)return{ledgeH:de,floorSpan:le,ledgeSpan:W()}},F=()=>{const ee=S.current,ne=document.querySelector(".canvas-notices");if(!ee||!ne)return null;const le=ee.getBoundingClientRect(),de=ne.getBoundingClientRect();return de.width<=0||de.height<=0?null:{left:de.left-le.right,right:de.right-le.right,height:de.height}},B=ee=>{const ne=(ee.place??"ledge")==="floor",le=ne?G()??W():W(),de=ne&&ee.floorFrac!=null?-Math.round(ee.floorFrac*le):ee.x;return Math.max(-le,Math.min(0,de))},Z=()=>{if(!A)return;const ee=B(A);ee!==q&&(i(Math.max(0,D+P-Date.now())),k(ne=>Cg({...A,x:ee},q,ne)),r(ee),q=ee)},V=()=>{M.schedule(()=>{const ee=tG(q,Math.random,H()),ne=ee.some(ue=>ue.place==="floor")?F():null;let le=q;const de=ee.flatMap(ue=>{const re=le;if(le=ue.x,!(ue.place==="floor"&&ue.act==="walk"))return[ue];const pe=oG(re,ue.x,ne),ye=pe.length-1;return ue.floorFrac==null?pe:pe.map((_e,he)=>he===ye?{..._e,floorFrac:ue.floorFrac}:_e)});K(de)},RV(Math.random))},X=(J=S.current)==null?void 0:J.parentElement,Y=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&Y&&Y.observe(X),V(),()=>{M.dispose(),Y==null||Y.disconnect(),j("ledge"),r(ee=>Math.max(-W(),Math.min(0,ee))),i(0),d(null),f(null),N(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){R(null);return}const M=BE(document),q=A=>{const D=cG(A,Math.random);R(D.dance),L(D.beatMs),M.schedule(()=>q(D.dance),uG(Math.random))};return q(null),()=>M.dispose()},[n,U]),{scene:S,suspended:E,x:s,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:b,riser:v,dance:I,beatMs:$}}const Rg={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Yh=Ga().filter(e=>!E1.has(e.cell)),xG=Ga().filter(e=>E1.has(e.cell)),qE=Yh.filter(e=>e.cell==="e"),vG=Ga(mG),bG=Yh.filter(e=>e.y<Vk&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),kG={left:Yh.filter(e=>e.y>=Vk&&e.x<FE),right:Yh.filter(e=>e.y>=Vk&&e.x>=FE)},jG=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${DE} ${dG}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:xG.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Rg[s.cell]},`g${s.y}-${s.x}`))})}),a.jsxs("g",{className:"fm-body",children:[qE.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),bG.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Rg[s.cell]},`b${s.y}-${s.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),qE.map(s=>a.jsx("rect",{x:s.x-(s.x>=DE/2?1:0)+(n==="right"?1:0),y:s.y,width:s.w,height:1,className:"fm-eye"},`eye-${s.x}`))]}),a.jsx("g",{className:"fm-hat",children:vG.map(s=>a.jsx("rect",{x:gG+s.x,y:yG+s.y,width:s.w,height:1,className:s.cell==="k"?"fm-hatband":void 0},`h${s.y}-${s.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:$3}),a.jsx("path",{className:"fm-grip-right",d:I3})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(s=>a.jsx("g",{className:"fm-leg","data-side":s,children:kG[s].map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Rg[r.cell]},`${s}${r.y}-${r.x}`))},s))]})}),NG=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],SG=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],ar={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},_G={p:"fm-pad"},ru=Ga(NG),EG=Ga(SG);function Gk(e,t,n){return e.map(s=>({...s,x:Math.max(t,s.x),w:Math.max(0,Math.min(n,s.x+s.w)-Math.max(t,s.x))})).filter(s=>s.w>0)}const CG=Gk(ru.filter(e=>e.y>=8),12,18),TG=ru.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),UE=ru.filter(e=>e.cell==="e"),RG={left:Gk(ru.filter(e=>e.y>=11),0,9),right:Gk(ru.filter(e=>e.y>=11),9,12)},AG=y.memo(function({act:t,facing:n}){const s=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",r=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-body","data-part":"tail",children:CG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar[i.cell]},`t${i.y}-${i.x}`))}),a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:EG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:_G[i.cell]},`g${i.y}-${i.x}`))})}),a.jsxs("g",{className:"fm-body",children:[TG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar[i.cell]},`b${i.y}-${i.x}`)),UE.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar.f},`bed${i.x}`)),a.jsxs("g",{className:"fm-arms",fill:ar.f,children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2})]}),UE.map(i=>a.jsx("rect",{x:i.x+(n==="right"?1:0)-(i.x>=9?1:0),y:i.y,width:i.w,height:1,className:"fm-eye",style:{fill:ar.n}},`e${i.x}`))]}),s&&a.jsxs("g",{className:"fm-grip",style:{fill:ar.f},children:[a.jsx("path",{className:"fm-grip-left",d:$3}),a.jsx("path",{className:"fm-grip-right",d:I3})]}),r&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:ar.f},children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:ar.f},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:ar.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>a.jsx("g",{className:"fm-leg","data-side":i,children:RG[i].map(c=>a.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:ar[c.cell]},`${c.y}-${c.x}`))},i))]})}),MG=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Pr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},$G={p:"fm-pad"},Xh=Ga(MG),IG=Ga(_1).filter(e=>E1.has(e.cell)),WE=Xh.filter(e=>e.cell==="e"),LG=Xh.filter(e=>e.y<12&&e.cell!=="e"),OG={left:Xh.filter(e=>e.y>=12&&e.x<9),right:Xh.filter(e=>e.y>=12&&e.x>=9)},PG=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",r=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:IG.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:$G[o.cell]},`g${o.y}-${o.x}`))})}),a.jsxs("g",{className:"fm-body",children:[LG.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Pr[o.cell]},`b${o.y}-${o.x}`)),WE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Pr.w},`bed${o.x}`)),a.jsxs("g",{className:"fm-arms",fill:Pr.d,children:[a.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),a.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),WE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Pr.e}},`e${o.x}`))]}),n&&a.jsxs("g",{className:"fm-grip",style:{fill:Pr.h},children:[a.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),s&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:Pr.b},children:[a.jsx("path",{d:"M5 12H8V13H5Z"}),a.jsx("path",{d:"M10 12H13V13H10Z"})]}),r&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:Pr.b},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:Pr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),a.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>a.jsx("g",{className:"fm-leg","data-side":o,children:OG[o].map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Pr.b},`${i.y}-${i.x}`))},o))]})});function L3({character:e,act:t,facing:n}){return e==="penguin"?a.jsx(PG,{act:t,facing:n}):e==="fox"?a.jsx(AG,{act:t,facing:n}):a.jsx(jG,{act:t,facing:n})}const DG={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function O3(e,t){return t&&dl(t.id)===e?t.name:Hf(e)?"Custom FM":DG[e]}function Ag(e,t){var s;const n=((s=e[0])==null?void 0:s.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:Ga(e).map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:r.cell==="s"?"var(--fm-prop-shadow, var(--bg))":r.cell==="l"?"var(--fm-prop-light, var(--text))":r.cell==="a"?"var(--accent)":void 0},`${t}${r.y}-${r.x}`))})}const HE={litter:Ag(Tg.litter,"litter"),ball:Ag(Tg.ball,"ball"),scope:Ag(Tg.scope,"scope")};function FG(e){try{return new URL(e).host}catch{return"the station's server"}}const BG=y.memo(function({player:t,source:n,customStation:s,character:r="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:m,act:w,prop:j,ballFlight:b,place:k,facing:v,riser:N,dance:S,beatMs:E}=wG(o,i,c);if(!o||i)return null;const C=O3(n,s),I=o.audio?FG(o.audio):"YouTube";return a.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":k,style:{"--fm-beat":`${E}ms`},children:[j&&!j.held&&a.jsx("div",{className:"fm-prop","data-prop":j.kind,"data-leaving":j.leaving?"":void 0,style:{"--fm-prop-x":`${j.at}px`,"--fm-roll-to":`${b.x}px`,"--fm-ball-drop":`${b.drop}px`,"--fm-ball-flight-ms":`${T3}ms`,"--fm-ball-turn":v==="right"?"1080deg":"-1080deg"},children:HE[j.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${m}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":w??void 0,"data-place":k,"data-facing":v,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${N}px`,"--fm-skip-beat":`${R3}ms`},children:[(j==null?void 0:j.held)&&a.jsx("div",{className:"fm-held","data-prop":j.kind,"data-toss":j.leaving?"":void 0,children:HE[j.kind]}),["cast","fish","reel","stow"].includes(w)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":c?"":void 0,"data-dance":c?S??A3[0]:void 0,onClick:d,title:c?`Stop ${C}`:`Play ${C} — streams from ${I}`,"aria-label":c?`Stop ${C}`:`Play ${C}`,children:a.jsx(L3,{character:r,act:w,facing:v})})]})]})});function qG({player:e,label:t}){const{probe:n,armed:s,frame:r,say:o}=e;return n?a.jsx(a.Fragment,{children:s&&!n.audio&&(n.channel||n.video)&&a.jsx("iframe",{ref:r,className:"fm-frame",title:t,src:mV(n.channel,window.location.origin,n.video),onLoad:()=>o(gV()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const UG={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6",headphones:"M4 14v-3a8 8 0 0 1 16 0v3 M4 12h3v8H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 1-2 M20 12h-3v8h2a2 2 0 0 0 2-2v-4a2 2 0 0 0-1-2",book:"M12 6v15 M12 6C9 4 6 3 3 4v15c3-1 6 0 9 2 3-2 6-3 9-2V4c-3-1-6 0-9 2",gamepad:"M8 7h8c3 0 4 2 5 8 1 5-2 6-5 2H8c-3 4-6 3-5-2 1-6 2-8 5-8z M6 11h4 M8 9v4 M16 10h.01 M18 13h.01",sunset:"M3 17h18 M5 21h14 M7 17a5 5 0 0 1 10 0 M12 3v3 M4 8l2 2 M20 8l-2 2",moon:"M20 14A9 9 0 0 1 10 3a9 9 0 1 0 10 11z",cassette:"M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z M7 8h10v5H7z M7 20l2-4h6l2 4 M9 10.5h.01 M15 10.5h.01",palm:"M12 8c2 4 3 8 2 13 M12 8C8 3 4 4 2 8c4-1 7-1 10 0 M12 8c1-6 6-7 10-2-4-1-7 0-10 2 M12 8c-5 0-7 3-7 7 2-3 4-5 7-7 M12 8c4 0 7 3 7 7-2-3-4-5-7-7 M10 21h8",coffee:"M4 8h12v8a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4z M16 9h2a3 3 0 0 1 0 6h-2 M7 3v2 M11 3v2 M3 22h15",check:"M5 12l4 4L19 6",filters:"M4 6h4 M12 6h8 M4 12h10 M18 12h2 M4 18h2 M10 18h10 M8 4v4 M14 10v4 M6 16v4"};function WG({name:e}){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:UG[e]})})}function HG({opening:e=!1}){const[t,n]=y.useState(()=>document.hidden);return y.useEffect(()=>{const s=()=>n(document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),a.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[a.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsxs("g",{className:"radio-tuning-tower",children:[a.jsx("circle",{cx:"40",cy:"24",r:"4"}),a.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),a.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),a.jsxs("g",{className:"radio-tuning-send",children:[a.jsx("path",{d:"M75 26q7 8 0 16"}),a.jsx("path",{d:"M102 26q7 8 0 16"}),a.jsx("path",{d:"M129 26q7 8 0 16"})]}),a.jsxs("g",{className:"radio-tuning-receiver",children:[a.jsx("path",{d:"M165 49l30-22"}),a.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),a.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),a.jsx("circle",{cx:"202",cy:"65",r:"7"}),a.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),a.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),a.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function zG({onClose:e}){const[t]=y.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),n=ct(e);return a.jsxs("div",{ref:n,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":"Opening Radio","data-keyboard-interaction":t||void 0,onKeyDown:S7,children:[a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:a.jsx(WG,{name:"close"})}),a.jsx(HG,{opening:!0})]})}const VG=y.lazy(()=>Nu(()=>import("./RadioPanel-CDl7ZImm.js"),[]));function GG({fm:e,characterEnabled:t,character:n,open:s,onClose:r}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=_V(),[f,p]=y.useState(null),m=y.useRef(new Set);y.useEffect(()=>{const R=new AbortController;return fetch("/api/music-config",{signal:R.signal}).then($=>$.ok?$.json():null).then($=>{R.signal.aborted||(i(($==null?void 0:$.enabled)===!0),d($?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{R.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>R.abort()},[s]);const w=e.customFmStations.find(R=>dl(R.id)===e.fmSource),j=w!=null&&w.radio?w:void 0,b=jV({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),k=O3(e.fmSource,w),v=o&&j&&b.dead&&e.fmPlayRequest>0?E3(f??h.catalogue,j.id,m.current):null,{remember:N}=h,S=(w==null?void 0:w.id)??e.fmSource;y.useEffect(()=>{b.playing&&N(S)},[S,b.playing,N]);const E=r,C=xt(r),I=y.useCallback((R,$=!1)=>{var M;if(!o)return;$||m.current.clear();const L=dl(R.id),U=L===e.fmSource;if(U&&b.armed&&!b.dead){b.press();return}const O=U&&!!w&&(w.url!==R.url||((M=w.radio)==null?void 0:M.hls)!==R.radio.hls);e.addFmStation(R,!0),U&&!b.dead&&!O?b.press():e.pickFmSource(L,O),fetch(`/api/radio-click?id=${encodeURIComponent(R.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,b.armed,b.dead,b.press]);return y.useEffect(()=>{b.playing&&!b.dead&&m.current.clear()},[b.playing,b.dead]),y.useEffect(()=>{if(!(!o||!j||!b.dead||e.fmPlayRequest===0))return EV(f??h.catalogue,j.id,m.current,R=>I(R,!0))},[o,j==null?void 0:j.id,b.dead,e.fmPlayRequest,f,h.catalogue,I]),a.jsxs(a.Fragment,{children:[t&&a.jsx(BG,{character:n,player:b,source:e.fmSource,customStation:w}),a.jsx(qG,{player:b,label:k}),s&&wt.createPortal(a.jsx("div",{className:"modal-backdrop radio-backdrop",...C,children:a.jsx(y.Suspense,{fallback:a.jsx(zG,{onClose:E}),children:a.jsx(VG,{fm:e,player:b,library:h,selected:j,label:k,enabled:o,disabledReason:c,autoNext:v==null?void 0:v.name,onPick:I,onQueueChange:p,onClose:E})})}),document.body)]})}function P3(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Kk(e){return P3(Math.floor(e/1e3))}function Su(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),r=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return s>0?`${s}d ${r}h`:r>0?`${r}h ${o}m`:`${o}m`}function KG(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Zh(e,t,n){const s=new Date(e),r=Kk(t-e);return{label:KG(s,new Date(t))?r:`${r} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function YG({data:e}){const t=Go(3e4),n=e.note,s=n.kind==="recap",r=Zh(n.at,t),o=s?"recap-note":`recap-note is-status status-${n.kind}`,i=s?void 0:Uf(n);return a.jsxs("div",{className:o,role:"note","aria-label":s?"Claude Code's recap":`Session note: ${Oa(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",title:i,children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Gh,{recap:s}),Oa(n.kind)]}),a.jsx("span",{className:"recap-note-age",title:r.title,children:r.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":s?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),K7(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:a9(n.text,i),children:n.text}),n.reply&&a.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Gh,{recap:s}),Oa(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:r.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(Bo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}function _u(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function Eu(e){return/mac|iphone|ipad/i.test(e)}const Jh=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function XG(e,t,n){return{positions:Jh(e.positions),pinned:Jh(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function ZG(e,t){t.positions.clear();for(const[n,s]of Jh(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of Jh(e.pinned))t.pinned.set(n,s);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const zE=7e3,JG=2e3,QG=140,eK="Layout re-arranged",tK="Layout re-arranged. Undo available.",VE="Layout restored.",nK={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function sK(e,t=nK){let n=null,s=null,r=0,o=zE;const i=new Set,c=()=>{s!==null&&t.clear(s),s=null},d=()=>{c(),!(n===null||i.size>0)&&(r=t.now()+o,s=t.set(()=>{s=null,h()},o))};function h(){c(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=zE,d(),p&&e(!0)},take(){const f=n;return h(),f},close:h,hold(f){n!==null&&(i.size===0&&s!==null&&(o=Math.max(0,r-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,JG),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function rK(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function aK(e){return Eu(e)?"⌘Z":"Ctrl+Z"}function oK({undo:e}){const{open:t,said:n,undo:s,dismiss:r,hold:o,release:i}=e,c=zi(t,QG),d=y.useRef(null);return y.useEffect(()=>t?Cn.push(r,0,"popover"):void 0,[t,r]),y.useEffect(()=>{var f;if(t)return;const h=d.current;h&&h.contains(document.activeElement)&&((f=h.closest("main"))==null||f.focus({preventScroll:!0}))},[t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),Ma(c)&&a.jsxs("div",{ref:d,className:c==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>o("hover"),onPointerLeave:()=>i("hover"),onFocus:()=>o("focus"),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||i("focus")},children:[a.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:eK}),a.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:s,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",a.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:aK(_u())})]})]})]})}function iK({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:r,targetPosition:o,style:i}){const[c]=s1({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:s,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:i,children:[a.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:s,r:3.5})]})}function Yk(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Qh(e,t){const n=Yk(e);return n?n.slice(-t):e.slice(-t)}function D3(e,t,n=4){const s=Yk(e);if(!s)return Qh(e,n);let r=n;for(const o of t){if(o===e)continue;const i=Yk(o);let c=0;for(;c<s.length&&c<i.length&&s[s.length-1-c]===i[i.length-1-c];)c++;r=Math.max(r,c+1)}return s.slice(-r)}const Dc=" · ",lK=32,cK=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function GE(e){return cK.test(e)?2:1}function KE(e,t=lK){const n=[...e];let s=0;for(const i of n)s+=GE(i);if(s<=t)return e;const r=[];let o=0;for(const i of n){const c=GE(i);if(o+c>t-1)break;r.push(i),o+=c}for(;r.length&&/[\s\-_.:/]/.test(r[r.length-1]);)r.pop();return`${r.join("")}…`}function uK(e,t,n,s,r=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=s?D3(n,r):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(Dc);return{label:KE(e),name:c?KE(c):void 0,shortId:d,fullLabel:h.join(Dc),title:`${i?"waiting on you: ":""}${f}
|
|
84
|
+
Blocked for ${cl(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:zh(e)}),a.jsx("b",{children:cl(e.since,void 0,t)})]})}function z9({tools:e,outputs:t}){const n=Go(1e3),{counts:s,title:r}=L9(e,t,n),o=Eg/Ji;return a.jsxs("div",{className:"tool-spark-row",title:r,children:[a.jsx("svg",{className:"tool-spark",width:Eg,height:_h,viewBox:`0 0 ${Eg} ${_h}`,"aria-hidden":!0,children:s.map((i,c)=>{const d=P9(i),h=c===Ji-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:_h-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function V9({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}const N1="agent-dag.single-key-shortcuts";function x3(e){return e!=="0"}function v3(e){return e.length===1}function b3(e,t){return!t&&v3(e)}function gn(e,t,n){return n?`${e} (${t})`:e}let Io=null;const Cc=new Set;function k3(){for(const e of Cc)e()}function Wk(){return Io===null&&(Io=x3(Ve(N1))),Io}function G9(e){Io!==e&&(Io=e,ze(N1,e?"1":"0"),k3())}function xE(e){if(e.key!==N1)return;const t=x3(e.newValue);t!==Io&&(Io=t,k3())}function K9(e){var t;return Cc.add(e),Cc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",xE)),()=>{var n;Cc.delete(e),Cc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",xE))}}function Kh(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const vE=99;function Y9(e){const t=Math.max(0,Math.floor(e));return t>vE?`${vE}+`:String(t)}const X9="Pause the canvas";function Z9(e){const t=e.singleKeys??!0;if(!e.paused)return gn("Pause live updates — events keep arriving and are applied when you resume","Space",t);const n=Math.max(0,Math.floor(e.dropped??0));return n>0?gn(`The pause is full — ${Kh(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?gn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):gn(`${Kh(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function J9(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const j3="paused · full",Q9=(e,t)=>t>0?j3:e>0?`paused · ${Y9(e)}`:"paused";function eV(e){const t=Math.max(0,Math.floor(e.dropped??0)),n=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:Q9(e.held,t),widest:j3,title:gn(t>0?`Connected — the pause is full at ${Kh(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${Kh(e.held)} held until you resume`:"Connected — updates held until you resume","Space",n)}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function Ln(){return y.useSyncExternalStore(K9,Wk,Wk)}const tV=e=>e.transform[2]>=e.maxZoom,nV=e=>e.transform[2]<=e.minZoom;function sV({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:r,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=ml(),h=tt(tV),f=tt(nV),p=Ln();return a.jsxs(mH,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(is,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(is,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(is,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(is,{"data-group-start":"",onClick:r,title:Z9({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":X9,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(is,{onClick:o,title:gn("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(is,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:gn("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(is,{"data-group-start":"",onClick:()=>c(m=>!m),title:p?gn("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const rV="modulepreload",aV=function(e){return"/"+e},bE={},Nu=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){let i=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=i(n.map(h=>{if(h=aV(h),h in bE)return;bE[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":rV,f||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),f)return new Promise((w,j)=>{m.addEventListener("load",w),m.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return r.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},kE="agent-dag.fm-custom-stations",jE="agent-dag.fm-muted",Hk="custom:",oV=/^UC[A-Za-z0-9_-]{22}$/,iV=/^[A-Za-z0-9_-]{11}$/,N3=/^[A-Za-z0-9_-]{1,80}$/,lV=/\.(mp3|aac|ogg)$/i,cV=/\.m3u8$/i,uV=2048,S3=80;function dl(e){return`${Hk}${e}`}function Hf(e){if(!e.startsWith(Hk))return null;const t=e.slice(Hk.length);return N3.test(t)?t:null}function NE(e){return Hf(e)??e}function S1(e){var i,c;const t=e.trim();if(t.length>uV)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const s=n.toString(),r=n.hostname.toLowerCase();if(r==="youtube.com"||r==="www.youtube.com"||r==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&oV.test(d))return{kind:"youtube-channel",url:s,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:s,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(iV.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return cV.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:lV.test(n.pathname)?{kind:"direct-audio",url:s,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:s,format:"audio"}}function dV(e){return e==="1"}function hV(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,s=[];for(const r of t){if(!r||typeof r!="object")continue;const o=typeof r.id=="string"?r.id:"",i=typeof r.name=="string"?r.name.trim():"",c=typeof r.url=="string"?r.url.trim():"",d=S1(c);if(!N3.test(o)||n.has(o)||!i||i.length>S3||!d)continue;n.add(o);const h=_3(r.radio);s.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return s}function fV(e,t,n){const s=Hf(e??"");return s&&t.some(r=>r.id===s)?dl(s):n(e)}function pV(e,t){return e===dl(t)?"claude-fm":e}function _3(e){if(!e||typeof e!="object")return null;const t=e,n=(r,o)=>typeof t[r]=="string"?t[r].slice(0,o):"",s=(r,o)=>typeof t[r]=="number"&&Number.isFinite(t[r])&&Math.abs(t[r])<=o?t[r]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:s("lat",90),lon:s("lon",180)}}const zk="https://www.youtube-nocookie.com";function mV(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${zk}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function Mi(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function gV(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const yV=[1],wV=[0,2],xV=[2,5,100,101,150,153];function vV(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:s}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const r=typeof s=="number"?s:Number(s==null?void 0:s.errorCode);return Number.isFinite(r)?{kind:"error",code:r}:null}if(n==="onStateChange"||n==="infoDelivery"){const r=typeof s=="number"?s:s==null?void 0:s.playerState;return typeof r!="number"||!Number.isFinite(r)?null:yV.includes(r)?{kind:"playing",playing:!0}:r===3?{kind:"buffering"}:wV.includes(r)?{kind:"playing",playing:!1}:null}return null}const wc=new Set;let SE="";function _E(e){const t=new Date().toISOString().slice(0,10);if(t!==SE&&(wc.clear(),SE=t),!wc.has(e)){wc.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&wc.delete(e)}catch{wc.delete(e)}}}const EE=864e5,bV=6e4;function nn(e,t=!0){y.useEffect(()=>{if(!t)return;_E(e);let n;const s=()=>{n=setTimeout(()=>{_E(e),s()},EE-Date.now()%EE+bV)};return s(),()=>clearTimeout(n)},[e,t])}const kV={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function jV({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:r,playRequest:o,customStation:i,onAvailabilityChange:c}){var q;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(!1),[j,b]=y.useState(!1),[k,v]=y.useState(!1);nn("claude-fm",j);const N=y.useRef(o),S=y.useRef(null),E=y.useRef(null),C=y.useRef(void 0),I=y.useRef(null),R=y.useCallback(()=>{var D;clearTimeout(C.current),(D=E.current)==null||D.destroy(),E.current=null;const A=S.current;A&&(A.pause(),A.removeAttribute("src"),A.load(),S.current=null)},[]),$=y.useCallback(A=>{var D,P;(P=(D=I.current)==null?void 0:D.contentWindow)==null||P.postMessage(A,zk)},[]),L=y.useRef(n);L.current=n;const U=y.useRef(s);U.current=s;const O=y.useCallback((A,D,P)=>{R();const K=new Audio;K.preload="none",K.volume=L.current/100,K.muted=U.current,S.current=K,w(!0),b(!1),v(!1);let G=!1;const W=()=>S.current===K,H=()=>{clearTimeout(C.current),R(),w(!1),b(!1),v(!1)},F=()=>{W()&&(H(),p(!0),c==null||c(P,!0))},B=V=>{if(W()&&!(V instanceof DOMException&&V.name==="AbortError")){if(V instanceof DOMException&&V.name==="NotAllowedError"){H();return}F()}};C.current=setTimeout(()=>{W()&&!G&&F()},15e3),K.addEventListener("playing",()=>{W()&&(clearTimeout(C.current),G=!0,b(!0),v(!1),c==null||c(P,!1))});const Z=()=>{W()&&(b(!1),v(G),clearTimeout(C.current),C.current=setTimeout(()=>{W()&&F()},15e3))};K.addEventListener("waiting",Z),K.addEventListener("stalled",Z),K.addEventListener("ended",()=>{W()&&H()}),K.addEventListener("error",F,{once:!0}),D&&!K.canPlayType("application/vnd.apple.mpegurl")?Nu(async()=>{const{default:V}=await import("./hls-BFpXDghs.js");return{default:V}},[]).then(({default:V})=>{if(!W())return;if(!V.isSupported()){F();return}const X=new V;E.current=X,X.on(V.Events.ERROR,(Y,J)=>{J.fatal&&F()}),X.on(V.Events.MEDIA_ATTACHED,()=>X.loadSource(A)),X.on(V.Events.MANIFEST_PARSED,()=>{K.play().catch(B)}),X.attachMedia(K)},F):(K.src=A,K.play().catch(B))},[c,R]);y.useEffect(()=>{m&&($(Mi("setVolume",[n])),$(Mi(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,$]),y.useEffect(()=>{var H;let A=!0;const D=e??fetch,P=N.current!==o;if(N.current=o,h(null),p(!1),v(!1),w(P),b(!1),R(),!t){w(!1),b(!1);return}const K=i&&dl(i.id)===r?S1(i.url):null;if(K){if(K.kind==="direct-audio"){const F=K.format==="hls"||((H=i==null?void 0:i.radio)==null?void 0:H.hls)===!0;return h({live:!0,channel:"",audio:K.url,hls:F}),c==null||c(r,!1),P&&O(K.url,F,r),()=>{A=!1}}return D(`/api/fm-station?url=${encodeURIComponent(K.url)}`).then(F=>F.ok?F.json():null).then(F=>{A&&(F!=null&&F.channel||F!=null&&F.video?(h({live:!0,channel:F.channel??"",video:F.video??void 0}),c==null||c(r,!1)):(p(!0),w(!1),b(!1),v(!1),c==null||c(r,!0)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),v(!1),c==null||c(r,!0))}),()=>{A=!1}}if(Hf(r))return p(!0),c==null||c(r,!0),()=>{A=!1};const G=r,W=kV[G];if(W)D(W).then(F=>F.ok?F.json():null).then(F=>{A&&(F!=null&&F.video&&h({live:!0,channel:"",video:F.video}),F!=null&&F.video||(p(!0),w(!1),b(!1)),c==null||c(r,!(F!=null&&F.video)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))});else if(G!=="claude-fm"){const F=G.replace("lofi-","");D(`/api/lofi-girl?station=${encodeURIComponent(F)}`).then(B=>B.ok?B.json():null).then(B=>{A&&(B!=null&&B.video&&h({live:!0,channel:"",video:B.video}),B!=null&&B.video||(p(!0),w(!1),b(!1)),c==null||c(r,!(B!=null&&B.video)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))})}else D("/api/claude-fm").then(F=>F.ok?F.json():null).then(F=>{if(!A)return;const B=!!(F!=null&&F.live&&(F!=null&&F.channel));B&&h({live:!0,channel:F.channel}),B||(p(!0),w(!1),b(!1)),c==null||c(r,!B)}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))});return()=>{A=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(q=i==null?void 0:i.radio)==null?void 0:q.hls,t,e,c,o,r,O,R]),y.useEffect(()=>()=>R(),[R]),y.useEffect(()=>{if(!m||d!=null&&d.audio)return;let A;const D=()=>{clearTimeout(A),A=void 0,w(!1),b(!1),v(!1),p(!0),c==null||c(r,!0)},P=()=>{A??(A=setTimeout(D,15e3))};P();const K=G=>{var H;if(G.origin!==zk||G.source!==((H=I.current)==null?void 0:H.contentWindow))return;const W=vV(G.data);if(W){if(W.kind==="ready"){$(Mi("setVolume",[L.current])),$(Mi(U.current?"mute":"unMute")),$(Mi("playVideo"));return}if(W.kind==="blocked"){clearTimeout(A),A=void 0,w(!1),b(!1),v(!1);return}if(W.kind==="buffering"){b(!1),v(!0),P();return}if(W.kind==="playing"){clearTimeout(A),A=void 0,b(W.playing),v(!1),W.playing||w(!1);return}xV.includes(W.code)&&D()}};return window.addEventListener("message",K),()=>{clearTimeout(A),window.removeEventListener("message",K)}},[m,d==null?void 0:d.audio,o,c,$,r]);const M=y.useCallback(()=>{if(d){if(d.audio){if(m){R(),w(!1),b(!1),v(!1);return}O(d.audio,d.hls===!0,r);return}if(!m){w(!0),b(!1),v(!1);return}$(Mi("pauseVideo")),w(!1),b(!1),v(!1)}},[d,m,j,r,$,O,R]);return y.useMemo(()=>({probe:d,dead:f,armed:m,playing:j,buffering:k,frame:I,say:$,press:M}),[d,f,m,j,k,$,M])}const CE="agent-dag.radio-favorites",TE="agent-dag.radio-recent",RE="agent-dag.radio-catalogue";function NV(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const s=n,r=typeof s.id=="string"?s.id:"",o=typeof s.name=="string"?s.name.trim().slice(0,80):"",i=typeof s.url=="string"?S1(s.url):null,c=_3(s.radio??s);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(r)||!o||!c||!i||i.kind!=="direct-audio"||t.has(r)?[]:(t.add(r),[{id:r,name:o,url:i.url,radio:c}])})}function AE(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function SV(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function Cwe(e,t,n=Math.random){const s=e.filter(r=>r.id!==t);return s.length?s[Math.min(s.length-1,Math.floor(Math.max(0,n())*s.length))]:null}function Twe(e,t,n){if(!e.length)return null;const s=e.findIndex(o=>o.id===t),r=e[s<0?n===1?0:e.length-1:(s+n+e.length)%e.length];return r.id===t?null:r}function E3(e,t,n){const s=e.findIndex(r=>r.id===t);for(let r=1;r<=e.length;r++){const o=e[(s+r)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function Rwe(e,t){if(!e.length)return null;const n=[...e].sort((r,o)=>r.id.localeCompare(o.id));let s=0;for(const r of t)s=Math.imul(s,31)+r.charCodeAt(0)>>>0;return n[s%n.length]}function Awe(e,t,n,s,r){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!s||e.radio.tags.toLowerCase().includes(s.toLowerCase()))&&(!r||e.radio.language.toLowerCase().includes(r.toLowerCase()))}function _V(){const[e,t]=y.useState(()=>AE(Ve(CE))),[n,s]=y.useState(()=>AE(Ve(TE))),[r,o]=y.useState(()=>{try{return NV(JSON.parse(Ve(RE)??"[]"))}catch{return[]}});y.useEffect(()=>{ze(CE,JSON.stringify(e))},[e]),y.useEffect(()=>{ze(TE,JSON.stringify(n))},[n]);const i=y.useCallback(h=>s(f=>SV(f,h)),[]),c=y.useCallback(h=>t(f=>f.includes(h)?f.filter(p=>p!==h):[...f,h].slice(-100)),[]),d=y.useCallback(h=>{o(h),ze(RE,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:r,remember:i,toggleFavorite:c,updateCatalogue:d}}function EV(e,t,n,s){const r=E3(e,t,n);if(!r)return()=>{};const o=setTimeout(()=>{n.add(t),s(r)},1e3);return()=>clearTimeout(o)}const zf=148,ME=6e3,CV=16e3,C3=46,$a=34;function TV(e,t,n=zf){let s=-Math.round(t()*n);if(Math.abs(s-e)<$a){const r=e-$a>=-n?-$a:$a;s=Math.max(-n,Math.min(0,Math.round(e+r)))}return{to:s,ms:Math.round(Math.abs(s-e)*C3)}}function RV(e){return Math.round(ME+e()*(CV-ME))}const $E=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function AV(e){const t=$E.reduce((s,r)=>s+r.weight,0);let n=e()*t;for(const s of $E)if(n-=s.weight,n<0)return s.kind;return"stroll"}const MV=720,$V=260,IV=620,LV=220,IE=520,T3=1600,LE=7e3,OV=15e3,OE=6e3,PV=14e3;function $i(e,t,n=zf){let s=-Math.round(t()*n);if(Math.abs(s-e)<$a){const r=e-$a>=-n?-$a:$a;s=Math.max(-n,Math.min(0,Math.round(e+r)))}return s}const Gt=(e,t)=>Math.round(Math.abs(t-e)*C3),DV=120,nh=0;function FV(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:Gt(e,t)},{x:t,prop:n({}),act:"stoop",ms:MV},{x:nh,prop:n({held:!0}),act:"carry",ms:Gt(t,nh)},{x:nh,prop:n({held:!0}),act:"windup",ms:$V},{x:nh,prop:n({held:!0,leaving:!0}),act:"toss",ms:IV}]}function BV(e,t){const n=t>e?1:-1,s=t-n*Math.min(15,Math.abs(t-e)),r=(o={})=>({kind:"ball",at:t,...o});return[{x:s,prop:r(),act:"walk",ms:Gt(e,s)},{x:s,prop:r(),act:"windup",ms:LV,facing:n>0?"right":"left"},{x:s,prop:r({leaving:!0}),act:"kick",ms:IE,facing:n>0?"right":"left"},{x:s,prop:r({leaving:!0}),act:"stand",ms:T3-IE}]}const R3=640;function qV(e,t,n){const s=Math.max(-70,Math.min(-20,t)),r={x:s,prop:null,facing:"left"};return[{x:s,prop:null,act:"walk",ms:Gt(e,s)},{...r,act:"sit",ms:600},{...r,act:"cast",ms:900},{...r,act:"fish",ms:6e3+Math.round(n()*4e3)},{...r,act:"reel",ms:1200},{...r,act:"stow",ms:500},{...r,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Gt(s,0)}]}function UV(e,t,n){const s=Math.max(-110,Math.min(-30,t)),r={x:s,prop:null};return[{...r,act:"walk",ms:Gt(e,s)},{...r,act:"skip-ready",ms:500},{...r,act:"skip",ms:R3*(6+Math.floor(n()*5))},{...r,act:"skip-rest",ms:600},{...r,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Gt(s,0)}]}function WV(e,t,n){return[{x:t,prop:null,act:"walk",ms:Gt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(OE+n()*(PV-OE))},{x:t,prop:null,act:"stand",ms:400}]}function HV(e,t,n){t=Math.max(-110,Math.min(0,t));const s=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Gt(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(LE+n()*(OV-LE))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Cg(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const zV=1500,VV=e=>Math.round(1e3*Math.sqrt(2*e/zV)),GV=115,KV=e=>Math.round(e/GV*1e3),YV=620,XV=200,ZV=760,JV=600,QV=240;function eG(e,t,n){const r=-(t.ledgeSpan??zf),o=VV(t.ledgeH),i=KV(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:r,act:"walk",prop:null,ms:Gt(e,r)},{x:r,act:"peer",prop:null,ms:YV},{x:r,act:"fall",prop:null,ms:o,place:"floor"},{x:r,act:"land",prop:null,ms:XV,place:"floor"},{x:h,act:"walk",prop:null,ms:Gt(r,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Gt(h,f),place:"floor",floorFrac:d},{x:r,act:"walk",prop:null,ms:Gt(f,r),place:"floor"},{x:r,act:"lasso",prop:null,ms:ZV,place:"floor"},{x:r,act:"rope-throw",prop:null,ms:JV,place:"floor"},{x:r,act:"rope-catch",prop:null,ms:QV,place:"floor"},{x:r,act:"climb",prop:null,ms:i},{x:r,act:"pull-up",prop:null,ms:480}]}function tG(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??zf;switch(AV(t)){case"tidy":return FV(e,$i(e,t,s));case"kick":return BV(e,$i(e,t,s));case"sit":return WV(e,$i(e,t,s),t);case"watch":return HV(e,$i(e,t,s),t);case"fish":return qV(e,$i(e,t,s),t);case"skip":return UV(e,$i(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return eG(e,n,t)}}const o=TV(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const nG=420;function sG(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(nG,Math.max(0,s))}const rG=260,aG=200;function oG(e,t,n){const s=(f,p=Gt(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[s(t)];const r=Math.min(e,t);if(Math.max(e,t)<=n.left||r>=n.right)return[s(t)];const i=t>e,c=i?n.left:n.right,d=i?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[s(c,Gt(e,c)),{...h,x:c,act:"mount",ms:rG},{...h,x:d,act:"walk",ms:Gt(c,d)},{x:d,prop:null,act:"dismount",ms:aG,place:"floor"},{x:t,prop:null,act:"walk",ms:Gt(d,t),place:"floor"}]}const A3=["bob","sway","groove"],PE=9e3,iG=16e3,M3=1e3,lG=.08;function cG(e,t){const n=A3.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],r=(t()*2-1)*lG;return{dance:s,beatMs:Math.round(M3*(1+r))}}function uG(e){return Math.round(PE+e()*(iG-PE))}const _1=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],DE=18,dG=_1.length,$3="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",I3="M12 9H14V6H13V3H11V2H9V4H12Z",E1=new Set(["a","c","p"]);function Ga(e=_1){const t=[];return e.forEach((n,s)=>{let r=0;for(;r<n.length;){const o=n[r];if(o==="."){r+=1;continue}let i=1;for(;r+i<n.length&&n[r+i]===o;)i+=1;t.push({x:r,y:s,w:i,cell:o}),r+=i}}),t}const hG=[".xx.","xxxx",".xx."],fG=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],pG=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],Tg={litter:hG,ball:fG,scope:pG},mG=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],gG=3,yG=-1,Vk=11,FE=9;function BE(e){let t=null,n=null,s=0,r=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(r=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},s))},d=()=>{e.hidden&&t!==null?(s=Math.max(0,s-(performance.now()-r)),i()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(i(),n=h,s=Math.max(0,f),c())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",d)}}}function wG(e,t,n){const[s,r]=y.useState(0),[o,i]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,m]=y.useState({x:0,drop:0}),[w,j]=y.useState("ledge"),[b,k]=y.useState("left"),[v,N]=y.useState(0),S=y.useRef(null),[E,C]=y.useState(()=>document.hidden);y.useEffect(()=>{const M=new Set,q=()=>{var A;if(document.hidden){for(const D of((A=S.current)==null?void 0:A.getAnimations({subtree:!0}))??[])if(D.playState==="running"||D.pending){const P=D.currentTime;D.pause(),P!==null&&(D.currentTime=P),M.add(D)}}else{for(const D of M)D.playState==="paused"&&D.play();M.clear()}C(document.hidden)};return q(),document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[e,t]);const[I,R]=y.useState(null),[$,L]=y.useState(M3),[U,O]=y.useState(()=>{var M;return((M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var A;const M=(A=window.matchMedia)==null?void 0:A.call(window,"(prefers-reduced-motion: reduce)");if(!M)return;const q=()=>O(M.matches);return q(),M.addEventListener("change",q),()=>M.removeEventListener("change",q)},[]),y.useEffect(()=>{var J;if(!e||t||U)return;const M=BE(document);let q=0;r(ee=>q=ee);let A=null,D=0,P=0;const K=ee=>{var re,pe;const[ne,...le]=ee;if(!ne){A=null,d(null),f(null),V();return}d(ne.act),f(ne.prop),j(ne.place??"ledge"),N(ne.riser??0);const de=q,ue=B(ne);if(ne.act==="kick"){const ye=(pe=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:pe.getBoundingClientRect();ye&&m({x:sG(ye.x,Cg(ne,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-ye.y+24)})}P=ne.act==="walk"?Math.max(Gt(de,ue),DV):ne.ms,ne.act==="carry"&&(P=Gt(de,ue)),i(P),k(ye=>Cg({...ne,x:ue},de,ye)),r(ue),q=ue,A=ne,D=Date.now(),M.schedule(()=>K(le),P)},G=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite"),le=ee==null?void 0:ee.parentElement;if(!ee||!ne||!le)return null;const de=ee.getBoundingClientRect(),ue=le.getBoundingClientRect(),re=ue.right-de.right,pe=ue.width-re*2-ne.offsetWidth;return pe>0?pe:null},W=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!ne?0:Math.max(0,ee.getBoundingClientRect().width-ne.offsetWidth)},H=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-walker"),le=G();if(!ee||!ne||le==null)return;const de=ee.getBoundingClientRect().bottom-ne.getBoundingClientRect().bottom;if(de>0)return{ledgeH:de,floorSpan:le,ledgeSpan:W()}},F=()=>{const ee=S.current,ne=document.querySelector(".canvas-notices");if(!ee||!ne)return null;const le=ee.getBoundingClientRect(),de=ne.getBoundingClientRect();return de.width<=0||de.height<=0?null:{left:de.left-le.right,right:de.right-le.right,height:de.height}},B=ee=>{const ne=(ee.place??"ledge")==="floor",le=ne?G()??W():W(),de=ne&&ee.floorFrac!=null?-Math.round(ee.floorFrac*le):ee.x;return Math.max(-le,Math.min(0,de))},Z=()=>{if(!A)return;const ee=B(A);ee!==q&&(i(Math.max(0,D+P-Date.now())),k(ne=>Cg({...A,x:ee},q,ne)),r(ee),q=ee)},V=()=>{M.schedule(()=>{const ee=tG(q,Math.random,H()),ne=ee.some(ue=>ue.place==="floor")?F():null;let le=q;const de=ee.flatMap(ue=>{const re=le;if(le=ue.x,!(ue.place==="floor"&&ue.act==="walk"))return[ue];const pe=oG(re,ue.x,ne),ye=pe.length-1;return ue.floorFrac==null?pe:pe.map((_e,he)=>he===ye?{..._e,floorFrac:ue.floorFrac}:_e)});K(de)},RV(Math.random))},X=(J=S.current)==null?void 0:J.parentElement,Y=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&Y&&Y.observe(X),V(),()=>{M.dispose(),Y==null||Y.disconnect(),j("ledge"),r(ee=>Math.max(-W(),Math.min(0,ee))),i(0),d(null),f(null),N(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){R(null);return}const M=BE(document),q=A=>{const D=cG(A,Math.random);R(D.dance),L(D.beatMs),M.schedule(()=>q(D.dance),uG(Math.random))};return q(null),()=>M.dispose()},[n,U]),{scene:S,suspended:E,x:s,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:b,riser:v,dance:I,beatMs:$}}const Rg={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Yh=Ga().filter(e=>!E1.has(e.cell)),xG=Ga().filter(e=>E1.has(e.cell)),qE=Yh.filter(e=>e.cell==="e"),vG=Ga(mG),bG=Yh.filter(e=>e.y<Vk&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),kG={left:Yh.filter(e=>e.y>=Vk&&e.x<FE),right:Yh.filter(e=>e.y>=Vk&&e.x>=FE)},jG=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${DE} ${dG}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:xG.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Rg[s.cell]},`g${s.y}-${s.x}`))})}),a.jsxs("g",{className:"fm-body",children:[qE.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),bG.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Rg[s.cell]},`b${s.y}-${s.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),qE.map(s=>a.jsx("rect",{x:s.x-(s.x>=DE/2?1:0)+(n==="right"?1:0),y:s.y,width:s.w,height:1,className:"fm-eye"},`eye-${s.x}`))]}),a.jsx("g",{className:"fm-hat",children:vG.map(s=>a.jsx("rect",{x:gG+s.x,y:yG+s.y,width:s.w,height:1,className:s.cell==="k"?"fm-hatband":void 0},`h${s.y}-${s.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:$3}),a.jsx("path",{className:"fm-grip-right",d:I3})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(s=>a.jsx("g",{className:"fm-leg","data-side":s,children:kG[s].map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Rg[r.cell]},`${s}${r.y}-${r.x}`))},s))]})}),NG=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],SG=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],ar={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},_G={p:"fm-pad"},ru=Ga(NG),EG=Ga(SG);function Gk(e,t,n){return e.map(s=>({...s,x:Math.max(t,s.x),w:Math.max(0,Math.min(n,s.x+s.w)-Math.max(t,s.x))})).filter(s=>s.w>0)}const CG=Gk(ru.filter(e=>e.y>=8),12,18),TG=ru.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),UE=ru.filter(e=>e.cell==="e"),RG={left:Gk(ru.filter(e=>e.y>=11),0,9),right:Gk(ru.filter(e=>e.y>=11),9,12)},AG=y.memo(function({act:t,facing:n}){const s=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",r=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-body","data-part":"tail",children:CG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar[i.cell]},`t${i.y}-${i.x}`))}),a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:EG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:_G[i.cell]},`g${i.y}-${i.x}`))})}),a.jsxs("g",{className:"fm-body",children:[TG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar[i.cell]},`b${i.y}-${i.x}`)),UE.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar.f},`bed${i.x}`)),a.jsxs("g",{className:"fm-arms",fill:ar.f,children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2})]}),UE.map(i=>a.jsx("rect",{x:i.x+(n==="right"?1:0)-(i.x>=9?1:0),y:i.y,width:i.w,height:1,className:"fm-eye",style:{fill:ar.n}},`e${i.x}`))]}),s&&a.jsxs("g",{className:"fm-grip",style:{fill:ar.f},children:[a.jsx("path",{className:"fm-grip-left",d:$3}),a.jsx("path",{className:"fm-grip-right",d:I3})]}),r&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:ar.f},children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:ar.f},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:ar.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>a.jsx("g",{className:"fm-leg","data-side":i,children:RG[i].map(c=>a.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:ar[c.cell]},`${c.y}-${c.x}`))},i))]})}),MG=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Pr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},$G={p:"fm-pad"},Xh=Ga(MG),IG=Ga(_1).filter(e=>E1.has(e.cell)),WE=Xh.filter(e=>e.cell==="e"),LG=Xh.filter(e=>e.y<12&&e.cell!=="e"),OG={left:Xh.filter(e=>e.y>=12&&e.x<9),right:Xh.filter(e=>e.y>=12&&e.x>=9)},PG=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",r=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:IG.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:$G[o.cell]},`g${o.y}-${o.x}`))})}),a.jsxs("g",{className:"fm-body",children:[LG.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Pr[o.cell]},`b${o.y}-${o.x}`)),WE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Pr.w},`bed${o.x}`)),a.jsxs("g",{className:"fm-arms",fill:Pr.d,children:[a.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),a.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),WE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Pr.e}},`e${o.x}`))]}),n&&a.jsxs("g",{className:"fm-grip",style:{fill:Pr.h},children:[a.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),s&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:Pr.b},children:[a.jsx("path",{d:"M5 12H8V13H5Z"}),a.jsx("path",{d:"M10 12H13V13H10Z"})]}),r&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:Pr.b},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:Pr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),a.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>a.jsx("g",{className:"fm-leg","data-side":o,children:OG[o].map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Pr.b},`${i.y}-${i.x}`))},o))]})});function L3({character:e,act:t,facing:n}){return e==="penguin"?a.jsx(PG,{act:t,facing:n}):e==="fox"?a.jsx(AG,{act:t,facing:n}):a.jsx(jG,{act:t,facing:n})}const DG={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function O3(e,t){return t&&dl(t.id)===e?t.name:Hf(e)?"Custom FM":DG[e]}function Ag(e,t){var s;const n=((s=e[0])==null?void 0:s.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:Ga(e).map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:r.cell==="s"?"var(--fm-prop-shadow, var(--bg))":r.cell==="l"?"var(--fm-prop-light, var(--text))":r.cell==="a"?"var(--accent)":void 0},`${t}${r.y}-${r.x}`))})}const HE={litter:Ag(Tg.litter,"litter"),ball:Ag(Tg.ball,"ball"),scope:Ag(Tg.scope,"scope")};function FG(e){try{return new URL(e).host}catch{return"the station's server"}}const BG=y.memo(function({player:t,source:n,customStation:s,character:r="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:m,act:w,prop:j,ballFlight:b,place:k,facing:v,riser:N,dance:S,beatMs:E}=wG(o,i,c);if(!o||i)return null;const C=O3(n,s),I=o.audio?FG(o.audio):"YouTube";return a.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":k,style:{"--fm-beat":`${E}ms`},children:[j&&!j.held&&a.jsx("div",{className:"fm-prop","data-prop":j.kind,"data-leaving":j.leaving?"":void 0,style:{"--fm-prop-x":`${j.at}px`,"--fm-roll-to":`${b.x}px`,"--fm-ball-drop":`${b.drop}px`,"--fm-ball-flight-ms":`${T3}ms`,"--fm-ball-turn":v==="right"?"1080deg":"-1080deg"},children:HE[j.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${m}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":w??void 0,"data-place":k,"data-facing":v,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${N}px`,"--fm-skip-beat":`${R3}ms`},children:[(j==null?void 0:j.held)&&a.jsx("div",{className:"fm-held","data-prop":j.kind,"data-toss":j.leaving?"":void 0,children:HE[j.kind]}),["cast","fish","reel","stow"].includes(w)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":c?"":void 0,"data-dance":c?S??A3[0]:void 0,onClick:d,title:c?`Stop ${C}`:`Play ${C} — streams from ${I}`,"aria-label":c?`Stop ${C}`:`Play ${C}`,children:a.jsx(L3,{character:r,act:w,facing:v})})]})]})});function qG({player:e,label:t}){const{probe:n,armed:s,frame:r,say:o}=e;return n?a.jsx(a.Fragment,{children:s&&!n.audio&&(n.channel||n.video)&&a.jsx("iframe",{ref:r,className:"fm-frame",title:t,src:mV(n.channel,window.location.origin,n.video),onLoad:()=>o(gV()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const UG={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6",headphones:"M4 14v-3a8 8 0 0 1 16 0v3 M4 12h3v8H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 1-2 M20 12h-3v8h2a2 2 0 0 0 2-2v-4a2 2 0 0 0-1-2",book:"M12 6v15 M12 6C9 4 6 3 3 4v15c3-1 6 0 9 2 3-2 6-3 9-2V4c-3-1-6 0-9 2",gamepad:"M8 7h8c3 0 4 2 5 8 1 5-2 6-5 2H8c-3 4-6 3-5-2 1-6 2-8 5-8z M6 11h4 M8 9v4 M16 10h.01 M18 13h.01",sunset:"M3 17h18 M5 21h14 M7 17a5 5 0 0 1 10 0 M12 3v3 M4 8l2 2 M20 8l-2 2",moon:"M20 14A9 9 0 0 1 10 3a9 9 0 1 0 10 11z",cassette:"M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z M7 8h10v5H7z M7 20l2-4h6l2 4 M9 10.5h.01 M15 10.5h.01",palm:"M12 8c2 4 3 8 2 13 M12 8C8 3 4 4 2 8c4-1 7-1 10 0 M12 8c1-6 6-7 10-2-4-1-7 0-10 2 M12 8c-5 0-7 3-7 7 2-3 4-5 7-7 M12 8c4 0 7 3 7 7-2-3-4-5-7-7 M10 21h8",coffee:"M4 8h12v8a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4z M16 9h2a3 3 0 0 1 0 6h-2 M7 3v2 M11 3v2 M3 22h15",check:"M5 12l4 4L19 6",filters:"M4 6h4 M12 6h8 M4 12h10 M18 12h2 M4 18h2 M10 18h10 M8 4v4 M14 10v4 M6 16v4"};function WG({name:e}){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:UG[e]})})}function HG({opening:e=!1}){const[t,n]=y.useState(()=>document.hidden);return y.useEffect(()=>{const s=()=>n(document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),a.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[a.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsxs("g",{className:"radio-tuning-tower",children:[a.jsx("circle",{cx:"40",cy:"24",r:"4"}),a.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),a.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),a.jsxs("g",{className:"radio-tuning-send",children:[a.jsx("path",{d:"M75 26q7 8 0 16"}),a.jsx("path",{d:"M102 26q7 8 0 16"}),a.jsx("path",{d:"M129 26q7 8 0 16"})]}),a.jsxs("g",{className:"radio-tuning-receiver",children:[a.jsx("path",{d:"M165 49l30-22"}),a.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),a.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),a.jsx("circle",{cx:"202",cy:"65",r:"7"}),a.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),a.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),a.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function zG({onClose:e}){const[t]=y.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),n=ct(e);return a.jsxs("div",{ref:n,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":"Opening Radio","data-keyboard-interaction":t||void 0,onKeyDown:S7,children:[a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:a.jsx(WG,{name:"close"})}),a.jsx(HG,{opening:!0})]})}const VG=y.lazy(()=>Nu(()=>import("./RadioPanel-DkXAgxKR.js"),[]));function GG({fm:e,characterEnabled:t,character:n,open:s,onClose:r}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=_V(),[f,p]=y.useState(null),m=y.useRef(new Set);y.useEffect(()=>{const R=new AbortController;return fetch("/api/music-config",{signal:R.signal}).then($=>$.ok?$.json():null).then($=>{R.signal.aborted||(i(($==null?void 0:$.enabled)===!0),d($?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{R.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>R.abort()},[s]);const w=e.customFmStations.find(R=>dl(R.id)===e.fmSource),j=w!=null&&w.radio?w:void 0,b=jV({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),k=O3(e.fmSource,w),v=o&&j&&b.dead&&e.fmPlayRequest>0?E3(f??h.catalogue,j.id,m.current):null,{remember:N}=h,S=(w==null?void 0:w.id)??e.fmSource;y.useEffect(()=>{b.playing&&N(S)},[S,b.playing,N]);const E=r,C=xt(r),I=y.useCallback((R,$=!1)=>{var M;if(!o)return;$||m.current.clear();const L=dl(R.id),U=L===e.fmSource;if(U&&b.armed&&!b.dead){b.press();return}const O=U&&!!w&&(w.url!==R.url||((M=w.radio)==null?void 0:M.hls)!==R.radio.hls);e.addFmStation(R,!0),U&&!b.dead&&!O?b.press():e.pickFmSource(L,O),fetch(`/api/radio-click?id=${encodeURIComponent(R.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,b.armed,b.dead,b.press]);return y.useEffect(()=>{b.playing&&!b.dead&&m.current.clear()},[b.playing,b.dead]),y.useEffect(()=>{if(!(!o||!j||!b.dead||e.fmPlayRequest===0))return EV(f??h.catalogue,j.id,m.current,R=>I(R,!0))},[o,j==null?void 0:j.id,b.dead,e.fmPlayRequest,f,h.catalogue,I]),a.jsxs(a.Fragment,{children:[t&&a.jsx(BG,{character:n,player:b,source:e.fmSource,customStation:w}),a.jsx(qG,{player:b,label:k}),s&&wt.createPortal(a.jsx("div",{className:"modal-backdrop radio-backdrop",...C,children:a.jsx(y.Suspense,{fallback:a.jsx(zG,{onClose:E}),children:a.jsx(VG,{fm:e,player:b,library:h,selected:j,label:k,enabled:o,disabledReason:c,autoNext:v==null?void 0:v.name,onPick:I,onQueueChange:p,onClose:E})})}),document.body)]})}function P3(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Kk(e){return P3(Math.floor(e/1e3))}function Su(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),r=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return s>0?`${s}d ${r}h`:r>0?`${r}h ${o}m`:`${o}m`}function KG(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Zh(e,t,n){const s=new Date(e),r=Kk(t-e);return{label:KG(s,new Date(t))?r:`${r} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function YG({data:e}){const t=Go(3e4),n=e.note,s=n.kind==="recap",r=Zh(n.at,t),o=s?"recap-note":`recap-note is-status status-${n.kind}`,i=s?void 0:Uf(n);return a.jsxs("div",{className:o,role:"note","aria-label":s?"Claude Code's recap":`Session note: ${Oa(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",title:i,children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Gh,{recap:s}),Oa(n.kind)]}),a.jsx("span",{className:"recap-note-age",title:r.title,children:r.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":s?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),K7(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:a9(n.text,i),children:n.text}),n.reply&&a.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Gh,{recap:s}),Oa(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:r.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(Bo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}function _u(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function Eu(e){return/mac|iphone|ipad/i.test(e)}const Jh=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function XG(e,t,n){return{positions:Jh(e.positions),pinned:Jh(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function ZG(e,t){t.positions.clear();for(const[n,s]of Jh(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of Jh(e.pinned))t.pinned.set(n,s);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const zE=7e3,JG=2e3,QG=140,eK="Layout re-arranged",tK="Layout re-arranged. Undo available.",VE="Layout restored.",nK={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function sK(e,t=nK){let n=null,s=null,r=0,o=zE;const i=new Set,c=()=>{s!==null&&t.clear(s),s=null},d=()=>{c(),!(n===null||i.size>0)&&(r=t.now()+o,s=t.set(()=>{s=null,h()},o))};function h(){c(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=zE,d(),p&&e(!0)},take(){const f=n;return h(),f},close:h,hold(f){n!==null&&(i.size===0&&s!==null&&(o=Math.max(0,r-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,JG),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function rK(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function aK(e){return Eu(e)?"⌘Z":"Ctrl+Z"}function oK({undo:e}){const{open:t,said:n,undo:s,dismiss:r,hold:o,release:i}=e,c=zi(t,QG),d=y.useRef(null);return y.useEffect(()=>t?Cn.push(r,0,"popover"):void 0,[t,r]),y.useEffect(()=>{var f;if(t)return;const h=d.current;h&&h.contains(document.activeElement)&&((f=h.closest("main"))==null||f.focus({preventScroll:!0}))},[t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),Ma(c)&&a.jsxs("div",{ref:d,className:c==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>o("hover"),onPointerLeave:()=>i("hover"),onFocus:()=>o("focus"),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||i("focus")},children:[a.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:eK}),a.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:s,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",a.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:aK(_u())})]})]})]})}function iK({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:r,targetPosition:o,style:i}){const[c]=s1({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:s,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:i,children:[a.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:s,r:3.5})]})}function Yk(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Qh(e,t){const n=Yk(e);return n?n.slice(-t):e.slice(-t)}function D3(e,t,n=4){const s=Yk(e);if(!s)return Qh(e,n);let r=n;for(const o of t){if(o===e)continue;const i=Yk(o);let c=0;for(;c<s.length&&c<i.length&&s[s.length-1-c]===i[i.length-1-c];)c++;r=Math.max(r,c+1)}return s.slice(-r)}const Dc=" · ",lK=32,cK=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function GE(e){return cK.test(e)?2:1}function KE(e,t=lK){const n=[...e];let s=0;for(const i of n)s+=GE(i);if(s<=t)return e;const r=[];let o=0;for(const i of n){const c=GE(i);if(o+c>t-1)break;r.push(i),o+=c}for(;r.length&&/[\s\-_.:/]/.test(r[r.length-1]);)r.pop();return`${r.join("")}…`}function uK(e,t,n,s,r=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=s?D3(n,r):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(Dc);return{label:KE(e),name:c?KE(c):void 0,shortId:d,fullLabel:h.join(Dc),title:`${i?"waiting on you: ":""}${f}
|
|
85
85
|
Zoom to this session
|
|
86
86
|
drag the wrapper to move the whole session`}}const To=18,Xk=26,C1=12,au=240,F3=130,Zk=To*2+Xk+C1,dK=72,Qi=Zk+dK,Eh=24,B3=To*2+Eh,ef=Qi;function q3(e,t){var s;let n=au;for(const r of e)n=Math.max(n,((s=t.get(r.id))==null?void 0:s.width)??au);return n}const tf=420,U3=1;function hK(e,t,n,s){return Math.min(U3,n/Math.max(1,e),s/Math.max(1,t))}function Gn(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function Vf(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const r=Gn(s),o=n.get(r);o?o.push(s):n.set(r,[s])}return n}function fK(e,t){return((t==null?void 0:t.get(e))??0)>0?tf:0}function pK(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function nf(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??au,h:(n==null?void 0:n.height)??F3}}function ou(e,t,n){const s=nf(e,t);return{w:s.w+fK(e,n),h:Math.max(s.h,pK(e,n))}}function mK(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const gK=240,W3=16;function H3(e,t){return(e+gK)*(t||1)}function yK(e,t){return{position:"absolute",left:0,top:0,transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h,"--session-hue":t}}function wK(e,t,n,s){return{position:"absolute",left:e.x+W3,top:e.y-C1/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??H3(e.w,t),"--session-hue":n}}function xK(e){const t=new Map;for(const r of e){if(r.type!=="agent"&&r.type!=="recapNote")continue;const o=r.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||r.width==null||r.height==null)continue;const i=r.position.x,c=r.position.y,d=i+r.width,h=c+r.height,f=t.get(Gn(r)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:vK(o);f?(f.minX=Math.min(f.minX,i),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,d),f.maxY=Math.max(f.maxY,h),p&&(f.label=p.label??f.label,f.name=p.name,f.alarm=p.alarm,f.branch=p.branch)):t.set(Gn(r),{minX:i,minY:c,maxX:d,maxY:h,label:(p==null?void 0:p.label)??o.sessionId,name:p==null?void 0:p.name,alarm:(p==null?void 0:p.alarm)??!1,branch:p==null?void 0:p.branch})}const n=new Map;for(const[r,o]of t){const i=n.get(o.label);i?i.push(r):n.set(o.label,[r])}const s=[];for(const[r,o]of t){const i=n.get(o.label)??[],c=i.length>1;s.push({sessionId:r,...uK(o.label,o.name,r,c,i,{branch:o.branch,alarm:o.alarm}),x:o.minX-To,y:o.minY-To-Xk,w:o.maxX-o.minX+To*2,h:o.maxY-o.minY+To*2+Xk,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return s}function vK(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:w1(e.sessionName,e.sessionTitle).face,alarm:Mn(e.waiting),branch:t&&t.total>0?d3(t):void 0}}function bK(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],r=t[n];if(s.sessionId!==r.sessionId||s.label!==r.label||s.name!==r.name||s.shortId!==r.shortId||s.alarm!==r.alarm||s.branch!==r.branch||s.fullLabel!==r.fullLabel||s.title!==r.title||s.x!==r.x||s.y!==r.y||s.w!==r.w||s.h!==r.h)return!1}return!0}const kK=20,Dr=4,jK=64,NK=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function SK(e,t,n,s){const r=t.zoom||1,o=H3(e.w,r);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+W3)*r+t.x,c=e.y*r+t.y-C1,d=c+kK;let h=Math.min(o,n.width-Dr-i),f=i<Dr||c<Dr||d>n.height-Dr;for(const p of s)if(!(p.top-Dr>=d||p.bottom+Dr<=c)&&!(p.right+Dr<=i)){if(p.left-Dr<=i){f=!0;break}h=Math.min(h,p.left-Dr-i)}return h<jK&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function _K(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(NK)){const r=s.getBoundingClientRect(),o=Math.max(r.left,t.left)-t.left,i=Math.max(r.top,t.top)-t.top,c=Math.min(r.right,t.right)-t.left,d=Math.min(r.bottom,t.bottom)-t.top;c-o<1||d-i<1||n.push({left:Math.round(o),top:Math.round(i),right:Math.round(c),bottom:Math.round(d)})}return n}function EK(e,t){return e.length===t.length&&e.every((n,s)=>{const r=t[s];return n.left===r.left&&n.top===r.top&&n.right===r.right&&n.bottom===r.bottom})}const CK=500;function z3({focus:e,setTimeout:t,clearTimeout:n,ms:s=CK}){let r=null;const o=()=>{r!==null&&(n(r),r=null)};return{hold(i){o(),r=t(()=>{r=null;try{e(i)}catch{}},s)},cancel:o}}function TK(e){return xK(e.nodeInternals.values())}const RK=e=>e.width,AK=e=>e.height,MK=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function $K({onFocusSession:e}){const{x:t,y:n,zoom:s}=lO(),r=tt(TK,bK),o=tt(RK),i=tt(AK),c={width:o,height:i},d=y.useRef(null),h=tt(MK),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var I;const S=(I=d.current)==null?void 0:I.parentElement;if(!S)return;const E=_K(S),C=requestAnimationFrame(()=>{p(R=>EK(R,E)?R:E)});return()=>cancelAnimationFrame(C)});const m=y.useRef(e);m.current=e;const[w]=y.useState(()=>z3({focus:S=>{var E;return(E=m.current)==null?void 0:E.call(m,S)},setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)}));if(y.useEffect(()=>()=>w.cancel(),[w]),r.length<=1)return null;const j=S=>{try{e==null||e(S)}catch{}},b=(S,E)=>{S.detail>0&&vu()?w.hold(E):j(E)},k={transform:`translate(${t}px, ${n}px) scale(${s})`},v=a.jsx("div",{className:"session-clusters",style:k,ref:d,children:r.map(S=>{const E=eu(S.sessionId),C=yK(S,E);return a.jsx("div",{className:"cluster-card",style:C,"aria-hidden":!0},S.sessionId)})}),N=h&&wt.createPortal(a.jsx("div",{className:"cluster-labels nopan",children:r.map(S=>{const E=eu(S.sessionId),C=SK(S,{x:t,y:n,zoom:s},c,f),I=wK(S,s,E,C.maxWidth);return a.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":C.hidden?"":void 0,style:I,title:S.title,onClick:R=>b(R,S.sessionId),children:[S.alarm?a.jsxs(a.Fragment,{children:[a.jsx(j1,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?a.jsx("span",{className:"cluster-label-branch",children:Dc+S.branch}):null,S.name?a.jsx("span",{className:"cluster-label-name",children:Dc+S.name}):null,S.shortId?a.jsx("span",{className:"cluster-label-id",children:Dc+S.shortId}):null]},S.sessionId)})}),h);return a.jsxs(a.Fragment,{children:[v,N]})}function IK({data:e}){return a.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const V3=600,LK=4,OK=36,sf=14,PK=60,DK=6,YE=220,FK=96,BK=28;function qK(e,t){return Math.max(FK,61+[...t].length*6.8)}function UK(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function WK(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/V3)}function HK(e,t){const n=[],s=new Set;for(let r=e.length-1;r>=0&&n.length<t;r--){const o=e[r];s.has(o.id)||(s.add(o.id),n.push(o))}return n.reverse()}function zK(e,t,n,s,r,o){const i=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>V3)continue;const d=s.get(c.id)??n.get(c.id);if(!d)continue;const h=HK(c.tools,LK);if(h.length===0)continue;const f=c.exitAt??null,p=r.get(c.id),m=Math.max((p==null?void 0:p.width)??YE,YE),w=(p==null?void 0:p.height)??130,j=d.x,b=d.y,k=j+m,v=b+w/2;h.forEach((N,S)=>{const E=S*OK,C=j+m+PK,I=b+DK+E,R=WK(o,f),$=N.inputPreview??"",L=UK(N),U=R<.999,O=k1(N.name);i.push({id:`${c.id}::${N.id}`,toolId:N.id,agentId:c.id,toolName:N.name,name:O.label,emoji:O.emoji,status:L,category:h3(N.name),mcpHue:O.hue,inputPreview:$,fade:R,fading:U,worldX:C,worldY:I,anchorX:k,anchorY:v,spawnDx:k-C,spawnDy:v-(I+sf)});const M=g3(N.name,N.input);if(M){const q=qK(N.name,O.label),A=C+q+BK,D=I,P=C+q,K=I+sf;i.push({id:`sub:${c.id}::${N.id}`,toolId:N.id,agentId:c.id,toolName:N.name,name:$9(M.label,M.category),fullName:M.label,emoji:M.emoji,isSub:!0,status:L,category:M.category,inputPreview:M.detail??$,fade:R,fading:U,worldX:A,worldY:D,anchorX:P,anchorY:K,spawnDx:P-A,spawnDy:0})}})}return i}function VK({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:r,spotlight:o,hiddenCategories:i,now:c,onOpenTool:d}){const h=zK(e,t,n,s,r,c),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return a.jsx(GK,{bursts:f,spotlight:o,onOpenTool:d})}function GK({bursts:e,spotlight:t,onOpenTool:n}){const s=e.map(o=>{const i=o.anchorX,c=o.anchorY,d=o.worldX+6,h=o.worldY+sf,f=Math.max(1,d-i),p=Math.min(1,Math.abs(h-c)/f),m=i+f*(.55-.22*p),w=c+(h-c)*.12,j=d-f*.25,b=t!=null&&!t.has(o.agentId),k=o.fade*(b?.14:1);return a.jsx("path",{d:`M ${i} ${c} C ${m} ${w}, ${j} ${h}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:k,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),r=e.map(o=>a.jsx(XK,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return a.jsx(KK,{connectors:s,bubbles:r})}function KK({connectors:e,bubbles:t}){const{x:n,y:s,zoom:r}=lO();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*sf}px`},children:[a.jsx("svg",{className:"tool-bursts-svg",children:a.jsx("g",{transform:`translate(${n} ${s}) scale(${r})`,children:e})}),a.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${s}px) scale(${r})`},children:t})]})}function YK(e,t){const n=e.b,s=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===s.id&&n.toolId===s.toolId&&n.worldX===s.worldX&&n.worldY===s.worldY&&n.spawnDx===s.spawnDx&&n.spawnDy===s.spawnDy&&n.status===s.status&&n.fading===s.fading&&n.category===s.category&&n.mcpHue===s.mcpHue&&n.isSub===s.isSub&&n.emoji===s.emoji&&n.name===s.name&&n.fullName===s.fullName&&n.toolName===s.toolName&&n.inputPreview===s.inputPreview}const XK=y.memo(function({b:t,dim:n,onOpenTool:s}){const r={left:`${t.worldX}px`,top:`${t.worldY}px`,"--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},o=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,i=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=s!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},h=n?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:r,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${h}`,style:d,title:i,onClick:c?()=>s(t.agentId,t.toolId):void 0,children:[a.jsx("span",{className:"tb-emoji",children:t.emoji}),a.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&a.jsx("span",{className:"tb-spin"}),t.status==="done"&&a.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&a.jsx("span",{className:"tb-mark err",children:"×"})]})})},YK),ZK={width:140,height:105},JK={agent:F9,sessionGroup:IK,recapNote:YG},QK={recapTie:iK},XE=400;function eY({graph:e,layout:t,viewport:n,clicks:s,drag:r,appearance:o,fm:i,radioOpen:c,onRadioClose:d,autoFit:h,pause:f,stateRef:p,measuredRef:m,hiddenCats:w,now:j,openTool:b,focusAgent:k,requestClear:v,setKeyHelpOpen:N}){const{allNodes:S,edges:E,visibleAgentIds:C,spotlightSet:I}=e,{positionsRef:R,pinnedRef:$,handleRelayout:L,rearrangeUndo:U}=t,{restoredViewport:O,onMoveStart:M,onMove:q}=n,{onNodeClick:A,onPaneClick:D,onNodeDoubleClick:P,onNodeMouseEnter:K,onNodeMouseLeave:G}=s,{onNodeDragStart:W,onNodeDrag:H,onNodeDragStop:F}=r,{palette:B,minimapNodeFill:Z,characterEnabled:V}=o,{autoFitDisabled:X,enableAutoFitAndRefit:Y}=h,{paused:J,pauseGate:ee,togglePause:ne}=f;return a.jsxs(iO,{nodes:S,edges:E,nodeTypes:JK,edgesFocusable:!1,edgeTypes:QK,fitView:!O,fitViewOptions:{padding:.25,duration:Pk({durationMs:XE,documentHidden:document.hidden})?XE:0},minZoom:fO,maxZoom:pO,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:A,onPaneClick:D,onNodeDoubleClick:P,onNodeMouseEnter:K,onNodeMouseLeave:G,onMoveStart:M,onMove:q,onNodeDragStart:(le,de,ue)=>{U.dismiss(),W(le,de,ue)},onNodeDrag:H,onNodeDragStop:F,children:[a.jsx(bH,{gap:28,size:1,color:B["--grid-line"]}),a.jsx($K,{onFocusSession:k}),a.jsx(VK,{agents:p.current.agents,visibleAgentIds:C,positions:R.current,pinned:$.current,measured:m.current,spotlight:I,hiddenCategories:w,now:j,onOpenTool:b}),a.jsxs("div",{className:"canvas-notices",children:[X&&a.jsx(V9,{enableAutoFitAndRefit:Y}),a.jsx(oK,{undo:U})]}),a.jsx(sV,{autoFitDisabled:X,enableAutoFitAndRefit:Y,paused:J,pauseGate:ee,togglePause:ne,handleRelayout:L,requestClear:v,setKeyHelpOpen:N}),a.jsx(lH,{style:ZK,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:B["--minimap-mask"],maskStrokeColor:B["--line"]}),a.jsx(GG,{fm:i,character:o.character,characterEnabled:V,open:c,onClose:d})]})}function tY(){const e=window.ccdeckWindow;return y.useEffect(()=>{if(!e)return;const t=()=>{const s=document.querySelector(".topbar");if(!s)return;const r=getComputedStyle(s),o=i=>{var d;const c=(d=i.match(/\d+/g))==null?void 0:d.slice(0,3);return(c==null?void 0:c.length)===3?`#${c.map(h=>Number(h).toString(16).padStart(2,"0")).join("")}`:"#191a1c"};e.colors({color:o(r.backgroundColor),symbolColor:o(r.color)}).catch(()=>{})};t();const n=new MutationObserver(t);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>n.disconnect()},[e]),!e||e.platform==="darwin"?null:a.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":"Application menu",title:"Application menu","aria-haspopup":"menu",onClick:()=>{e.menu().catch(()=>{})},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:a.jsx("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})})}function nY(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,r=0,o=0;for(const i of e){const c=In(i);t.input+=c.input,t.output+=c.output,t.cacheRead+=c.cacheRead,t.cacheWrite+=c.cacheWrite,t.total+=c.total,n+=i.usage.inputTokens,s+=i.usage.outputTokens,r+=i.usage.cacheReadTokens,o+=i.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:r,cacheCreateTokens:o,sum:n+s}}const sY="spend on this board",rY="on this board",G3=`Everything on the board right now, and only that.
|
|
87
87
|
Finished sessions are evicted from the canvas a couple of minutes after they end, and their tokens and dollars leave with them — so this figure falls on its own.
|
|
@@ -106,7 +106,7 @@ ${n}`:t}const ide=new Set(["idle","checking","current","downloading","ready","er
|
|
|
106
106
|
${Xe(i.total)} spent${d?` · ${d}`:""}`:""}`,onClick:()=>{try{s(e.id)}catch{}},children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("span",{className:"selected-label",children:e.label}),i.total>0&&a.jsxs("span",{className:"selected-cost",children:[Xe(i.total),d?a.jsxs("span",{className:"selected-rate",children:[" · ",d]}):null]}),h>0&&a.jsxs("span",{className:"selected-extra",children:["+",h]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),r()},children:"×"})]})}function Cde({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:s,toggleCat:r}){return a.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(o=>{const i=s.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${i?" off":""}`,onClick:()=>r(o),"aria-pressed":!i,title:`${i?"Show":"Hide"} ${vf[o]} tools`,children:[a.jsx(Tue,{cat:o}),a.jsx("span",{className:"cat-name",children:vf[o]})]},o)})})}const Tde=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Rde(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(Tde)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function Ade({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:s}){const r=Ln();return a.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[a.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M8 7V5.8C8 4.8 8.8 4 9.8 4h4.4c1 0 1.8.8 1.8 1.8V7m-10 0h12M8 10v8m4-8v8m4-8v8M7 7l.7 13h8.6L17 7"})}),a.jsxs("span",{className:"drag-trash-copy",children:[a.jsx("span",{className:"drag-trash-text",children:t==="over"?a.jsxs(a.Fragment,{children:["Release to remove ",a.jsx("strong",{className:"drag-trash-name",children:s||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?`${gn("The session list","L",r)} brings it back`:"The session keeps running"})]})]})}function Mde({canvasRef:e,bubbling:t,dragging:n,trash:s,zoom:r,viewport:o,stateRef:i,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:m,trashLabel:w}=s,{lod:j,lodRef:b}=r,{markCanvasInput:k}=o,{peekAgent:v,peekLabel:N,peekRecap:S,peekBounds:E}=c;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":j,ref:e,onMouseDownCapture:Rde,onPointerDownCapture:k,onPointerUpCapture:k,onWheelCapture:k,onFocusCapture:C=>{const I=C.target;if(!Sj(I)||b.current==null||b.current==="detail")return;const R=I.getAttribute("data-id");R&&i.current.agents.has(R)&&I.matches(":focus-visible")&&OD(R,I,"focus")},onBlurCapture:C=>{var R,$;const I=($=(R=C.target).getAttribute)==null?void 0:$.call(R,"data-id");I&&Ua(I)},children:[d,Ma(p)&&a.jsx(Ade,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),a.jsx(zle,{agentFor:v,recapFor:S,labelFor:N,bounds:E})]})}function $de({restarting:e,restartMode:t,live:n,paused:s}){return a.jsxs("div",{className:"conn-banner",role:"alert",children:[a.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Ct}…`:(()=>{const r=J9({connected:n,paused:s});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${Ct} server. Reconnecting…`,r&&a.jsx("span",{className:"conn-sub",children:r})]})})()]})}function Ide({oldName:e,version:t,dismissOldName:n}){return a.jsxs("div",{className:"ver-banner",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:[e," still works — the deck is called ",Ct," now."]}),t!=null&&t.renameFix?a.jsx("span",{className:"ver-sub",children:t.renameFix}):null,a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const h5="Thanks — that helps.",Lde=Array.from({length:11},(e,t)=>t);function Ode(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const Pde=6;function Dde(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,s=n==null?void 0:n.closest(".app");if(!n||!s)return;const r=()=>s.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);r();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return o==null||o.observe(n),()=>{o==null||o.disconnect(),s.style.removeProperty("--rating-h")}},[e]),t}function Fde(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Bde({phase:e,score:t,onAnswer:n,onLater:s,onClose:r,onFeedback:o,onHold:i}){const c=Dde(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var m,w;e!=="thanks"||!f.current||(f.current=!1,Kn(((m=document.activeElement)==null?void 0:m.tagName)??null)&&((w=d.current??h.current)==null||w.focus()))},[e]);const p=m=>{var w;(w=c.current)!=null&&w.contains(document.activeElement)&&Fde(),m()};return e==="thanks"?a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>i(!0),onBlur:m=>{m.currentTarget.contains(m.relatedTarget)||i(!1)},children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{children:h5}),t!==null&&t<=Pde?a.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,a.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(r),children:"×"})]}):a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),a.jsx("span",{className:"rating-scale",children:Lde.map(m=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":Ode(m),onClick:w=>{f.current=w.detail===0||w.currentTarget.matches(":focus-visible"),n(m)},children:m},m))}),a.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),a.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(s),children:"Not now"})]})}const qde=3e4;function Ude({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Wde({bundle:e,running:t,pending:n,lastTried:s}){return t?Ude({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Hde(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function zde({asked:e,reported:t}){return t?t!==e:!1}function f5(e){const t=e.thresholdMs??qde;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function Vde(e){const t=Math.max(0,Math.ceil(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Gde(e,t){return e?t==null?"auto when idle":`auto in ${Vde(t)}`:"auto-restart off"}function rI(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Kde(e,t=!1){return e<=0&&t?{label:"Restart anyway",clause:"the canvas is paused — running agents cannot be seen"}:e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function Yde(e){const t=f5(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}const L0={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",one_off:"this deck runs from a one-off pnpm dlx, bunx or yarn dlx copy that cannot be upgraded in place — to keep one, run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"};function Xde({notice:e,version:t,dismissNotice:n,upgradeState:s,startUpgrade:r,copyCommand:o,cmdCopied:i,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:m}){var w,j,b;return a.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[a.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...Ps(m),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
|
|
107
107
|
|
|
108
108
|
Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:m?"restarting…":f.label}),!m&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":"Auto-restart when idle",title:c?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:Gde(c,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[Ct," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&s!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:r,...Ps(s==="running",s==="done"),title:`Runs ${((w=t==null?void 0:t.upgrade)==null?void 0:w.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:s==="running"?"installing…":s==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...Ps(m),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:m?"fetching…":s==="failed"?"Retry update":"Update & restart"}),s==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((j=t==null?void 0:t.upgrade)==null?void 0:j.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((b=t==null?void 0:t.upgrade)==null?void 0:b.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":L0.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Vt(L0,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:i?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function Zde({restart:e,versionCheck:t,upgrade:n,oldNameNotice:s,rating:r,onFeedback:o,everConnected:i,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:m,restartedTo:w,askRestart:j,restartCopy:b,restartFuseMs:k}=e,{version:v,notice:N,noticeOpen:S,dismissNotice:E}=t,{upgradeState:C,startUpgrade:I,copyCommand:R,cmdCopied:$}=n,{oldName:L,oldNameOpen:U,dismissOldName:O}=s,{ratingPhase:M,ratingScore:q,answerRating:A,rateLater:D,closeRating:P,holdThanks:K}=r,G=w?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",w,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):i&&!c?a.jsx($de,{restarting:p,restartMode:m,live:c,paused:d}):S&&N?a.jsx(Xde,{notice:N,version:v,dismissNotice:E,upgradeState:C,startUpgrade:I,copyCommand:R,cmdCopied:$,autoRestart:h,toggleAutoRestart:f,askRestart:j,restartCopy:b,restartFuseMs:k,restarting:p}):U&&L?a.jsx(Ide,{oldName:L,version:v,dismissOldName:O}):M!=="hidden"?a.jsx(Bde,{phase:M,score:q,onAnswer:A,onLater:D,onClose:P,onFeedback:o,onHold:K}):null;return a.jsxs(a.Fragment,{children:[G,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?h5:""})]})}function Jde(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Qde(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function ehe(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function the(e,t){const n=ehe(e),s=(...i)=>[n?`${n} on the canvas`:null,...i,"layout, pins and selection"].filter(c=>c!==null),r="This cannot be undone.";if(!t)return{goes:s("the event log on disk — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise"),stays:[],final:r,confirm:"Clear everything"};if(!t.path)return{goes:s(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${r}`,confirm:"Clear everything"};if(!t.mine){const i=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,c=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:s(),stays:[`the event log — ${i}${c}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:s("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:r,confirm:"Clear everything"};const o=t.decks-1;return{goes:s(`the event log ${o===1?"1 other running deck shares":`${o} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[o===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:r,confirm:"Clear everything"}}function nhe({agentCount:e,onConfirm:t,onCancel:n}){const s=y.useRef(null),r=ct(n,{focusRef:s,layer:v7}),o=xt(n),[i,c]=y.useState(null);y.useEffect(()=>{let m=!1;return fetch("/api/clear").then(w=>w.ok?w.json():null).then(w=>{m||c(Qde(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=the(e,i);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:d.map(m=>a.jsx("span",{children:m},m))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:h.length>0?h.map(m=>a.jsx("span",{children:m},m)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}const bf=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
|
|
109
|
-
What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function p5(e){return bf.find(t=>t.value===e)??bf[0]}const O0=3,fk=120,m5=1e4,g5=200,she="Write something first.";function aI(e){return e.trim()!==""}function rhe(e){var o;const t=e.trim();if(t==="")return"";const n=oI(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,r=pk(s).length>=O0?pk(s):pk(n);return ohe(r.length>=O0?r:oI(t))}function ahe(e,t){const n=rhe(t);return n.length>=O0?n:`${p5(e).label}: ${n}`}function oI(e){return e.replace(/\s+/g," ").trim()}function pk(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function ohe(e){if(e.length<=fk)return e;const t=e.slice(0,fk-1),n=t.lastIndexOf(" ");return`${(n>=fk/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function ihe({kind:e,body:t,contact:n}){const s={kind:e,title:ahe(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function lhe(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const che={darwin:"macOS",win32:"Windows",linux:"Linux"};function uhe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),r=che[n]??n;return s?`${r} · ${s}`:r}function dhe(e){return e?`ccdeck ${e.appVersion} · ${uhe(e.platform)}`:null}const hhe="sent with it",fhe="Your ccdeck version and system are sent with it.",phe="Add details",mhe="How to reach you",ghe="Email or GitHub @name",yhe="Only if you would like an answer.",whe=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function xhe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function y5(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function vhe(e){return Eu(e)?["⌘","Enter"]:["Ctrl","Enter"]}function bhe(e){return[...e].length===1}const w5="Thanks — feedback sent.";function iI(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const s=n==null?void 0:n.images;return e===400&&Array.isArray(s)&&typeof s[0]=="string"?`The server did not accept an image. ${s[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here."}function khe(e){return e==="sending"?"Sending…":e==="sent"?w5:""}const lI=1400,jhe=160;function Nhe({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),bf.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:s=>{y5(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const x5="fb-details";function She({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":x5,onClick:t,children:[phe,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function _he({open:e,contact:t,onContact:n}){const s=y.useId();return a.jsx("div",{id:x5,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[mhe,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:g5,autoComplete:"email",placeholder:ghe,"aria-describedby":s,onChange:r=>n(r.target.value),onKeyDown:r=>{y5(r.nativeEvent)&&r.preventDefault()}}),a.jsx("p",{id:s,className:"fb-hint",children:yhe})]}),a.jsx("div",{className:"fb-where",children:whe.map(r=>a.jsx("p",{children:r},r))})]})})})}const Ro=3,Ehe=5*1024*1024,Che=12*1024*1024,P0=8192,The=64*1024,Rhe=256*1024,Ahe=.92,Mhe=640,v5=.9,$he=.85,Ihe=6,Lhe=512*1024,kf={png:"image/png",jpeg:"image/jpeg"},Ohe={png:"png",jpeg:"jpg"},Phe=[137,80,78,71,13,10,26,10],Dhe=[255,216,255];function b5(e){const t=n=>e.length>=n.length&&n.every((s,r)=>e[r]===s);return t(Phe)?"png":t(Dhe)?"jpeg":null}function Fhe(e){const t=b5(e);return t==="png"?Bhe(e):t==="jpeg"?Uhe(e):null}function Bhe(e){const t=[73,72,68,82];if(e.length<24||!t.every((s,r)=>e[12+r]===s))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function qhe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function Uhe(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const s=e[t]<<8|e[t+1];if(s<2)return null;if(qhe(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=s}return null}function cI(e,t){return e.bytes>t||e.width>P0||e.height>P0}function Whe(e){return Math.min(Ehe,Che-The-e)}function k5(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function Hhe(e,t){const n=P0/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*v5:1;return k5(e,Math.min(1,n,s))}async function zhe(e,t,n){let s=Hhe(e,t),r=e.format;for(let o=0;o<Ihe;o++){const i=await n(s,r,r==="jpeg"?Ahe:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:r};if(r==="png"){r="jpeg";continue}if(s=k5(s,Math.min($he,Math.sqrt(t/i.size)*v5)),Math.max(s.width,s.height)<Mhe)return null}return null}async function Vhe(e,t,n){const s=new Uint8Array(await e.slice(0,Lhe).arrayBuffer()),r=b5(s);if(!r)return{ok:!1,problem:"type"};if(t<Rhe)return{ok:!1,problem:"no_room"};const o=e.type===kf[r]?e:new Blob([e],{type:kf[r]}),i=Fhe(s);if(i&&!cI({...i,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:r};if(!cI(d,t))return{ok:!0,blob:o,resized:null};const h=await zhe(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Ghe(e){return({width:t,height:n},s,r)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const c=i.getContext("2d");if(!c)return o(null);s==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),i.toBlob(d=>{i.width=0,i.height=0,o(d)},kf[s],r)})}const Khe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Ghe(t),release:()=>t.close()}};function Yhe(e){return e.includes("Files")}function Xhe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Zhe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Jhe(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((s,r)=>{const o=s.type===kf.jpeg?"jpeg":"png";n.append("images",s,`image-${r+1}.${Ohe[o]}`)}),{method:"POST",body:n}}const Qhe="Add screenshot",uI="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",efe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",dI="Three images at most. Remove one to add another.",tfe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function nfe(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function sfe(e,t){const n=`${e} of ${Ro}`;return t>0?`${n} · ${t} resized to fit`:n}function rfe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function afe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function ofe(e,t){const n=afe(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const j5="image/png,image/jpeg";function N5({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function ife({images:e,buttonRef:t}){const n=y.useRef(null),s=e.shots.length>=Ro;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:uI,"aria-describedby":"fb-attach-hint",onClick:()=>{var r;return s?e.sayFull():(r=n.current)==null?void 0:r.click()},children:[a.jsx(N5,{}),Qhe]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:uI}),a.jsx("input",{ref:n,type:"file",accept:j5,multiple:!0,hidden:!0,onChange:r=>{e.add(Array.from(r.target.files??[])),r.target.value=""}})]})}function lfe({images:e,addRef:t}){const n=y.useRef(new Map),s=y.useRef(null),r=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=sfe(d.length,d.filter(m=>m.resized).length);y.useLayoutEffect(()=>{var m;i!==null&&((m=i==="add"?t.current:n.current.get(i))==null||m.focus(),c(null))},[i,t]),y.useEffect(()=>{var m;e.problem&&((m=s.current)==null||m.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(m){c(Zhe(d.map(w=>w.id),m)??"add"),e.remove(m)}function p(m){var w;o.current=m,(w=r.current)==null||w.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:r,type:"file",accept:j5,hidden:!0,onChange:m=>{const w=o.current;w!==null&&e.replace(w,Array.from(m.target.files??[])),o.current=null,m.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((m,w)=>a.jsxs("li",{className:"fb-shot","data-fitting":m.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":nfe(w,m.name,m.resized),onClick:()=>p(m.id),children:[a.jsx("img",{className:"fb-shot-img",src:m.url,alt:""}),m.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:j=>{j?n.current.set(m.id,j):n.current.delete(m.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${w+1}`,title:`Remove image ${w+1}`,onClick:()=>f(m.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},m.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:efe})]}),e.problem&&a.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function cfe(e,t){return e.map((n,s)=>({id:t+s,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function ufe(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function dfe(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function hfe(e){const[t,n]=y.useState(()=>cfe((e==null?void 0:e.ready)??[],1)),[s,r]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback(M=>{M&&o.current++,r(q=>M?{problem:M,id:q.id+1}:q.problem?{problem:"",id:q.id}:q)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),m=y.useRef(!0),w=y.useRef(new Map),j=y.useRef([]),b=y.useRef(0),k=y.useCallback(M=>{h.current=M(h.current),n(h.current)},[]);y.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const M of h.current)URL.revokeObjectURL(M.url)}),[]);const v=y.useCallback(async(M,q)=>{const A=h.current.reduce((Z,V)=>{var X;return Z+(V.id===(q==null?void 0:q.id)?0:((X=V.blob)==null?void 0:X.size)??0)},0),D=(q==null?void 0:q.id)??++p.current,P=URL.createObjectURL(M),K={id:D,name:M.name||"image",url:P,blob:null,resized:null},G=b.current;w.current.set(D,M);let W=!1;const H=()=>{W||(W=!0,k(Z=>ufe(Z,K,q!==void 0)))},F=await Vhe(M,Whe(A),async Z=>(H(),Khe(Z))).catch(()=>({ok:!1,problem:"unreadable"})),B=h.current.some(Z=>Z.id===D);return!m.current||b.current!==G||!B&&(W||q)?(URL.revokeObjectURL(P),q&&URL.revokeObjectURL(q.url),m.current&&w.current.delete(D),""):(w.current.delete(D),F.ok?(H(),q&&URL.revokeObjectURL(q.url),k(Z=>Z.map(V=>V.id===D?{...V,blob:F.blob,resized:F.resized}:V)),""):(URL.revokeObjectURL(P),W&&k(Z=>dfe(Z,D,q)),ofe(F.problem,M.name||"image")))},[k]),N=y.useCallback(async M=>{i("");const q=b.current,A=[];let D=0,P=0;for(const G of M){if(!m.current||b.current!==q)return;const W=j.current.indexOf(G);if(W!==-1&&j.current.splice(W,1),h.current.length>=Ro){D++;continue}const H=h.current.length,F=await v(G);F&&A.push(F),h.current.length>H&&P++}if(!m.current||b.current!==q)return;D>0&&A.push(P===0&&A.length===0?dI:rfe(D)),i(A.join(" "));const K=h.current.length;P>0&&d(`${P===1?"Image":`${P} images`} added, ${K} of ${Ro}.`)},[v,i]),S=y.useCallback(async(M,q)=>{i("");const A=h.current.find(K=>K.id===M);if(!A)return N([q]);const D=await v(q,A);if(!m.current)return;i(D);const P=h.current.findIndex(K=>K.id===M);!D&&P!==-1&&d(`Image ${P+1} replaced, ${h.current.length} of ${Ro}.`)},[N,v,i]),E=y.useCallback(M=>{const q=b.current;f.current=(f.current??Promise.resolve()).then(()=>b.current===q?M():void 0).catch(()=>{})},[]),C=y.useCallback(M=>{M.length!==0&&(j.current.push(...M),E(()=>N(M)))},[N,E]);y.useEffect(()=>{e&&e.waiting.length>0&&C(e.waiting)},[]);const I=y.useCallback((M,q)=>{const A=q[0];A&&E(()=>S(M,A))},[E,S]),R=y.useCallback(M=>{const q=h.current.find(A=>A.id===M);q&&(URL.revokeObjectURL(q.url),w.current.delete(M),k(A=>A.filter(D=>D.id!==M)),i(""),d(`Image removed, ${h.current.length} of ${Ro}.`))},[k,i]),$=y.useCallback(()=>i(dI),[i]),L=y.useCallback(async()=>{const M=o.current;return await f.current,o.current!==M?null:h.current.flatMap(q=>q.blob?[q.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap(M=>M.blob&&!w.current.has(M.id)?[{name:M.name,blob:M.blob,resized:M.resized}]:[]),waiting:[...w.current.values(),...j.current]}),[]),O=y.useCallback(()=>{b.current++;for(const M of h.current)URL.revokeObjectURL(M.url);w.current.clear(),j.current=[],k(()=>[]),i("")},[k,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:c,add:C,replace:I,remove:R,sayFull:$,ready:L,kept:U,clear:O}}function ffe(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(s=>s.ok?s.json():null).then(s=>{n&&t(lhe(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function pfe(e){const[t,n]=y.useState({state:"idle"}),s=y.useRef(!1),r=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=r.current)==null?void 0:c.abort()},[]);async function o(c){if(!An(s.current))return;s.current=!0;const{signal:d}=r.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:tfe});return}const f=await fetch("/api/feedback",{...Jhe(ihe(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:iI(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:iI(0,null)})}finally{s.current=!1}}const i=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function mfe(e,t){const[n,s]=y.useState(!1),r=y.useRef(t);return r.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>s(!0),lI),i=window.setTimeout(()=>r.current(),lI+jhe);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const mk="agent-dag.feedbackDrafts",hI=4;function gfe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function yfe(e){return JSON.stringify([e.kind,e.body])}function wfe(e){return e.ready.length+e.waiting.length}function S5(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function xfe(e){return e===1?"The screenshot was not kept through the page reload. Add it again to send it.":`The ${e} screenshots were not kept through the page reload. Add them again to send them.`}const vfe="Discard",bfe="Confirm discard",kfe="Clear the message, the screenshots and the contact",fI="Press again to clear this draft. It cannot be brought back.",jfe={ready:[],waiting:[]};function Nfe(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:s,contact:r,images:o}=t;return!bf.some(i=>i.value===n)||typeof s!="string"||s.length>m5||typeof r!="string"||r.length>g5||typeof o!="number"||!Number.isInteger(o)||o<0||o>Ro?null:[e[0],{kind:n,body:s,contact:r,images:o}]}function Sfe(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const i=(o=e())==null?void 0:o.getItem(mk),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-hI)){const h=Nfe(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function s(){try{const o=e();if(!o)return;const i=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);i.length===0?o.removeItem(mk):o.setItem(mk,JSON.stringify(i))}catch{}}function r(o){n().delete(o)&&s()}return{read(o){const i=n().get(o);return i?{kind:i.kind,body:i.body,contact:i.contact,images:i.images??jfe,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=wfe(i.images);if(!S5({body:i.body,contact:i.contact,images:d},c)){r(o);return}const h=n();h.delete(o),h.set(o,{kind:i.kind,body:i.body,contact:i.contact,images:i.images,imageCount:d});for(const f of h.keys()){if(h.size<=hI)break;h.delete(f)}s()},forget:r}}function _fe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const D0=Sfe(_fe),Efe=4e3;function Cfe(e,t,n,s,r){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:s,sent:r};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||D0.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(i,[i,n.kind,n.body,n.contact,s.shots]),y.useEffect(()=>i,[i]),y.useEffect(()=>{r&&D0.forget(e)},[r,e])}const pI="draft";function Tfe(e){const[t,n]=y.useState(!1),s=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Efe);return()=>window.clearTimeout(o)},[t]);function r(){const o=Date.now(),i=fl({armedFor:t?pI:null,target:pI,armedAt:s.current,now:o,gapMs:hl});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:r}}function _5({onClose:e,initialKind:t,initialBody:n}){const s=y.useRef(null),r=y.useRef(null),o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),p=y.useRef(0),m=ct(e,{focusRef:s}),w=xt(e),j=gfe({initialKind:t,initialBody:n}),b=yfe(j),[k]=y.useState(()=>D0.read(b)),[v,N]=y.useState((k==null?void 0:k.kind)??j.kind),[S,E]=y.useState((k==null?void 0:k.body)??j.body),[C,I]=y.useState((k==null?void 0:k.contact)??""),[R,$]=y.useState((k==null?void 0:k.imagesLost)??0),[L,U]=y.useState(!1),[O,M]=y.useState(!1),[q,A]=y.useState(!1),D=hfe(k==null?void 0:k.images),P=dhe(ffe()),{outcome:K,sending:G,send:W,clearFailure:H}=pfe(D),F=K.state==="sent",B=mfe(F,e);Cfe(b,j,{kind:v,body:S,contact:C},D,F);const Z=S5({body:S,contact:C,images:D.shots.length},j),V=Tfe(()=>{var me;N(j.kind),E(j.body),I(""),$(0),M(!1),D.clear(),H(),(me=s.current)==null||me.focus()}),X=p5(v),Y=O&&!aI(S),J=R>0&&D.shots.length===0,ee=[Y&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ne,le]=vhe(_u());y.useEffect(()=>{var Pe,qe;const me=i.current;if(!me)return;const $e=me.contains(document.activeElement)||Kn(((Pe=document.activeElement)==null?void 0:Pe.tagName)??null);me.inert=F,F&&$e&&((qe=r.current)==null||qe.focus())},[F]),y.useEffect(()=>{var Le,Qe;const me=c.current;if(!me)return;const $e=h.current;if(G){const je=document.activeElement,Ae=je!=null&&(me.contains(je)||je===$e);f.current=Ae?je:null,me.inert=!0,$e&&($e.inert=!0),f.current&&((Le=d.current)==null||Le.focus());return}me.inert=!1,$e&&($e.inert=!1);const Pe=f.current;f.current=null;const qe=document.activeElement===d.current||Kn(((Qe=document.activeElement)==null?void 0:Qe.tagName)??null);!F&&Pe&&qe&&Pe.focus()},[G,F]);function de(me){var $e;if(me.preventDefault(),!aI(S)){M(!0),($e=s.current)==null||$e.focus();return}W({kind:v,body:S,contact:C})}const ue=!F&&!G,re=me=>Yhe(Array.from(me.dataTransfer.types));function pe(me){!re(me)||!ue||(me.preventDefault(),p.current++,A(!0))}function ye(me){re(me)&&(me.preventDefault(),me.dataTransfer.dropEffect=ue?"copy":"none")}function _e(me){re(me)&&(p.current=Math.max(0,p.current-1),p.current===0&&A(!1))}function he(me){re(me)&&(me.preventDefault(),p.current=0,A(!1),ue&&D.add(Array.from(me.dataTransfer.files)))}function ae(me){me.target!==me.currentTarget||!re(me)||(me.preventDefault(),me.dataTransfer.dropEffect="none")}function ge(me){re(me)&&me.preventDefault()}function Se(me){if(!ue)return;const $e=Array.from(me.clipboardData.files),Pe=me.target,qe=Pe instanceof HTMLTextAreaElement||Pe instanceof HTMLInputElement,Le=Array.from(me.clipboardData.types).includes("text/plain");Xhe({files:$e.length,hasText:Le,intoTextField:qe})&&(me.preventDefault(),D.add($e))}return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ae,onDrop:ge,"data-leaving":B||void 0,children:a.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:me=>me.stopPropagation(),onDragEnter:pe,onDragOver:ye,onDragLeave:_e,onDrop:he,onPaste:Se,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:r,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:V.armed?fI:khe(K.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:me=>{xhe(me.nativeEvent)&&(me.preventDefault(),me.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(Nhe,{kind:v,onChange:N}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),a.jsx("textarea",{ref:s,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:m5,rows:5,placeholder:X.placeholder,onChange:me=>E(me.target.value),"aria-invalid":Y||void 0,"aria-describedby":ee,required:!0}),Y&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:she}),a.jsx(lfe,{images:D,addRef:o}),J&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:xfe(R)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(ife,{images:D,buttonRef:o}),a.jsx(She,{open:L,onToggle:()=>U(me=>!me)})]}),a.jsx(_he,{open:L,contact:C,onContact:I})]}),a.jsx("p",{className:"fb-facts",children:P?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:P})," — ",hhe]}):fhe}),K.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:K.message})]}),a.jsxs("div",{className:"fb-foot",children:[Z&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${V.armed?" armed":""}`,onKeyDown:me=>{me.repeat&&me.preventDefault()},onClick:V.press,title:V.armed?fI:kfe,children:V.armed?bfe:vfe}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":bhe(ne)||void 0,children:ne}),a.jsx("kbd",{children:le})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Ps(G),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),F&&a.jsxs("div",{className:"fb-done",children:[a.jsx(hf,{}),a.jsx("p",{className:"fb-done-line",children:w5})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":q||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(N5,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const E5="Press Esc first if a key does nothing.",mI=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",action:"undo a re-arrange, while the canvas offers it",binds:["z","Z"],chord:!0},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","],chord:!0},{cap:"V",action:"sound settings — the switch, and each tone's volume and sound",binds:["v","V"]},{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]}]}],Rfe=/ \([A-Z?]\)/g;function C5(e){return e?mI:mI.map(t=>({...t,rows:t.rows.filter(n=>n.chord||!n.binds.some(v3)).map(n=>({...n,action:n.action.replace(Rfe,"")}))})).filter(t=>t.rows.length>0)}const Afe="Single-key shortcuts are off.",T5="Settings › Keyboard",Mfe=`Single-key shortcuts can be turned off in ${T5}.`;function $fe({onClose:e,onTour:t,onSettings:n}){const s=ct(e),r=xt(e),o=Eu(_u()),i=Ln(),c=C5(i);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal key-help",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[!i&&a.jsxs("div",{className:"kh-off",children:[a.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[a.jsx("strong",{children:Afe})," Turn them back on in"," ",a.jsx("span",{className:"kh-place",children:T5}),". Everything below still works."]}),n&&a.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:c.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:d.title}),d.rows.map(h=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o&&h.macCap?h.macCap:h.cap}),a.jsx("span",{children:h.action})]},`${d.title}:${h.cap}:${h.action}`))]},d.title))}),i&&a.jsxs("p",{className:"kh-foot",children:[E5," ",Mfe]})]})]})})}function Aj(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:s})=>a.jsx(Ife,{name:t,onClose:s})})))}function Ife({name:e,onClose:t}){const n=y.useRef(null),s=ct(t,{focusRef:n}),r=xt(t);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function Lfe(e,t){return`${e}#${t}`}function Ofe(e,{lan:t,now:n,closed:s}){if(t===void 0)return[];const r=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=Lfe(i.key,i.since);if(s.has(c)||bQ(i.key,o.email,t,n))continue;const d=o.email??"";r.push({id:c,key:i.key,since:i.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return r}function Pfe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(s=>s.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(s.num)===String(t.num))).map(s=>s.id):[]}function R5({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Dfe(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Ffe(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Bfe="Login expired",qfe="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",Ufe="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function Wfe(e,t){const n=(e??[]).filter(r=>r&&typeof r.fp=="string"&&!t.has(r.fp));if(!n.length)return{request:null,waiting:0};const s=[...n].sort((r,o)=>(r.at??0)-(o.at??0));return{request:s[0],waiting:s.length-1}}function Hfe({request:e,waiting:t,busy:n,now:s,onAccept:r,onDecline:o,onLater:i}){const c=y.useRef(null),d=ct(i,{focusRef:c}),h=xt(i),f=Fa(n,"accept"),p=Fa(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:i,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",Y1(e.at,s)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:r,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function zfe(e){const t=y.useRef(!1),n=Vfe(e),s=R5({rows:n?1:0,ours:t.current,dialogs:Cn.dialogDepth()});return t.current=s,s?n:null}function Vfe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:r}){const{request:o,waiting:i}=Wfe(e,t.current);return o?a.jsx(Hfe,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void s("accept",o.fp),onDecline:()=>void s("dismiss",o.fp),onLater:()=>r(o.fp)},o.fp):null}function Gfe({rows:e,onSignIn:t,onLater:n,firstRef:s}){const r=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[r?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:r.name}),r.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",r.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:qfe})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Ffe(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:Bfe}),a.jsx("button",{type:"button",className:"btn",ref:i===0?s:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:Ufe,onClick:n,children:"Not now"}),r&&a.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(r),children:"Sign in again"})]})]})}function Kfe({rows:e,onSignIn:t,onLater:n}){const s=y.useRef(null),r=ct(n,{focusRef:s}),o=xt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:Dfe(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(Gfe,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function Yfe({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:r,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=Cn.dialogDepth()+(c?1:0),f=t!=null||R5({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(KP,{email:t.email||null,onClose:o,onChanged:r,onSignedIn:s}):f?a.jsx(Kfe,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Xfe={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4","3.40.1","3.41.3"],"3.43.0":[{title:"🏠 Auto-switch can come back to a home account",body:"Choose Set as home in an account’s ⋯ menu. With Auto-switch on, Next account › Soonest weekly reset uses up quota that resets within 4 days first."},{title:"🔄 Sessions already running appear when ccdeck starts",body:"Busy Codex sessions, and Claude ones on macOS and Linux, show up again after a restart. Restore unfinished sessions, in Settings › General, turns it off."},{title:"⚙️ Settings, reorganized and searchable",body:"Search every setting from the top of the list. Keyboard, Data and About have sections of their own."},{title:"📋 Plan progress and reasoning effort on agent cards",body:"Cards show how far an agent is through its plan, and the effort beside the model. Finished sessions can hide themselves after a delay you choose."},{title:"✨ Calmer desktop updates, marked shared accounts, Codex sub-agents kept together",body:"The desktop app installs an update only when no agent is working or waiting. Accounts shared on Local network are marked."}],"3.42.0":[{title:"🔠 Text size and density, in Settings",body:"Five text sizes and five spacing levels, under Settings › Text & density."},{title:"🛠️ Tool activity: which tools your agents use, how long they take and what fails",body:"A new page on the stripe on the right. Its history is kept on this device only."},{title:"🎨 Gruvbox Dark, Light and Material themes",body:"Pick one in Settings › General. Switching themes now fades instead of snapping."},{title:"✨ A session-list drawer on phones, whole dates in usage history, the waiting session in the minimap",body:"Smaller fixes for the phone layout, the usage history chart and the canvas minimap."}],"3.41.1":[{title:"🪟 More reliable Windows updates",body:"Restart to update stops the app’s background server before installation begins."},{title:"📊 More accurate account capacity",body:"Elapsed resets and older readings no longer imply newly available quota. Account refreshes keep the latest valid readings."},{title:"🖥️ Better layouts on portrait displays",body:"Sessions fill the right columns, and the canvas starts near the top. Usage history controls stay reachable in narrow windows."},{title:"✨ Clearer load history and consistent icons",body:"Load history includes the current core-capacity multiplier below the charts. Refresh and external-link icons look consistent across system fonts."}],"3.41.0":[{title:"📅 Plan account resets",body:"See the next seven days of resets, account capacity and which readings need refreshing."},{title:"📊 Follow quota history",body:"Inspect recorded Claude and Codex quota readings to see how remaining capacity changes over time."},{title:"♻️ See cached input reuse",body:"Session usage details now show the percentage of measured input reused from cache."},{title:"📻 A more polished Radio Explorer",body:"Find radio stations with compact search and filters, explore workspace streams separately, and save favorites from either source. Playback and keyboard navigation are more reliable."},{title:"🌍 Radio flags on Windows",body:"Country flags now display correctly in the radio station list on Windows."},{title:"🔧 Clearer Telemetry Radar controls",body:"Change individual telemetry flags and use a simpler Monitor view."}],"3.40.2":[{title:"📻 Music is in Radio now, not in Settings",body:"Settings no longer has a Music section. Claude FM, Lofi Girl and the streams you added are under Workspace streams in Radio, on the right sidebar, and Radio’s player has the volume and mute. Your station, volume and streams are kept. Adding, renaming or removing a stream link is no longer offered."}],"3.40.0":[{title:"📻 Explore radio around the world",body:"Open Radio from the right sidebar to discover stations on a world map, filter by country, sound or language, and save your favorites. Recent listening, a daily pick and Surprise me make it easier to find something to play. Music keeps playing when you close the explorer. Volume now adjusts in 1% steps, and an unavailable stream automatically advances to the next station after one second."},{title:"🦊 Choose your canvas companion",body:"Choose Deck companion, Fox or Penguin in Settings › General. Your companion shares the existing canvas movements and music controls, and your choice stays saved."},{title:"📊 See what each session used",body:"Open a session’s usage details to inspect tokens, models and estimated cost. For Codex, compare Automatic, Standard, Fast and Flex pricing estimates without changing your Codex settings or billing."},{title:"A clearer canvas",body:"Session cards, tool traces and connections are easier to scan. The canvas reframes more reliably when resizing to portrait or rearranging sessions, and model cost estimates use updated pricing."}],"3.39.3":[{title:"A cleaner desktop window",body:"The desktop app now has one compact toolbar that follows your theme, with native window controls and an application menu. Wider side rails give icons more room; the Local network footer and unread badges are more compact."},{title:"Clearer account usage and Telemetry Radar",body:"Account usage shows reset times together with capacity. Telemetry Radar has a clearer monitoring workspace and keeps history for up to 24 hours. Radar remains Beta."},{title:"🔎 Telemetry Radar on Linux and Windows, with no Terminal step",body:"Radar now works on macOS, Linux and Windows. Press Start monitoring and ccdeck runs the capture itself, with no command to paste into Terminal, and keeps listening until you stop it. Capture needs a one-time setup for your user: Wireshark’s ChmodBPF helper on macOS, tcpdump with capture permission on Linux, or Wireshark with Npcap on Windows. Radar says what is missing, and once permission is granted it starts listening by itself."}],"3.39.1":[{title:"🎨 More themes, with clearer contrast",body:"Choose Omarchy, Matrix, Black Contrast, White Contrast or Catppuccin Mocha in Settings › General. Fresh installations start with Rider Black; your saved theme choice is preserved."},{title:"A little more room on the canvas",body:"The minimap is smaller, leaving more room for the character and your sessions. Undo and Resume now sit beside each other at the bottom of the canvas. Telemetry Radar is marked Beta while it is being tested and improved."}],"3.39.0":[{title:"🔎 Inspect Claude Code telemetry on macOS",body:"Telemetry Radar shows Claude Code's configured telemetry and can inspect traffic at destinations you choose. When settings are absent, it can show observed connections separately; a connection alone does not prove telemetry or reveal message contents. Captured telemetry can contain prompt or response content, and other apps sending to the same destination may appear too. Captured messages stay in ccdeck's memory, and no capture file is written."},{title:"🧭 Open panels from the edges",body:"Open the session list, Claude accounts, Usage, This machine, Usage history and Browser Watch from the window edges. You can keep several panels open beside the canvas; on a phone, the same controls sit in a bottom dock."},{title:"More control while you work",body:"Turn off single-key shortcuts if typed letters should not control the deck, see each stage while adding a Claude account, and undo a recent rearrangement. The topbar also names the Claude Code session waiting on you."},{title:"🎨 Two new dark themes",body:"Choose Rider Black or VS Code Black in Settings › General. Both add a darker canvas with flatter panels and distinct focus accents; your existing Light or Dark choice stays as it was."}],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). V opens it at Sounds, with each tone's volume and sound, and M turns sounds off or on from anywhere. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in Settings › Notifications, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:"Feedback, beside Settings at the right of the topbar (under More on a phone), opens a short form: pick what kind it is, write a few lines, and add a way to reach you under Add details if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why."}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The desktop app can also restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"Settings › General shows a small preview of the deck in each theme. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
|
|
109
|
+
What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function p5(e){return bf.find(t=>t.value===e)??bf[0]}const O0=3,fk=120,m5=1e4,g5=200,she="Write something first.";function aI(e){return e.trim()!==""}function rhe(e){var o;const t=e.trim();if(t==="")return"";const n=oI(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,r=pk(s).length>=O0?pk(s):pk(n);return ohe(r.length>=O0?r:oI(t))}function ahe(e,t){const n=rhe(t);return n.length>=O0?n:`${p5(e).label}: ${n}`}function oI(e){return e.replace(/\s+/g," ").trim()}function pk(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function ohe(e){if(e.length<=fk)return e;const t=e.slice(0,fk-1),n=t.lastIndexOf(" ");return`${(n>=fk/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function ihe({kind:e,body:t,contact:n}){const s={kind:e,title:ahe(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function lhe(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const che={darwin:"macOS",win32:"Windows",linux:"Linux"};function uhe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),r=che[n]??n;return s?`${r} · ${s}`:r}function dhe(e){return e?`ccdeck ${e.appVersion} · ${uhe(e.platform)}`:null}const hhe="sent with it",fhe="Your ccdeck version and system are sent with it.",phe="Add details",mhe="How to reach you",ghe="Email or GitHub @name",yhe="Only if you would like an answer.",whe=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function xhe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function y5(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function vhe(e){return Eu(e)?["⌘","Enter"]:["Ctrl","Enter"]}function bhe(e){return[...e].length===1}const w5="Thanks — feedback sent.";function iI(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const s=n==null?void 0:n.images;return e===400&&Array.isArray(s)&&typeof s[0]=="string"?`The server did not accept an image. ${s[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here."}function khe(e){return e==="sending"?"Sending…":e==="sent"?w5:""}const lI=1400,jhe=160;function Nhe({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),bf.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:s=>{y5(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const x5="fb-details";function She({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":x5,onClick:t,children:[phe,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function _he({open:e,contact:t,onContact:n}){const s=y.useId();return a.jsx("div",{id:x5,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[mhe,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:g5,autoComplete:"email",placeholder:ghe,"aria-describedby":s,onChange:r=>n(r.target.value),onKeyDown:r=>{y5(r.nativeEvent)&&r.preventDefault()}}),a.jsx("p",{id:s,className:"fb-hint",children:yhe})]}),a.jsx("div",{className:"fb-where",children:whe.map(r=>a.jsx("p",{children:r},r))})]})})})}const Ro=3,Ehe=5*1024*1024,Che=12*1024*1024,P0=8192,The=64*1024,Rhe=256*1024,Ahe=.92,Mhe=640,v5=.9,$he=.85,Ihe=6,Lhe=512*1024,kf={png:"image/png",jpeg:"image/jpeg"},Ohe={png:"png",jpeg:"jpg"},Phe=[137,80,78,71,13,10,26,10],Dhe=[255,216,255];function b5(e){const t=n=>e.length>=n.length&&n.every((s,r)=>e[r]===s);return t(Phe)?"png":t(Dhe)?"jpeg":null}function Fhe(e){const t=b5(e);return t==="png"?Bhe(e):t==="jpeg"?Uhe(e):null}function Bhe(e){const t=[73,72,68,82];if(e.length<24||!t.every((s,r)=>e[12+r]===s))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function qhe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function Uhe(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const s=e[t]<<8|e[t+1];if(s<2)return null;if(qhe(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=s}return null}function cI(e,t){return e.bytes>t||e.width>P0||e.height>P0}function Whe(e){return Math.min(Ehe,Che-The-e)}function k5(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function Hhe(e,t){const n=P0/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*v5:1;return k5(e,Math.min(1,n,s))}async function zhe(e,t,n){let s=Hhe(e,t),r=e.format;for(let o=0;o<Ihe;o++){const i=await n(s,r,r==="jpeg"?Ahe:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:r};if(r==="png"){r="jpeg";continue}if(s=k5(s,Math.min($he,Math.sqrt(t/i.size)*v5)),Math.max(s.width,s.height)<Mhe)return null}return null}async function Vhe(e,t,n){const s=new Uint8Array(await e.slice(0,Lhe).arrayBuffer()),r=b5(s);if(!r)return{ok:!1,problem:"type"};if(t<Rhe)return{ok:!1,problem:"no_room"};const o=e.type===kf[r]?e:new Blob([e],{type:kf[r]}),i=Fhe(s);if(i&&!cI({...i,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:r};if(!cI(d,t))return{ok:!0,blob:o,resized:null};const h=await zhe(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Ghe(e){return({width:t,height:n},s,r)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const c=i.getContext("2d");if(!c)return o(null);s==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),i.toBlob(d=>{i.width=0,i.height=0,o(d)},kf[s],r)})}const Khe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Ghe(t),release:()=>t.close()}};function Yhe(e){return e.includes("Files")}function Xhe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Zhe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Jhe(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((s,r)=>{const o=s.type===kf.jpeg?"jpeg":"png";n.append("images",s,`image-${r+1}.${Ohe[o]}`)}),{method:"POST",body:n}}const Qhe="Add screenshot",uI="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",efe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",dI="Three images at most. Remove one to add another.",tfe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function nfe(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function sfe(e,t){const n=`${e} of ${Ro}`;return t>0?`${n} · ${t} resized to fit`:n}function rfe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function afe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function ofe(e,t){const n=afe(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const j5="image/png,image/jpeg";function N5({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function ife({images:e,buttonRef:t}){const n=y.useRef(null),s=e.shots.length>=Ro;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:uI,"aria-describedby":"fb-attach-hint",onClick:()=>{var r;return s?e.sayFull():(r=n.current)==null?void 0:r.click()},children:[a.jsx(N5,{}),Qhe]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:uI}),a.jsx("input",{ref:n,type:"file",accept:j5,multiple:!0,hidden:!0,onChange:r=>{e.add(Array.from(r.target.files??[])),r.target.value=""}})]})}function lfe({images:e,addRef:t}){const n=y.useRef(new Map),s=y.useRef(null),r=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=sfe(d.length,d.filter(m=>m.resized).length);y.useLayoutEffect(()=>{var m;i!==null&&((m=i==="add"?t.current:n.current.get(i))==null||m.focus(),c(null))},[i,t]),y.useEffect(()=>{var m;e.problem&&((m=s.current)==null||m.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(m){c(Zhe(d.map(w=>w.id),m)??"add"),e.remove(m)}function p(m){var w;o.current=m,(w=r.current)==null||w.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:r,type:"file",accept:j5,hidden:!0,onChange:m=>{const w=o.current;w!==null&&e.replace(w,Array.from(m.target.files??[])),o.current=null,m.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((m,w)=>a.jsxs("li",{className:"fb-shot","data-fitting":m.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":nfe(w,m.name,m.resized),onClick:()=>p(m.id),children:[a.jsx("img",{className:"fb-shot-img",src:m.url,alt:""}),m.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:j=>{j?n.current.set(m.id,j):n.current.delete(m.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${w+1}`,title:`Remove image ${w+1}`,onClick:()=>f(m.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},m.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:efe})]}),e.problem&&a.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function cfe(e,t){return e.map((n,s)=>({id:t+s,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function ufe(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function dfe(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function hfe(e){const[t,n]=y.useState(()=>cfe((e==null?void 0:e.ready)??[],1)),[s,r]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback(M=>{M&&o.current++,r(q=>M?{problem:M,id:q.id+1}:q.problem?{problem:"",id:q.id}:q)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),m=y.useRef(!0),w=y.useRef(new Map),j=y.useRef([]),b=y.useRef(0),k=y.useCallback(M=>{h.current=M(h.current),n(h.current)},[]);y.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const M of h.current)URL.revokeObjectURL(M.url)}),[]);const v=y.useCallback(async(M,q)=>{const A=h.current.reduce((Z,V)=>{var X;return Z+(V.id===(q==null?void 0:q.id)?0:((X=V.blob)==null?void 0:X.size)??0)},0),D=(q==null?void 0:q.id)??++p.current,P=URL.createObjectURL(M),K={id:D,name:M.name||"image",url:P,blob:null,resized:null},G=b.current;w.current.set(D,M);let W=!1;const H=()=>{W||(W=!0,k(Z=>ufe(Z,K,q!==void 0)))},F=await Vhe(M,Whe(A),async Z=>(H(),Khe(Z))).catch(()=>({ok:!1,problem:"unreadable"})),B=h.current.some(Z=>Z.id===D);return!m.current||b.current!==G||!B&&(W||q)?(URL.revokeObjectURL(P),q&&URL.revokeObjectURL(q.url),m.current&&w.current.delete(D),""):(w.current.delete(D),F.ok?(H(),q&&URL.revokeObjectURL(q.url),k(Z=>Z.map(V=>V.id===D?{...V,blob:F.blob,resized:F.resized}:V)),""):(URL.revokeObjectURL(P),W&&k(Z=>dfe(Z,D,q)),ofe(F.problem,M.name||"image")))},[k]),N=y.useCallback(async M=>{i("");const q=b.current,A=[];let D=0,P=0;for(const G of M){if(!m.current||b.current!==q)return;const W=j.current.indexOf(G);if(W!==-1&&j.current.splice(W,1),h.current.length>=Ro){D++;continue}const H=h.current.length,F=await v(G);F&&A.push(F),h.current.length>H&&P++}if(!m.current||b.current!==q)return;D>0&&A.push(P===0&&A.length===0?dI:rfe(D)),i(A.join(" "));const K=h.current.length;P>0&&d(`${P===1?"Image":`${P} images`} added, ${K} of ${Ro}.`)},[v,i]),S=y.useCallback(async(M,q)=>{i("");const A=h.current.find(K=>K.id===M);if(!A)return N([q]);const D=await v(q,A);if(!m.current)return;i(D);const P=h.current.findIndex(K=>K.id===M);!D&&P!==-1&&d(`Image ${P+1} replaced, ${h.current.length} of ${Ro}.`)},[N,v,i]),E=y.useCallback(M=>{const q=b.current;f.current=(f.current??Promise.resolve()).then(()=>b.current===q?M():void 0).catch(()=>{})},[]),C=y.useCallback(M=>{M.length!==0&&(j.current.push(...M),E(()=>N(M)))},[N,E]);y.useEffect(()=>{e&&e.waiting.length>0&&C(e.waiting)},[]);const I=y.useCallback((M,q)=>{const A=q[0];A&&E(()=>S(M,A))},[E,S]),R=y.useCallback(M=>{const q=h.current.find(A=>A.id===M);q&&(URL.revokeObjectURL(q.url),w.current.delete(M),k(A=>A.filter(D=>D.id!==M)),i(""),d(`Image removed, ${h.current.length} of ${Ro}.`))},[k,i]),$=y.useCallback(()=>i(dI),[i]),L=y.useCallback(async()=>{const M=o.current;return await f.current,o.current!==M?null:h.current.flatMap(q=>q.blob?[q.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap(M=>M.blob&&!w.current.has(M.id)?[{name:M.name,blob:M.blob,resized:M.resized}]:[]),waiting:[...w.current.values(),...j.current]}),[]),O=y.useCallback(()=>{b.current++;for(const M of h.current)URL.revokeObjectURL(M.url);w.current.clear(),j.current=[],k(()=>[]),i("")},[k,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:c,add:C,replace:I,remove:R,sayFull:$,ready:L,kept:U,clear:O}}function ffe(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(s=>s.ok?s.json():null).then(s=>{n&&t(lhe(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function pfe(e){const[t,n]=y.useState({state:"idle"}),s=y.useRef(!1),r=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=r.current)==null?void 0:c.abort()},[]);async function o(c){if(!An(s.current))return;s.current=!0;const{signal:d}=r.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:tfe});return}const f=await fetch("/api/feedback",{...Jhe(ihe(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:iI(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:iI(0,null)})}finally{s.current=!1}}const i=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function mfe(e,t){const[n,s]=y.useState(!1),r=y.useRef(t);return r.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>s(!0),lI),i=window.setTimeout(()=>r.current(),lI+jhe);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const mk="agent-dag.feedbackDrafts",hI=4;function gfe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function yfe(e){return JSON.stringify([e.kind,e.body])}function wfe(e){return e.ready.length+e.waiting.length}function S5(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function xfe(e){return e===1?"The screenshot was not kept through the page reload. Add it again to send it.":`The ${e} screenshots were not kept through the page reload. Add them again to send them.`}const vfe="Discard",bfe="Confirm discard",kfe="Clear the message, the screenshots and the contact",fI="Press again to clear this draft. It cannot be brought back.",jfe={ready:[],waiting:[]};function Nfe(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:s,contact:r,images:o}=t;return!bf.some(i=>i.value===n)||typeof s!="string"||s.length>m5||typeof r!="string"||r.length>g5||typeof o!="number"||!Number.isInteger(o)||o<0||o>Ro?null:[e[0],{kind:n,body:s,contact:r,images:o}]}function Sfe(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const i=(o=e())==null?void 0:o.getItem(mk),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-hI)){const h=Nfe(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function s(){try{const o=e();if(!o)return;const i=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);i.length===0?o.removeItem(mk):o.setItem(mk,JSON.stringify(i))}catch{}}function r(o){n().delete(o)&&s()}return{read(o){const i=n().get(o);return i?{kind:i.kind,body:i.body,contact:i.contact,images:i.images??jfe,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=wfe(i.images);if(!S5({body:i.body,contact:i.contact,images:d},c)){r(o);return}const h=n();h.delete(o),h.set(o,{kind:i.kind,body:i.body,contact:i.contact,images:i.images,imageCount:d});for(const f of h.keys()){if(h.size<=hI)break;h.delete(f)}s()},forget:r}}function _fe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const D0=Sfe(_fe),Efe=4e3;function Cfe(e,t,n,s,r){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:s,sent:r};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||D0.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(i,[i,n.kind,n.body,n.contact,s.shots]),y.useEffect(()=>i,[i]),y.useEffect(()=>{r&&D0.forget(e)},[r,e])}const pI="draft";function Tfe(e){const[t,n]=y.useState(!1),s=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Efe);return()=>window.clearTimeout(o)},[t]);function r(){const o=Date.now(),i=fl({armedFor:t?pI:null,target:pI,armedAt:s.current,now:o,gapMs:hl});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:r}}function _5({onClose:e,initialKind:t,initialBody:n}){const s=y.useRef(null),r=y.useRef(null),o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),p=y.useRef(0),m=ct(e,{focusRef:s}),w=xt(e),j=gfe({initialKind:t,initialBody:n}),b=yfe(j),[k]=y.useState(()=>D0.read(b)),[v,N]=y.useState((k==null?void 0:k.kind)??j.kind),[S,E]=y.useState((k==null?void 0:k.body)??j.body),[C,I]=y.useState((k==null?void 0:k.contact)??""),[R,$]=y.useState((k==null?void 0:k.imagesLost)??0),[L,U]=y.useState(!1),[O,M]=y.useState(!1),[q,A]=y.useState(!1),D=hfe(k==null?void 0:k.images),P=dhe(ffe()),{outcome:K,sending:G,send:W,clearFailure:H}=pfe(D),F=K.state==="sent",B=mfe(F,e);Cfe(b,j,{kind:v,body:S,contact:C},D,F);const Z=S5({body:S,contact:C,images:D.shots.length},j),V=Tfe(()=>{var me;N(j.kind),E(j.body),I(""),$(0),M(!1),D.clear(),H(),(me=s.current)==null||me.focus()}),X=p5(v),Y=O&&!aI(S),J=R>0&&D.shots.length===0,ee=[Y&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ne,le]=vhe(_u());y.useEffect(()=>{var Pe,qe;const me=i.current;if(!me)return;const $e=me.contains(document.activeElement)||Kn(((Pe=document.activeElement)==null?void 0:Pe.tagName)??null);me.inert=F,F&&$e&&((qe=r.current)==null||qe.focus())},[F]),y.useEffect(()=>{var Le,Qe;const me=c.current;if(!me)return;const $e=h.current;if(G){const je=document.activeElement,Ae=je!=null&&(me.contains(je)||je===$e);f.current=Ae?je:null,me.inert=!0,$e&&($e.inert=!0),f.current&&((Le=d.current)==null||Le.focus());return}me.inert=!1,$e&&($e.inert=!1);const Pe=f.current;f.current=null;const qe=document.activeElement===d.current||Kn(((Qe=document.activeElement)==null?void 0:Qe.tagName)??null);!F&&Pe&&qe&&Pe.focus()},[G,F]);function de(me){var $e;if(me.preventDefault(),!aI(S)){M(!0),($e=s.current)==null||$e.focus();return}W({kind:v,body:S,contact:C})}const ue=!F&&!G,re=me=>Yhe(Array.from(me.dataTransfer.types));function pe(me){!re(me)||!ue||(me.preventDefault(),p.current++,A(!0))}function ye(me){re(me)&&(me.preventDefault(),me.dataTransfer.dropEffect=ue?"copy":"none")}function _e(me){re(me)&&(p.current=Math.max(0,p.current-1),p.current===0&&A(!1))}function he(me){re(me)&&(me.preventDefault(),p.current=0,A(!1),ue&&D.add(Array.from(me.dataTransfer.files)))}function ae(me){me.target!==me.currentTarget||!re(me)||(me.preventDefault(),me.dataTransfer.dropEffect="none")}function ge(me){re(me)&&me.preventDefault()}function Se(me){if(!ue)return;const $e=Array.from(me.clipboardData.files),Pe=me.target,qe=Pe instanceof HTMLTextAreaElement||Pe instanceof HTMLInputElement,Le=Array.from(me.clipboardData.types).includes("text/plain");Xhe({files:$e.length,hasText:Le,intoTextField:qe})&&(me.preventDefault(),D.add($e))}return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ae,onDrop:ge,"data-leaving":B||void 0,children:a.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:me=>me.stopPropagation(),onDragEnter:pe,onDragOver:ye,onDragLeave:_e,onDrop:he,onPaste:Se,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:r,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:V.armed?fI:khe(K.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:me=>{xhe(me.nativeEvent)&&(me.preventDefault(),me.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(Nhe,{kind:v,onChange:N}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),a.jsx("textarea",{ref:s,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:m5,rows:5,placeholder:X.placeholder,onChange:me=>E(me.target.value),"aria-invalid":Y||void 0,"aria-describedby":ee,required:!0}),Y&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:she}),a.jsx(lfe,{images:D,addRef:o}),J&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:xfe(R)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(ife,{images:D,buttonRef:o}),a.jsx(She,{open:L,onToggle:()=>U(me=>!me)})]}),a.jsx(_he,{open:L,contact:C,onContact:I})]}),a.jsx("p",{className:"fb-facts",children:P?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:P})," — ",hhe]}):fhe}),K.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:K.message})]}),a.jsxs("div",{className:"fb-foot",children:[Z&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${V.armed?" armed":""}`,onKeyDown:me=>{me.repeat&&me.preventDefault()},onClick:V.press,title:V.armed?fI:kfe,children:V.armed?bfe:vfe}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":bhe(ne)||void 0,children:ne}),a.jsx("kbd",{children:le})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Ps(G),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),F&&a.jsxs("div",{className:"fb-done",children:[a.jsx(hf,{}),a.jsx("p",{className:"fb-done-line",children:w5})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":q||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(N5,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const E5="Press Esc first if a key does nothing.",mI=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",action:"undo a re-arrange, while the canvas offers it",binds:["z","Z"],chord:!0},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","],chord:!0},{cap:"V",action:"sound settings — the switch, and each tone's volume and sound",binds:["v","V"]},{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]}]}],Rfe=/ \([A-Z?]\)/g;function C5(e){return e?mI:mI.map(t=>({...t,rows:t.rows.filter(n=>n.chord||!n.binds.some(v3)).map(n=>({...n,action:n.action.replace(Rfe,"")}))})).filter(t=>t.rows.length>0)}const Afe="Single-key shortcuts are off.",T5="Settings › Keyboard",Mfe=`Single-key shortcuts can be turned off in ${T5}.`;function $fe({onClose:e,onTour:t,onSettings:n}){const s=ct(e),r=xt(e),o=Eu(_u()),i=Ln(),c=C5(i);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal key-help",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[!i&&a.jsxs("div",{className:"kh-off",children:[a.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[a.jsx("strong",{children:Afe})," Turn them back on in"," ",a.jsx("span",{className:"kh-place",children:T5}),". Everything below still works."]}),n&&a.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:c.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:d.title}),d.rows.map(h=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o&&h.macCap?h.macCap:h.cap}),a.jsx("span",{children:h.action})]},`${d.title}:${h.cap}:${h.action}`))]},d.title))}),i&&a.jsxs("p",{className:"kh-foot",children:[E5," ",Mfe]})]})]})})}function Aj(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:s})=>a.jsx(Ife,{name:t,onClose:s})})))}function Ife({name:e,onClose:t}){const n=y.useRef(null),s=ct(t,{focusRef:n}),r=xt(t);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function Lfe(e,t){return`${e}#${t}`}function Ofe(e,{lan:t,now:n,closed:s}){if(t===void 0)return[];const r=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=Lfe(i.key,i.since);if(s.has(c)||bQ(i.key,o.email,t,n))continue;const d=o.email??"";r.push({id:c,key:i.key,since:i.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return r}function Pfe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(s=>s.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(s.num)===String(t.num))).map(s=>s.id):[]}function R5({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Dfe(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Ffe(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Bfe="Login expired",qfe="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",Ufe="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function Wfe(e,t){const n=(e??[]).filter(r=>r&&typeof r.fp=="string"&&!t.has(r.fp));if(!n.length)return{request:null,waiting:0};const s=[...n].sort((r,o)=>(r.at??0)-(o.at??0));return{request:s[0],waiting:s.length-1}}function Hfe({request:e,waiting:t,busy:n,now:s,onAccept:r,onDecline:o,onLater:i}){const c=y.useRef(null),d=ct(i,{focusRef:c}),h=xt(i),f=Fa(n,"accept"),p=Fa(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:i,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",Y1(e.at,s)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:r,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function zfe(e){const t=y.useRef(!1),n=Vfe(e),s=R5({rows:n?1:0,ours:t.current,dialogs:Cn.dialogDepth()});return t.current=s,s?n:null}function Vfe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:r}){const{request:o,waiting:i}=Wfe(e,t.current);return o?a.jsx(Hfe,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void s("accept",o.fp),onDecline:()=>void s("dismiss",o.fp),onLater:()=>r(o.fp)},o.fp):null}function Gfe({rows:e,onSignIn:t,onLater:n,firstRef:s}){const r=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[r?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:r.name}),r.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",r.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:qfe})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Ffe(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:Bfe}),a.jsx("button",{type:"button",className:"btn",ref:i===0?s:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:Ufe,onClick:n,children:"Not now"}),r&&a.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(r),children:"Sign in again"})]})]})}function Kfe({rows:e,onSignIn:t,onLater:n}){const s=y.useRef(null),r=ct(n,{focusRef:s}),o=xt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:Dfe(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(Gfe,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function Yfe({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:r,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=Cn.dialogDepth()+(c?1:0),f=t!=null||R5({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(KP,{email:t.email||null,onClose:o,onChanged:r,onSignedIn:s}):f?a.jsx(Kfe,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Xfe={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4","3.40.1","3.41.3","3.43.1"],"3.43.0":[{title:"🏠 Auto-switch can come back to a home account",body:"Choose Set as home in an account’s ⋯ menu. With Auto-switch on, Next account › Soonest weekly reset uses up quota that resets within 4 days first."},{title:"🔄 Sessions already running appear when ccdeck starts",body:"Busy Codex sessions, and Claude ones on macOS and Linux, show up again after a restart. Restore unfinished sessions, in Settings › General, turns it off."},{title:"⚙️ Settings, reorganized and searchable",body:"Search every setting from the top of the list. Keyboard, Data and About have sections of their own."},{title:"📋 Plan progress and reasoning effort on agent cards",body:"Cards show how far an agent is through its plan, and the effort beside the model. Finished sessions can hide themselves after a delay you choose."},{title:"✨ Calmer desktop updates, marked shared accounts, Codex sub-agents kept together",body:"The desktop app installs an update only when no agent is working or waiting. Accounts shared on Local network are marked."}],"3.42.0":[{title:"🔠 Text size and density, in Settings",body:"Five text sizes and five spacing levels, under Settings › Text & density."},{title:"🛠️ Tool activity: which tools your agents use, how long they take and what fails",body:"A new page on the stripe on the right. Its history is kept on this device only."},{title:"🎨 Gruvbox Dark, Light and Material themes",body:"Pick one in Settings › General. Switching themes now fades instead of snapping."},{title:"✨ A session-list drawer on phones, whole dates in usage history, the waiting session in the minimap",body:"Smaller fixes for the phone layout, the usage history chart and the canvas minimap."}],"3.41.1":[{title:"🪟 More reliable Windows updates",body:"Restart to update stops the app’s background server before installation begins."},{title:"📊 More accurate account capacity",body:"Elapsed resets and older readings no longer imply newly available quota. Account refreshes keep the latest valid readings."},{title:"🖥️ Better layouts on portrait displays",body:"Sessions fill the right columns, and the canvas starts near the top. Usage history controls stay reachable in narrow windows."},{title:"✨ Clearer load history and consistent icons",body:"Load history includes the current core-capacity multiplier below the charts. Refresh and external-link icons look consistent across system fonts."}],"3.41.0":[{title:"📅 Plan account resets",body:"See the next seven days of resets, account capacity and which readings need refreshing."},{title:"📊 Follow quota history",body:"Inspect recorded Claude and Codex quota readings to see how remaining capacity changes over time."},{title:"♻️ See cached input reuse",body:"Session usage details now show the percentage of measured input reused from cache."},{title:"📻 A more polished Radio Explorer",body:"Find radio stations with compact search and filters, explore workspace streams separately, and save favorites from either source. Playback and keyboard navigation are more reliable."},{title:"🌍 Radio flags on Windows",body:"Country flags now display correctly in the radio station list on Windows."},{title:"🔧 Clearer Telemetry Radar controls",body:"Change individual telemetry flags and use a simpler Monitor view."}],"3.40.2":[{title:"📻 Music is in Radio now, not in Settings",body:"Settings no longer has a Music section. Claude FM, Lofi Girl and the streams you added are under Workspace streams in Radio, on the right sidebar, and Radio’s player has the volume and mute. Your station, volume and streams are kept. Adding, renaming or removing a stream link is no longer offered."}],"3.40.0":[{title:"📻 Explore radio around the world",body:"Open Radio from the right sidebar to discover stations on a world map, filter by country, sound or language, and save your favorites. Recent listening, a daily pick and Surprise me make it easier to find something to play. Music keeps playing when you close the explorer. Volume now adjusts in 1% steps, and an unavailable stream automatically advances to the next station after one second."},{title:"🦊 Choose your canvas companion",body:"Choose Deck companion, Fox or Penguin in Settings › General. Your companion shares the existing canvas movements and music controls, and your choice stays saved."},{title:"📊 See what each session used",body:"Open a session’s usage details to inspect tokens, models and estimated cost. For Codex, compare Automatic, Standard, Fast and Flex pricing estimates without changing your Codex settings or billing."},{title:"A clearer canvas",body:"Session cards, tool traces and connections are easier to scan. The canvas reframes more reliably when resizing to portrait or rearranging sessions, and model cost estimates use updated pricing."}],"3.39.3":[{title:"A cleaner desktop window",body:"The desktop app now has one compact toolbar that follows your theme, with native window controls and an application menu. Wider side rails give icons more room; the Local network footer and unread badges are more compact."},{title:"Clearer account usage and Telemetry Radar",body:"Account usage shows reset times together with capacity. Telemetry Radar has a clearer monitoring workspace and keeps history for up to 24 hours. Radar remains Beta."},{title:"🔎 Telemetry Radar on Linux and Windows, with no Terminal step",body:"Radar now works on macOS, Linux and Windows. Press Start monitoring and ccdeck runs the capture itself, with no command to paste into Terminal, and keeps listening until you stop it. Capture needs a one-time setup for your user: Wireshark’s ChmodBPF helper on macOS, tcpdump with capture permission on Linux, or Wireshark with Npcap on Windows. Radar says what is missing, and once permission is granted it starts listening by itself."}],"3.39.1":[{title:"🎨 More themes, with clearer contrast",body:"Choose Omarchy, Matrix, Black Contrast, White Contrast or Catppuccin Mocha in Settings › General. Fresh installations start with Rider Black; your saved theme choice is preserved."},{title:"A little more room on the canvas",body:"The minimap is smaller, leaving more room for the character and your sessions. Undo and Resume now sit beside each other at the bottom of the canvas. Telemetry Radar is marked Beta while it is being tested and improved."}],"3.39.0":[{title:"🔎 Inspect Claude Code telemetry on macOS",body:"Telemetry Radar shows Claude Code's configured telemetry and can inspect traffic at destinations you choose. When settings are absent, it can show observed connections separately; a connection alone does not prove telemetry or reveal message contents. Captured telemetry can contain prompt or response content, and other apps sending to the same destination may appear too. Captured messages stay in ccdeck's memory, and no capture file is written."},{title:"🧭 Open panels from the edges",body:"Open the session list, Claude accounts, Usage, This machine, Usage history and Browser Watch from the window edges. You can keep several panels open beside the canvas; on a phone, the same controls sit in a bottom dock."},{title:"More control while you work",body:"Turn off single-key shortcuts if typed letters should not control the deck, see each stage while adding a Claude account, and undo a recent rearrangement. The topbar also names the Claude Code session waiting on you."},{title:"🎨 Two new dark themes",body:"Choose Rider Black or VS Code Black in Settings › General. Both add a darker canvas with flatter panels and distinct focus accents; your existing Light or Dark choice stays as it was."}],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). V opens it at Sounds, with each tone's volume and sound, and M turns sounds off or on from anywhere. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in Settings › Notifications, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:"Feedback, beside Settings at the right of the topbar (under More on a phone), opens a short form: pick what kind it is, write a few lines, and add a way to reach you under Add details if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why."}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The desktop app can also restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"Settings › General shows a small preview of the deck in each theme. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
|
|
110
110
|
|
|
111
111
|
A problem stays on the row — an expired login, one that was never stored, a keychain the deck cannot open — with the reason and the sign-in one press away. Auto-switch is one row now: its threshold and its switch. Local network moved out of the column into a view of its own, reached from a row at the foot that says how many of the paired machines are on right now, and shows which ones when you hover it.`},{title:"💬 A resting session shows Claude Code's recap beside its card",body:"When a session stops, Claude Code's own recap of what it did is drawn beside the card — so a board you come back to says what happened without opening anything."},{title:"🪟 The chrome went quiet",body:`The topbar is borderless, one set of corners runs through the app, the canvas ground is flat, and the minimap, the zoom controls, the type filter and the Machine and Usage panels read as tooling rather than as cards.
|
|
112
112
|
|
|
@@ -300,11 +300,11 @@ While it is open it polls this machine once every few seconds, and it stops the
|
|
|
300
300
|
|
|
301
301
|
It marks that work now. A chart with bars in it means the agent is doing something, whether or not it has called a tool in the last minute; a flat chart means it genuinely is not. Hover it for the split — how many tool calls and how many blocks of thinking and writing landed in the last 60 seconds.
|
|
302
302
|
|
|
303
|
-
Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},Mj="agent-dag.releaseNotesSeen";function gI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Vo(e,t){const n=gI(e),s=gI(t);for(let r=0;r<Math.max(n.length,s.length);r++){const o=(n[r]??0)-(s[r]??0);if(o!==0)return o<0?-1:1}return 0}function Wa(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Zfe(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function Jfe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!Wa(n)||!Array.isArray(s))continue;const r=s.filter(Zfe);r.length&&t.push({version:n,notes:r})}return t.sort((n,s)=>Vo(s.version,n.version))}const yI=Jfe(Xfe);function A5(e,t,n){return e.filter(s=>Vo(s.version,n)<=0&&(t===null||Vo(s.version,t)>0))}function Qfe(e,t){return e.filter(n=>Vo(n.version,t)===0)}function epe(e){if(!e.length)return"";const t=e[0].version,n=e[e.length-1].version;return t===n?`v${t}`:`v${n} – v${t}`}function tpe({since:e,running:t,entries:n,firstRun:s}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const i=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${i} changed something you would notice. Clicking the version in the topbar brings this back.`}if(s&&Wa(t))return`The deck has not run in this browser before, so this is what v${t} — the release you have — changed. Earlier releases are not repeated here; clicking the version in the topbar brings all of them back.`;const r=n[0].version;if(!Wa(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const o=Vo(r,t);return o<0?`v${t} · 🐛 Bug fixes and performance improvements. Earlier release notes are shown below.`:o>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const npe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function spe(e){const t=npe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function rpe(e){if(!e)return null;let t=null;try{t=e.getItem(Mj)}catch{return null}return Wa(t)?t:null}function ape(e){if(!e)return!1;try{return e.getItem(Mj),!0}catch{return!1}}function ope(e,t){if(!e)return!1;try{return e.setItem(Mj,t),!0}catch{return!1}}const M5="agent-dag.tourSeen";function ipe(e){if(!e)return!1;try{return e.getItem(M5)==="1"}catch{return!1}}function lpe(e){if(!e)return!1;try{return e.setItem(M5,"1"),!0}catch{return!1}}function cpe({tourSeen:e,decision:t}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};if(t.reason==="welcome"||t.reason==="first-run")return{tour:!e,notes:"none"};const n=t.show.length>0;return e?{tour:!1,notes:n?"now":"none"}:{tour:!0,notes:n?"after":"none"}}function upe({stored:e,running:t,notes:n,remembers:s=!0}){if(!Wa(t))return{show:[],record:null,reason:"no-version"};if(!Wa(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=Qfe(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const r=Vo(e,t);if(r===0)return{show:[],record:null,reason:"seen"};if(r>0)return{show:[],record:null,reason:"ahead"};const o=A5(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function dpe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const s=e.indexOf("`",n+1);if(s<0)break;n=s+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function $5(e,t=!0){const n=[];let s="";const r=()=>{s&&(n.push({kind:"text",text:s}),s="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const i=e.indexOf("`",o+1);if(i>o+1){r(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=dpe(e,o);if(i>0){r(),n.push({kind:"bold",kids:$5(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return r(),n}function Ha(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function Iwe(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function Lwe(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function hpe(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function Owe(e){return!Number.isFinite(e)||e<=0?"empty":qr(e)}function Pwe(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,r)=>s+r.programVisits,0)}))}function fpe(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function Dwe(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],r=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(r>0?`, and ${r} more`:"")+". The watch continues on the profiles it can read."}}const n=hpe(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(s=>s.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}const ppe="Check for updates",I5="Ask npm now whether a newer ccdeck is out.",wI="Checking…",mpe="Couldn't reach npm. Try again.",gpe="Couldn't reach the deck. Try again.",L5="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",ype="The deck looks again in five minutes.";function wpe(e,t,n,s){const r=s?t.npx:n?Vt(t,n):void 0;return r?`${e} is out, but ${r}`:`${e} is out. Run:`}const Tn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),No=e=>Tn(e,{tone:"note"});function xI(e,t){return fpe(e,t)??"just now"}function xpe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?No(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?No("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?No(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?No(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?No("The app's last update check failed. Try Check for updates again."):No("The app keeps itself up to date. Check for updates here.")}function vpe(e,t,n){var i;const s=e.version;if((s==null?void 0:s.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return Tn(`${t} is installed.`);const c=e.upgradeState==="running",d=`Runs ${((i=s.upgrade)==null?void 0:i.command)??s.command} here, then restarts once nothing is running.`;return Tn(c?`Installing ${t}…`:`${t} is out.`,{action:{kind:"install",label:"Update now",busy:c,why:d}})}if((s==null?void 0:s.upgradeMode)==="npx"&&s.canRestart){const c=e.upgradeState==="failed";return Tn(c?`The last update to ${t} came back on ${e.running}.`:`${t} is out.`,{action:{kind:"npx",label:c?"Retry update":"Update & restart",busy:e.restarting,why:`Runs ${s.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`}})}const r=e.upgradeState==="failed"?`Installing ${t} failed. Run it yourself:`:wpe(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return Tn(r,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function bpe(e){const t=e.version;if(e.unreachable)return Tn(gpe,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Tn(mpe,{tone:"warn",age:e.answered?null:`Last tried ${xI(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return Tn(`${s} is tagged on npm but can't be installed yet. ${ype}`);const r=t!=null&&t.checkedAt?xI(t.checkedAt,e.now):null;if(e.answered&&(t!=null&&t.latest)){const o=t.latest===e.running?`You're on the latest, ${e.running}.`:`You're on ${e.running}, ahead of npm's ${t.latest}.`;return Tn(o,{age:r?`Checked ${r}.`:null})}return Tn("",{age:r?`Last checked ${r}.`:null})}function kpe(e,t){var r,o;const n=e.version;if((r=e.app)!=null&&r.inApp&&(n!=null&&n.checkDisabled)){const i=xpe(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Tn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Tn(wI):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:No(L5)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:vpe(e,s.to,t)};if((s==null?void 0:s.kind)==="restart"){const i=n!=null&&n.canRestart?`${s.to} is installed. Restart the deck to start running it.`:`${s.to} is installed. Restart ccdeck to start running it.`;return{canCheck:!0,checking:e.checking,line:Tn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Tn(wI)}:{canCheck:!0,checking:!1,line:bpe(e)}}const O5=450;async function jpe(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(O5)]);return n?"answered":"unreachable"}async function Npe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,O5))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const F0="Eight pictures of what the deck shows.",vI="Restart the deck. Sessions, settings and pairings come back as they were.";function Spe(e){var I;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Go(3e4),[s,r]=y.useState(!1),o=y.useRef(!1),[i,c]=y.useState(!1),[d,h]=y.useState(!1),f=y.useRef(t);if(y.useEffect(()=>{f.current&&!t&&h(!0),f.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:m,restart:w,desktopUpdate:j,running:b,onHandOff:k}=e,v=kpe({version:p.version,running:b,checking:s||t,answered:d,unreachable:i,now:n,upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:Ha(),update:j.appUpdate,version:a5(),menu:i5()}},L0);if(!v)return null;const N=Ha()&&((I=p.version)==null?void 0:I.checkDisabled);return{state:v,check:async()=>{var $;if(!An(o.current||t)||N&&(($=j.appUpdate)==null?void 0:$.status)==="checking")return;o.current=!0,r(!0);const R=N?await Npe():await jpe(p.loadVersion);o.current=!1,r(!1),c(R==="unreachable"),h(!0)},act:R=>{if(R.kind==="copy")return void m.copyCommand();k(),p.showNotice(),R.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:N?"Ask the desktop app whether a newer ccdeck is out.":I5}}function _pe({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=jl("above","dialog"),r=Spe(n),o=y.useId(),i=(r==null?void 0:r.state.canCheck)??!1,d=((h=r==null?void 0:r.state.line.action)==null?void 0:h.kind)==="install"||((f=r==null?void 0:r.state.line.action)==null?void 0:f.kind)==="npx"?void 0:t;return!e&&!i&&!d&&!r?null:a.jsxs("div",{className:"rn-actions",children:[(e||i||d)&&a.jsxs("div",{className:"rn-acts",children:[e&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:e,"aria-describedby":`${o}-tour`,...s.bind({label:F0}),children:[a.jsx(PQ,{}),"Take the tour"]}),r&&i&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:()=>void r.check(),"aria-busy":r.state.checking||void 0,"aria-describedby":`${o}-check`,...s.bind({label:r.checkWhy}),children:[a.jsx(DQ,{}),ppe]}),d&&a.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...s.bind({label:vI}),children:[a.jsx(FQ,{}),"Restart"]})]}),r&&a.jsx(Epe,{line:r.state.line,onAct:r.act,bindHint:s.bind,whyId:`${o}-act`}),a.jsx("span",{hidden:!0,id:`${o}-tour`,children:F0}),a.jsx("span",{hidden:!0,id:`${o}-check`,children:(r==null?void 0:r.checkWhy)??I5}),a.jsx("span",{hidden:!0,id:`${o}-restart`,children:vI}),s.node]})}function Epe({line:e,onAct:t,bindHint:n,whyId:s}){const{action:r}=e,o=r&&a.jsx(Cpe,{action:r,onAct:t,bindHint:n,whyId:s});return a.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[a.jsx("span",{className:"rn-update-what",role:"status",children:e.said}),e.age&&a.jsx("span",{className:"rn-update-age",children:e.age}),e.command?a.jsxs("span",{className:"rn-update-cmd",children:[a.jsx("code",{className:"rn-code",children:e.command}),o]}):o]})}function Cpe({action:e,onAct:t,bindHint:n,whyId:s}){const r=e.kind==="copy"?null:e.why;return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:r?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":r&&s?s:void 0,...r&&n?n({label:r}):{},children:e.label}),r&&s&&a.jsx("span",{hidden:!0,id:s,children:r})]})}function Tpe({entries:e,since:t,running:n,firstRun:s,onClose:r,onTour:o,updateVersion:i,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f,updateCheck:p}){const m=ct(r),w=xt(r),j=epe(e);return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:a.jsxs("div",{ref:m,className:"modal release-notes",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),j&&a.jsx("span",{className:"modal-tool-id",children:j})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(i||h)&&a.jsxs("div",{className:"rn-update",children:[i&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",i," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":pl})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:tpe({since:t,running:n,firstRun:s,entries:e})}),a.jsx(_pe,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(b=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",b.version]}),a.jsx("ul",{className:"rn-notes",children:b.notes.map((k,v)=>{const{icon:N,rest:S}=spe(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[N&&a.jsx("span",{className:"rn-note-icon",children:N}),S]}),a.jsx("p",{className:"rn-note-body",children:P5($5(k.body))})]},v)})})]},b.version))]})]})})}function P5(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:P5(t.kids)},n))}function Rpe({state:e,sessionId:t,onClose:n}){const s=y.useMemo(()=>Ape(e,t),[e,e.revision,t]),r=y.useRef(null),o=ct(n,{focusRef:r}),i=xt(n);return s?a.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),a.jsx("button",{type:"button",ref:r,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:K3}),a.jsx("div",{className:"ss-cost",children:Xe(s.cost.total)}),s.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:s.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":Of(c),title:c,children:Da(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(L1,{cost:s.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:Xe(s.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:Xe(s.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:Xe(s.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:Xe(s.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(Fi,{label:"agents",value:s.agentCount}),a.jsx(Fi,{label:"subagents",value:s.subagentCount}),a.jsx(Fi,{label:"tool calls",value:s.toolCount}),a.jsx(Fi,{label:"prompts",value:s.promptCount}),a.jsx(Fi,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&a.jsx(Fi,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/s.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),s.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Fi({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function Ape(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const S of e.agents.values())S.sessionId===t&&s.push(S);if(s.length===0)return null;const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,i=new Map;let c=0,d=0,h=0,f=0,p=0,m,w=1/0,j=0;for(const S of s){const E=In(S);r.input+=E.input,r.output+=E.output,r.cacheRead+=E.cacheRead,r.cacheWrite+=E.cacheWrite,r.total+=E.total;for(const I of YO(S))o.add(I);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const C=TO(S.prompts);d+=C.length,!m&&C.length>0&&(m=C[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[I,R]of S.toolCountByName??[])i.set(I,(i.get(I)??0)+R);w=Math.min(w,S.startedAt),j=Math.max(j,S.endedAt??Date.now())}const b=Math.max(0,j-w),k=Math.floor(b/1e3),v=k<60?`${k}s`:k<3600?`${Math.floor(k/60)}m ${String(k%60).padStart(2,"0")}s`:`${Math.floor(k/3600)}h ${Math.floor(k%3600/60)}m`,N=Array.from(i.entries()).sort((S,E)=>E[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:v,cost:r,modelChips:Array.from(o),agentCount:s.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:N,firstPrompt:m}}function sn({id:e,title:t,note:n,noteId:s,aside:r,list:o=!0,settingId:i,className:c,children:d}){const h=c?`settings-group ${c}`:"settings-group",f=o?a.jsx("div",{className:"settings-list",children:d}):d;return t===void 0?a.jsx("div",{className:h,"data-setting":i,children:f}):a.jsxs("section",{className:h,"aria-labelledby":e,"data-setting":i,children:[a.jsxs("div",{className:"settings-caption",children:[a.jsxs("div",{className:"settings-caption-text",children:[a.jsx("h3",{id:e,children:t}),n&&a.jsx("p",{className:"settings-caption-note",id:s,children:n})]}),r]}),f]})}function yt({name:e,nameId:t,note:n,noteId:s,control:r,as:o="label",settingId:i,className:c,children:d}){const h=o;return a.jsxs(h,{className:c?`settings-row ${c}`:"settings-row","data-setting":i,children:[a.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&a.jsx("span",{className:"settings-row-note",id:s,children:n}),r!==void 0&&a.jsx("span",{className:"settings-row-control",children:r}),d]})}function bI({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,[s,r]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(""),h=y.useRef(!1);y.useEffect(()=>{let p=!0;return fetch("/api/prefs").then(m=>{if(!m.ok)throw new Error;return m.json()}).then(m=>{var w;if(!m.ok)throw new Error;p&&r(((w=m.prefs)==null?void 0:w[t])!==!1)}).catch(()=>{p&&d("Could not read this setting. Reopen Settings to retry.")}),()=>{p=!1}},[t]);const f=async()=>{if(!(s===null||!An(h.current))){h.current=!0,i(!0),d("");try{const p=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[t]:!s})});if(!p.ok)throw new Error;const m=await p.json();if(!m.ok)throw new Error;r(m.prefs[t]!==!1)}catch{d("Could not save this setting. Try again.")}finally{h.current=!1,i(!1)}}};return a.jsxs(sn,{id:`${n}-title`,title:`${e} sessions`,note:"Choose what appears after ccdeck starts.",children:[a.jsx(yt,{settingId:n,name:"Restore unfinished sessions",note:e==="Codex"?"Find unfinished turns in recent local Codex logs on the next start. A missing ending does not confirm the process is still running.":"On the next start, find busy local Claude sessions whose process identity can be verified.",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":`Restore unfinished ${e} sessions`,"aria-checked":s===!0,...Ps(o,s===null),onClick:()=>{f()},children:a.jsx("span",{className:"switch-knob"})})}),c&&a.jsx("p",{role:"alert",children:c})]})}const D5="agent-dag.character",Ih=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function Mpe(e){return e==="fox"||e==="penguin"?e:"deck"}function $pe(){return Mpe(Ve(D5))}const Ipe="With no deck tab open, get a notification wherever a sound would have played.",Lpe="With the ccdeck window closed, get a notification wherever a sound would have played.";function Ope(e){return e?Lpe:Ipe}const Ppe="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",F5=[{kind:"notifySwap",label:"Account auto-switched",title:"When auto-switch moves Claude Code to another account"},{kind:"notifyQuota",label:"Quota at 90% and 100%",title:"When a quota window of the account you're on reaches 90%, and again at 100%"},{kind:"notifyReset",label:"Quota reset",title:"When a quota window that reached 90% is available again"}],Dpe="For the Claude and Codex accounts you're on, whether or not the deck is open.",Fpe="Held off for this run too.",kI="Get notified when you're away from this tab.";function Bpe(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:kI};case"default":return{status:null,ask:!0,ok:!1,note:kI};case"denied":return{status:"Blocked",ask:!1,ok:!1,note:"Your browser is blocking them; only its own site settings can undo that. You'll still be told once this tab is closed."};default:return{status:"Unavailable",ask:!1,ok:!1,note:"This browser cannot show them. You'll still be told once this tab is closed."}}}const B5="section:";function q5(e){return e.id.startsWith(B5)}const qpe={general:["behaviour","behavior","preferences"],appearance:["look","style"],reading:["readability","legibility"],keyboard:["shortcuts","hotkeys","keybindings","keys"],notifications:["alerts","notify"],sounds:["audio","tones","chimes"],data:["privacy","local data"],about:["information"]},Upe={done:"Turn finished","needs-input":"Claude is asking"},Wpe={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},Hpe={notifySwap:["auto-switch","switch account","swap","alerts"],notifyQuota:["quota","limit","rate limit","usage","alerts"],notifyReset:["quota","limit","window","available","alerts"]},$j=e=>{var t;return((t=Aa.find(n=>n.id===e))==null?void 0:t.label)??e};function zpe(e){return{id:`${B5}${e}`,section:e,label:$j(e),keywords:qpe[e]}}function Vpe(){const e={general:[{id:"claude-session-recovery",claudeOnly:!0,section:"general",group:"Claude sessions",label:"Restore unfinished sessions",keywords:["claude","recover","restore","startup","restart","busy"]},{id:"codex-session-recovery",section:"general",group:"Codex sessions",label:"Restore unfinished sessions",keywords:["codex","recover","restore","startup","restart","unfinished"]},{id:"hide-finished",section:"general",group:"Board",label:"Hide finished sessions after",keywords:["finished","done","completed","idle","clean up","auto hide","canvas","board","remove"]},{id:"auto-update",section:"general",group:"Updates",label:"Update when idle",keywords:["update","auto update","automatic updates","upgrade","restart","new version"]},{id:"accounts",section:"general",group:"Elsewhere on the deck",label:"Accounts and auto-switch",claudeOnly:!0,keywords:["accounts","auto-switch","switch account","login","claude accounts"]},{id:"local-network",section:"general",group:"Elsewhere on the deck",label:"Local network",claudeOnly:!0,keywords:["lan","pairing","pair","other machines","sync","network"]},{id:"browser-watch",section:"general",group:"Elsewhere on the deck",label:"Browser Watch",keywords:["browser","watch","away","automation","security"]}],appearance:[{id:"theme",section:"appearance",label:"Theme",keywords:["colour theme","color theme","dark mode","light mode","colours","colors","palette","skin"]},...Wr.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:Du[t].name,keywords:t.endsWith("contrast")?["high contrast","accessibility"]:[]})),{id:"character",section:"appearance",group:"Character",label:"Show the character",keywords:["character","mascot","companion","claude fm","radio","music","minimap","hide the character"]},{id:"character-choice",section:"appearance",group:"Character",label:"Choose character",keywords:["mascot","avatar",...Ih.map(t=>t.name.toLowerCase())]}],reading:[{id:"text-size",section:"reading",label:"Text size",keywords:["font","font size","zoom","bigger","larger","smaller","scale","readability"]},{id:"density",section:"reading",label:"Density",keywords:["spacing","compact","comfortable","padding","tight","dense"]}],keyboard:[{id:"single-keys",section:"keyboard",label:"Single-key shortcuts",keywords:["single key","letters","voice control","dictation","accessibility"]}],notifications:[{id:"notify-closed",section:"notifications",group:"While the deck is closed",label:"Notifications while closed",keywords:["alerts","desktop notifications","browser notifications","push","background","permission"]},...F5.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:Hpe[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...Wc.map(t=>({id:`tone-${t}`,section:"sounds",label:Upe[t],keywords:Wpe[t]})),{id:"custom-sounds",section:"sounds",label:"Custom sounds",keywords:["voice","speech","text to speech","spoken voice","own sound","library"]},{id:"custom-import",section:"sounds",group:"Custom sounds",label:"Import audio",keywords:["import","upload","file","mp3","wav","ogg","own sound"]},{id:"custom-record",section:"sounds",group:"Custom sounds",label:"Record a clip",keywords:["record","microphone","mic","clip"]}],data:[{id:"tool-history-retention",section:"data",group:"Tool history",label:"Keep history",keywords:["retention","delete history","history","days","tool calls","statistics"]},{id:"tool-history-size",section:"data",group:"Tool history",label:"Space used",keywords:["storage","disk","size","bytes"]},{id:"tool-history-clear",section:"data",group:"Tool history",label:"Clear history",keywords:["delete history","erase","wipe","remove"]}],about:[{id:"version",section:"about",group:"ccdeck",label:"Version",keywords:["update","release","build","about"]},{id:"whats-new",section:"about",group:"ccdeck",label:"What's new",keywords:["changelog","release notes","changes","news"]},{id:"licence",section:"about",group:"ccdeck",label:"Licence",keywords:["license","agpl","source","source code","open source","github"]},{id:"tour",section:"about",group:"Tour and feedback",label:"Take the tour",keywords:["tour","guide","help","onboarding","tutorial","introduction"]},{id:"feedback",section:"about",group:"Tour and feedback",label:"Send feedback",keywords:["feedback","bug","report","contact","suggestion","idea"]}]};return Aa.flatMap(({id:t})=>[zpe(t),...e[t]])}const B0=Vpe();function Gpe(e){return e?B0:B0.filter(t=>!t.claudeOnly)}function U5(e){if(q5(e))return"Section";const t=$j(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function Kpe(e){return`${e.label}, ${U5(e).replace(/ › /g,", ")}`}function Ic(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function wh(e,t){for(let n=e.indexOf(t);n!==-1;n=e.indexOf(t,n+1))if(n===0||!/[a-z0-9]/.test(e[n-1]))return!0;return!1}function Ype(e,t){const n=Ic(e.label);if(n.startsWith(t))return 0;if(wh(n,t))return 1;const s=e.keywords.map(Ic);if(s.some(i=>wh(i,t)))return 2;const r=[Ic($j(e.section)),...e.group?[Ic(e.group)]:[]];if(r.some(i=>wh(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...r];if(o.every(c=>i.some(d=>wh(d,c))))return 4}return null}const Xpe=12;function Zpe(e,t=B0){const n=Ic(e);return n?t.map((s,r)=>({entry:s,at:r,score:Ype(s,n)})).filter(s=>s.score!==null).sort((s,r)=>s.score-r.score||s.at-r.at).slice(0,Xpe).map(s=>s.entry):[]}function W5(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function Jpe(e,t,n,s){if(e==="Escape")return t!==""?{kind:"clear"}:{kind:"pass"};if(n===0)return{kind:"pass"};const r=Math.min(Math.max(s,0),n-1);return e==="ArrowDown"?{kind:"move",index:(r+1)%n}:e==="ArrowUp"?{kind:"move",index:(r-1+n)%n}:e==="Enter"?{kind:"open",index:r}:{kind:"pass"}}const Qpe="Hide finished sessions after",eme="A finished session leaves the canvas after this long. It stays in the session list (L), and comes back when it starts working again or needs you.";function tme(){const e=GD();return a.jsx(sn,{id:"settings-board-caption",title:"Board",children:a.jsx(yt,{settingId:"hide-finished",name:Qpe,nameId:"settings-hide-finished-label",note:eme,noteId:"settings-hide-finished-note",control:a.jsx("select",{className:"sm-select",value:e,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:t=>qce(Number(t.target.value)),children:WD.map(t=>a.jsx("option",{value:t,children:Bce(t)},t))})})})}const nme="Accounts and auto-switch",sme="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",rme="Local network",ame="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",ome="Browser Watch",ime="Whether something drove your browser while you were away, and what the deck does about it.";function lme({claudeHere:e,singleKeys:t,doors:n}){return a.jsxs(sn,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&a.jsx(gk,{settingId:"accounts",name:nme,note:sme,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&a.jsx(gk,{settingId:"local-network",name:rme,note:ame,onOpen:n.localNetwork,cap:null}),a.jsx(gk,{settingId:"browser-watch",name:ome,note:ime,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function gk({settingId:e,name:t,note:n,onOpen:s,cap:r,dialog:o=!1}){const i=`settings-${e}`;return a.jsx(yt,{as:"div",settingId:e,name:t,nameId:`${i}-name`,note:n,control:a.jsxs(a.Fragment,{children:[r&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:r.title,children:r.key}),a.jsx("button",{type:"button",className:"btn",id:`${i}-open`,"aria-labelledby":`${i}-open ${i}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":r?r.key:void 0,onClick:s,children:"Open"})]})})}const cme="Single-key shortcuts",ume="Keys like L, U, M, ? and Space open panels and toggle things. Turn this off if you use voice control or press them by accident.";function dme(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function hme(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function fme({singleKeys:e,onToggleSingleKeys:t}){const n=Eu(_u()),[s,r]=y.useState(""),o=y.useId(),i=C5(e).map(c=>({...c,rows:c.rows.filter(d=>hme(d,s))})).filter(c=>c.rows.length>0);return a.jsxs(a.Fragment,{children:[a.jsx(sn,{children:a.jsx(yt,{settingId:"single-keys",name:cme,nameId:"settings-single-keys-label",note:ume,noteId:"settings-single-keys-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-single-keys-label","aria-describedby":"settings-single-keys-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})}),a.jsxs("div",{className:"settings-filter",children:[a.jsx("label",{className:"vis-hidden",htmlFor:o,children:"Filter shortcuts"}),a.jsx("input",{id:o,type:"search",className:"settings-filter-field",placeholder:"Filter shortcuts",autoComplete:"off",spellCheck:!1,value:s,onChange:c=>r(c.target.value),onKeyDown:c=>{n3(c.key)&&s&&(c.stopPropagation(),r(""))}})]}),i.map(c=>{const d=`settings-keys-${c.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return a.jsx(sn,{id:d,title:c.title,className:"settings-keys",children:c.rows.map(h=>a.jsx(yt,{as:"div",name:dme(h),control:a.jsx("kbd",{className:"settings-key",children:n&&h.macCap?h.macCap:h.cap})},`${h.cap}:${h.action}`))},c.title)}),i.length===0&&a.jsxs("p",{className:"settings-empty",role:"status",children:["No shortcut matches “",s.trim(),"”."]}),s.trim()===""&&a.jsx("p",{className:"settings-foot",children:E5})]})}function pme({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:r,accountNotify:o,onToggleAccountNotify:i}){const c=Bpe(s),d=Ha(),h=e&&!n&&!d,f=y.useRef(null),p=Ur(!c.ask,f);return a.jsxs(a.Fragment,{children:[a.jsxs(sn,{id:"sm-closed-caption",title:"While the deck is closed",children:[a.jsx(yt,{settingId:"notify-closed",name:"Notifications while closed",nameId:"sm-notify-label",note:n?Ppe:Ope(d),noteId:"sm-notify-note",control:a.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":"sm-notify-note",className:"switch",onClick:t,children:a.jsx("span",{className:"switch-knob"})})}),h&&a.jsx(yt,{as:"div",name:"Browser notifications",nameId:"sm-channel-name",note:c.note,control:c.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),r()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})})]}),a.jsx(sn,{id:"sm-accounts-caption",title:"Accounts",note:n?Fpe:Dpe,children:F5.map(({kind:m,label:w,title:j})=>a.jsx(yt,{settingId:m,name:w,nameId:`sm-${m}-label`,note:j,noteId:`sm-${m}-note`,control:a.jsx("button",{type:"button",role:"switch","aria-checked":o[m],"aria-labelledby":`sm-${m}-label`,"aria-describedby":`sm-${m}-note`,className:"switch",onClick:()=>i(m),children:a.jsx("span",{className:"switch-knob"})})},m))})]})}function H5({section:e}){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e==="reading"&&a.jsx(a.Fragment,{children:a.jsx("path",{d:"M2 11 5.5 3 9 11M3.3 8h4.4M10.5 4h2M10.5 7h2M10.5 10h2"})}),e==="sounds"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),a.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),a.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}),e==="general"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),a.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),a.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),a.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="appearance"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M7 1.7a5.3 5.3 0 1 0 0 10.6c.8 0 1.3-.5 1.3-1.2 0-.6-.5-1-.5-1.6 0-.7.5-1.2 1.2-1.2h1.3a2.3 2.3 0 0 0 2.3-2.3C12.6 3.7 10.1 1.7 7 1.7z"}),a.jsx("path",{d:"M4.3 6.7h.01M5.7 4.4h.01M8.4 4.2h.01"})]}),e==="keyboard"&&a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"1.5",y:"3.5",width:"11",height:"7",rx:"1.4"}),a.jsx("path",{d:"M4 5.9h.01M6 5.9h.01M8 5.9h.01M10 5.9h.01M4.6 8.2h4.8"})]}),e==="data"&&a.jsxs(a.Fragment,{children:[a.jsx("ellipse",{cx:"7",cy:"3.6",rx:"4.6",ry:"1.7"}),a.jsx("path",{d:"M2.4 3.6v6.8c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7V3.6"}),a.jsx("path",{d:"M2.4 7c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7"})]}),e==="about"&&a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"7",cy:"7",r:"5.4"}),a.jsx("path",{d:"M7 6.4v3.4M7 4.4h.01"})]}),e==="notifications"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.4 9.1c.6-.8.6-1.8.6-3V4.7a3 3 0 0 1 6 0v1.4c0 1.2 0 2.2.6 3"}),a.jsx("path",{d:"M2.2 9.1h9.6"}),a.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]})]})}const mme=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function gme(e){return mme.find(t=>e(t))}const yme=4400;function wme(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function xme({full:e,setCustomError:t,runCustom:n,onImportCustom:s}){const[r,o]=y.useState(!1),i=y.useRef(null),c=y.useRef(null),d=y.useRef(!1),h=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=i.current)==null?void 0:p.state)==="recording"&&i.current.stop()},f=async()=>{var m;if(e)return;if(t(""),!((m=navigator.mediaDevices)!=null&&m.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||i.current){p.getTracks().forEach(w=>w.stop());return}try{const w=gme(k=>MediaRecorder.isTypeSupported(k)),j=new MediaRecorder(p,w?{mimeType:w}:void 0),b=[];i.current=j,j.ondataavailable=k=>{k.data.size&&b.push(k.data)},j.onerror=()=>t("Recording failed. Please try again."),j.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const k=i.current===j;if(k&&(i.current=null),o(!1),!k||!b.length)return;const v=wme(j.mimeType),N=new File(b,v.name,{type:v.type});n(()=>s(N))},j.start(200),o(!0),c.current=setTimeout(h,yme)}catch{i.current=null,p.getTracks().forEach(w=>w.stop()),t("This browser cannot record a supported audio format.")}};return y.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const p=i.current;i.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:r,startRecording:f,stopRecording:h}}function vme({full:e,fullProps:t,runCustom:n,onCreateVoice:s}){const[r,o]=y.useState("Custom voice"),[i,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[m,w]=y.useState("1"),[j,b]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const k=()=>{b(window.speechSynthesis.getVoices())};return k(),window.speechSynthesis.addEventListener("voiceschanged",k),()=>window.speechSynthesis.removeEventListener("voiceschanged",k)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{className:"settings-row",...t,onClick:k=>{const v=k.currentTarget.parentElement;e&&v&&!v.open&&k.preventDefault()},children:[a.jsx("span",{className:"settings-row-name",children:"Spoken voice"}),a.jsx("span",{className:"settings-row-note",children:"Create from text"}),a.jsx("span",{className:"settings-row-control",children:a.jsx("svg",{className:"sm-voice-chevron",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),a.jsxs("div",{className:"sm-voice-fields",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Name"}),a.jsx("input",{className:"ap-manage-input",value:r,maxLength:80,onChange:k=>o(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:k=>c(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:k=>h(k.target.value),children:[a.jsx("option",{value:"",children:"System default"}),j.map(k=>a.jsx("option",{value:k.voiceURI,children:k.name},k.voiceURI))]})]}),a.jsxs("div",{className:"sm-voice-pair",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Rate"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:k=>p(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Pitch"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:m,onChange:k=>w(k.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await s({name:r,text:i,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(m)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function bme({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:r,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=S0(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=y.useState(null),j=y.useRef(0),b=y.useRef(new Map),k=y.useRef(null),v=y.useRef(null);y.useEffect(()=>{if(!m)return;const R=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(R)},[m]);const N=async R=>{c("");try{await R()}catch($){c($ instanceof Error?$.message:"Custom audio could not be saved.")}},S=(R,$)=>{const L=Date.now(),U=fl({armedFor:m,target:R,armedAt:j.current,now:L,gapMs:hl});if(U==="arm"){w(R),j.current=L;return}if(U==="ignore")return;w(null);const O=yre(e.map(M=>M.id),R);N(async()=>{var q;await o(R);const M=document.activeElement;M!==$&&!Kn((M==null?void 0:M.tagName)??null)||(q=O?b.current.get(O):k.current)==null||q.focus()})},{recording:E,startRecording:C,stopRecording:I}=xme({full:f,setCustomError:c,runCustom:N,onImportCustom:t});return a.jsxs(sn,{id:"sm-custom-title",title:"Custom sounds",note:"Your own files, clips and voices, kept on this machine. Either tone above can play one.",aside:a.jsxs("span",{className:"settings-caption-count",children:[d," of ",N0]}),className:"sm-custom",settingId:"custom-sounds",children:[f&&a.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:h}),a.jsx(yt,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:a.jsx("button",{ref:k,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var R;f||(R=v.current)==null||R.click()},children:"Choose file"}),children:a.jsx("input",{ref:v,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:R=>{var L;const $=(L=R.target.files)==null?void 0:L[0];R.currentTarget.value="",$&&!f&&N(()=>t($))}})}),a.jsx(yt,{as:"div",settingId:"custom-record",name:"Record a clip",note:E?"Recording…":"Up to 5 seconds",control:E?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:I,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void C(),children:"Record"})}),a.jsx(vme,{full:f,fullProps:p,runCustom:N,onCreateVoice:n}),e.map(R=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${R.name}`,defaultValue:R.name,maxLength:80,onBlur:$=>{if(!$.target.value.trim()){$.target.value=R.name;return}N(()=>s(R.id,$.target.value))},onKeyDown:$=>{$.key==="Enter"&&$.currentTarget.blur()}}),a.jsx("span",{children:R.kind==="audio"?`${R.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${R.name}`,onClick:()=>r(R.id),children:"Play"}),a.jsx("button",{type:"button",ref:$=>{$?b.current.set(R.id,$):b.current.delete(R.id)},className:`btn sm-custom-icon${m===R.id?" armed":""}`,onKeyDown:$=>{$.repeat&&$.preventDefault()},onClick:$=>S(R.id,$.currentTarget),"aria-label":m===R.id?`Confirm deleting ${R.name}`:`Delete ${R.name}`,title:m===R.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:m===R.id?"Confirm":"Delete"})]},R.id)),i&&a.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:i})]})}const kme="A tone when a turn finishes, and when Claude asks for something.";function jme({soundOn:e,onToggleSound:t}){const n=y.useId(),s=Ln(),r=y.useId();return a.jsx(sn,{children:a.jsx(yt,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:kme,noteId:r,control:a.jsxs(a.Fragment,{children:[s&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press M anywhere to mute or unmute",children:"M"}),a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,"aria-describedby":r,"aria-keyshortcuts":s?"M":void 0,className:"switch",onClick:t,children:a.jsx("span",{className:"switch-knob"})})]})})})}const q0="custom:";function jI(e){return`${q0}${e}`}function Nme(e){return e.startsWith(q0)?e.slice(q0.length):null}function Sme({id:e,label:t="Volume",value:n,step:s=rj,onLevel:r,"aria-describedby":o}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:t}),a.jsx("input",{id:e,type:"range",min:Mh,max:gf,step:s,value:n,"aria-describedby":o,onChange:i=>r(Number(i.target.value)),style:{"--sm-level":`${(n-Mh)/(gf-Mh)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const NI={done:"Turn finished","needs-input":"Claude is asking"},_me={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Eme({chime:e,tone:t,soundOn:n,customAssets:s,customSelections:r,onLevel:o,onFigure:i,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,m=r[e];return a.jsxs(sn,{id:`sm-name-${e}`,title:NI[e],note:_me[e],settingId:`tone-${e}`,aside:a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${NI[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when sounds are off","aria-describedby":n?void 0:"sm-preview-note",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]}),children:[a.jsx(Sme,{id:f,value:t.level,onLevel:w=>o(e,w)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:m?jI(m):t.figure,onChange:w=>{const j=w.target.value,b=Nme(j);b!==null?h(e,b):(d(e),i(e,j))},children:[sj[e].map(w=>a.jsx("option",{value:w.id,children:w.label},w.id)),s.length>0&&a.jsx("optgroup",{label:"Custom",children:s.map(w=>a.jsx("option",{value:jI(w.id),children:w.name},w.id))})]})]})]})}const Cme="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Tme({soundOn:e,onToggleSound:t,prefs:n,claudeHere:s,onLevel:r,onFigure:o,onPreview:i,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:b}){var S;const k=mre(d),v=((S=c.find(E=>E.id===k))==null?void 0:S.name)??"the same custom sound",N=k?`Both tones use “${v}”. They may be harder to tell apart.`:"";return a.jsxs("div",{className:"sm-sounds",children:[a.jsx(jme,{soundOn:e,onToggleSound:t}),!s&&a.jsx("p",{className:"sm-note",children:Cme}),!e&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when sounds are off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:Wc.map(E=>a.jsx(Eme,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:d,onLevel:r,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},E))}),N&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:N}),a.jsx("p",{className:"vis-hidden",role:"status",children:N}),a.jsx(bme,{customAssets:c,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:b})]})}const Rme="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function Ame(){const[e,t]=y.useState(null),[n,s]=y.useState(""),[r,o]=y.useState(!1),[i,c]=y.useState(null),[d,h]=y.useState(""),f=y.useRef(!1),p=y.useRef(!0),m=async()=>{if(f.current)return;f.current=!0,o(!0),s("");const b=new AbortController,k=window.setTimeout(()=>b.abort(),12e3);try{const v=await fetch("/api/tool-audit/storage",{signal:b.signal}),N=await v.json();if(!v.ok||!N.ok)throw new Error;p.current&&t(N)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(k),f.current=!1,p.current&&o(!1)}};y.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(b,k)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let v=!1;const N=new AbortController,S=window.setTimeout(()=>N.abort(),15e3);try{const E=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b==="clear"?{action:b,confirm:!0}:{action:b,days:k}),signal:N.signal}),C=await E.json();if(!E.ok||!C.ok)throw new Error;v=!0,p.current&&(c(null),h(b==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${k} days.`))}catch{p.current&&s("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(S),f.current=!1,p.current&&(o(!1),v&&m())}},j=i!==null&&a.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":"Confirm",children:[a.jsx("p",{children:i==="clear"?"Delete all recorded tool statistics on this device? This cannot be undone.":`Keep ${i} days? Older calls will be permanently deleted.`}),a.jsxs("div",{children:[a.jsx("button",{type:"button",className:"btn danger","aria-busy":r,onClick:()=>{w(i==="clear"?"clear":"retention",typeof i=="number"?i:void 0)},children:i==="clear"?"Delete tool history":"Apply retention"}),a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{f.current||c(null)},children:"Cancel"})]})]});return a.jsxs(sn,{id:"tool-history-settings-title",title:"Tool history",note:Rme,className:"ta-settings",children:[e?a.jsxs(a.Fragment,{children:[a.jsx(yt,{settingId:"tool-history-retention",name:"Keep history",nameId:"ta-keep-label",note:"Calls older than this are deleted.",control:a.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:e.retentionDays,"aria-busy":r,onChange:b=>{if(f.current)return;const k=Number(b.target.value);k<e.retentionDays?c(k):w("retention",k)},children:[30,60,90].map(b=>a.jsxs("option",{value:b,children:[b," days"]},b))})}),typeof i=="number"&&j,a.jsx(yt,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${yY(e.startedAt)}`,control:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"settings-read",children:gY(e.bytes)}),a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{m()},children:"Refresh"})]})}),a.jsx(yt,{as:"div",settingId:"tool-history-clear",name:"Clear history",note:"Deletes every recorded call on this device. New calls are still recorded.",control:a.jsx("button",{type:"button",className:"btn danger","aria-busy":r,onClick:()=>{f.current||c("clear")},children:"Clear…"})}),i==="clear"&&j,!e.storageOk&&a.jsx(yt,{as:"div",name:"Some calls could not be saved",note:"Check free space and storage permissions."})]}):a.jsx(yt,{as:"div",name:r?"Reading storage…":"Storage size unavailable."}),n&&a.jsxs("div",{className:"settings-row",role:"alert",children:[a.jsx("span",{className:"settings-row-name",children:n}),a.jsx("span",{className:"settings-row-control",children:a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{m()},children:"Retry"})})]}),d&&a.jsx("p",{className:"settings-row settings-row-status",role:"status",children:d})]})}function Mme({theme:e}){return a.jsx("span",{className:"appearance-preview","data-swatch":e,children:a.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),a.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),a.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),a.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),a.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),a.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),a.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),a.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),a.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),a.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function $me({theme:e,onTheme:t,singleKeys:n}){const s=r=>{var d,h;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(r.key))return;r.preventDefault();const o=(d=r.target.closest("[data-theme-choice]"))==null?void 0:d.dataset.themeChoice,c=(Wr.indexOf(o??e)+(r.key==="ArrowLeft"||r.key==="ArrowUp"?-1:1)+Wr.length)%Wr.length;t(Wr[c]),(h=r.currentTarget.querySelectorAll('[role="radio"]')[c])==null||h.focus()};return a.jsx(sn,{id:"appearance-theme-caption",title:"Theme",list:!1,settingId:"theme",aside:n&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"}),children:a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:Wr.map(r=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":r,"data-setting":`theme-${r}`,"aria-checked":e===r,tabIndex:e===r?0:-1,onClick:()=>t(r),children:[a.jsx(Mme,{theme:r}),a.jsxs("span",{className:"appearance-theme-name",children:[Du[r].name,a.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},r))})})}const Ime=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],Lme=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function SI(){return a.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:a.jsx("path",{d:"m2.5 6 2.2 2.2 4.8-4.4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ome({textSize:e,density:t,onTextSize:n,onDensity:s}){const r=e!=="default"||t!=="default";return a.jsx("button",{type:"button",className:"btn",disabled:!r,onClick:()=>{n("default"),s("default")},children:"Reset to defaults"})}function Pme({textSize:e,density:t,onTextSize:n,onDensity:s}){return a.jsxs(a.Fragment,{children:[a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Text size"}),a.jsx("p",{id:"reading-size-help",children:"Adjust interface text without changing your browser zoom."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help","data-setting":"text-size",style:{"--reading-count":nC.length,"--reading-selected":nC.indexOf(e)},children:Ime.map(([r,o,i])=>a.jsxs("label",{className:"reading-choice","data-size":r,children:[a.jsx("input",{type:"radio",name:"text-size","aria-label":`${o} ${i}`,value:r,checked:e===r,onChange:()=>n(r)}),a.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:o}),a.jsx("small",{children:i})]}),a.jsx(SI,{})]},r))})]}),a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Density"}),a.jsx("p",{id:"reading-density-help",children:"Choose the spacing in lists, panels and controls. Text size stays the same."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help","data-setting":"density",style:{"--reading-count":sC.length,"--reading-selected":sC.indexOf(t)},children:Lme.map(([r,o,i])=>a.jsxs("label",{className:"reading-choice",children:[a.jsx("input",{type:"radio",name:"density","aria-label":`${o} ${i} spacing`,value:r,checked:t===r,onChange:()=>s(r)}),a.jsxs("span",{className:"reading-density-sample","data-density":r,"aria-hidden":"true",children:[a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{})]}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:o}),a.jsx("small",{children:i})]}),a.jsx(SI,{})]},r))})]}),a.jsxs(sn,{id:"reading-preview-title",title:"Preview",children:[a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Frontend session"}),a.jsx("span",{children:"Waiting for your review"})]}),a.jsx("span",{className:"reading-preview-time",children:"4m"})]}),a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"API integration"}),a.jsx("span",{children:"Working · 3 tool calls"})]}),a.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),a.jsx("p",{className:"settings-foot",children:"Preferences stay in this browser when storage is available. Default restores the existing ccdeck appearance."})]})}const Dme="AGPL-3.0-only",Fme="GNU Affero General Public License, version 3 only.",Bme="https://github.com/BarganConstantin/ccdeck",qme="What changed in each release, newest first.",Ume="Tell the people who make ccdeck what works and what does not.";function Wme(e){return`This page is from v${e}. The deck has most likely been updated since this tab opened, and a reload picks up the new version.`}function Hme(e,t){return Wa(e)&&Wa(t)&&Vo(e,t)<0}function zme(e,t){return e?{kind:"ready",to:e.version,name:"Update ready",note:`${Ct} v${e.version} is downloaded and verified.`}:t?t.kind==="restart"?{kind:"notice",name:"Update installed",note:`v${t.to} is installed — this deck still runs v${t.from}.`}:{kind:"notice",name:"Update available",note:`${Ct} v${t.to} is out — you are on v${t.from}.`}:null}function Vme({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:r,onUpdateRestart:o,doors:i,bundle:c="3.43.0"}){const d=(e==null?void 0:e.running)??c,h=zme(n,t);return a.jsxs(a.Fragment,{children:[a.jsxs(sn,{id:"settings-about-caption",title:Ct,children:[a.jsx(yt,{as:"div",settingId:"version",name:"Version",note:Hme(c,e==null?void 0:e.running)?Wme(c):void 0,control:a.jsx("span",{className:"settings-read",children:d})}),h&&a.jsx(Gme,{offer:h,restarting:s,failure:r,onRestart:o,onUpdate:i.update}),a.jsx(yt,{as:"div",settingId:"whats-new",name:"What's new",note:qme,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open What's new",onClick:i.whatsNew,children:"Open"})}),a.jsx(yt,{as:"div",settingId:"licence",name:"Licence",note:Fme,control:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"settings-read",children:Dme}),a.jsxs("a",{className:"settings-link",href:Bme,target:"_blank",rel:"noreferrer",children:["Source",a.jsx("span",{className:"vis-hidden",children:": the source code, opens in your browser"})]})]})})]}),a.jsxs(sn,{id:"settings-about-help-caption",title:"Tour and feedback",children:[a.jsx(yt,{as:"div",settingId:"tour",name:"Take the tour",note:F0,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Start the tour",onClick:i.tour,children:"Start"})}),a.jsx(yt,{as:"div",settingId:"feedback",name:"Send feedback",note:Ume,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function Gme({offer:e,restarting:t,failure:n,onRestart:s,onUpdate:r}){if(e.kind==="notice")return a.jsx(yt,{as:"div",name:e.name,note:e.note,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:r,children:"Update…"})});const o=l5(e.to,t),i=n&&n.version===e.to?c5(n.failure,n.version):"";return a.jsx(yt,{as:"div",name:e.name,note:e.note,control:a.jsx("button",{type:"button",className:"btn",onClick:()=>s(e.to),"aria-busy":t||void 0,"aria-label":o.label,title:o.title,children:o.text}),children:a.jsx("span",{className:"settings-row-said",role:"status",children:i})})}const Kme="Update when idle",Yme="When nothing has been running for 30 seconds, the deck restarts into a newer version. While you are looking at it, that is one already installed, and only while its notice is up; while nobody is, it installs the new version first. Off, it updates only when you press.",Xme=`${L5} It hears of no new release from npm, and restarts only into a version installed some other way, once nothing has been running for 30 seconds.`,Zme="This deck cannot restart itself (it runs without its supervisor, with --no-persist, or cannot write its event log), so nothing updates on its own here. Your choice is saved for the next start.",Jme="The desktop app keeps itself up to date. It installs a new version once it has been left alone and no agent has been working for a minute, or after waiting a day for that.";function Qme(e,t){return t&&(e!=null&&e.checkDisabled)?"app":(e==null?void 0:e.canRestart)===!1?"no-restart":e!=null&&e.checkDisabled?"checks-off":"plain"}const ege={plain:Yme,"checks-off":Xme,"no-restart":Zme};function tge({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=Ha()}){const r=Qme(n,s);return a.jsx(sn,{id:"settings-updates-caption",title:"Updates",children:r==="app"?a.jsx(yt,{as:"div",settingId:"auto-update",name:"Updates",note:Jme}):a.jsx(yt,{settingId:"auto-update",name:Kme,nameId:"settings-auto-update-label",note:ege[r],noteId:"settings-auto-update-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-auto-update-label","aria-describedby":"settings-auto-update-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})})}function nge({character:e,onCharacter:t}){const n=y.useRef([]);function s(r,o){var c;const i=J1(r,o,Ih.length,"vertical");i.kind==="select"&&(r.preventDefault(),t(Ih[i.index].id),(c=n.current[i.index])==null||c.focus())}return a.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character","data-setting":"character-choice",children:Ih.map((r,o)=>a.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===r.id,tabIndex:e===r.id?0:-1,ref:i=>{n.current[o]=i},onClick:()=>t(r.id),onKeyDown:i=>s(i,o),children:[a.jsx("span",{className:"character-preview",children:a.jsx(L3,{character:r.id,act:null,facing:"right"})}),a.jsx("span",{children:r.name}),a.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},r.id))})}const sge="Stands beside the minimap. Press it to play the radio.";function rge({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:s}){return a.jsxs(sn,{id:"appearance-character-caption",title:"Character",list:!1,children:[a.jsx("div",{className:"settings-list",children:a.jsx(yt,{settingId:"character",name:"Show the character",nameId:"appearance-character-label",note:sge,noteId:"appearance-character-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})}),a.jsx(nge,{character:n,onCharacter:s})]})}const _I="settings-search-field",z5="settings-search-results",U0=e=>`settings-result-${e}`;function age({inputRef:e,query:t,onQuery:n,results:s,active:r,onActive:o,onOpen:i}){const c=t.trim()!=="",d=c&&s.length>0,h=f=>{if(f.nativeEvent.isComposing)return;const p=Jpe(f.key,t,c?s.length:0,r);p.kind!=="pass"&&(f.preventDefault(),p.kind==="move"?o(p.index):p.kind==="open"?i(s[p.index]):(f.stopPropagation(),n("")))};return a.jsxs("div",{className:"settings-search",children:[a.jsx("label",{className:"vis-hidden",htmlFor:_I,children:"Search settings"}),a.jsxs("svg",{className:"settings-search-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"6",cy:"6",r:"4.2"}),a.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]}),a.jsx("input",{ref:e,id:_I,type:"search",className:"settings-filter-field settings-search-field",placeholder:"Search settings",autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":d,"aria-controls":d?z5:void 0,"aria-activedescendant":d?U0(Math.min(r,s.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:f=>n(f.target.value),onKeyDown:h})]})}function oge({query:e,results:t,active:n,onOpen:s}){const r=W5(t.length,e);return y.useEffect(()=>{var o,i;(i=(o=document.getElementById(U0(n)))==null?void 0:o.scrollIntoView)==null||i.call(o,{block:"nearest"})},[n]),a.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[a.jsx("div",{className:"settings-pane-head",children:a.jsxs("div",{className:"settings-pane-heading",children:[a.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:"Search"}),a.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:r})]})}),t.length>0&&a.jsx("div",{className:"settings-group",children:a.jsx("div",{className:"settings-list",id:z5,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>a.jsxs("button",{type:"button",role:"option",id:U0(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":Kpe(o),"data-highlighted":i===n,onMouseDown:c=>c.preventDefault(),onClick:()=>s(o),children:[a.jsx(H5,{section:o.section}),a.jsxs("span",{className:"settings-result-text",children:[a.jsx("span",{className:"settings-result-name",children:o.label}),a.jsx("span",{className:"settings-result-place",children:U5(o)})]})]},o.id))})})]})}function ige({query:e,count:t}){return a.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?W5(t,e):""})}const lge=1500,cge=3e3,uge=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function dge(e){if(e.matches(Vh)&&!e.disabled)return e;const t=e.querySelector('input[type="radio"]:checked, [role="radio"][aria-checked="true"]');if(t)return t;const n=Array.from(e.querySelectorAll(Vh)).filter(s=>s3({disabled:s.disabled,tabIndex:s.tabIndex,rendered:uge(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function hge(e,t,n){const[s,r]=y.useState(null),o=y.useRef(void 0),i=y.useRef(null);return y.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=i.current)==null||c.removeAttribute("data-jumped")},[]),y.useEffect(()=>{const c=e.current;if(!s||!t||!c)return;const d=()=>c.querySelector(`[data-setting="${CSS.escape(s)}"]`),h=w=>{var b,k;r(null);const j=w.offsetHeight>c.clientHeight-48;w.scrollIntoView({block:j?"start":"center"}),(b=dge(w))==null||b.focus({preventScroll:!0}),window.clearTimeout(o.current),(k=i.current)==null||k.removeAttribute("data-jumped"),w.offsetWidth,w.setAttribute("data-jumped",""),i.current=w,o.current=window.setTimeout(()=>{w.removeAttribute("data-jumped"),i.current===w&&(i.current=null)},lge)},f=d();if(f){h(f);return}const p=new MutationObserver(()=>{const w=d();w&&(p.disconnect(),window.clearTimeout(m),h(w))});p.observe(c,{childList:!0,subtree:!0});const m=window.setTimeout(()=>{p.disconnect(),r(null)},cge);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),r}function fge({section:e,onSection:t,onClose:n,providers:s,sound:r,tones:o,customTones:i,notify:c,appearance:d,versionCheck:h,desktopUpdate:f,restart:p,doors:m}){const w=y.useRef(null),j=ct(n,{focusRef:w}),b=xt(n),k=y.useRef([]),v=iue(e),[N,S]=y.useState(""),[E,C]=y.useState(0),I=y.useRef(null),R=y.useRef(null),$=N.trim()!=="",L=y.useMemo(()=>Zpe(N,Gpe(s.claude)),[N,s.claude]),U=hge(R,!$,e),O=je=>{S(je),C(0)},M=je=>{O(""),t(je)},q=je=>{O(""),t(je.section),q5(je)||U(je.id)};y.useEffect(()=>{const je=Ae=>{var Ze,ft;if(!fue(Ae))return;const De=j.current,He=Ae.target;!De||!(He===document.body||He===document.documentElement||He&&De.contains(He))||(Ae.preventDefault(),(Ze=I.current)==null||Ze.focus(),(ft=I.current)==null||ft.select())};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[j]),y.useEffect(()=>{var je,Ae,De,He;lue((je=document.activeElement)==null?void 0:je.id,e)&&((Ae=w.current)==null||Ae.focus()),(He=(De=w.current)==null?void 0:De.scrollIntoView)==null||He.call(De,{block:"nearest",inline:"nearest"})},[e]);const{theme:A,setTheme:D,characterEnabled:P,setCharacterEnabled:K,character:G,setCharacter:W}=d,H=Ln(),F=je=>{var De;const Ae=J1(je,v,Aa.length,"vertical");Ae.kind!=="pass"&&(je.preventDefault(),O(""),t(Aa[Ae.index].id),(De=k.current[Ae.index])==null||De.focus())},B=je=>{var He;if(je.key===" "){je.stopPropagation();return}if(b3(je.key,H))return;const Ae=je.target;if($o(Ae)||Ae.tagName==="SELECT"||je.key!=="t"&&je.key!=="T"||je.ctrlKey||je.metaKey||je.altKey)return;je.preventDefault(),je.stopPropagation();const De=$0(Ae.dataset.themeChoice??A);D($0),Ae.getAttribute("role")==="radio"&&((He=je.currentTarget.querySelector(`[role="radio"][data-theme-choice="${De}"]`))==null||He.focus())},{soundOn:Z,toggleSound:V}=r,{tonePrefs:X,previewTone:Y,changeTone:J}=o,{customSelections:ee,customAssets:ne,clearCustomOnly:le,selectCustomTone:de,importNotificationAudio:ue,createNotificationVoice:re,renameCustomAsset:pe,deleteCustomAsset:ye,previewCustomAsset:_e}=i,{notifyPermission:he,notifyOn:ae,notifyVetoed:ge,toggleNotify:Se,notifySupported:me,askForNotifications:$e,accountNotify:Pe,toggleAccountNotify:qe}=c,Le=(()=>{switch(e){case"appearance":return a.jsxs(a.Fragment,{children:[a.jsx($me,{theme:A,onTheme:D,singleKeys:H}),a.jsx(rge,{characterEnabled:P,character:G,onCharacter:W,onToggleCharacter:()=>K(je=>!je)})]});case"reading":return a.jsx(Pme,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"keyboard":return a.jsx(fme,{singleKeys:H,onToggleSingleKeys:()=>G9(!H)});case"notifications":return a.jsx(pme,{notifyOn:ae,onToggleNotify:Se,notifyVetoed:ge,notifyPermission:me?he:"unsupported",onAskNotify:$e,accountNotify:Pe,onToggleAccountNotify:qe});case"sounds":return a.jsx(Tme,{soundOn:Z===!0,onToggleSound:V,prefs:X,claudeHere:s.claude,onLevel:(je,Ae)=>J(je,{level:Ae}),onFigure:(je,Ae)=>J(je,{figure:Ae}),onPreview:je=>Y(je),customAssets:ne,customSelections:ee,onBuiltInSelected:le,onCustomSelected:de,onImportCustom:ue,onCreateVoice:re,onRenameCustom:pe,onPreviewCustom:_e,onDeleteCustom:ye});case"data":return a.jsx(Ame,{});case"about":return a.jsx(Vme,{version:h.version,notice:h.notice,readyAppUpdate:f.readyAppUpdate,updateRestarting:f.desktopUpdateRestarting,updateFailure:f.desktopUpdateFailure,onUpdateRestart:je=>{f.askDesktopUpdateRestart(je)},doors:m});default:return a.jsxs(a.Fragment,{children:[a.jsx(tme,{}),a.jsx(bI,{provider:"Codex"}),s.claude&&a.jsx(bI,{provider:"Claude"}),a.jsx(tge,{autoRestart:p.autoRestart,onToggleAutoRestart:p.toggleAutoRestart,version:h.version}),a.jsx(lme,{claudeHere:s.claude,singleKeys:H,doors:m})]})}})(),Qe=e==="reading"?a.jsx(Ome,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity}):null;return a.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:a.jsxs("div",{ref:j,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:je=>je.stopPropagation(),onKeyDown:B,children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"settings-body",children:[a.jsxs("div",{className:"settings-side",children:[a.jsx(age,{inputRef:I,query:N,onQuery:O,results:L,active:E,onActive:C,onOpen:q}),a.jsx(ige,{query:N,count:L.length}),a.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:F,children:Aa.map((je,Ae)=>a.jsxs("button",{ref:De=>{k.current[Ae]=De,je.id===e&&(w.current=De)},type:"button",role:"tab",id:`settings-tab-${je.id}`,className:"settings-tab","aria-selected":je.id===e,"aria-controls":"settings-pane",tabIndex:je.id===e?0:-1,onClick:()=>M(je.id),children:[a.jsx(H5,{section:je.id}),a.jsx("span",{className:"settings-tab-label",children:je.label})]},je.id))})]}),a.jsxs("div",{ref:R,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:$||void 0,children:[a.jsxs("div",{className:"settings-pane-head",children:[a.jsxs("div",{className:"settings-pane-heading",children:[a.jsx("h2",{className:"settings-pane-title",children:Aa[v].label}),a.jsx("p",{className:"settings-pane-note",children:Aa[v].note})]}),Qe]}),Le]},e),$&&a.jsx(oge,{query:N,results:L,active:E,onOpen:q})]})]})})}function pge({tool:e,onClose:t}){const n=ct(t),s=xt(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const i=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=ez(e.name,i,c);return{input:f.input.map((p,m)=>a.jsx(EI,{block:p},m)),response:f.response.map((p,m)=>a.jsx(EI,{block:p},m)),copyInput:Z_(e.name,"input",i),copyResponse:Z_(e.name,"response",c)}},[e.name,i,c]);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:e3(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[d&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(CI,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",r==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(CI,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const mge={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function EI({block:e}){const[t,n]=y.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const s=y.useMemo(()=>GH(e),[e]),{shown:r}=RO(s,t),o=KH(s,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?r.map((i,c)=>a.jsxs("span",{className:i.tone?mge[i.tone]:void 0,children:[i.text,c<r.length-1?`
|
|
303
|
+
Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},Mj="agent-dag.releaseNotesSeen";function gI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Vo(e,t){const n=gI(e),s=gI(t);for(let r=0;r<Math.max(n.length,s.length);r++){const o=(n[r]??0)-(s[r]??0);if(o!==0)return o<0?-1:1}return 0}function Wa(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Zfe(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function Jfe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!Wa(n)||!Array.isArray(s))continue;const r=s.filter(Zfe);r.length&&t.push({version:n,notes:r})}return t.sort((n,s)=>Vo(s.version,n.version))}const yI=Jfe(Xfe);function A5(e,t,n){return e.filter(s=>Vo(s.version,n)<=0&&(t===null||Vo(s.version,t)>0))}function Qfe(e,t){return e.filter(n=>Vo(n.version,t)===0)}function epe(e){if(!e.length)return"";const t=e[0].version,n=e[e.length-1].version;return t===n?`v${t}`:`v${n} – v${t}`}function tpe({since:e,running:t,entries:n,firstRun:s}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const i=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${i} changed something you would notice. Clicking the version in the topbar brings this back.`}if(s&&Wa(t))return`The deck has not run in this browser before, so this is what v${t} — the release you have — changed. Earlier releases are not repeated here; clicking the version in the topbar brings all of them back.`;const r=n[0].version;if(!Wa(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const o=Vo(r,t);return o<0?`v${t} · 🐛 Bug fixes and performance improvements. Earlier release notes are shown below.`:o>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const npe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function spe(e){const t=npe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function rpe(e){if(!e)return null;let t=null;try{t=e.getItem(Mj)}catch{return null}return Wa(t)?t:null}function ape(e){if(!e)return!1;try{return e.getItem(Mj),!0}catch{return!1}}function ope(e,t){if(!e)return!1;try{return e.setItem(Mj,t),!0}catch{return!1}}const M5="agent-dag.tourSeen";function ipe(e){if(!e)return!1;try{return e.getItem(M5)==="1"}catch{return!1}}function lpe(e){if(!e)return!1;try{return e.setItem(M5,"1"),!0}catch{return!1}}function cpe({tourSeen:e,decision:t}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};if(t.reason==="welcome"||t.reason==="first-run")return{tour:!e,notes:"none"};const n=t.show.length>0;return e?{tour:!1,notes:n?"now":"none"}:{tour:!0,notes:n?"after":"none"}}function upe({stored:e,running:t,notes:n,remembers:s=!0}){if(!Wa(t))return{show:[],record:null,reason:"no-version"};if(!Wa(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=Qfe(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const r=Vo(e,t);if(r===0)return{show:[],record:null,reason:"seen"};if(r>0)return{show:[],record:null,reason:"ahead"};const o=A5(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function dpe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const s=e.indexOf("`",n+1);if(s<0)break;n=s+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function $5(e,t=!0){const n=[];let s="";const r=()=>{s&&(n.push({kind:"text",text:s}),s="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const i=e.indexOf("`",o+1);if(i>o+1){r(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=dpe(e,o);if(i>0){r(),n.push({kind:"bold",kids:$5(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return r(),n}function Ha(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function Iwe(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function Lwe(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function hpe(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function Owe(e){return!Number.isFinite(e)||e<=0?"empty":qr(e)}function Pwe(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,r)=>s+r.programVisits,0)}))}function fpe(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function Dwe(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],r=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(r>0?`, and ${r} more`:"")+". The watch continues on the profiles it can read."}}const n=hpe(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(s=>s.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}const ppe="Check for updates",I5="Ask npm now whether a newer ccdeck is out.",wI="Checking…",mpe="Couldn't reach npm. Try again.",gpe="Couldn't reach the deck. Try again.",L5="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",ype="The deck looks again in five minutes.";function wpe(e,t,n,s){const r=s?t.npx:n?Vt(t,n):void 0;return r?`${e} is out, but ${r}`:`${e} is out. Run:`}const Tn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),No=e=>Tn(e,{tone:"note"});function xI(e,t){return fpe(e,t)??"just now"}function xpe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?No(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?No("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?No(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?No(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?No("The app's last update check failed. Try Check for updates again."):No("The app keeps itself up to date. Check for updates here.")}function vpe(e,t,n){var i;const s=e.version;if((s==null?void 0:s.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return Tn(`${t} is installed.`);const c=e.upgradeState==="running",d=`Runs ${((i=s.upgrade)==null?void 0:i.command)??s.command} here, then restarts once nothing is running.`;return Tn(c?`Installing ${t}…`:`${t} is out.`,{action:{kind:"install",label:"Update now",busy:c,why:d}})}if((s==null?void 0:s.upgradeMode)==="npx"&&s.canRestart){const c=e.upgradeState==="failed";return Tn(c?`The last update to ${t} came back on ${e.running}.`:`${t} is out.`,{action:{kind:"npx",label:c?"Retry update":"Update & restart",busy:e.restarting,why:`Runs ${s.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`}})}const r=e.upgradeState==="failed"?`Installing ${t} failed. Run it yourself:`:wpe(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return Tn(r,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function bpe(e){const t=e.version;if(e.unreachable)return Tn(gpe,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Tn(mpe,{tone:"warn",age:e.answered?null:`Last tried ${xI(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return Tn(`${s} is tagged on npm but can't be installed yet. ${ype}`);const r=t!=null&&t.checkedAt?xI(t.checkedAt,e.now):null;if(e.answered&&(t!=null&&t.latest)){const o=t.latest===e.running?`You're on the latest, ${e.running}.`:`You're on ${e.running}, ahead of npm's ${t.latest}.`;return Tn(o,{age:r?`Checked ${r}.`:null})}return Tn("",{age:r?`Last checked ${r}.`:null})}function kpe(e,t){var r,o;const n=e.version;if((r=e.app)!=null&&r.inApp&&(n!=null&&n.checkDisabled)){const i=xpe(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Tn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Tn(wI):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:No(L5)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:vpe(e,s.to,t)};if((s==null?void 0:s.kind)==="restart"){const i=n!=null&&n.canRestart?`${s.to} is installed. Restart the deck to start running it.`:`${s.to} is installed. Restart ccdeck to start running it.`;return{canCheck:!0,checking:e.checking,line:Tn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Tn(wI)}:{canCheck:!0,checking:!1,line:bpe(e)}}const O5=450;async function jpe(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(O5)]);return n?"answered":"unreachable"}async function Npe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,O5))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const F0="Eight pictures of what the deck shows.",vI="Restart the deck. Sessions, settings and pairings come back as they were.";function Spe(e){var I;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Go(3e4),[s,r]=y.useState(!1),o=y.useRef(!1),[i,c]=y.useState(!1),[d,h]=y.useState(!1),f=y.useRef(t);if(y.useEffect(()=>{f.current&&!t&&h(!0),f.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:m,restart:w,desktopUpdate:j,running:b,onHandOff:k}=e,v=kpe({version:p.version,running:b,checking:s||t,answered:d,unreachable:i,now:n,upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:Ha(),update:j.appUpdate,version:a5(),menu:i5()}},L0);if(!v)return null;const N=Ha()&&((I=p.version)==null?void 0:I.checkDisabled);return{state:v,check:async()=>{var $;if(!An(o.current||t)||N&&(($=j.appUpdate)==null?void 0:$.status)==="checking")return;o.current=!0,r(!0);const R=N?await Npe():await jpe(p.loadVersion);o.current=!1,r(!1),c(R==="unreachable"),h(!0)},act:R=>{if(R.kind==="copy")return void m.copyCommand();k(),p.showNotice(),R.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:N?"Ask the desktop app whether a newer ccdeck is out.":I5}}function _pe({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=jl("above","dialog"),r=Spe(n),o=y.useId(),i=(r==null?void 0:r.state.canCheck)??!1,d=((h=r==null?void 0:r.state.line.action)==null?void 0:h.kind)==="install"||((f=r==null?void 0:r.state.line.action)==null?void 0:f.kind)==="npx"?void 0:t;return!e&&!i&&!d&&!r?null:a.jsxs("div",{className:"rn-actions",children:[(e||i||d)&&a.jsxs("div",{className:"rn-acts",children:[e&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:e,"aria-describedby":`${o}-tour`,...s.bind({label:F0}),children:[a.jsx(PQ,{}),"Take the tour"]}),r&&i&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:()=>void r.check(),"aria-busy":r.state.checking||void 0,"aria-describedby":`${o}-check`,...s.bind({label:r.checkWhy}),children:[a.jsx(DQ,{}),ppe]}),d&&a.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...s.bind({label:vI}),children:[a.jsx(FQ,{}),"Restart"]})]}),r&&a.jsx(Epe,{line:r.state.line,onAct:r.act,bindHint:s.bind,whyId:`${o}-act`}),a.jsx("span",{hidden:!0,id:`${o}-tour`,children:F0}),a.jsx("span",{hidden:!0,id:`${o}-check`,children:(r==null?void 0:r.checkWhy)??I5}),a.jsx("span",{hidden:!0,id:`${o}-restart`,children:vI}),s.node]})}function Epe({line:e,onAct:t,bindHint:n,whyId:s}){const{action:r}=e,o=r&&a.jsx(Cpe,{action:r,onAct:t,bindHint:n,whyId:s});return a.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[a.jsx("span",{className:"rn-update-what",role:"status",children:e.said}),e.age&&a.jsx("span",{className:"rn-update-age",children:e.age}),e.command?a.jsxs("span",{className:"rn-update-cmd",children:[a.jsx("code",{className:"rn-code",children:e.command}),o]}):o]})}function Cpe({action:e,onAct:t,bindHint:n,whyId:s}){const r=e.kind==="copy"?null:e.why;return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:r?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":r&&s?s:void 0,...r&&n?n({label:r}):{},children:e.label}),r&&s&&a.jsx("span",{hidden:!0,id:s,children:r})]})}function Tpe({entries:e,since:t,running:n,firstRun:s,onClose:r,onTour:o,updateVersion:i,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f,updateCheck:p}){const m=ct(r),w=xt(r),j=epe(e);return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:a.jsxs("div",{ref:m,className:"modal release-notes",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),j&&a.jsx("span",{className:"modal-tool-id",children:j})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(i||h)&&a.jsxs("div",{className:"rn-update",children:[i&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",i," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":pl})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:tpe({since:t,running:n,firstRun:s,entries:e})}),a.jsx(_pe,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(b=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",b.version]}),a.jsx("ul",{className:"rn-notes",children:b.notes.map((k,v)=>{const{icon:N,rest:S}=spe(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[N&&a.jsx("span",{className:"rn-note-icon",children:N}),S]}),a.jsx("p",{className:"rn-note-body",children:P5($5(k.body))})]},v)})})]},b.version))]})]})})}function P5(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:P5(t.kids)},n))}function Rpe({state:e,sessionId:t,onClose:n}){const s=y.useMemo(()=>Ape(e,t),[e,e.revision,t]),r=y.useRef(null),o=ct(n,{focusRef:r}),i=xt(n);return s?a.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),a.jsx("button",{type:"button",ref:r,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:K3}),a.jsx("div",{className:"ss-cost",children:Xe(s.cost.total)}),s.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:s.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":Of(c),title:c,children:Da(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(L1,{cost:s.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:Xe(s.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:Xe(s.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:Xe(s.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:Xe(s.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(Fi,{label:"agents",value:s.agentCount}),a.jsx(Fi,{label:"subagents",value:s.subagentCount}),a.jsx(Fi,{label:"tool calls",value:s.toolCount}),a.jsx(Fi,{label:"prompts",value:s.promptCount}),a.jsx(Fi,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&a.jsx(Fi,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/s.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),s.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Fi({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function Ape(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const S of e.agents.values())S.sessionId===t&&s.push(S);if(s.length===0)return null;const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,i=new Map;let c=0,d=0,h=0,f=0,p=0,m,w=1/0,j=0;for(const S of s){const E=In(S);r.input+=E.input,r.output+=E.output,r.cacheRead+=E.cacheRead,r.cacheWrite+=E.cacheWrite,r.total+=E.total;for(const I of YO(S))o.add(I);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const C=TO(S.prompts);d+=C.length,!m&&C.length>0&&(m=C[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[I,R]of S.toolCountByName??[])i.set(I,(i.get(I)??0)+R);w=Math.min(w,S.startedAt),j=Math.max(j,S.endedAt??Date.now())}const b=Math.max(0,j-w),k=Math.floor(b/1e3),v=k<60?`${k}s`:k<3600?`${Math.floor(k/60)}m ${String(k%60).padStart(2,"0")}s`:`${Math.floor(k/3600)}h ${Math.floor(k%3600/60)}m`,N=Array.from(i.entries()).sort((S,E)=>E[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:v,cost:r,modelChips:Array.from(o),agentCount:s.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:N,firstPrompt:m}}function sn({id:e,title:t,note:n,noteId:s,aside:r,list:o=!0,settingId:i,className:c,children:d}){const h=c?`settings-group ${c}`:"settings-group",f=o?a.jsx("div",{className:"settings-list",children:d}):d;return t===void 0?a.jsx("div",{className:h,"data-setting":i,children:f}):a.jsxs("section",{className:h,"aria-labelledby":e,"data-setting":i,children:[a.jsxs("div",{className:"settings-caption",children:[a.jsxs("div",{className:"settings-caption-text",children:[a.jsx("h3",{id:e,children:t}),n&&a.jsx("p",{className:"settings-caption-note",id:s,children:n})]}),r]}),f]})}function yt({name:e,nameId:t,note:n,noteId:s,control:r,as:o="label",settingId:i,className:c,children:d}){const h=o;return a.jsxs(h,{className:c?`settings-row ${c}`:"settings-row","data-setting":i,children:[a.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&a.jsx("span",{className:"settings-row-note",id:s,children:n}),r!==void 0&&a.jsx("span",{className:"settings-row-control",children:r}),d]})}function bI({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,[s,r]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(""),h=y.useRef(!1);y.useEffect(()=>{let p=!0;return fetch("/api/prefs").then(m=>{if(!m.ok)throw new Error;return m.json()}).then(m=>{var w;if(!m.ok)throw new Error;p&&r(((w=m.prefs)==null?void 0:w[t])!==!1)}).catch(()=>{p&&d("Could not read this setting. Reopen Settings to retry.")}),()=>{p=!1}},[t]);const f=async()=>{if(!(s===null||!An(h.current))){h.current=!0,i(!0),d("");try{const p=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[t]:!s})});if(!p.ok)throw new Error;const m=await p.json();if(!m.ok)throw new Error;r(m.prefs[t]!==!1)}catch{d("Could not save this setting. Try again.")}finally{h.current=!1,i(!1)}}};return a.jsxs(sn,{id:`${n}-title`,title:`${e} sessions`,note:"Choose what appears after ccdeck starts.",children:[a.jsx(yt,{settingId:n,name:"Restore unfinished sessions",note:e==="Codex"?"Find unfinished turns in recent local Codex logs on the next start. A missing ending does not confirm the process is still running.":"On the next start, find busy local Claude sessions whose process identity can be verified.",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":`Restore unfinished ${e} sessions`,"aria-checked":s===!0,...Ps(o,s===null),onClick:()=>{f()},children:a.jsx("span",{className:"switch-knob"})})}),c&&a.jsx("p",{role:"alert",children:c})]})}const D5="agent-dag.character",Ih=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function Mpe(e){return e==="fox"||e==="penguin"?e:"deck"}function $pe(){return Mpe(Ve(D5))}const Ipe="With no deck tab open, get a notification wherever a sound would have played.",Lpe="With the ccdeck window closed, get a notification wherever a sound would have played.";function Ope(e){return e?Lpe:Ipe}const Ppe="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",F5=[{kind:"notifySwap",label:"Account auto-switched",title:"When auto-switch moves Claude Code to another account"},{kind:"notifyQuota",label:"Quota at 90% and 100%",title:"When a quota window of the account you're on reaches 90%, and again at 100%"},{kind:"notifyReset",label:"Quota reset",title:"When a quota window that reached 90% is available again"}],Dpe="For the Claude and Codex accounts you're on, whether or not the deck is open.",Fpe="Held off for this run too.",kI="Get notified when you're away from this tab.";function Bpe(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:kI};case"default":return{status:null,ask:!0,ok:!1,note:kI};case"denied":return{status:"Blocked",ask:!1,ok:!1,note:"Your browser is blocking them; only its own site settings can undo that. You'll still be told once this tab is closed."};default:return{status:"Unavailable",ask:!1,ok:!1,note:"This browser cannot show them. You'll still be told once this tab is closed."}}}const B5="section:";function q5(e){return e.id.startsWith(B5)}const qpe={general:["behaviour","behavior","preferences"],appearance:["look","style"],reading:["readability","legibility"],keyboard:["shortcuts","hotkeys","keybindings","keys"],notifications:["alerts","notify"],sounds:["audio","tones","chimes"],data:["privacy","local data"],about:["information"]},Upe={done:"Turn finished","needs-input":"Claude is asking"},Wpe={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},Hpe={notifySwap:["auto-switch","switch account","swap","alerts"],notifyQuota:["quota","limit","rate limit","usage","alerts"],notifyReset:["quota","limit","window","available","alerts"]},$j=e=>{var t;return((t=Aa.find(n=>n.id===e))==null?void 0:t.label)??e};function zpe(e){return{id:`${B5}${e}`,section:e,label:$j(e),keywords:qpe[e]}}function Vpe(){const e={general:[{id:"claude-session-recovery",claudeOnly:!0,section:"general",group:"Claude sessions",label:"Restore unfinished sessions",keywords:["claude","recover","restore","startup","restart","busy"]},{id:"codex-session-recovery",section:"general",group:"Codex sessions",label:"Restore unfinished sessions",keywords:["codex","recover","restore","startup","restart","unfinished"]},{id:"hide-finished",section:"general",group:"Board",label:"Hide finished sessions after",keywords:["finished","done","completed","idle","clean up","auto hide","canvas","board","remove"]},{id:"auto-update",section:"general",group:"Updates",label:"Update when idle",keywords:["update","auto update","automatic updates","upgrade","restart","new version"]},{id:"accounts",section:"general",group:"Elsewhere on the deck",label:"Accounts and auto-switch",claudeOnly:!0,keywords:["accounts","auto-switch","switch account","login","claude accounts"]},{id:"local-network",section:"general",group:"Elsewhere on the deck",label:"Local network",claudeOnly:!0,keywords:["lan","pairing","pair","other machines","sync","network"]},{id:"browser-watch",section:"general",group:"Elsewhere on the deck",label:"Browser Watch",keywords:["browser","watch","away","automation","security"]}],appearance:[{id:"theme",section:"appearance",label:"Theme",keywords:["colour theme","color theme","dark mode","light mode","colours","colors","palette","skin"]},...Wr.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:Du[t].name,keywords:t.endsWith("contrast")?["high contrast","accessibility"]:[]})),{id:"character",section:"appearance",group:"Character",label:"Show the character",keywords:["character","mascot","companion","claude fm","radio","music","minimap","hide the character"]},{id:"character-choice",section:"appearance",group:"Character",label:"Choose character",keywords:["mascot","avatar",...Ih.map(t=>t.name.toLowerCase())]}],reading:[{id:"text-size",section:"reading",label:"Text size",keywords:["font","font size","zoom","bigger","larger","smaller","scale","readability"]},{id:"density",section:"reading",label:"Density",keywords:["spacing","compact","comfortable","padding","tight","dense"]}],keyboard:[{id:"single-keys",section:"keyboard",label:"Single-key shortcuts",keywords:["single key","letters","voice control","dictation","accessibility"]}],notifications:[{id:"notify-closed",section:"notifications",group:"While the deck is closed",label:"Notifications while closed",keywords:["alerts","desktop notifications","browser notifications","push","background","permission"]},...F5.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:Hpe[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...Wc.map(t=>({id:`tone-${t}`,section:"sounds",label:Upe[t],keywords:Wpe[t]})),{id:"custom-sounds",section:"sounds",label:"Custom sounds",keywords:["voice","speech","text to speech","spoken voice","own sound","library"]},{id:"custom-import",section:"sounds",group:"Custom sounds",label:"Import audio",keywords:["import","upload","file","mp3","wav","ogg","own sound"]},{id:"custom-record",section:"sounds",group:"Custom sounds",label:"Record a clip",keywords:["record","microphone","mic","clip"]}],data:[{id:"tool-history-retention",section:"data",group:"Tool history",label:"Keep history",keywords:["retention","delete history","history","days","tool calls","statistics"]},{id:"tool-history-size",section:"data",group:"Tool history",label:"Space used",keywords:["storage","disk","size","bytes"]},{id:"tool-history-clear",section:"data",group:"Tool history",label:"Clear history",keywords:["delete history","erase","wipe","remove"]}],about:[{id:"version",section:"about",group:"ccdeck",label:"Version",keywords:["update","release","build","about"]},{id:"whats-new",section:"about",group:"ccdeck",label:"What's new",keywords:["changelog","release notes","changes","news"]},{id:"licence",section:"about",group:"ccdeck",label:"Licence",keywords:["license","agpl","source","source code","open source","github"]},{id:"tour",section:"about",group:"Tour and feedback",label:"Take the tour",keywords:["tour","guide","help","onboarding","tutorial","introduction"]},{id:"feedback",section:"about",group:"Tour and feedback",label:"Send feedback",keywords:["feedback","bug","report","contact","suggestion","idea"]}]};return Aa.flatMap(({id:t})=>[zpe(t),...e[t]])}const B0=Vpe();function Gpe(e){return e?B0:B0.filter(t=>!t.claudeOnly)}function U5(e){if(q5(e))return"Section";const t=$j(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function Kpe(e){return`${e.label}, ${U5(e).replace(/ › /g,", ")}`}function Ic(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function wh(e,t){for(let n=e.indexOf(t);n!==-1;n=e.indexOf(t,n+1))if(n===0||!/[a-z0-9]/.test(e[n-1]))return!0;return!1}function Ype(e,t){const n=Ic(e.label);if(n.startsWith(t))return 0;if(wh(n,t))return 1;const s=e.keywords.map(Ic);if(s.some(i=>wh(i,t)))return 2;const r=[Ic($j(e.section)),...e.group?[Ic(e.group)]:[]];if(r.some(i=>wh(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...r];if(o.every(c=>i.some(d=>wh(d,c))))return 4}return null}const Xpe=12;function Zpe(e,t=B0){const n=Ic(e);return n?t.map((s,r)=>({entry:s,at:r,score:Ype(s,n)})).filter(s=>s.score!==null).sort((s,r)=>s.score-r.score||s.at-r.at).slice(0,Xpe).map(s=>s.entry):[]}function W5(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function Jpe(e,t,n,s){if(e==="Escape")return t!==""?{kind:"clear"}:{kind:"pass"};if(n===0)return{kind:"pass"};const r=Math.min(Math.max(s,0),n-1);return e==="ArrowDown"?{kind:"move",index:(r+1)%n}:e==="ArrowUp"?{kind:"move",index:(r-1+n)%n}:e==="Enter"?{kind:"open",index:r}:{kind:"pass"}}const Qpe="Hide finished sessions after",eme="A finished session leaves the canvas after this long. It stays in the session list (L), and comes back when it starts working again or needs you.";function tme(){const e=GD();return a.jsx(sn,{id:"settings-board-caption",title:"Board",children:a.jsx(yt,{settingId:"hide-finished",name:Qpe,nameId:"settings-hide-finished-label",note:eme,noteId:"settings-hide-finished-note",control:a.jsx("select",{className:"sm-select",value:e,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:t=>qce(Number(t.target.value)),children:WD.map(t=>a.jsx("option",{value:t,children:Bce(t)},t))})})})}const nme="Accounts and auto-switch",sme="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",rme="Local network",ame="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",ome="Browser Watch",ime="Whether something drove your browser while you were away, and what the deck does about it.";function lme({claudeHere:e,singleKeys:t,doors:n}){return a.jsxs(sn,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&a.jsx(gk,{settingId:"accounts",name:nme,note:sme,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&a.jsx(gk,{settingId:"local-network",name:rme,note:ame,onOpen:n.localNetwork,cap:null}),a.jsx(gk,{settingId:"browser-watch",name:ome,note:ime,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function gk({settingId:e,name:t,note:n,onOpen:s,cap:r,dialog:o=!1}){const i=`settings-${e}`;return a.jsx(yt,{as:"div",settingId:e,name:t,nameId:`${i}-name`,note:n,control:a.jsxs(a.Fragment,{children:[r&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:r.title,children:r.key}),a.jsx("button",{type:"button",className:"btn",id:`${i}-open`,"aria-labelledby":`${i}-open ${i}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":r?r.key:void 0,onClick:s,children:"Open"})]})})}const cme="Single-key shortcuts",ume="Keys like L, U, M, ? and Space open panels and toggle things. Turn this off if you use voice control or press them by accident.";function dme(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function hme(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function fme({singleKeys:e,onToggleSingleKeys:t}){const n=Eu(_u()),[s,r]=y.useState(""),o=y.useId(),i=C5(e).map(c=>({...c,rows:c.rows.filter(d=>hme(d,s))})).filter(c=>c.rows.length>0);return a.jsxs(a.Fragment,{children:[a.jsx(sn,{children:a.jsx(yt,{settingId:"single-keys",name:cme,nameId:"settings-single-keys-label",note:ume,noteId:"settings-single-keys-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-single-keys-label","aria-describedby":"settings-single-keys-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})}),a.jsxs("div",{className:"settings-filter",children:[a.jsx("label",{className:"vis-hidden",htmlFor:o,children:"Filter shortcuts"}),a.jsx("input",{id:o,type:"search",className:"settings-filter-field",placeholder:"Filter shortcuts",autoComplete:"off",spellCheck:!1,value:s,onChange:c=>r(c.target.value),onKeyDown:c=>{n3(c.key)&&s&&(c.stopPropagation(),r(""))}})]}),i.map(c=>{const d=`settings-keys-${c.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return a.jsx(sn,{id:d,title:c.title,className:"settings-keys",children:c.rows.map(h=>a.jsx(yt,{as:"div",name:dme(h),control:a.jsx("kbd",{className:"settings-key",children:n&&h.macCap?h.macCap:h.cap})},`${h.cap}:${h.action}`))},c.title)}),i.length===0&&a.jsxs("p",{className:"settings-empty",role:"status",children:["No shortcut matches “",s.trim(),"”."]}),s.trim()===""&&a.jsx("p",{className:"settings-foot",children:E5})]})}function pme({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:r,accountNotify:o,onToggleAccountNotify:i}){const c=Bpe(s),d=Ha(),h=e&&!n&&!d,f=y.useRef(null),p=Ur(!c.ask,f);return a.jsxs(a.Fragment,{children:[a.jsxs(sn,{id:"sm-closed-caption",title:"While the deck is closed",children:[a.jsx(yt,{settingId:"notify-closed",name:"Notifications while closed",nameId:"sm-notify-label",note:n?Ppe:Ope(d),noteId:"sm-notify-note",control:a.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":"sm-notify-note",className:"switch",onClick:t,children:a.jsx("span",{className:"switch-knob"})})}),h&&a.jsx(yt,{as:"div",name:"Browser notifications",nameId:"sm-channel-name",note:c.note,control:c.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),r()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})})]}),a.jsx(sn,{id:"sm-accounts-caption",title:"Accounts",note:n?Fpe:Dpe,children:F5.map(({kind:m,label:w,title:j})=>a.jsx(yt,{settingId:m,name:w,nameId:`sm-${m}-label`,note:j,noteId:`sm-${m}-note`,control:a.jsx("button",{type:"button",role:"switch","aria-checked":o[m],"aria-labelledby":`sm-${m}-label`,"aria-describedby":`sm-${m}-note`,className:"switch",onClick:()=>i(m),children:a.jsx("span",{className:"switch-knob"})})},m))})]})}function H5({section:e}){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e==="reading"&&a.jsx(a.Fragment,{children:a.jsx("path",{d:"M2 11 5.5 3 9 11M3.3 8h4.4M10.5 4h2M10.5 7h2M10.5 10h2"})}),e==="sounds"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),a.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),a.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}),e==="general"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),a.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),a.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),a.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="appearance"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M7 1.7a5.3 5.3 0 1 0 0 10.6c.8 0 1.3-.5 1.3-1.2 0-.6-.5-1-.5-1.6 0-.7.5-1.2 1.2-1.2h1.3a2.3 2.3 0 0 0 2.3-2.3C12.6 3.7 10.1 1.7 7 1.7z"}),a.jsx("path",{d:"M4.3 6.7h.01M5.7 4.4h.01M8.4 4.2h.01"})]}),e==="keyboard"&&a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"1.5",y:"3.5",width:"11",height:"7",rx:"1.4"}),a.jsx("path",{d:"M4 5.9h.01M6 5.9h.01M8 5.9h.01M10 5.9h.01M4.6 8.2h4.8"})]}),e==="data"&&a.jsxs(a.Fragment,{children:[a.jsx("ellipse",{cx:"7",cy:"3.6",rx:"4.6",ry:"1.7"}),a.jsx("path",{d:"M2.4 3.6v6.8c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7V3.6"}),a.jsx("path",{d:"M2.4 7c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7"})]}),e==="about"&&a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"7",cy:"7",r:"5.4"}),a.jsx("path",{d:"M7 6.4v3.4M7 4.4h.01"})]}),e==="notifications"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.4 9.1c.6-.8.6-1.8.6-3V4.7a3 3 0 0 1 6 0v1.4c0 1.2 0 2.2.6 3"}),a.jsx("path",{d:"M2.2 9.1h9.6"}),a.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]})]})}const mme=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function gme(e){return mme.find(t=>e(t))}const yme=4400;function wme(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function xme({full:e,setCustomError:t,runCustom:n,onImportCustom:s}){const[r,o]=y.useState(!1),i=y.useRef(null),c=y.useRef(null),d=y.useRef(!1),h=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=i.current)==null?void 0:p.state)==="recording"&&i.current.stop()},f=async()=>{var m;if(e)return;if(t(""),!((m=navigator.mediaDevices)!=null&&m.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||i.current){p.getTracks().forEach(w=>w.stop());return}try{const w=gme(k=>MediaRecorder.isTypeSupported(k)),j=new MediaRecorder(p,w?{mimeType:w}:void 0),b=[];i.current=j,j.ondataavailable=k=>{k.data.size&&b.push(k.data)},j.onerror=()=>t("Recording failed. Please try again."),j.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const k=i.current===j;if(k&&(i.current=null),o(!1),!k||!b.length)return;const v=wme(j.mimeType),N=new File(b,v.name,{type:v.type});n(()=>s(N))},j.start(200),o(!0),c.current=setTimeout(h,yme)}catch{i.current=null,p.getTracks().forEach(w=>w.stop()),t("This browser cannot record a supported audio format.")}};return y.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const p=i.current;i.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:r,startRecording:f,stopRecording:h}}function vme({full:e,fullProps:t,runCustom:n,onCreateVoice:s}){const[r,o]=y.useState("Custom voice"),[i,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[m,w]=y.useState("1"),[j,b]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const k=()=>{b(window.speechSynthesis.getVoices())};return k(),window.speechSynthesis.addEventListener("voiceschanged",k),()=>window.speechSynthesis.removeEventListener("voiceschanged",k)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{className:"settings-row",...t,onClick:k=>{const v=k.currentTarget.parentElement;e&&v&&!v.open&&k.preventDefault()},children:[a.jsx("span",{className:"settings-row-name",children:"Spoken voice"}),a.jsx("span",{className:"settings-row-note",children:"Create from text"}),a.jsx("span",{className:"settings-row-control",children:a.jsx("svg",{className:"sm-voice-chevron",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),a.jsxs("div",{className:"sm-voice-fields",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Name"}),a.jsx("input",{className:"ap-manage-input",value:r,maxLength:80,onChange:k=>o(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:k=>c(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:k=>h(k.target.value),children:[a.jsx("option",{value:"",children:"System default"}),j.map(k=>a.jsx("option",{value:k.voiceURI,children:k.name},k.voiceURI))]})]}),a.jsxs("div",{className:"sm-voice-pair",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Rate"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:k=>p(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Pitch"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:m,onChange:k=>w(k.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await s({name:r,text:i,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(m)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function bme({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:r,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=S0(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=y.useState(null),j=y.useRef(0),b=y.useRef(new Map),k=y.useRef(null),v=y.useRef(null);y.useEffect(()=>{if(!m)return;const R=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(R)},[m]);const N=async R=>{c("");try{await R()}catch($){c($ instanceof Error?$.message:"Custom audio could not be saved.")}},S=(R,$)=>{const L=Date.now(),U=fl({armedFor:m,target:R,armedAt:j.current,now:L,gapMs:hl});if(U==="arm"){w(R),j.current=L;return}if(U==="ignore")return;w(null);const O=yre(e.map(M=>M.id),R);N(async()=>{var q;await o(R);const M=document.activeElement;M!==$&&!Kn((M==null?void 0:M.tagName)??null)||(q=O?b.current.get(O):k.current)==null||q.focus()})},{recording:E,startRecording:C,stopRecording:I}=xme({full:f,setCustomError:c,runCustom:N,onImportCustom:t});return a.jsxs(sn,{id:"sm-custom-title",title:"Custom sounds",note:"Your own files, clips and voices, kept on this machine. Either tone above can play one.",aside:a.jsxs("span",{className:"settings-caption-count",children:[d," of ",N0]}),className:"sm-custom",settingId:"custom-sounds",children:[f&&a.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:h}),a.jsx(yt,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:a.jsx("button",{ref:k,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var R;f||(R=v.current)==null||R.click()},children:"Choose file"}),children:a.jsx("input",{ref:v,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:R=>{var L;const $=(L=R.target.files)==null?void 0:L[0];R.currentTarget.value="",$&&!f&&N(()=>t($))}})}),a.jsx(yt,{as:"div",settingId:"custom-record",name:"Record a clip",note:E?"Recording…":"Up to 5 seconds",control:E?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:I,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void C(),children:"Record"})}),a.jsx(vme,{full:f,fullProps:p,runCustom:N,onCreateVoice:n}),e.map(R=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${R.name}`,defaultValue:R.name,maxLength:80,onBlur:$=>{if(!$.target.value.trim()){$.target.value=R.name;return}N(()=>s(R.id,$.target.value))},onKeyDown:$=>{$.key==="Enter"&&$.currentTarget.blur()}}),a.jsx("span",{children:R.kind==="audio"?`${R.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${R.name}`,onClick:()=>r(R.id),children:"Play"}),a.jsx("button",{type:"button",ref:$=>{$?b.current.set(R.id,$):b.current.delete(R.id)},className:`btn sm-custom-icon${m===R.id?" armed":""}`,onKeyDown:$=>{$.repeat&&$.preventDefault()},onClick:$=>S(R.id,$.currentTarget),"aria-label":m===R.id?`Confirm deleting ${R.name}`:`Delete ${R.name}`,title:m===R.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:m===R.id?"Confirm":"Delete"})]},R.id)),i&&a.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:i})]})}const kme="A tone when a turn finishes, and when Claude asks for something.";function jme({soundOn:e,onToggleSound:t}){const n=y.useId(),s=Ln(),r=y.useId();return a.jsx(sn,{children:a.jsx(yt,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:kme,noteId:r,control:a.jsxs(a.Fragment,{children:[s&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press M anywhere to mute or unmute",children:"M"}),a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,"aria-describedby":r,"aria-keyshortcuts":s?"M":void 0,className:"switch",onClick:t,children:a.jsx("span",{className:"switch-knob"})})]})})})}const q0="custom:";function jI(e){return`${q0}${e}`}function Nme(e){return e.startsWith(q0)?e.slice(q0.length):null}function Sme({id:e,label:t="Volume",value:n,step:s=rj,onLevel:r,"aria-describedby":o}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:t}),a.jsx("input",{id:e,type:"range",min:Mh,max:gf,step:s,value:n,"aria-describedby":o,onChange:i=>r(Number(i.target.value)),style:{"--sm-level":`${(n-Mh)/(gf-Mh)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const NI={done:"Turn finished","needs-input":"Claude is asking"},_me={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Eme({chime:e,tone:t,soundOn:n,customAssets:s,customSelections:r,onLevel:o,onFigure:i,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,m=r[e];return a.jsxs(sn,{id:`sm-name-${e}`,title:NI[e],note:_me[e],settingId:`tone-${e}`,aside:a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${NI[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when sounds are off","aria-describedby":n?void 0:"sm-preview-note",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]}),children:[a.jsx(Sme,{id:f,value:t.level,onLevel:w=>o(e,w)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:m?jI(m):t.figure,onChange:w=>{const j=w.target.value,b=Nme(j);b!==null?h(e,b):(d(e),i(e,j))},children:[sj[e].map(w=>a.jsx("option",{value:w.id,children:w.label},w.id)),s.length>0&&a.jsx("optgroup",{label:"Custom",children:s.map(w=>a.jsx("option",{value:jI(w.id),children:w.name},w.id))})]})]})]})}const Cme="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Tme({soundOn:e,onToggleSound:t,prefs:n,claudeHere:s,onLevel:r,onFigure:o,onPreview:i,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:b}){var S;const k=mre(d),v=((S=c.find(E=>E.id===k))==null?void 0:S.name)??"the same custom sound",N=k?`Both tones use “${v}”. They may be harder to tell apart.`:"";return a.jsxs("div",{className:"sm-sounds",children:[a.jsx(jme,{soundOn:e,onToggleSound:t}),!s&&a.jsx("p",{className:"sm-note",children:Cme}),!e&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when sounds are off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:Wc.map(E=>a.jsx(Eme,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:d,onLevel:r,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},E))}),N&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:N}),a.jsx("p",{className:"vis-hidden",role:"status",children:N}),a.jsx(bme,{customAssets:c,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:b})]})}const Rme="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function Ame(){const[e,t]=y.useState(null),[n,s]=y.useState(""),[r,o]=y.useState(!1),[i,c]=y.useState(null),[d,h]=y.useState(""),f=y.useRef(!1),p=y.useRef(!0),m=async()=>{if(f.current)return;f.current=!0,o(!0),s("");const b=new AbortController,k=window.setTimeout(()=>b.abort(),12e3);try{const v=await fetch("/api/tool-audit/storage",{signal:b.signal}),N=await v.json();if(!v.ok||!N.ok)throw new Error;p.current&&t(N)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(k),f.current=!1,p.current&&o(!1)}};y.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(b,k)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let v=!1;const N=new AbortController,S=window.setTimeout(()=>N.abort(),15e3);try{const E=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b==="clear"?{action:b,confirm:!0}:{action:b,days:k}),signal:N.signal}),C=await E.json();if(!E.ok||!C.ok)throw new Error;v=!0,p.current&&(c(null),h(b==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${k} days.`))}catch{p.current&&s("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(S),f.current=!1,p.current&&(o(!1),v&&m())}},j=i!==null&&a.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":"Confirm",children:[a.jsx("p",{children:i==="clear"?"Delete all recorded tool statistics on this device? This cannot be undone.":`Keep ${i} days? Older calls will be permanently deleted.`}),a.jsxs("div",{children:[a.jsx("button",{type:"button",className:"btn danger","aria-busy":r,onClick:()=>{w(i==="clear"?"clear":"retention",typeof i=="number"?i:void 0)},children:i==="clear"?"Delete tool history":"Apply retention"}),a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{f.current||c(null)},children:"Cancel"})]})]});return a.jsxs(sn,{id:"tool-history-settings-title",title:"Tool history",note:Rme,className:"ta-settings",children:[e?a.jsxs(a.Fragment,{children:[a.jsx(yt,{settingId:"tool-history-retention",name:"Keep history",nameId:"ta-keep-label",note:"Calls older than this are deleted.",control:a.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:e.retentionDays,"aria-busy":r,onChange:b=>{if(f.current)return;const k=Number(b.target.value);k<e.retentionDays?c(k):w("retention",k)},children:[30,60,90].map(b=>a.jsxs("option",{value:b,children:[b," days"]},b))})}),typeof i=="number"&&j,a.jsx(yt,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${yY(e.startedAt)}`,control:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"settings-read",children:gY(e.bytes)}),a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{m()},children:"Refresh"})]})}),a.jsx(yt,{as:"div",settingId:"tool-history-clear",name:"Clear history",note:"Deletes every recorded call on this device. New calls are still recorded.",control:a.jsx("button",{type:"button",className:"btn danger","aria-busy":r,onClick:()=>{f.current||c("clear")},children:"Clear…"})}),i==="clear"&&j,!e.storageOk&&a.jsx(yt,{as:"div",name:"Some calls could not be saved",note:"Check free space and storage permissions."})]}):a.jsx(yt,{as:"div",name:r?"Reading storage…":"Storage size unavailable."}),n&&a.jsxs("div",{className:"settings-row",role:"alert",children:[a.jsx("span",{className:"settings-row-name",children:n}),a.jsx("span",{className:"settings-row-control",children:a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{m()},children:"Retry"})})]}),d&&a.jsx("p",{className:"settings-row settings-row-status",role:"status",children:d})]})}function Mme({theme:e}){return a.jsx("span",{className:"appearance-preview","data-swatch":e,children:a.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),a.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),a.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),a.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),a.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),a.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),a.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),a.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),a.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),a.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function $me({theme:e,onTheme:t,singleKeys:n}){const s=r=>{var d,h;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(r.key))return;r.preventDefault();const o=(d=r.target.closest("[data-theme-choice]"))==null?void 0:d.dataset.themeChoice,c=(Wr.indexOf(o??e)+(r.key==="ArrowLeft"||r.key==="ArrowUp"?-1:1)+Wr.length)%Wr.length;t(Wr[c]),(h=r.currentTarget.querySelectorAll('[role="radio"]')[c])==null||h.focus()};return a.jsx(sn,{id:"appearance-theme-caption",title:"Theme",list:!1,settingId:"theme",aside:n&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"}),children:a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:Wr.map(r=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":r,"data-setting":`theme-${r}`,"aria-checked":e===r,tabIndex:e===r?0:-1,onClick:()=>t(r),children:[a.jsx(Mme,{theme:r}),a.jsxs("span",{className:"appearance-theme-name",children:[Du[r].name,a.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},r))})})}const Ime=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],Lme=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function SI(){return a.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:a.jsx("path",{d:"m2.5 6 2.2 2.2 4.8-4.4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ome({textSize:e,density:t,onTextSize:n,onDensity:s}){const r=e!=="default"||t!=="default";return a.jsx("button",{type:"button",className:"btn",disabled:!r,onClick:()=>{n("default"),s("default")},children:"Reset to defaults"})}function Pme({textSize:e,density:t,onTextSize:n,onDensity:s}){return a.jsxs(a.Fragment,{children:[a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Text size"}),a.jsx("p",{id:"reading-size-help",children:"Adjust interface text without changing your browser zoom."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help","data-setting":"text-size",style:{"--reading-count":nC.length,"--reading-selected":nC.indexOf(e)},children:Ime.map(([r,o,i])=>a.jsxs("label",{className:"reading-choice","data-size":r,children:[a.jsx("input",{type:"radio",name:"text-size","aria-label":`${o} ${i}`,value:r,checked:e===r,onChange:()=>n(r)}),a.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:o}),a.jsx("small",{children:i})]}),a.jsx(SI,{})]},r))})]}),a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Density"}),a.jsx("p",{id:"reading-density-help",children:"Choose the spacing in lists, panels and controls. Text size stays the same."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help","data-setting":"density",style:{"--reading-count":sC.length,"--reading-selected":sC.indexOf(t)},children:Lme.map(([r,o,i])=>a.jsxs("label",{className:"reading-choice",children:[a.jsx("input",{type:"radio",name:"density","aria-label":`${o} ${i} spacing`,value:r,checked:t===r,onChange:()=>s(r)}),a.jsxs("span",{className:"reading-density-sample","data-density":r,"aria-hidden":"true",children:[a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{})]}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:o}),a.jsx("small",{children:i})]}),a.jsx(SI,{})]},r))})]}),a.jsxs(sn,{id:"reading-preview-title",title:"Preview",children:[a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Frontend session"}),a.jsx("span",{children:"Waiting for your review"})]}),a.jsx("span",{className:"reading-preview-time",children:"4m"})]}),a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"API integration"}),a.jsx("span",{children:"Working · 3 tool calls"})]}),a.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),a.jsx("p",{className:"settings-foot",children:"Preferences stay in this browser when storage is available. Default restores the existing ccdeck appearance."})]})}const Dme="AGPL-3.0-only",Fme="GNU Affero General Public License, version 3 only.",Bme="https://github.com/BarganConstantin/ccdeck",qme="What changed in each release, newest first.",Ume="Tell the people who make ccdeck what works and what does not.";function Wme(e){return`This page is from v${e}. The deck has most likely been updated since this tab opened, and a reload picks up the new version.`}function Hme(e,t){return Wa(e)&&Wa(t)&&Vo(e,t)<0}function zme(e,t){return e?{kind:"ready",to:e.version,name:"Update ready",note:`${Ct} v${e.version} is downloaded and verified.`}:t?t.kind==="restart"?{kind:"notice",name:"Update installed",note:`v${t.to} is installed — this deck still runs v${t.from}.`}:{kind:"notice",name:"Update available",note:`${Ct} v${t.to} is out — you are on v${t.from}.`}:null}function Vme({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:r,onUpdateRestart:o,doors:i,bundle:c="3.43.1"}){const d=(e==null?void 0:e.running)??c,h=zme(n,t);return a.jsxs(a.Fragment,{children:[a.jsxs(sn,{id:"settings-about-caption",title:Ct,children:[a.jsx(yt,{as:"div",settingId:"version",name:"Version",note:Hme(c,e==null?void 0:e.running)?Wme(c):void 0,control:a.jsx("span",{className:"settings-read",children:d})}),h&&a.jsx(Gme,{offer:h,restarting:s,failure:r,onRestart:o,onUpdate:i.update}),a.jsx(yt,{as:"div",settingId:"whats-new",name:"What's new",note:qme,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open What's new",onClick:i.whatsNew,children:"Open"})}),a.jsx(yt,{as:"div",settingId:"licence",name:"Licence",note:Fme,control:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"settings-read",children:Dme}),a.jsxs("a",{className:"settings-link",href:Bme,target:"_blank",rel:"noreferrer",children:["Source",a.jsx("span",{className:"vis-hidden",children:": the source code, opens in your browser"})]})]})})]}),a.jsxs(sn,{id:"settings-about-help-caption",title:"Tour and feedback",children:[a.jsx(yt,{as:"div",settingId:"tour",name:"Take the tour",note:F0,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Start the tour",onClick:i.tour,children:"Start"})}),a.jsx(yt,{as:"div",settingId:"feedback",name:"Send feedback",note:Ume,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function Gme({offer:e,restarting:t,failure:n,onRestart:s,onUpdate:r}){if(e.kind==="notice")return a.jsx(yt,{as:"div",name:e.name,note:e.note,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:r,children:"Update…"})});const o=l5(e.to,t),i=n&&n.version===e.to?c5(n.failure,n.version):"";return a.jsx(yt,{as:"div",name:e.name,note:e.note,control:a.jsx("button",{type:"button",className:"btn",onClick:()=>s(e.to),"aria-busy":t||void 0,"aria-label":o.label,title:o.title,children:o.text}),children:a.jsx("span",{className:"settings-row-said",role:"status",children:i})})}const Kme="Update when idle",Yme="When nothing has been running for 30 seconds, the deck restarts into a newer version. While you are looking at it, that is one already installed, and only while its notice is up; while nobody is, it installs the new version first. Off, it updates only when you press.",Xme=`${L5} It hears of no new release from npm, and restarts only into a version installed some other way, once nothing has been running for 30 seconds.`,Zme="This deck cannot restart itself (it runs without its supervisor, with --no-persist, or cannot write its event log), so nothing updates on its own here. Your choice is saved for the next start.",Jme="The desktop app keeps itself up to date. It installs a new version once it has been left alone and no agent has been working for a minute, or after waiting a day for that.";function Qme(e,t){return t&&(e!=null&&e.checkDisabled)?"app":(e==null?void 0:e.canRestart)===!1?"no-restart":e!=null&&e.checkDisabled?"checks-off":"plain"}const ege={plain:Yme,"checks-off":Xme,"no-restart":Zme};function tge({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=Ha()}){const r=Qme(n,s);return a.jsx(sn,{id:"settings-updates-caption",title:"Updates",children:r==="app"?a.jsx(yt,{as:"div",settingId:"auto-update",name:"Updates",note:Jme}):a.jsx(yt,{settingId:"auto-update",name:Kme,nameId:"settings-auto-update-label",note:ege[r],noteId:"settings-auto-update-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-auto-update-label","aria-describedby":"settings-auto-update-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})})}function nge({character:e,onCharacter:t}){const n=y.useRef([]);function s(r,o){var c;const i=J1(r,o,Ih.length,"vertical");i.kind==="select"&&(r.preventDefault(),t(Ih[i.index].id),(c=n.current[i.index])==null||c.focus())}return a.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character","data-setting":"character-choice",children:Ih.map((r,o)=>a.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===r.id,tabIndex:e===r.id?0:-1,ref:i=>{n.current[o]=i},onClick:()=>t(r.id),onKeyDown:i=>s(i,o),children:[a.jsx("span",{className:"character-preview",children:a.jsx(L3,{character:r.id,act:null,facing:"right"})}),a.jsx("span",{children:r.name}),a.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},r.id))})}const sge="Stands beside the minimap. Press it to play the radio.";function rge({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:s}){return a.jsxs(sn,{id:"appearance-character-caption",title:"Character",list:!1,children:[a.jsx("div",{className:"settings-list",children:a.jsx(yt,{settingId:"character",name:"Show the character",nameId:"appearance-character-label",note:sge,noteId:"appearance-character-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})}),a.jsx(nge,{character:n,onCharacter:s})]})}const _I="settings-search-field",z5="settings-search-results",U0=e=>`settings-result-${e}`;function age({inputRef:e,query:t,onQuery:n,results:s,active:r,onActive:o,onOpen:i}){const c=t.trim()!=="",d=c&&s.length>0,h=f=>{if(f.nativeEvent.isComposing)return;const p=Jpe(f.key,t,c?s.length:0,r);p.kind!=="pass"&&(f.preventDefault(),p.kind==="move"?o(p.index):p.kind==="open"?i(s[p.index]):(f.stopPropagation(),n("")))};return a.jsxs("div",{className:"settings-search",children:[a.jsx("label",{className:"vis-hidden",htmlFor:_I,children:"Search settings"}),a.jsxs("svg",{className:"settings-search-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"6",cy:"6",r:"4.2"}),a.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]}),a.jsx("input",{ref:e,id:_I,type:"search",className:"settings-filter-field settings-search-field",placeholder:"Search settings",autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":d,"aria-controls":d?z5:void 0,"aria-activedescendant":d?U0(Math.min(r,s.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:f=>n(f.target.value),onKeyDown:h})]})}function oge({query:e,results:t,active:n,onOpen:s}){const r=W5(t.length,e);return y.useEffect(()=>{var o,i;(i=(o=document.getElementById(U0(n)))==null?void 0:o.scrollIntoView)==null||i.call(o,{block:"nearest"})},[n]),a.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[a.jsx("div",{className:"settings-pane-head",children:a.jsxs("div",{className:"settings-pane-heading",children:[a.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:"Search"}),a.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:r})]})}),t.length>0&&a.jsx("div",{className:"settings-group",children:a.jsx("div",{className:"settings-list",id:z5,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>a.jsxs("button",{type:"button",role:"option",id:U0(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":Kpe(o),"data-highlighted":i===n,onMouseDown:c=>c.preventDefault(),onClick:()=>s(o),children:[a.jsx(H5,{section:o.section}),a.jsxs("span",{className:"settings-result-text",children:[a.jsx("span",{className:"settings-result-name",children:o.label}),a.jsx("span",{className:"settings-result-place",children:U5(o)})]})]},o.id))})})]})}function ige({query:e,count:t}){return a.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?W5(t,e):""})}const lge=1500,cge=3e3,uge=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function dge(e){if(e.matches(Vh)&&!e.disabled)return e;const t=e.querySelector('input[type="radio"]:checked, [role="radio"][aria-checked="true"]');if(t)return t;const n=Array.from(e.querySelectorAll(Vh)).filter(s=>s3({disabled:s.disabled,tabIndex:s.tabIndex,rendered:uge(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function hge(e,t,n){const[s,r]=y.useState(null),o=y.useRef(void 0),i=y.useRef(null);return y.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=i.current)==null||c.removeAttribute("data-jumped")},[]),y.useEffect(()=>{const c=e.current;if(!s||!t||!c)return;const d=()=>c.querySelector(`[data-setting="${CSS.escape(s)}"]`),h=w=>{var b,k;r(null);const j=w.offsetHeight>c.clientHeight-48;w.scrollIntoView({block:j?"start":"center"}),(b=dge(w))==null||b.focus({preventScroll:!0}),window.clearTimeout(o.current),(k=i.current)==null||k.removeAttribute("data-jumped"),w.offsetWidth,w.setAttribute("data-jumped",""),i.current=w,o.current=window.setTimeout(()=>{w.removeAttribute("data-jumped"),i.current===w&&(i.current=null)},lge)},f=d();if(f){h(f);return}const p=new MutationObserver(()=>{const w=d();w&&(p.disconnect(),window.clearTimeout(m),h(w))});p.observe(c,{childList:!0,subtree:!0});const m=window.setTimeout(()=>{p.disconnect(),r(null)},cge);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),r}function fge({section:e,onSection:t,onClose:n,providers:s,sound:r,tones:o,customTones:i,notify:c,appearance:d,versionCheck:h,desktopUpdate:f,restart:p,doors:m}){const w=y.useRef(null),j=ct(n,{focusRef:w}),b=xt(n),k=y.useRef([]),v=iue(e),[N,S]=y.useState(""),[E,C]=y.useState(0),I=y.useRef(null),R=y.useRef(null),$=N.trim()!=="",L=y.useMemo(()=>Zpe(N,Gpe(s.claude)),[N,s.claude]),U=hge(R,!$,e),O=je=>{S(je),C(0)},M=je=>{O(""),t(je)},q=je=>{O(""),t(je.section),q5(je)||U(je.id)};y.useEffect(()=>{const je=Ae=>{var Ze,ft;if(!fue(Ae))return;const De=j.current,He=Ae.target;!De||!(He===document.body||He===document.documentElement||He&&De.contains(He))||(Ae.preventDefault(),(Ze=I.current)==null||Ze.focus(),(ft=I.current)==null||ft.select())};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[j]),y.useEffect(()=>{var je,Ae,De,He;lue((je=document.activeElement)==null?void 0:je.id,e)&&((Ae=w.current)==null||Ae.focus()),(He=(De=w.current)==null?void 0:De.scrollIntoView)==null||He.call(De,{block:"nearest",inline:"nearest"})},[e]);const{theme:A,setTheme:D,characterEnabled:P,setCharacterEnabled:K,character:G,setCharacter:W}=d,H=Ln(),F=je=>{var De;const Ae=J1(je,v,Aa.length,"vertical");Ae.kind!=="pass"&&(je.preventDefault(),O(""),t(Aa[Ae.index].id),(De=k.current[Ae.index])==null||De.focus())},B=je=>{var He;if(je.key===" "){je.stopPropagation();return}if(b3(je.key,H))return;const Ae=je.target;if($o(Ae)||Ae.tagName==="SELECT"||je.key!=="t"&&je.key!=="T"||je.ctrlKey||je.metaKey||je.altKey)return;je.preventDefault(),je.stopPropagation();const De=$0(Ae.dataset.themeChoice??A);D($0),Ae.getAttribute("role")==="radio"&&((He=je.currentTarget.querySelector(`[role="radio"][data-theme-choice="${De}"]`))==null||He.focus())},{soundOn:Z,toggleSound:V}=r,{tonePrefs:X,previewTone:Y,changeTone:J}=o,{customSelections:ee,customAssets:ne,clearCustomOnly:le,selectCustomTone:de,importNotificationAudio:ue,createNotificationVoice:re,renameCustomAsset:pe,deleteCustomAsset:ye,previewCustomAsset:_e}=i,{notifyPermission:he,notifyOn:ae,notifyVetoed:ge,toggleNotify:Se,notifySupported:me,askForNotifications:$e,accountNotify:Pe,toggleAccountNotify:qe}=c,Le=(()=>{switch(e){case"appearance":return a.jsxs(a.Fragment,{children:[a.jsx($me,{theme:A,onTheme:D,singleKeys:H}),a.jsx(rge,{characterEnabled:P,character:G,onCharacter:W,onToggleCharacter:()=>K(je=>!je)})]});case"reading":return a.jsx(Pme,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"keyboard":return a.jsx(fme,{singleKeys:H,onToggleSingleKeys:()=>G9(!H)});case"notifications":return a.jsx(pme,{notifyOn:ae,onToggleNotify:Se,notifyVetoed:ge,notifyPermission:me?he:"unsupported",onAskNotify:$e,accountNotify:Pe,onToggleAccountNotify:qe});case"sounds":return a.jsx(Tme,{soundOn:Z===!0,onToggleSound:V,prefs:X,claudeHere:s.claude,onLevel:(je,Ae)=>J(je,{level:Ae}),onFigure:(je,Ae)=>J(je,{figure:Ae}),onPreview:je=>Y(je),customAssets:ne,customSelections:ee,onBuiltInSelected:le,onCustomSelected:de,onImportCustom:ue,onCreateVoice:re,onRenameCustom:pe,onPreviewCustom:_e,onDeleteCustom:ye});case"data":return a.jsx(Ame,{});case"about":return a.jsx(Vme,{version:h.version,notice:h.notice,readyAppUpdate:f.readyAppUpdate,updateRestarting:f.desktopUpdateRestarting,updateFailure:f.desktopUpdateFailure,onUpdateRestart:je=>{f.askDesktopUpdateRestart(je)},doors:m});default:return a.jsxs(a.Fragment,{children:[a.jsx(tme,{}),a.jsx(bI,{provider:"Codex"}),s.claude&&a.jsx(bI,{provider:"Claude"}),a.jsx(tge,{autoRestart:p.autoRestart,onToggleAutoRestart:p.toggleAutoRestart,version:h.version}),a.jsx(lme,{claudeHere:s.claude,singleKeys:H,doors:m})]})}})(),Qe=e==="reading"?a.jsx(Ome,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity}):null;return a.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:a.jsxs("div",{ref:j,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:je=>je.stopPropagation(),onKeyDown:B,children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"settings-body",children:[a.jsxs("div",{className:"settings-side",children:[a.jsx(age,{inputRef:I,query:N,onQuery:O,results:L,active:E,onActive:C,onOpen:q}),a.jsx(ige,{query:N,count:L.length}),a.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:F,children:Aa.map((je,Ae)=>a.jsxs("button",{ref:De=>{k.current[Ae]=De,je.id===e&&(w.current=De)},type:"button",role:"tab",id:`settings-tab-${je.id}`,className:"settings-tab","aria-selected":je.id===e,"aria-controls":"settings-pane",tabIndex:je.id===e?0:-1,onClick:()=>M(je.id),children:[a.jsx(H5,{section:je.id}),a.jsx("span",{className:"settings-tab-label",children:je.label})]},je.id))})]}),a.jsxs("div",{ref:R,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:$||void 0,children:[a.jsxs("div",{className:"settings-pane-head",children:[a.jsxs("div",{className:"settings-pane-heading",children:[a.jsx("h2",{className:"settings-pane-title",children:Aa[v].label}),a.jsx("p",{className:"settings-pane-note",children:Aa[v].note})]}),Qe]}),Le]},e),$&&a.jsx(oge,{query:N,results:L,active:E,onOpen:q})]})]})})}function pge({tool:e,onClose:t}){const n=ct(t),s=xt(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const i=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=ez(e.name,i,c);return{input:f.input.map((p,m)=>a.jsx(EI,{block:p},m)),response:f.response.map((p,m)=>a.jsx(EI,{block:p},m)),copyInput:Z_(e.name,"input",i),copyResponse:Z_(e.name,"response",c)}},[e.name,i,c]);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:e3(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[d&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(CI,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",r==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(CI,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const mge={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function EI({block:e}){const[t,n]=y.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const s=y.useMemo(()=>GH(e),[e]),{shown:r}=RO(s,t),o=KH(s,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?r.map((i,c)=>a.jsxs("span",{className:i.tone?mge[i.tone]:void 0,children:[i.text,c<r.length-1?`
|
|
304
304
|
`:""]},c)):r.map(i=>i.text).join(`
|
|
305
|
-
`)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function CI({text:e,what:t}){const[n,s]=y.useState(!1),r=y.useRef(!0);return y.useEffect(()=>()=>{r.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void Ko(e).then(o=>{!o||!r.current||(s(!0),window.setTimeout(()=>{r.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const gge=Aj(()=>Nu(()=>import("./UsageHistoryModal-
|
|
305
|
+
`)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function CI({text:e,what:t}){const[n,s]=y.useState(!1),r=y.useRef(!0);return y.useEffect(()=>()=>{r.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void Ko(e).then(o=>{!o||!r.current||(s(!0),window.setTimeout(()=>{r.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const gge=Aj(()=>Nu(()=>import("./UsageHistoryModal-BW9jTi6E.js"),[]),"Usage history"),yge=Aj(()=>Nu(()=>import("./BrowserWatchModal-1On-pA6T.js"),[]),"Browser Watch"),wge=Aj(()=>Nu(()=>import("./TrafficRadar-DWilzdA3.js"),[]),"Telemetry Radar");function xge({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:s,restart:r,upgrade:o,lanPairs:i,attention:c,clearFlow:d,watchBadge:h,announcements:f,appearance:p,providers:m,stateRef:w,agentCount:j,menus:b,sound:k,tones:v,customTones:N,notify:S,panelDoors:E}){const{openedTool:C,setOpenedToolKey:I,usageHistoryOpen:R,setUsageHistoryOpen:$,browserWatchOpen:L,setBrowserWatchOpen:U,contextAgent:O,setContextFor:M,summaryFor:q,setSummaryFor:A,keyHelpOpen:D,setKeyHelpOpen:P,feedbackOpen:K,setFeedbackOpen:G,feedbackPrefill:W,setFeedbackPrefill:H,openFeedback:F}=e,{trafficRadarOpen:B,setTrafficRadarOpen:Z}=e,{tourOpen:V,openTour:X,closeTour:Y,releaseNotes:J,closeReleaseNotes:ee,chipVersion:ne,openReleaseNotes:le}=t,{desktopUpdateRestarting:de,desktopUpdateFailure:ue,readyAppUpdate:re,askDesktopUpdateRestart:pe}=n,{version:ye,showNotice:_e}=s,{askRestart:he}=r,{clearConfirmOpen:ae,setClearConfirmOpen:ge,requestClear:Se}=d,{setWatchOn:me,markWatchSeen:$e}=h,{setWatchSaid:Pe}=f,{palette:qe}=p,{settingsOpen:Le,settingsSection:Qe,showSection:je,closeSettings:Ae,openSettings:De}=b;return a.jsxs(a.Fragment,{children:[C&&a.jsx(pge,{tool:C,onClose:()=>I(null)}),R&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(gge,{providers:m,onClose:()=>$(!1)})}),L&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(yge,{onClose:()=>U(!1),onSeen:He=>{Pe(""),$e(He)},onWatching:me,palette:qe})}),O&&a.jsx(P7,{agent:O,onClose:()=>M(null)}),B&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(wge,{sessions:[...w.current.agents.values()].filter(He=>He.kind==="root"&&He.provider!=="codex").map(He=>({id:He.sessionId,label:He.cwdBasename??He.label})),onClose:()=>Z(!1)})}),K&&a.jsx(_5,{initialKind:W==null?void 0:W.initialKind,initialBody:W==null?void 0:W.initialBody,onClose:()=>{G(!1),H(null)}}),q&&a.jsx(Rpe,{state:w.current,sessionId:q,onClose:()=>A(null)}),Le&&a.jsx(fge,{section:Qe,onSection:je,onClose:Ae,providers:m,sound:k,tones:v,customTones:N,notify:S,appearance:p,versionCheck:s,desktopUpdate:n,restart:r,doors:{whatsNew:vo(Ae,le),update:vo(Ae,()=>{le(),_e()}),tour:vo(Ae,X),feedback:vo(Ae,()=>F()),accounts:vo(Ae,E.accounts),localNetwork:vo(Ae,E.localNetwork),browserWatch:vo(Ae,()=>U(!0))}}),J&&a.jsx(Tpe,{entries:J.entries,since:J.since,firstRun:J.firstRun,running:ne,onClose:ee,onTour:()=>{ee(),X()},updateVersion:re==null?void 0:re.version,updateBusy:de,updateFailure:ue&&(!re||re.version===ue.version)?c5(ue.failure,ue.version):void 0,onUpdateRestart:re?()=>{pe(re.version)}:void 0,onRestart:!re&&(ye!=null&&ye.canRestart)?()=>{ee(),he()}:void 0,updateCheck:{versionCheck:s,upgrade:o,restart:r,desktopUpdate:n,running:ne,onHandOff:ee}}),a.jsx(vge,{lanPairs:i,attention:c}),D&&a.jsx($fe,{onClose:()=>P(!1),onTour:()=>{P(!1),X()},onSettings:()=>{P(!1),De("keyboard")}}),V&&a.jsx(JP,{title:"What the deck shows you",steps:bte,onClose:Y}),ae&&a.jsx(nhe,{agentCount:j,onConfirm:()=>Se("confirmation"),onCancel:()=>ge(!1)})]})}function vge({lanPairs:e,attention:t}){const n=zfe(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(Yfe,{...t,pairing:n!=null})]})}const bge=10,V5=500,G5=4e3,kge=[/ResizeObserver loop/i,/^Script error\.?$/i],TI=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,jge=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function Nge(e,t){const n=typeof e=="string"?e.split(`
|
|
306
306
|
`):[],s=n.some(o=>/^\s*at\s/.test(o)),r=n.flatMap(o=>!s||/^\s*at\s/.test(o)?o.match(jge)??[]:[]);return r.length?r.every(o=>TI.test(o)):typeof t=="string"&&TI.test(t)}const jf=String.raw`[^\s\\/:'"\`<>|?*;,]`,Sge=String.raw`${jf}(?:[^\\/\r\n:'"\`<>|?*;,]*${jf})?[\\/]`,_ge=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Nc=String.raw`(?:${Sge})*(?:${_ge})?`,Ege=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Nc}|[A-Za-z]:[\\/]${Nc}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Nc}|/(?=${jf})${Nc}|(?<!:)//(?=${jf})${Nc})`,Cge=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,Tge=new Set([".claude",".codex"]);function Rge(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?Tge.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const Age=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Mge(e,t,n){return n?"<deck>":`${t}://<host>`}const RI=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,K5=String.raw`${RI}(?:\.${RI}){3}`,yk=String.raw`[0-9A-Fa-f]{1,4}`,AI=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${yk}:){7})(?:(?:${yk})?:)+(?:${K5}|${yk})?`,MI=String.raw`%[\w-]+(?:\.[\w-]+)*`,$I=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,$ge=String.raw`(?<![\w:.%-])(?:\[(?!${$I}\])${AI}(?:${MI})?\]|(?!${$I}(?::\d{1,5})?(?![\w:%]|\.\d))${AI}(?:${MI})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${K5}(?![\w-]|\.\d)`,wk=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Ige=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${wk}|${wk}(?=:\d{1,5}(?![\w:-]|\.\w))|${wk}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function II(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Ege,"g"),Rge).replace(new RegExp(Cge,"g"),"<project>").replace(new RegExp(Age,"g"),Mge).replace(new RegExp($ge,"g"),"<host>").replace(new RegExp(Ige,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const Y5=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Lge(e,t,n=Y5){const s=String(e??"").slice(0,V5).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,G5):void 0})}function Oge(e,t=window,n=Y5){let s=0;const r=new Set,o=(d,h,f)=>{const p=String(d??"").slice(0,V5).trim();!e()||!p||s>=bge||r.has(p)||kge.some(m=>m.test(p))||Nge(h,f)||(r.add(p),s++,n({message:p,stack:typeof h=="string"?h.slice(0,G5):void 0}))},i=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack,d.filename)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",i),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",i),t.removeEventListener("unhandledrejection",c)}}const Pge=12;function Dge(e,t){const n=[II(e).trim()||"The deck threw an error with no message."],s=t==null?void 0:t.trim();if(s){const r=s.split(`
|
|
307
307
|
`).slice(0,Pge).join(`
|
|
308
308
|
`);n.push("",II(r).trim())}return n.join(`
|
|
309
309
|
`)}class Fge extends y.Component{constructor(){super(...arguments);rg(this,"state",{error:null,componentStack:null,reportOpen:!1});rg(this,"onKey",n=>{n3(n.key)&&Cn.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,s){console.error("ccdeck hit a render error it could not draw past",n,s.componentStack),this.setState({componentStack:s.componentStack??null}),Lge(n.message,n.stack),XD("offline")}componentDidUpdate(n,s){this.state.reportOpen!==s.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:s,reportOpen:r}=this.state;return n?a.jsxs("div",{className:"error-fallback",children:[a.jsxs("div",{className:"error-fallback-card",role:"alert",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),r&&a.jsx(_5,{initialKind:"bug",initialBody:Dge(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Bge=1e3;function qge(e={}){const t=Math.max(1,Math.floor(e.limit??Bge)),n=e.protect;let s=!1,r=[],o=new Set,i=0,c=0,d=null;return{get paused(){return s},get size(){return r.length},get dropped(){return i},get overflowed(){return i>0},get through(){return c},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,m=p!==null&&p!==d;m&&(d=p,c=0);const w=f!==null&&!m&&f<=c;if(f!==null&&f>c&&(c=f),!s)return!0;if(w)return!1;if(r.push(h),n!=null&&n(h)&&o.add(h),r.length>t){let j=0;if(o.size<r.length)for(;o.has(r[j]);)j++;const[b]=r.splice(j,1);o.delete(b),i++}return!1},setPaused(h){if(s=h,h)return[];const f=r;return r=[],o=new Set,i=0,f}}}function Uge(e){const t=y.useState(()=>qge({protect:o=>dz(e.current,o)}))[0],[n,s]=y.useState(!1),r=y.useCallback(()=>{const o=t.paused&&t.dropped>0,i=t.setPaused(!t.paused);o&&Hz(e.current);for(const c of i)e.current=HO(e.current,c);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:r}}const W0={kind:"assumed",claude:!0,codex:!0};function Wge(e){if(!e||typeof e!="object")return W0;const t=e.providers;if(!t||typeof t!="object")return W0;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Hge(e){const[t,n]=y.useState(null),[s,r]=y.useState(W0);y.useEffect(()=>{let i=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{i||(r(Wge(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=zn(s);return{workspace:t,providers:s,providersRef:o}}const X5=3*6e4,zge=2e4;function Vge({fetchReport:e,visible:t,now:n,onReport:s}){let r=0,o=!0;const i=async()=>{if(!t())return;const c=await e();!o||!c||(r=n(),s(c))};return{tick:i,wake:async()=>{t()&&n()-r>=X5&&await i()},stop:()=>{o=!1}}}async function Gge(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(zge)});return e.ok?await e.json():null}catch{return null}}function Kge(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const s=Vge({fetchReport:Gge,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const r=window.setInterval(s.tick,X5),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(r),document.removeEventListener("visibilitychange",o)}},[e]),t}const Yge={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Xge={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Zge={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Jge={claude:"Claude",codex:"Codex"},Qge=new Set(["status.claude.com","status.openai.com"]),eye=30*6e4,tye=10*6e4;function nye(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Qge.has(t.hostname)?t:null}catch{return null}}function LI(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function sye(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function rye(e,t){if(!e||typeof e!="object")return null;const n=Vt(Yge,e.state),s=Vt(Jge,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>eye)return null;const r=nye(e.statusPageUrl);if(!r)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>tye,c=[`${s}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${s}'s components`:null,i?`Last read from ${r.hostname} at ${LI(e.checkedAt)}; this is the last thing it said`:`Reported by ${r.hostname}, checked ${sye(t-e.checkedAt)}`,"Opens the status page"],d=i?LI(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Vt(Xge,e.state)??n,shortWords:Vt(Zge,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:r.href,host:r.hostname,stale:i,detail:c.filter(Boolean).join(`
|
|
310
|
-
`)}}function aye(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>rye(n,t)).filter(n=>n!==null)}function oye(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const iye="The providers' status pages report no incident.";function lye({version:e,loadVersion:t}){var h;const[n,s]=y.useState(!1),r=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Hde(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(An(i.current||r==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[r,t]);y.useEffect(()=>{if(r!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[r,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await Ko(f)||(s(!0),window.setTimeout(()=>s(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:r,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const OI="agent-dag.browserWatch.seenMs";function cye(e,t){return e.filter(n=>n.startMs>t)}function uye(){const[e,t]=y.useState(()=>Number(Ve(OI))||0),[n,s]=y.useState([]),[r,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var m;!d||!(p!=null&&p.ok)||(s(p.episodes??[]),o(((m=p.settings)==null?void 0:m.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const i=y.useMemo(()=>cye(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),ze(OI,String(d))},[]);return{watchOn:r,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const Z5="agent-dag.character-enabled",J5="agent-dag.fm-volume",dye=1,PI="agent-dag.fm-source",Fwe=[{value:"claude-fm",label:"🎧 Claude FM"},{group:"📻 Lofi Girl",value:"lofi-relax",label:"📚 Relax / study"},{group:"📻 Lofi Girl",value:"lofi-game",label:"🎮 Chill / game"},{group:"📻 Lofi Girl",value:"lofi-vibe",label:"🌅 Vibe / chill"},{group:"📻 Lofi Girl",value:"lofi-sleep",label:"💤 Sleep / chill"},{group:"📻 Radio Mix",value:"radio-mix",label:"📡 Live radio mix"},{group:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"}];function hye(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function fye(e){return e!=="0"}function pye(){return fye(Ve(Z5))}function mye(e){return R4(e,dye)}function gye(){return mye(Ve(J5))}const Q5=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function DI(e){const t={};for(const n of Q5)t[n]=e(n);return t}function yye(e){return t=>e[t]??""}function wye(e,t){return Q5.every(n=>e[n]===t[n])}function xye(e,t){let n=null,s=0;function r(){s++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:r,run(o){r();const i=s;let c=!1;const d=()=>{i!==s||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){d();return}e.documentElement.dataset.themeTransition="true";try{const h=e.startViewTransition(d);n=h,h.ready.catch(()=>{}),h.updateCallbackDone.catch(()=>{d()}),h.finished.then(()=>{n===h&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===h&&(d(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,d()}}}}function FI(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function vye(){const[e,t]=y.useState(IY),[n,s]=y.useState(LY),[r,o]=y.useState(mue),i=y.useRef(r),[c]=y.useState(()=>xye(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=y.useCallback(v=>{const N=typeof v=="function"?v(i.current):v;N!==i.current&&(i.current=N,c.run(()=>wt.flushSync(()=>o(N))))},[c]);y.useEffect(()=>()=>c.cancel(),[c]);const[h,f]=y.useState(pye),[p,m]=y.useState($pe),[w,j]=y.useState(()=>DI(FI)),b=y.useMemo(()=>yye(w),[w]),k=y.useCallback(v=>Ece(v,b),[b]);return y.useEffect(()=>{document.documentElement.dataset.textSize=e,ze(e0,e)},[e]),y.useEffect(()=>{document.documentElement.dataset.density=n,ze(t0,n)},[n]),y.useEffect(()=>{const v=N=>{N.storageArea===cr()&&((N.key===e0||N.key===null)&&t($1(N.newValue)),(N.key===t0||N.key===null)&&s(Z3(N.newValue)))};return window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[]),y.useLayoutEffect(()=>{document.documentElement.dataset.theme=r,document.documentElement.dataset.colorScheme=Du[r].colorScheme,ze(ZD,r),j(v=>{const N=DI(FI);return wye(v,N)?v:N})},[r]),y.useEffect(()=>{ze(Z5,h?"1":"0")},[h]),y.useEffect(()=>{ze(D5,p)},[p]),y.useEffect(()=>{const v=document.querySelector('meta[name="theme-color"]'),N=w["--panel"];v&&N&&v.setAttribute("content",N)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:r,setTheme:d,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:k}}function bye(e){const t=y.useRef(null),[n,s]=y.useState(!1),[r,o]=y.useState(()=>new Set),i=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(e5(f.name));return Object.keys(QD).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(i.length<=1){s(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),m=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(j=>j.getBoundingClientRect()),w=hY(p,m,8);s(j=>j===w?j:w)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[i.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:i,hiddenCats:r,toggleCat:c,catBarRef:t,catBarOccluded:n}}function kye(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const s=new Set,r=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var m;return(m=e.onState)==null?void 0:m.call(e,r())};function i(){var m,w;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(m=n.addEventListener)==null||m.call(n,"statechange",o)),(w=n.resume)==null||w.call(n).then(o,()=>{}),o()}catch{}}function c(m,w,j=w.figure){if(!n||n.state!=="running")return!1;const b=_0(m,j),k=Rre(w.level,b),v=n.currentTime;for(const N of b.notes){const S=n.createOscillator(),E=n.createGain();S.type=b.type??"sine",S.frequency.value=N.hz;const C=v+N.at,I=C+N.ms/1e3;E.gain.setValueAtTime(yT,C),E.gain.exponentialRampToValueAtTime(k,C+Are),E.gain.exponentialRampToValueAtTime(yT,I),S.connect(E).connect(n.destination),S.start(C),S.stop(I+.02)}return!0}async function d(m,w){var k;if(!e.loadCustom)return"unavailable";let j;try{j=await e.loadCustom(m)}catch{return"unavailable"}if(!j)return"missing";if(j.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const v=new SpeechSynthesisUtterance(j.text),N=window.speechSynthesis.getVoices();v.voice=N.find(S=>S.voiceURI===j.voiceURI)??null,v.rate=j.rate,v.pitch=j.pitch,v.volume=Mre(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(v),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let b;try{b=await n.decodeAudioData(j.bytes.slice(0))}catch{return"broken"}try{const v=n.createBufferSource(),N=n.createGain();return v.buffer=b,N.gain.setValueAtTime($re(j.normalizationGain,w.level),n.currentTime),v.connect(N).connect(n.destination),s.add(v),(k=v.addEventListener)==null||k.call(v,"ended",()=>s.delete(v)),v.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var k,v;if(!w&&!e.enabled())return!1;const j=Bre((k=e.prefs)==null?void 0:k.call(e),m),b=((v=e.customSelection)==null?void 0:v.call(e)[m])??null;return b&&e.loadCustom?(d(b,j).then(N=>{var S;N==="played"||N==="locked"||((N==="missing"||N==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,b)),c(m,{...j,figure:Hn},Hn))}),!0):!n||n.state!=="running"?!1:c(m,j)}function f(m,w=zo){return d(m,{level:ip(w),figure:Hn}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const m of s)try{m.stop()}catch{}s.clear()}return{unlock:i,play:h,previewCustom:f,silence:p,state:r,get context(){return n}}}function jye({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:r}){y.useEffect(()=>{const o=kye({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:Sre,onCustomFailure:(h,f)=>r.current(h,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],c=()=>{for(const h of i)window.removeEventListener(h,d,{capture:!0})},d=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&c()};for(const h of i)window.addEventListener(h,d,{capture:!0});return c},[])}function Nye(){const[e,t]=y.useState(gye),[n,s]=y.useState(()=>hV(Ve(kE))),[r,o]=y.useState(()=>dV(Ve(jE))),[i,c]=y.useState(()=>fV(Ve(PI),n,hye)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{ze(J5,String(e))},[e]),y.useEffect(()=>{ze(jE,r?"1":"0")},[r]),y.useEffect(()=>{ze(kE,JSON.stringify(n))},[n]),y.useEffect(()=>{ze(PI,i)},[i]);const m=y.useCallback((v,N=!1)=>{s(S=>{const E=S.find(C=>C.id===v.id);return E?!N||!v.radio||!E.radio||E.url===v.url&&JSON.stringify(E.radio)===JSON.stringify(v.radio)?S:S.map(C=>C.id===v.id?{...C,url:v.url,radio:v.radio}:C):[...S,v]}),h(S=>{if(!S.has(v.id))return S;const E=new Set(S);return E.delete(v.id),E})},[]),w=y.useCallback((v,N)=>{const S=N.trim();!S||S.length>S3||s(E=>E.map(C=>C.id===v?{...C,name:S}:C))},[]),j=y.useCallback(v=>{s(N=>N.filter(S=>S.id!==v)),c(N=>pV(N,v)),h(N=>{if(!N.has(v))return N;const S=new Set(N);return S.delete(v),S})},[]),b=y.useCallback((v,N=!1)=>{const S=NE(v),E=d.has(S);v===i&&!E&&!N||(E&&h(C=>{const I=new Set(C);return I.delete(S),I}),c(v),p(C=>C+1))},[i,d]),k=y.useCallback((v,N)=>{const S=NE(v);h(E=>{if(E.has(S)===N)return E;const I=new Set(E);return N?I.add(S):I.delete(S),I})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:r,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:j,pickFmSource:b,markFmStationAvailability:k}}function Sye(e){const[t,n]=y.useState(null),[s,r]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!Ha())return;let j=!1;const b=c.current;return fetch("/api/desktop-update").then(k=>k.ok?k.json():null).then(k=>{if(j||c.current!==b)return;const v=nI(k);v&&n(v)}).catch(()=>{}),()=>{j=!0}},[e]);const d=lde(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=y.useCallback(async j=>{if(!An(h.current))return;const b=++p.current;window.clearTimeout(f.current),h.current=!0,r(!0),i(null);const k=v=>{b===p.current&&(window.clearTimeout(f.current),h.current=!1,r(!1),i({failure:v,version:j}))};try{const v=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:j})});if(!v.ok)return k(ude(await v.json().catch(()=>null)))}catch{return k("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>k("timeout"),o5))},[]),w=y.useCallback(j=>{if(Ha())try{const b=nI(JSON.parse(j));b&&(c.current++,n(b),b.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,r(!1)))}catch{}},[]);return{desktopUpdateRestarting:s,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:m,onDesktopUpdateEvent:w}}const xh="agent-dag.autoRestart",BI="agent-dag.bundleReloadedFor";function _ye({now:e,stateRef:t,version:n,notice:s,noticeOpen:r,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ve(xh)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,hr(xh),d(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(O=>O.ok?O.json():null).then(O=>{var M;O!=null&&O.ok&&d(((M=O.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,m]=y.useState(!1),[w,j]=y.useState("restart"),[b,k]=y.useState(null),v=y.useRef(!1),N=y.useRef(null),S=y.useRef(0),E=y.useRef(null),C=y.useCallback(async U=>{if(!An(v.current))return;const O=(U==null?void 0:U.upgrade)===!0,M=(U==null?void 0:U.whenIdle)===!0;v.current=!0,N.current=o;const q=++S.current,A=()=>{j(O?"npx":"restart"),m(!0)};M||A();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let D=!1;try{const P=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M?{upgrade:O,whenIdle:M}:{upgrade:O})});D=M&&P.status===409}catch{}if(D){v.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}M&&A(),window.setTimeout(()=>{if(S.current===q&&v.current){v.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},O?18e4:3e4)},[s==null?void 0:s.to,o]);y.useEffect(()=>{const U=rI(t.current.agents.values())>0,O=Yde({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:r,visible:document.visibilityState==="visible",busy:U,idleSince:E.current,now:e});E.current=O.idleSince,O.restart&&C({whenIdle:!0})},[c,s==null?void 0:s.kind,n==null?void 0:n.canRestart,r,e,C]);const I=rI(t.current.agents.values()),R=Kde(I,i),$=f5({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:r,visible:document.visibilityState==="visible",busy:I>0,idleSince:E.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let O=null,M=null;try{O=window.sessionStorage.getItem("agent-dag.restartPending"),M=window.sessionStorage.getItem(BI)}catch{return}const q=Wde({bundle:"3.43.0",running:U,pending:O,lastTried:M});if(q==="reload"){try{window.sessionStorage.setItem(BI,U??"")}catch{return}window.location.reload();return}if(q!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}v.current=!1,m(!1),k(U??null);const A=window.setTimeout(()=>k(null),6e3);return()=>window.clearTimeout(A)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&zde({asked:N.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}v.current=!1,m(!1)}},[p,o]);const L=y.useCallback(U=>{var O,M;if(!h.current){const q=Ve(xh)==="0";hr(xh),q&&((O=U.prefs)==null?void 0:O.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((M=U.prefs)==null?void 0:M.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:b,askRestart:C,restartCopy:R,restartFuseMs:$,loadAutoRestartPrefs:L}}function Eye(){const[e,t]=y.useState([]),n=y.useRef(new Set),[s,r]=y.useState(null),[o,i]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(m=>m.ok?m.json():null).then(m=>h?(m!=null&&m.ok&&t(AC(Array.isArray(m.pending)?m.pending:[],m.aliases)),m):null).catch(()=>null).then(m=>{h&&(i(w=>m!=null&&m.ok?m:w===void 0?null:w),f=window.setTimeout(p,(m==null?void 0:m.enabled)===!0?w0:ZP))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!s){r(h);try{const m=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);m&&Array.isArray(m.pending)?t(AC(m.pending,m.aliases)):t(w=>w.filter(j=>j.fp!==f))}catch{}finally{r(null)}}},[s]),d=y.useCallback(h=>{s||(n.current.add(h),t(f=>[...f]))},[s]);return{lanPending:e,lanDeferred:n,lanBusy:s,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Cye=6e4;function Tye({enabled:e,lanStatus:t,now:n}){const[s,r]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(v=>{v!=null&&v.ok&&Array.isArray(v.accounts)&&r(v.accounts)},[]),f=y.useCallback(async v=>{try{const N=await fetch(`/api/claude-accounts${v?"?refresh=1":""}`);N.ok&&h(await N.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let v=Date.now();const N=()=>{document.visibilityState!=="visible"||Date.now()-v<Cye||(v=Date.now(),f(!1))};return document.addEventListener("visibilitychange",N),window.addEventListener("focus",N),()=>{document.removeEventListener("visibilitychange",N),window.removeEventListener("focus",N)}},[e,f]);const p=y.useMemo(()=>e?Ofe(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=y.useRef(p);m.current=p;const w=y.useCallback(v=>{v.length&&i(N=>new Set([...N,...v]))},[]),j=y.useCallback(()=>{const v=m.current;v.length&&(w(v.map(N=>N.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:v.map(N=>({key:N.key,since:N.since}))})}).catch(()=>{}))},[w]),b=y.useRef(c);b.current=c;const k=y.useCallback(v=>{const N=b.current;w(Pfe(N?[N,...m.current]:m.current,v))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:k,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:j}}const e6=288,Rye=e6;function Aye(e,t,n){return e?"session-list":t||n?"accounts":null}function Mye(e){return e==="session-list"?Rye:e==="accounts"?e6:0}const $ye=240,Iye=20;function Lye(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=vu()?0:performance.now()+$ye+Iye)},[e]),t}const t6="agent-dag.sessionListOpen",n6="agent-dag.accountsPanelOpen";function Oye(){return Ve(t6)==="1"}function Pye(e){ze(t6,e?"1":"0")}function Dye(){const e=Ve(n6);return e===null?!0:e==="1"}function Fye(){const[e,t]=y.useState(Oye);y.useEffect(()=>{Pye(e)},[e]);const n=y.useRef(!1),[s,r]=y.useState(()=>{const m=Dye();return m&&e?(n.current=!0,!1):m});y.useEffect(()=>{!s&&n.current||ze(n6,s?"1":"0")},[s]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,r(!0))},[e]);const o=y.useCallback(()=>{t(m=>(m||r(w=>(w&&(n.current=!0),!1)),!m))},[]),i=y.useCallback(()=>{n.current=!1,r(m=>(m||t(!1),!m))},[]),c=y.useCallback(()=>{n.current=!1,r(m=>(m||t(!1),!0))},[]),d=y.useCallback(()=>t(!1),[]),h=y.useCallback(()=>{n.current=!1,t(!1)},[]),f=y.useCallback(()=>r(!1),[]),p=Aye(e,s,n.current);return{sessionListOpen:e,accountsPanelOpen:s,panel:p,toggleSessionList:o,toggleAccountsPanel:i,openAccountsPanel:c,closeSessionList:d,closeSessionListToCanvas:h,closeAccountsPanel:f}}const s6="agent-dag.detailOpen",r6="agent-dag.usagePanelOpen",a6="agent-dag.systemPanelOpen";function Bye(){return Ve(s6)==="1"}function qye(e){ze(s6,e?"1":"0")}function Uye(){const e=Ve(r6);return e===null?!0:e==="1"}function Wye(e){ze(r6,e?"1":"0")}function Hye(){const e=Ve(a6);return e===null?!0:e==="1"}function zye(e){ze(a6,e?"1":"0")}function Vye(){const[e,t]=y.useState(Bye);y.useEffect(()=>{qye(e)},[e]);const[n,s]=y.useState(Uye);y.useEffect(()=>{Wye(n)},[n]);const[r,o]=y.useState(Hye);return y.useEffect(()=>{zye(r)},[r]),nn("usage-panel",n),nn("machine-panel",r),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:s,machinePanelOpen:r,setMachinePanelOpen:o}}const Gye={permission:"your permission",asked:"your answer"},Kye="No sessions are waiting for you.";function Yye(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,r=n.every(i=>i.waiting.kind===s)?Gye[s]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${r}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${r}.`}function xk(e,t,n=Kye){return t!==""?t:e===""?"":n}function Xye({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,r]=y.useState(""),o=Yye(e);y.useEffect(()=>{r(m=>xk(m,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(m=>xk(m,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=oye(n);return y.useEffect(()=>{f(m=>xk(m,p,iye))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const Zye="/icon-192.png",o6=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function qI(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:o6[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Jye({waitingSessions:e,liveSince:t,focusSession:n}){const[s,r]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,m]=y.useState(o6),w=y.useCallback($=>{const L=!p[$];m(U=>({...U,[$]:L})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[$]:L})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&m(qI(U.prefs))}).catch(()=>{})},[p]),j=y.useRef(()=>{}),b=y.useRef(new Set),k=zn(e),v=y.useCallback(()=>{const $=!c;d($),$&&(b.current=eh(k.current)),$&&typeof Notification<"u"&&Notification.permission==="default"&&j.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:$})}).then(L=>L.ok?L.json():null).then(L=>{var U;L!=null&&L.ok&&(d(((U=L.prefs)==null?void 0:U.notifications)===!0),f(L.notificationsVetoed===!0))}).catch(()=>{})},[c]),N=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const L=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(L)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then($=>{const L=$;r(L),L==="granted"?i("on"):L==="denied"&&i("blocked")})},[]);j.current=S;const E=y.useRef(null),C=e.map($=>Df($.id,$.waiting)).join("|");y.useEffect(()=>{u7(E.current,s)&&(E.current=s,b.current=eh(e))},[s]);const I=y.useRef(!1);y.useEffect(()=>{d7(I.current,t)&&(I.current=!0,b.current=eh(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!h7(E.current,t))return;const $=typeof document>"u"||!document.hidden,L=l7(e,b.current,$,c);for(const U of L)try{const O=new Notification(U.title,{body:U.body,tag:U.key,icon:Zye});O.onclick=()=>{window.focus(),n(U.sessionId),O.close()}}catch{}b.current=$?eh(e):c7(e,L,b.current)},[C,t]);const R=y.useCallback($=>{var L;d(((L=$.prefs)==null?void 0:L.notifications)===!0),f($.notificationsVetoed===!0),m(qI($.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:v,notifySupported:N,askForNotifications:S,loadNotifyPrefs:R,accountNotify:p,toggleAccountNotify:w}}function Qye({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:r,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=zn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||s||r!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function ewe({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,r]=y.useState(null),o=y.useCallback((M,q)=>r({agentId:M,toolId:q}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(M=>h(M),[]),[p,m]=y.useState(!1),[w,j]=y.useState(!1),[b,k]=y.useState(!1),[v,N]=y.useState(!1),[S,E]=y.useState(!1),[C,I]=y.useState(null),R=y.useCallback(M=>{I(M??null),E(!0)},[]);nn("tool-detail",s!==null),nn("session-summary",i!==null),nn("context-window",d!==null),nn("keyboard-help",p),nn("usage-history",w),nn("browser-watch",b),nn("feedback",S);const $=s?iz(e.current.agents,s.agentId,s.toolId):null,L=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:O}=Qye({openedTool:$,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:v});return{setOpenedToolKey:r,openTool:o,openedTool:$,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:L,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:j,browserWatchOpen:b,setBrowserWatchOpen:k,trafficRadarOpen:v,setTrafficRadarOpen:N,feedbackOpen:S,setFeedbackOpen:E,feedbackPrefill:C,setFeedbackPrefill:I,openFeedback:R,keyHelpOpenRef:U,modalOpenRef:O}}function twe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:s,lastLayoutSigRef:r,forgetRemovals:o,clearSelection:i,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=c1(),t.current.clear(),n.current.clear(),s.current.clear(),r.current="",qD(),o(),i(),c()},[c,i,o]),m=zn(h),w=y.useCallback(j=>{const b=Jde(j,{confirmOpen:m.current,modalOpen:d.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const UI="agent-dag.oldNameNoticeDismissed";function nwe(e){const[t,n]=y.useState(()=>Ve(UI)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Ct?e.invokedAs:null,r=s!=null&&t!==s,o=y.useCallback(()=>{s&&(n(s),ze(UI,s))},[s]);return{oldName:s,oldNameOpen:r,dismissOldName:o}}const swe=300*1e3,rwe=1800*1e3,awe=8e3,owe=3e4;function WI(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function iwe({modalOpenRef:e}){const t=y.useCallback(()=>Sh({appModal:e.current,dialogDepth:Cn.dialogDepth()}),[e]),[n,s]=y.useState("hidden"),[r,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const j=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const v=await fetch("/api/rating").then(N=>N.ok?N.json():null).catch(()=>null);w||!v||s(N=>N==="thanks"?N:v.ask===!0?"asking":"hidden")},b=window.setTimeout(j,swe),k=window.setInterval(j,rwe);return()=>{w=!0,window.clearTimeout(b),window.clearInterval(k)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=r!==null&&r<=6?owe:awe;let j=0;const b=()=>{t()?j=window.setTimeout(b,w):s("hidden")};return j=window.setTimeout(b,w),()=>window.clearTimeout(j)},[n,r,i,t]);const h=y.useCallback(w=>{o(w),c(!1),s("thanks"),WI({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{s("hidden"),WI({later:!0})},[]),m=y.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:r,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function lwe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[r,o]=y.useState(()=>fre(Ve)),i=zn(r),[c,d]=y.useState([]),h=y.useCallback(N=>{o(S=>{const E={...S,[N]:null};return i.current=E,E}),hr(Uc[N])},[]),f=y.useCallback((N,S)=>{const E=i.current[N];S&&E!==S||(h(N),t(C=>{const I={...C,[N]:{...C[N],figure:Hn}};return n.current=I,I}),ze(yf[N],Hn))},[h]),p=zn(f);y.useEffect(()=>{let N=!0;return Nre().then(S=>{if(!N)return;d(S);const E=new Set(S.map(C=>C.id));for(const C of Wc){const I=i.current[C];I&&!E.has(I)&&p.current(C,I)}},()=>{}),()=>{N=!1}},[]);const m=y.useCallback((N,S)=>{if(!c.some(C=>C.id===S))return;const E={...i.current,[N]:S};i.current=E,o(E),ze(Uc[N],S),s(N,!0)},[c,s]),w=y.useCallback(async N=>{var I;const S=S0(c.length);if(S)throw new Error(S);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const C=new E;try{const R=await xre(N,L=>C.decodeAudioData(L));await mT(R);const $=mu(R);d(L=>[...L.filter(U=>U.id!==$.id),$])}finally{(I=C.close)==null||I.call(C)}},[c.length]),j=y.useCallback(async N=>{const S=S0(c.length);if(S)throw new Error(S);const E=vre(N);await mT(E);const C=mu(E);d(I=>[...I.filter(R=>R.id!==C.id),C])},[c.length]),b=y.useCallback(async(N,S)=>{const E=c.find(I=>I.id===N),C=S.trim().slice(0,80);!E||!C||C===E.name||(await _re(N,C),d(I=>I.map(R=>R.id===N?{...R,name:C}:R)))},[c]),k=y.useCallback(async N=>{await Ere(N),d(I=>I.filter(R=>R.id!==N));const S=i.current,E=pre(S,N);i.current=E,o(E);const C=Wc.filter(I=>S[I]===N);for(const I of C)hr(Uc[I]),ze(yf[I],Hn);C.length>0&&t(I=>{const R={...I};for(const $ of C)R[$]={...R[$],figure:Hn};return n.current=R,R})},[]),v=y.useCallback(N=>{var C,I;const S=Wc.find(R=>i.current[R]===N),E=S?n.current[S].level:zo;(C=e.current)==null||C.unlock(),(I=e.current)==null||I.previewCustom(N,E)},[]);return{customSelections:r,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:j,renameCustomAsset:b,deleteCustomAsset:k,previewCustomAsset:v}}function cwe(e){const[t,n]=y.useState(()=>Fre(Ve)),s=zn(t),r=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),r.current!==null&&clearTimeout(r.current),r.current=null,!d){(f=e.current)==null||f.play(c,!0);return}r.current=setTimeout(()=>{var p;r.current=null,(p=e.current)==null||p.play(c,!0)},Ire)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:ip(d.level??h[c].level),figure:C4(c,d.figure??h[c].figure)};return ze(A4[c],String(f.level)),ze(yf[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:s,previewTone:o,changeTone:i}}const uwe=15e3;function dwe(e){return e.visibilityState==="visible"&&e.hasFocus()}function hwe(e,t){return t||e===!0}function fwe(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function pwe(){y.useEffect(()=>{const e=fwe();let t=null;const n=i=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:i}),keepalive:!0}).catch(()=>{})},s=()=>{const i=dwe(document);hwe(t,i)&&n(i),t=i},r=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,uwe);return window.addEventListener("focus",s),window.addEventListener("blur",s),document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",r),()=>{window.clearInterval(o),window.removeEventListener("focus",s),window.removeEventListener("blur",s),document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",r),r()}},[])}function mwe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let s=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!s||!(r!=null&&r.ok)||(e(r),t(r),n(r))}).catch(()=>{}),()=>{s=!1}},[])}const vk="agent-dag.versionNoticeDismissed",gwe=15*6e4;function ywe(e){const[t,n]=y.useState(null),[s,r]=y.useState(()=>Ve(vk)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((b=!1)=>(b&&(o.current=Date.now(),c(!0)),fetch(b?"/api/version?refresh=1":"/api/version").then(k=>k.ok?k.json():null).then(k=>(k&&n(k),k??null)).catch(()=>null).finally(()=>{b&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=gwe)},[d]);y.useEffect(()=>{d();const b=window.setInterval(h,5*6e4),k=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",k)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=u5(f),m=mde(f,s),w=y.useCallback(()=>{r(""),ze(vk,"")},[]),j=y.useCallback(()=>{f&&(r(p),ze(vk,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:j,versionChecking:i,loadVersion:d}}function wwe({version:e,readyAppUpdate:t}){const[n,s]=y.useState(!1),r=y.useRef(null),[o,i]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const k=cr(),v=rpe(k),N=upe({stored:v,running:(e==null?void 0:e.running)??null,notes:yI,remembers:ape(k)});if(N.reason==="no-version")return;h.current=!0,N.record&&ope(k,N.record);let S=!0;return(async()=>{var $;let C=ipe(k);if(Ha())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const U=await L.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const O=(($=U.prefs)==null?void 0:$.tourSeen)===!0;C&&!O&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),C=C||O}catch{C=!0}if(!S)return;const I=cpe({tourSeen:C,decision:N}),R=N.show.length?{entries:N.show,since:v,firstRun:!1}:null;I.tour&&s(!0),I.notes==="now"?i(R):I.notes==="after"&&(r.current=R)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.43.0",p=y.useMemo(()=>A5(yI,null,f),[f]),m=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>s(!0),[]),j=y.useCallback(()=>i(null),[]),b=y.useCallback(()=>{s(!1),lpe(cr()),Ha()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const k=r.current;r.current=null,k&&i(k)},[]);return{tourOpen:n,openTour:w,closeTour:b,releaseNotes:o,closeReleaseNotes:j,chipVersion:f,openReleaseNotes:m}}function xwe(){const[e,t]=y.useState(void 0),[n,s]=y.useState(!1),r=y.useRef(!1);return r.current=e===!0&&!n,y.useEffect(()=>Oge(()=>r.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function vwe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ve("agent-dag.sound");n(c===null?!0:c==="on")},[]);const s=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return ze("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),r=y.useCallback(c=>{s()},[s]),o=zn(r),i=zn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function bwe(){const[e,t]=y.useState(cue),n=y.useCallback(o=>{t(i=>uue(i,o))},[]),s=y.useCallback(()=>t(o=>({...o,open:!1})),[]),r=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:s,showSection:r}}const kwe="agent-dag.autoFitDisabled";function jwe(e){const t=y.useRef(!1),[n,s]=y.useState(!1);y.useEffect(()=>{hr(kwe)},[]);const r=y.useCallback(()=>{t.current||(t.current=!0,s(!0))},[]),o=y.useCallback(()=>{t.current=!1,s(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:r,enableAutoFitAndRefit:o}}function Nwe(){return a.jsx(l1,{children:a.jsx(Fge,{children:a.jsx(Swe,{})})})}function Swe(){var Yu;const e=ml(),t=y.useState(c1)[0],n=y.useRef(t),[,s]=y.useState(0),r=y.useCallback(()=>s(Qn=>Qn+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Vye(),{selectedIds:p,primarySelectedId:m,selectAgent:w,clearSelection:j,pruneSelectionToBoard:b}=sae(n,i),{sessionListOpen:k,accountsPanelOpen:v,panel:N,toggleSessionList:S,toggleAccountsPanel:E,openAccountsPanel:C,closeSessionList:I,closeSessionListToCanvas:R,closeAccountsPanel:$}=Fye(),L=zi(v,200),U=zi(k,200),O=H_(k,U),M=zi(c,130),q=zi(h,130),A=y.useRef(null),D=vwe(A),{activateSoundRef:P,soundOnRef:K}=D,G=cwe(A),{setTonePrefs:W,tonePrefsRef:H,previewTone:F}=G,B=lwe({chimesRef:A,setTonePrefs:W,tonePrefsRef:H,previewTone:F}),{customSelectionsRef:Z,fallbackCustomRef:V}=B,X=bwe(),{openSettings:Y}=X;jye({chimesRef:A,soundOnRef:K,tonePrefsRef:H,customSelectionsRef:Z,fallbackCustomRef:V});const J=Uge(n),{pauseGate:ee,paused:ne,togglePause:le}=J,de=y.useRef(()=>{}),{live:ue,tabCapped:re,everConnected:pe,liveSince:ye}=Gre({stateRef:n,rerender:r,pauseGate:ee,chimesRef:A,desktopUpdateRef:de}),_e=ywe(ue),{version:he,notice:ae,noticeOpen:ge,loadVersion:Se}=_e,me=Sye(ue),{readyAppUpdate:$e,onDesktopUpdateEvent:Pe}=me;de.current=Pe,pwe();const qe=wwe({version:he,readyAppUpdate:$e}),{tourOpen:Le,openTour:Qe,releaseNotes:je}=qe,{workspace:Ae,providers:De,providersRef:He}=Hge(ue),Ze=Mye(N==="accounts"&&!De.claude?null:N),ft=Lye(Ze),ut=H_(v,L)&&De.claude,[Je,Dt]=y.useState(!1),vt=y.useCallback(()=>{C(),Dt(!0)},[C]);y.useEffect(()=>{v||Dt(!1)},[v]);const It=y.useCallback(()=>Dt(!1),[]),it=nwe(he),Lt=lye({version:he,loadVersion:Se}),{upgradeFailure:Ft}=Lt,dt=ewe({stateRef:n,tourOpen:Le,releaseNotes:je}),St=iwe({modalOpenRef:dt.modalOpenRef}),{openTool:rt,setSummaryFor:ys,setContextFor:Ws,openContext:ws,setKeyHelpOpen:Yn,setUsageHistoryOpen:Xn,setBrowserWatchOpen:wn,keyHelpOpenRef:At,modalOpenRef:an}=dt,Ne=xwe(),Te=uye(),{watchOn:We,watchUnseen:pt}=Te,at=Eye(),[Zn,Hs]=y.useState(0),{presentCats:zs,hiddenCats:On,toggleCat:xn,catBarRef:Jr,catBarOccluded:Vs}=bye(n),yr=y.useRef(null),[wr,xr]=y.useState(0),Bt=rae({stateRef:n,rerender:r,pruneSelectionToBoard:b,setContextFor:Ws,setSummaryFor:ys}),Qr=Kge(De.claude||De.codex),Gs=aye(Qr,Bt),vr=Tye({enabled:De.claude,lanStatus:at.lanStatus,now:Bt}),ot=_ye({now:Bt,stateRef:n,version:he,notice:ae,noticeOpen:ge,upgradeFailure:Ft,paused:J.paused}),{askRestart:Ya,loadAutoRestartPrefs:br}=ot,xs=vye(),{setTheme:vs,palette:ea}=xs,kr=Nye(),Pn=tce(),{applyViewport:Jt,moveCamera:Ks,fitLeft:qt,cameraEpochRef:we,lastFitTimeRef:Ye}=Pn,lt=mce(Pn),{pinnedRef:ht,positionsRef:dn,lastLayoutSigRef:bs,handleRelayout:ta,rearrangeUndo:Nl}=lt,Xa=y.useRef(null),Ys=y.useRef(()=>{}),Sl=ye!==null,Qo=y.useRef(0),na=y.useCallback(()=>{Qo.current=Date.now()},[]),{canvasRef:Xs,canvasSize:_l,paneSizeRef:st}=sue(ft),El=jwe(qt),{autoFitDisabledRef:Cl,disableAutoFit:Za}=El,ei=y.useRef(!1),{measuredRef:Zs,measuredVersionRef:Fu,sizeVersion:Tl,domSizeVersion:ti}=rue(ei),{removedNodes:Jn,removedAgentIds:hn,removeNode:Js,removeSelectedNode:sa,removalNotice:ra,hideSessions:Qs,bringBack:Rl,bringBackAll:Bu,forgetRemovals:Ja}=Oce({stateRef:n,pinnedRef:ht,positionsRef:dn,canvasRef:Xs,clearSelection:j,primarySelectedId:m});Vce({stateRef:n,removedNodes:Jn,hideSessions:Qs,ready:Sl,keepSessionId:m?((Yu=n.current.agents.get(m))==null?void 0:Yu.sessionId)??m:null});const Al=Ace({stateRef:n,now:Bt,removedAgentIds:hn,sizeVersion:Tl,domSizeVersion:ti});gce(Al,lt),Lce({layoutSig:Al,rf:e,stateRef:n,measuredRef:Zs,pinnedRef:ht,positionsRef:dn,paneSizeRef:st,lastInteractRef:Qo,autoFitDisabledRef:Cl,lastFitTimeRef:Ye,fitLeft:qt});const Ml=aue(),{bubbling:ni,endBubble:qu,onBubble:Sp}=Qse(),[jr,Qa]=y.useState(!1),Nr=Zse(),{beginTrashDrag:si,trackTrashDrag:_p,endTrashDrag:Ep}=Nr,ri=ore({stateRef:n,measuredRef:Zs,measuredVersionRef:Fu,canvasRef:Xs}),{lodRef:ai,applyZoom:$l}=ri,Il=eue({applyViewport:Jt,lastFitTimeRef:Ye,cameraEpochRef:we,disableAutoFit:Za,markInteract:na,canvasRef:Xs,applyZoom:$l}),vn=m?n.current.agents.get(m):null,eo=o&&vn!=null,ks=wue({sessionListShown:O,usageShown:Ma(M),machineShown:Ma(q),accountsShown:ut,detailShown:eo,primarySelectedId:m,canvasRef:Xs}),{railInsetRef:to,availableWidth:no,availableHeight:so}=Xle({canvasRef:Xs,canvasSize:_l,machinePhase:q,usagePhase:M,usagePanelOpen:c,detailShown:eo}),Ll=Mce({stateRef:n,now:Bt,availableWidth:no,availableHeight:so,layout:lt,measuredRef:Zs,onBubble:Sp,settled:Ml,dragging:jr,layoutSig:Al,selectedIds:p,openContext:ws,historyReplayed:Sl,removedNodes:Jn,removedAgentIds:hn,dragTick:Zn,dragPatchRef:yr,dragMoveTick:wr}),{nodes:Qt,edges:aa}=Ll,ro=zn(m);yce({nodes:Qt,edges:aa,settled:Ml,dragging:jr,availableWidth:no,availableHeight:so,layout:lt,camera:Pn,rf:e,measuredRef:Zs,stateRef:n,lastFocusRef:Xa,primarySelectedIdRef:ro,focusAgentRef:Ys,autoFitDisabledRef:Cl});const oa=twe({stateRef:n,pinnedRef:ht,measuredRef:Zs,positionsRef:dn,lastLayoutSigRef:bs,forgetRemovals:Ja,clearSelection:j,rerender:r,modalOpenRef:an}),{requestClear:Uu}=oa,Ol=xue({nodes:Qt,stateRef:n,pinnedRef:ht,positionsRef:dn,draggingRef:ei,dragPatchRef:yr,setDragging:Qa,setDragMoveTick:xr,setDragTick:Hs,endBubble:qu,markInteract:na,disableAutoFit:Za,beginTrashDrag:si,trackTrashDrag:_p,endTrashDrag:Ep,removeNode:Js}),Pl=y.useCallback(()=>qt(500),[qt]),Sr=zn(Qt),{focusAgent:_r,stepAgent:Wu,focusSession:ia}=sce({canvasRef:Xs,stateRef:n,measuredRef:Zs,nodesRef:Sr,railInsetRef:to,moveCamera:Ks,disableAutoFit:Za,lastFocusRef:Xa,focusAgentRef:Ys,selectAgent:w,primarySelectedIdRef:ro}),Cp=tue({clearSelection:j,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:eo,focusAgent:_r,draggingRef:ei,lodRef:ai}),Tp=rce({nodesRef:Sr,stateRef:n,canvasRef:Xs,railInsetRef:to}),Dl=zn(sa),Fl=y.useRef(null),Hu=y.useCallback(Qn=>{hn.has(Qn)&&Rl([Qn]),ia(Qn)},[hn,Rl,ia]),Rp=oue();gue({pointerFocusRef:Rp,nodesRef:Sr,stateRef:n,primarySelectedIdRef:ro,providersRef:He,soundOnRef:K,keyHelpOpenRef:At,modalOpenRef:an,waitingCursorRef:Fl,removeSelectedRef:Dl,activateSoundRef:P,clearSelection:j,selectAgent:w,focusAgent:_r,stepAgent:Wu,focusSession:ia,requestClear:Uu,handleRelayout:ta,undoRearrange:Nl.undo,handleFit:Pl,togglePause:le,toggleSessionList:S,toggleAccountsPanel:E,setDetailOpen:i,setUsageHistoryOpen:Xn,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:wn,setKeyHelpOpen:Yn,setTheme:vs,openSettings:Y});const zu=n.current.agents.size,la=y.useMemo(()=>Fk(n.current.agents.values()),[n.current,n.current.revision]);Pce({stateRef:n,waitingSessions:la,removedAgentIds:hn,removedNodes:Jn,bringBack:Rl}),Zce({stateRef:n,waitingSessions:la,live:ue});const Bl=Xye({waitingSessions:la,watchUnseen:pt,incidents:Gs}),ql=Jye({waitingSessions:la,liveSince:ye,focusSession:ia}),{loadNotifyPrefs:Ap}=ql;mwe({loadAutoRestartPrefs:br,loadNotifyPrefs:Ap,loadReportsPrefs:Ne.loadReportsPrefs});const Er=R1(Jue),[Vu,oi]=y.useState(!1),[Mp,Gu]=y.useState(!1),$p=y.useCallback(()=>Gu(!1),[]),Ku=y.useCallback(()=>oi(!1),[]),er=ede({providers:De,sessionListOpen:k,toggleSessionList:S,accountsPanelOpen:v,toggleAccountsPanel:E,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:Xn,watchOn:We,watchUnseen:pt,setBrowserWatchOpen:wn,setTrafficRadarOpen:dt.setTrafficRadarOpen,openSettings:Y,onFeedback:dt.openFeedback,radioOpen:Vu,setRadioOpen:oi,openToolActivity:()=>Gu(!0),toggles:ks.toggles}),[Ip,Lp]=y.useState(0),Op=y.useCallback(Qn=>{Hu(Qn),Er&&R()},[Hu,Er,R]),Pp=y.useCallback(()=>{k||S(),requestAnimationFrame(()=>{var Qn;return(Qn=document.querySelector("#session-list .sl-row"))==null?void 0:Qn.focus()})},[k,S]);return a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(tY,{}),a.jsx(_de,{versionCheck:_e,welcome:qe,desktopUpdate:me,pause:J,announcements:Bl,notify:ql,waitingSessions:la,waitingCursorRef:Fl,focusSession:ia,live:ue,now:Bt,incidents:Gs,queueNamed:Er?0:Ip}),!Er&&a.jsx(jde,{waitingSessions:la,waitingCursorRef:Fl,focusSession:ia,now:Bt,onFit:Lp,onMore:Pp}),vn&&a.jsx(Ede,{selected:vn,now:Bt,selectedIds:p,focusAgent:_r,clearSelection:j}),!Er&&a.jsx("div",{className:"actions",children:a.jsx(Xue,{items:er.utilities})})]}),Er?a.jsx(Yue,{items:[...er.left,...er.right[0],er.utilities[0]],more:[...er.right.slice(1).flat(),er.utilities[1]]}):a.jsx(eI,{side:"left",label:"Left column",groups:[er.left]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ra?`${ra.label} removed from the board.`:""}),a.jsx(Zde,{restart:ot,versionCheck:_e,upgrade:Lt,oldNameNotice:it,rating:St,onFeedback:dt.openFeedback,everConnected:pe,live:ue,paused:ne}),(O||ut)&&a.jsxs(Hse,{width:Ze,children:[ut&&a.jsx(Wse,{leaving:z_(v,L),onReport:dt.openFeedback,onRoster:vr.observe,onClose:()=>{ks.accounts(),$()},lanWanted:Je,onLanShown:It}),O&&a.jsx(mY,{leaving:z_(k,U),state:n.current,now:Bt,selectedIds:p,onSelect:Op,onClose:()=>{ks.sessionList(),I()},removedIds:hn,onBringBackAll:Bu})]}),a.jsxs(Mde,{canvasRef:Xs,bubbling:ni,dragging:jr,trash:Nr,zoom:ri,viewport:Il,stateRef:n,peek:Tp,children:[zu===0&&(!ue&&re?a.jsx(bue,{reservedRight:to.current}):a.jsx(kue,{live:ue,everConnected:pe,providers:De,workspace:Ae,onTour:Qe,reservedRight:to.current})),(zs.length>1||On.size>0)&&a.jsx(Cde,{catBarRef:Jr,catBarOccluded:Vs,presentCats:zs,hiddenCats:On,toggleCat:xn}),a.jsx(eY,{graph:Ll,layout:lt,viewport:Il,clicks:Cp,drag:Ol,appearance:xs,fm:kr,radioOpen:Vu,onRadioClose:Ku,autoFit:El,pause:J,stateRef:n,measuredRef:Zs,hiddenCats:On,now:Bt,openTool:rt,focusAgent:_r,requestClear:Uu,setKeyHelpOpen:Yn})]}),!Er&&a.jsx(eI,{side:"right",label:"Right panels",groups:er.right}),Mp&&a.jsx(GY,{onClose:$p}),Ma(M)&&a.jsx(eZ,{state:n.current,now:Bt,providers:De,incidents:Gs,liveSince:ye,leaving:M==="leaving",onClose:()=>{ks.usage(),d(!1)}}),Ma(q)&&a.jsx(FZ,{usageOpen:c,leaving:q==="leaving",onClose:()=>{ks.machine(),f(!1)}}),o&&vn?a.jsx(Oue,{selected:vn,now:Bt,openTool:rt,setSummaryFor:ys,stateRef:n,removeSelectedNode:sa,onClose:()=>{ks.detail(),i(!1)}}):null,a.jsx(xge,{dialogs:dt,welcome:qe,desktopUpdate:me,versionCheck:_e,restart:ot,upgrade:Lt,lanPairs:at,attention:vr,clearFlow:oa,watchBadge:Te,announcements:Bl,appearance:xs,providers:De,stateRef:n,agentCount:zu,menus:X,sound:D,tones:G,customTones:B,notify:ql,panelDoors:{accounts:C,localNetwork:vt}})]})}try{H7(window.localStorage)}catch{}const _we=vF.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);_we.render(a.jsx(Nwe,{}));export{fl as A,Fa as B,J1 as C,WG as D,Qf as E,Fwe as F,S1 as G,dl as H,NV as I,Awe as J,Twe as K,Rwe as L,Hf as M,S7 as N,dye as O,Cwe as P,HG as Q,rP as R,Sme as V,lP as a,gt as b,Da as c,xt as d,Ur as e,Xe as f,Mwe as g,Ps as h,$we as i,a as j,fu as k,Kn as l,yre as m,Iwe as n,fpe as o,r0 as p,Lwe as q,y as r,An as s,Owe as t,ct as u,Pwe as v,Ko as w,hpe as x,Dwe as y,Xf as z};
|
|
310
|
+
`)}}function aye(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>rye(n,t)).filter(n=>n!==null)}function oye(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const iye="The providers' status pages report no incident.";function lye({version:e,loadVersion:t}){var h;const[n,s]=y.useState(!1),r=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Hde(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(An(i.current||r==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[r,t]);y.useEffect(()=>{if(r!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[r,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await Ko(f)||(s(!0),window.setTimeout(()=>s(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:r,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const OI="agent-dag.browserWatch.seenMs";function cye(e,t){return e.filter(n=>n.startMs>t)}function uye(){const[e,t]=y.useState(()=>Number(Ve(OI))||0),[n,s]=y.useState([]),[r,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var m;!d||!(p!=null&&p.ok)||(s(p.episodes??[]),o(((m=p.settings)==null?void 0:m.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const i=y.useMemo(()=>cye(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),ze(OI,String(d))},[]);return{watchOn:r,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const Z5="agent-dag.character-enabled",J5="agent-dag.fm-volume",dye=1,PI="agent-dag.fm-source",Fwe=[{value:"claude-fm",label:"🎧 Claude FM"},{group:"📻 Lofi Girl",value:"lofi-relax",label:"📚 Relax / study"},{group:"📻 Lofi Girl",value:"lofi-game",label:"🎮 Chill / game"},{group:"📻 Lofi Girl",value:"lofi-vibe",label:"🌅 Vibe / chill"},{group:"📻 Lofi Girl",value:"lofi-sleep",label:"💤 Sleep / chill"},{group:"📻 Radio Mix",value:"radio-mix",label:"📡 Live radio mix"},{group:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"}];function hye(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function fye(e){return e!=="0"}function pye(){return fye(Ve(Z5))}function mye(e){return R4(e,dye)}function gye(){return mye(Ve(J5))}const Q5=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function DI(e){const t={};for(const n of Q5)t[n]=e(n);return t}function yye(e){return t=>e[t]??""}function wye(e,t){return Q5.every(n=>e[n]===t[n])}function xye(e,t){let n=null,s=0;function r(){s++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:r,run(o){r();const i=s;let c=!1;const d=()=>{i!==s||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){d();return}e.documentElement.dataset.themeTransition="true";try{const h=e.startViewTransition(d);n=h,h.ready.catch(()=>{}),h.updateCallbackDone.catch(()=>{d()}),h.finished.then(()=>{n===h&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===h&&(d(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,d()}}}}function FI(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function vye(){const[e,t]=y.useState(IY),[n,s]=y.useState(LY),[r,o]=y.useState(mue),i=y.useRef(r),[c]=y.useState(()=>xye(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=y.useCallback(v=>{const N=typeof v=="function"?v(i.current):v;N!==i.current&&(i.current=N,c.run(()=>wt.flushSync(()=>o(N))))},[c]);y.useEffect(()=>()=>c.cancel(),[c]);const[h,f]=y.useState(pye),[p,m]=y.useState($pe),[w,j]=y.useState(()=>DI(FI)),b=y.useMemo(()=>yye(w),[w]),k=y.useCallback(v=>Ece(v,b),[b]);return y.useEffect(()=>{document.documentElement.dataset.textSize=e,ze(e0,e)},[e]),y.useEffect(()=>{document.documentElement.dataset.density=n,ze(t0,n)},[n]),y.useEffect(()=>{const v=N=>{N.storageArea===cr()&&((N.key===e0||N.key===null)&&t($1(N.newValue)),(N.key===t0||N.key===null)&&s(Z3(N.newValue)))};return window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[]),y.useLayoutEffect(()=>{document.documentElement.dataset.theme=r,document.documentElement.dataset.colorScheme=Du[r].colorScheme,ze(ZD,r),j(v=>{const N=DI(FI);return wye(v,N)?v:N})},[r]),y.useEffect(()=>{ze(Z5,h?"1":"0")},[h]),y.useEffect(()=>{ze(D5,p)},[p]),y.useEffect(()=>{const v=document.querySelector('meta[name="theme-color"]'),N=w["--panel"];v&&N&&v.setAttribute("content",N)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:r,setTheme:d,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:k}}function bye(e){const t=y.useRef(null),[n,s]=y.useState(!1),[r,o]=y.useState(()=>new Set),i=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(e5(f.name));return Object.keys(QD).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(i.length<=1){s(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),m=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(j=>j.getBoundingClientRect()),w=hY(p,m,8);s(j=>j===w?j:w)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[i.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:i,hiddenCats:r,toggleCat:c,catBarRef:t,catBarOccluded:n}}function kye(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const s=new Set,r=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var m;return(m=e.onState)==null?void 0:m.call(e,r())};function i(){var m,w;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(m=n.addEventListener)==null||m.call(n,"statechange",o)),(w=n.resume)==null||w.call(n).then(o,()=>{}),o()}catch{}}function c(m,w,j=w.figure){if(!n||n.state!=="running")return!1;const b=_0(m,j),k=Rre(w.level,b),v=n.currentTime;for(const N of b.notes){const S=n.createOscillator(),E=n.createGain();S.type=b.type??"sine",S.frequency.value=N.hz;const C=v+N.at,I=C+N.ms/1e3;E.gain.setValueAtTime(yT,C),E.gain.exponentialRampToValueAtTime(k,C+Are),E.gain.exponentialRampToValueAtTime(yT,I),S.connect(E).connect(n.destination),S.start(C),S.stop(I+.02)}return!0}async function d(m,w){var k;if(!e.loadCustom)return"unavailable";let j;try{j=await e.loadCustom(m)}catch{return"unavailable"}if(!j)return"missing";if(j.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const v=new SpeechSynthesisUtterance(j.text),N=window.speechSynthesis.getVoices();v.voice=N.find(S=>S.voiceURI===j.voiceURI)??null,v.rate=j.rate,v.pitch=j.pitch,v.volume=Mre(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(v),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let b;try{b=await n.decodeAudioData(j.bytes.slice(0))}catch{return"broken"}try{const v=n.createBufferSource(),N=n.createGain();return v.buffer=b,N.gain.setValueAtTime($re(j.normalizationGain,w.level),n.currentTime),v.connect(N).connect(n.destination),s.add(v),(k=v.addEventListener)==null||k.call(v,"ended",()=>s.delete(v)),v.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var k,v;if(!w&&!e.enabled())return!1;const j=Bre((k=e.prefs)==null?void 0:k.call(e),m),b=((v=e.customSelection)==null?void 0:v.call(e)[m])??null;return b&&e.loadCustom?(d(b,j).then(N=>{var S;N==="played"||N==="locked"||((N==="missing"||N==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,b)),c(m,{...j,figure:Hn},Hn))}),!0):!n||n.state!=="running"?!1:c(m,j)}function f(m,w=zo){return d(m,{level:ip(w),figure:Hn}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const m of s)try{m.stop()}catch{}s.clear()}return{unlock:i,play:h,previewCustom:f,silence:p,state:r,get context(){return n}}}function jye({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:r}){y.useEffect(()=>{const o=kye({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:Sre,onCustomFailure:(h,f)=>r.current(h,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],c=()=>{for(const h of i)window.removeEventListener(h,d,{capture:!0})},d=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&c()};for(const h of i)window.addEventListener(h,d,{capture:!0});return c},[])}function Nye(){const[e,t]=y.useState(gye),[n,s]=y.useState(()=>hV(Ve(kE))),[r,o]=y.useState(()=>dV(Ve(jE))),[i,c]=y.useState(()=>fV(Ve(PI),n,hye)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{ze(J5,String(e))},[e]),y.useEffect(()=>{ze(jE,r?"1":"0")},[r]),y.useEffect(()=>{ze(kE,JSON.stringify(n))},[n]),y.useEffect(()=>{ze(PI,i)},[i]);const m=y.useCallback((v,N=!1)=>{s(S=>{const E=S.find(C=>C.id===v.id);return E?!N||!v.radio||!E.radio||E.url===v.url&&JSON.stringify(E.radio)===JSON.stringify(v.radio)?S:S.map(C=>C.id===v.id?{...C,url:v.url,radio:v.radio}:C):[...S,v]}),h(S=>{if(!S.has(v.id))return S;const E=new Set(S);return E.delete(v.id),E})},[]),w=y.useCallback((v,N)=>{const S=N.trim();!S||S.length>S3||s(E=>E.map(C=>C.id===v?{...C,name:S}:C))},[]),j=y.useCallback(v=>{s(N=>N.filter(S=>S.id!==v)),c(N=>pV(N,v)),h(N=>{if(!N.has(v))return N;const S=new Set(N);return S.delete(v),S})},[]),b=y.useCallback((v,N=!1)=>{const S=NE(v),E=d.has(S);v===i&&!E&&!N||(E&&h(C=>{const I=new Set(C);return I.delete(S),I}),c(v),p(C=>C+1))},[i,d]),k=y.useCallback((v,N)=>{const S=NE(v);h(E=>{if(E.has(S)===N)return E;const I=new Set(E);return N?I.add(S):I.delete(S),I})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:r,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:j,pickFmSource:b,markFmStationAvailability:k}}function Sye(e){const[t,n]=y.useState(null),[s,r]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!Ha())return;let j=!1;const b=c.current;return fetch("/api/desktop-update").then(k=>k.ok?k.json():null).then(k=>{if(j||c.current!==b)return;const v=nI(k);v&&n(v)}).catch(()=>{}),()=>{j=!0}},[e]);const d=lde(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=y.useCallback(async j=>{if(!An(h.current))return;const b=++p.current;window.clearTimeout(f.current),h.current=!0,r(!0),i(null);const k=v=>{b===p.current&&(window.clearTimeout(f.current),h.current=!1,r(!1),i({failure:v,version:j}))};try{const v=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:j})});if(!v.ok)return k(ude(await v.json().catch(()=>null)))}catch{return k("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>k("timeout"),o5))},[]),w=y.useCallback(j=>{if(Ha())try{const b=nI(JSON.parse(j));b&&(c.current++,n(b),b.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,r(!1)))}catch{}},[]);return{desktopUpdateRestarting:s,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:m,onDesktopUpdateEvent:w}}const xh="agent-dag.autoRestart",BI="agent-dag.bundleReloadedFor";function _ye({now:e,stateRef:t,version:n,notice:s,noticeOpen:r,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ve(xh)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,hr(xh),d(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(O=>O.ok?O.json():null).then(O=>{var M;O!=null&&O.ok&&d(((M=O.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,m]=y.useState(!1),[w,j]=y.useState("restart"),[b,k]=y.useState(null),v=y.useRef(!1),N=y.useRef(null),S=y.useRef(0),E=y.useRef(null),C=y.useCallback(async U=>{if(!An(v.current))return;const O=(U==null?void 0:U.upgrade)===!0,M=(U==null?void 0:U.whenIdle)===!0;v.current=!0,N.current=o;const q=++S.current,A=()=>{j(O?"npx":"restart"),m(!0)};M||A();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let D=!1;try{const P=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M?{upgrade:O,whenIdle:M}:{upgrade:O})});D=M&&P.status===409}catch{}if(D){v.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}M&&A(),window.setTimeout(()=>{if(S.current===q&&v.current){v.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},O?18e4:3e4)},[s==null?void 0:s.to,o]);y.useEffect(()=>{const U=rI(t.current.agents.values())>0,O=Yde({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:r,visible:document.visibilityState==="visible",busy:U,idleSince:E.current,now:e});E.current=O.idleSince,O.restart&&C({whenIdle:!0})},[c,s==null?void 0:s.kind,n==null?void 0:n.canRestart,r,e,C]);const I=rI(t.current.agents.values()),R=Kde(I,i),$=f5({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:r,visible:document.visibilityState==="visible",busy:I>0,idleSince:E.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let O=null,M=null;try{O=window.sessionStorage.getItem("agent-dag.restartPending"),M=window.sessionStorage.getItem(BI)}catch{return}const q=Wde({bundle:"3.43.1",running:U,pending:O,lastTried:M});if(q==="reload"){try{window.sessionStorage.setItem(BI,U??"")}catch{return}window.location.reload();return}if(q!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}v.current=!1,m(!1),k(U??null);const A=window.setTimeout(()=>k(null),6e3);return()=>window.clearTimeout(A)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&zde({asked:N.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}v.current=!1,m(!1)}},[p,o]);const L=y.useCallback(U=>{var O,M;if(!h.current){const q=Ve(xh)==="0";hr(xh),q&&((O=U.prefs)==null?void 0:O.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((M=U.prefs)==null?void 0:M.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:b,askRestart:C,restartCopy:R,restartFuseMs:$,loadAutoRestartPrefs:L}}function Eye(){const[e,t]=y.useState([]),n=y.useRef(new Set),[s,r]=y.useState(null),[o,i]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(m=>m.ok?m.json():null).then(m=>h?(m!=null&&m.ok&&t(AC(Array.isArray(m.pending)?m.pending:[],m.aliases)),m):null).catch(()=>null).then(m=>{h&&(i(w=>m!=null&&m.ok?m:w===void 0?null:w),f=window.setTimeout(p,(m==null?void 0:m.enabled)===!0?w0:ZP))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!s){r(h);try{const m=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);m&&Array.isArray(m.pending)?t(AC(m.pending,m.aliases)):t(w=>w.filter(j=>j.fp!==f))}catch{}finally{r(null)}}},[s]),d=y.useCallback(h=>{s||(n.current.add(h),t(f=>[...f]))},[s]);return{lanPending:e,lanDeferred:n,lanBusy:s,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Cye=6e4;function Tye({enabled:e,lanStatus:t,now:n}){const[s,r]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(v=>{v!=null&&v.ok&&Array.isArray(v.accounts)&&r(v.accounts)},[]),f=y.useCallback(async v=>{try{const N=await fetch(`/api/claude-accounts${v?"?refresh=1":""}`);N.ok&&h(await N.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let v=Date.now();const N=()=>{document.visibilityState!=="visible"||Date.now()-v<Cye||(v=Date.now(),f(!1))};return document.addEventListener("visibilitychange",N),window.addEventListener("focus",N),()=>{document.removeEventListener("visibilitychange",N),window.removeEventListener("focus",N)}},[e,f]);const p=y.useMemo(()=>e?Ofe(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=y.useRef(p);m.current=p;const w=y.useCallback(v=>{v.length&&i(N=>new Set([...N,...v]))},[]),j=y.useCallback(()=>{const v=m.current;v.length&&(w(v.map(N=>N.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:v.map(N=>({key:N.key,since:N.since}))})}).catch(()=>{}))},[w]),b=y.useRef(c);b.current=c;const k=y.useCallback(v=>{const N=b.current;w(Pfe(N?[N,...m.current]:m.current,v))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:k,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:j}}const e6=288,Rye=e6;function Aye(e,t,n){return e?"session-list":t||n?"accounts":null}function Mye(e){return e==="session-list"?Rye:e==="accounts"?e6:0}const $ye=240,Iye=20;function Lye(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=vu()?0:performance.now()+$ye+Iye)},[e]),t}const t6="agent-dag.sessionListOpen",n6="agent-dag.accountsPanelOpen";function Oye(){return Ve(t6)==="1"}function Pye(e){ze(t6,e?"1":"0")}function Dye(){const e=Ve(n6);return e===null?!0:e==="1"}function Fye(){const[e,t]=y.useState(Oye);y.useEffect(()=>{Pye(e)},[e]);const n=y.useRef(!1),[s,r]=y.useState(()=>{const m=Dye();return m&&e?(n.current=!0,!1):m});y.useEffect(()=>{!s&&n.current||ze(n6,s?"1":"0")},[s]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,r(!0))},[e]);const o=y.useCallback(()=>{t(m=>(m||r(w=>(w&&(n.current=!0),!1)),!m))},[]),i=y.useCallback(()=>{n.current=!1,r(m=>(m||t(!1),!m))},[]),c=y.useCallback(()=>{n.current=!1,r(m=>(m||t(!1),!0))},[]),d=y.useCallback(()=>t(!1),[]),h=y.useCallback(()=>{n.current=!1,t(!1)},[]),f=y.useCallback(()=>r(!1),[]),p=Aye(e,s,n.current);return{sessionListOpen:e,accountsPanelOpen:s,panel:p,toggleSessionList:o,toggleAccountsPanel:i,openAccountsPanel:c,closeSessionList:d,closeSessionListToCanvas:h,closeAccountsPanel:f}}const s6="agent-dag.detailOpen",r6="agent-dag.usagePanelOpen",a6="agent-dag.systemPanelOpen";function Bye(){return Ve(s6)==="1"}function qye(e){ze(s6,e?"1":"0")}function Uye(){const e=Ve(r6);return e===null?!0:e==="1"}function Wye(e){ze(r6,e?"1":"0")}function Hye(){const e=Ve(a6);return e===null?!0:e==="1"}function zye(e){ze(a6,e?"1":"0")}function Vye(){const[e,t]=y.useState(Bye);y.useEffect(()=>{qye(e)},[e]);const[n,s]=y.useState(Uye);y.useEffect(()=>{Wye(n)},[n]);const[r,o]=y.useState(Hye);return y.useEffect(()=>{zye(r)},[r]),nn("usage-panel",n),nn("machine-panel",r),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:s,machinePanelOpen:r,setMachinePanelOpen:o}}const Gye={permission:"your permission",asked:"your answer"},Kye="No sessions are waiting for you.";function Yye(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,r=n.every(i=>i.waiting.kind===s)?Gye[s]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${r}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${r}.`}function xk(e,t,n=Kye){return t!==""?t:e===""?"":n}function Xye({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,r]=y.useState(""),o=Yye(e);y.useEffect(()=>{r(m=>xk(m,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(m=>xk(m,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=oye(n);return y.useEffect(()=>{f(m=>xk(m,p,iye))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const Zye="/icon-192.png",o6=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function qI(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:o6[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Jye({waitingSessions:e,liveSince:t,focusSession:n}){const[s,r]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,m]=y.useState(o6),w=y.useCallback($=>{const L=!p[$];m(U=>({...U,[$]:L})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[$]:L})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&m(qI(U.prefs))}).catch(()=>{})},[p]),j=y.useRef(()=>{}),b=y.useRef(new Set),k=zn(e),v=y.useCallback(()=>{const $=!c;d($),$&&(b.current=eh(k.current)),$&&typeof Notification<"u"&&Notification.permission==="default"&&j.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:$})}).then(L=>L.ok?L.json():null).then(L=>{var U;L!=null&&L.ok&&(d(((U=L.prefs)==null?void 0:U.notifications)===!0),f(L.notificationsVetoed===!0))}).catch(()=>{})},[c]),N=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const L=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(L)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then($=>{const L=$;r(L),L==="granted"?i("on"):L==="denied"&&i("blocked")})},[]);j.current=S;const E=y.useRef(null),C=e.map($=>Df($.id,$.waiting)).join("|");y.useEffect(()=>{u7(E.current,s)&&(E.current=s,b.current=eh(e))},[s]);const I=y.useRef(!1);y.useEffect(()=>{d7(I.current,t)&&(I.current=!0,b.current=eh(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!h7(E.current,t))return;const $=typeof document>"u"||!document.hidden,L=l7(e,b.current,$,c);for(const U of L)try{const O=new Notification(U.title,{body:U.body,tag:U.key,icon:Zye});O.onclick=()=>{window.focus(),n(U.sessionId),O.close()}}catch{}b.current=$?eh(e):c7(e,L,b.current)},[C,t]);const R=y.useCallback($=>{var L;d(((L=$.prefs)==null?void 0:L.notifications)===!0),f($.notificationsVetoed===!0),m(qI($.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:v,notifySupported:N,askForNotifications:S,loadNotifyPrefs:R,accountNotify:p,toggleAccountNotify:w}}function Qye({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:r,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=zn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||s||r!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function ewe({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,r]=y.useState(null),o=y.useCallback((M,q)=>r({agentId:M,toolId:q}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(M=>h(M),[]),[p,m]=y.useState(!1),[w,j]=y.useState(!1),[b,k]=y.useState(!1),[v,N]=y.useState(!1),[S,E]=y.useState(!1),[C,I]=y.useState(null),R=y.useCallback(M=>{I(M??null),E(!0)},[]);nn("tool-detail",s!==null),nn("session-summary",i!==null),nn("context-window",d!==null),nn("keyboard-help",p),nn("usage-history",w),nn("browser-watch",b),nn("feedback",S);const $=s?iz(e.current.agents,s.agentId,s.toolId):null,L=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:O}=Qye({openedTool:$,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:v});return{setOpenedToolKey:r,openTool:o,openedTool:$,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:L,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:j,browserWatchOpen:b,setBrowserWatchOpen:k,trafficRadarOpen:v,setTrafficRadarOpen:N,feedbackOpen:S,setFeedbackOpen:E,feedbackPrefill:C,setFeedbackPrefill:I,openFeedback:R,keyHelpOpenRef:U,modalOpenRef:O}}function twe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:s,lastLayoutSigRef:r,forgetRemovals:o,clearSelection:i,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=c1(),t.current.clear(),n.current.clear(),s.current.clear(),r.current="",qD(),o(),i(),c()},[c,i,o]),m=zn(h),w=y.useCallback(j=>{const b=Jde(j,{confirmOpen:m.current,modalOpen:d.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const UI="agent-dag.oldNameNoticeDismissed";function nwe(e){const[t,n]=y.useState(()=>Ve(UI)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Ct?e.invokedAs:null,r=s!=null&&t!==s,o=y.useCallback(()=>{s&&(n(s),ze(UI,s))},[s]);return{oldName:s,oldNameOpen:r,dismissOldName:o}}const swe=300*1e3,rwe=1800*1e3,awe=8e3,owe=3e4;function WI(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function iwe({modalOpenRef:e}){const t=y.useCallback(()=>Sh({appModal:e.current,dialogDepth:Cn.dialogDepth()}),[e]),[n,s]=y.useState("hidden"),[r,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const j=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const v=await fetch("/api/rating").then(N=>N.ok?N.json():null).catch(()=>null);w||!v||s(N=>N==="thanks"?N:v.ask===!0?"asking":"hidden")},b=window.setTimeout(j,swe),k=window.setInterval(j,rwe);return()=>{w=!0,window.clearTimeout(b),window.clearInterval(k)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=r!==null&&r<=6?owe:awe;let j=0;const b=()=>{t()?j=window.setTimeout(b,w):s("hidden")};return j=window.setTimeout(b,w),()=>window.clearTimeout(j)},[n,r,i,t]);const h=y.useCallback(w=>{o(w),c(!1),s("thanks"),WI({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{s("hidden"),WI({later:!0})},[]),m=y.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:r,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function lwe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[r,o]=y.useState(()=>fre(Ve)),i=zn(r),[c,d]=y.useState([]),h=y.useCallback(N=>{o(S=>{const E={...S,[N]:null};return i.current=E,E}),hr(Uc[N])},[]),f=y.useCallback((N,S)=>{const E=i.current[N];S&&E!==S||(h(N),t(C=>{const I={...C,[N]:{...C[N],figure:Hn}};return n.current=I,I}),ze(yf[N],Hn))},[h]),p=zn(f);y.useEffect(()=>{let N=!0;return Nre().then(S=>{if(!N)return;d(S);const E=new Set(S.map(C=>C.id));for(const C of Wc){const I=i.current[C];I&&!E.has(I)&&p.current(C,I)}},()=>{}),()=>{N=!1}},[]);const m=y.useCallback((N,S)=>{if(!c.some(C=>C.id===S))return;const E={...i.current,[N]:S};i.current=E,o(E),ze(Uc[N],S),s(N,!0)},[c,s]),w=y.useCallback(async N=>{var I;const S=S0(c.length);if(S)throw new Error(S);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const C=new E;try{const R=await xre(N,L=>C.decodeAudioData(L));await mT(R);const $=mu(R);d(L=>[...L.filter(U=>U.id!==$.id),$])}finally{(I=C.close)==null||I.call(C)}},[c.length]),j=y.useCallback(async N=>{const S=S0(c.length);if(S)throw new Error(S);const E=vre(N);await mT(E);const C=mu(E);d(I=>[...I.filter(R=>R.id!==C.id),C])},[c.length]),b=y.useCallback(async(N,S)=>{const E=c.find(I=>I.id===N),C=S.trim().slice(0,80);!E||!C||C===E.name||(await _re(N,C),d(I=>I.map(R=>R.id===N?{...R,name:C}:R)))},[c]),k=y.useCallback(async N=>{await Ere(N),d(I=>I.filter(R=>R.id!==N));const S=i.current,E=pre(S,N);i.current=E,o(E);const C=Wc.filter(I=>S[I]===N);for(const I of C)hr(Uc[I]),ze(yf[I],Hn);C.length>0&&t(I=>{const R={...I};for(const $ of C)R[$]={...R[$],figure:Hn};return n.current=R,R})},[]),v=y.useCallback(N=>{var C,I;const S=Wc.find(R=>i.current[R]===N),E=S?n.current[S].level:zo;(C=e.current)==null||C.unlock(),(I=e.current)==null||I.previewCustom(N,E)},[]);return{customSelections:r,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:j,renameCustomAsset:b,deleteCustomAsset:k,previewCustomAsset:v}}function cwe(e){const[t,n]=y.useState(()=>Fre(Ve)),s=zn(t),r=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),r.current!==null&&clearTimeout(r.current),r.current=null,!d){(f=e.current)==null||f.play(c,!0);return}r.current=setTimeout(()=>{var p;r.current=null,(p=e.current)==null||p.play(c,!0)},Ire)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:ip(d.level??h[c].level),figure:C4(c,d.figure??h[c].figure)};return ze(A4[c],String(f.level)),ze(yf[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:s,previewTone:o,changeTone:i}}const uwe=15e3;function dwe(e){return e.visibilityState==="visible"&&e.hasFocus()}function hwe(e,t){return t||e===!0}function fwe(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function pwe(){y.useEffect(()=>{const e=fwe();let t=null;const n=i=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:i}),keepalive:!0}).catch(()=>{})},s=()=>{const i=dwe(document);hwe(t,i)&&n(i),t=i},r=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,uwe);return window.addEventListener("focus",s),window.addEventListener("blur",s),document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",r),()=>{window.clearInterval(o),window.removeEventListener("focus",s),window.removeEventListener("blur",s),document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",r),r()}},[])}function mwe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let s=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!s||!(r!=null&&r.ok)||(e(r),t(r),n(r))}).catch(()=>{}),()=>{s=!1}},[])}const vk="agent-dag.versionNoticeDismissed",gwe=15*6e4;function ywe(e){const[t,n]=y.useState(null),[s,r]=y.useState(()=>Ve(vk)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((b=!1)=>(b&&(o.current=Date.now(),c(!0)),fetch(b?"/api/version?refresh=1":"/api/version").then(k=>k.ok?k.json():null).then(k=>(k&&n(k),k??null)).catch(()=>null).finally(()=>{b&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=gwe)},[d]);y.useEffect(()=>{d();const b=window.setInterval(h,5*6e4),k=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",k)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=u5(f),m=mde(f,s),w=y.useCallback(()=>{r(""),ze(vk,"")},[]),j=y.useCallback(()=>{f&&(r(p),ze(vk,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:j,versionChecking:i,loadVersion:d}}function wwe({version:e,readyAppUpdate:t}){const[n,s]=y.useState(!1),r=y.useRef(null),[o,i]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const k=cr(),v=rpe(k),N=upe({stored:v,running:(e==null?void 0:e.running)??null,notes:yI,remembers:ape(k)});if(N.reason==="no-version")return;h.current=!0,N.record&&ope(k,N.record);let S=!0;return(async()=>{var $;let C=ipe(k);if(Ha())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const U=await L.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const O=(($=U.prefs)==null?void 0:$.tourSeen)===!0;C&&!O&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),C=C||O}catch{C=!0}if(!S)return;const I=cpe({tourSeen:C,decision:N}),R=N.show.length?{entries:N.show,since:v,firstRun:!1}:null;I.tour&&s(!0),I.notes==="now"?i(R):I.notes==="after"&&(r.current=R)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.43.1",p=y.useMemo(()=>A5(yI,null,f),[f]),m=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>s(!0),[]),j=y.useCallback(()=>i(null),[]),b=y.useCallback(()=>{s(!1),lpe(cr()),Ha()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const k=r.current;r.current=null,k&&i(k)},[]);return{tourOpen:n,openTour:w,closeTour:b,releaseNotes:o,closeReleaseNotes:j,chipVersion:f,openReleaseNotes:m}}function xwe(){const[e,t]=y.useState(void 0),[n,s]=y.useState(!1),r=y.useRef(!1);return r.current=e===!0&&!n,y.useEffect(()=>Oge(()=>r.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function vwe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ve("agent-dag.sound");n(c===null?!0:c==="on")},[]);const s=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return ze("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),r=y.useCallback(c=>{s()},[s]),o=zn(r),i=zn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function bwe(){const[e,t]=y.useState(cue),n=y.useCallback(o=>{t(i=>uue(i,o))},[]),s=y.useCallback(()=>t(o=>({...o,open:!1})),[]),r=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:s,showSection:r}}const kwe="agent-dag.autoFitDisabled";function jwe(e){const t=y.useRef(!1),[n,s]=y.useState(!1);y.useEffect(()=>{hr(kwe)},[]);const r=y.useCallback(()=>{t.current||(t.current=!0,s(!0))},[]),o=y.useCallback(()=>{t.current=!1,s(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:r,enableAutoFitAndRefit:o}}function Nwe(){return a.jsx(l1,{children:a.jsx(Fge,{children:a.jsx(Swe,{})})})}function Swe(){var Yu;const e=ml(),t=y.useState(c1)[0],n=y.useRef(t),[,s]=y.useState(0),r=y.useCallback(()=>s(Qn=>Qn+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Vye(),{selectedIds:p,primarySelectedId:m,selectAgent:w,clearSelection:j,pruneSelectionToBoard:b}=sae(n,i),{sessionListOpen:k,accountsPanelOpen:v,panel:N,toggleSessionList:S,toggleAccountsPanel:E,openAccountsPanel:C,closeSessionList:I,closeSessionListToCanvas:R,closeAccountsPanel:$}=Fye(),L=zi(v,200),U=zi(k,200),O=H_(k,U),M=zi(c,130),q=zi(h,130),A=y.useRef(null),D=vwe(A),{activateSoundRef:P,soundOnRef:K}=D,G=cwe(A),{setTonePrefs:W,tonePrefsRef:H,previewTone:F}=G,B=lwe({chimesRef:A,setTonePrefs:W,tonePrefsRef:H,previewTone:F}),{customSelectionsRef:Z,fallbackCustomRef:V}=B,X=bwe(),{openSettings:Y}=X;jye({chimesRef:A,soundOnRef:K,tonePrefsRef:H,customSelectionsRef:Z,fallbackCustomRef:V});const J=Uge(n),{pauseGate:ee,paused:ne,togglePause:le}=J,de=y.useRef(()=>{}),{live:ue,tabCapped:re,everConnected:pe,liveSince:ye}=Gre({stateRef:n,rerender:r,pauseGate:ee,chimesRef:A,desktopUpdateRef:de}),_e=ywe(ue),{version:he,notice:ae,noticeOpen:ge,loadVersion:Se}=_e,me=Sye(ue),{readyAppUpdate:$e,onDesktopUpdateEvent:Pe}=me;de.current=Pe,pwe();const qe=wwe({version:he,readyAppUpdate:$e}),{tourOpen:Le,openTour:Qe,releaseNotes:je}=qe,{workspace:Ae,providers:De,providersRef:He}=Hge(ue),Ze=Mye(N==="accounts"&&!De.claude?null:N),ft=Lye(Ze),ut=H_(v,L)&&De.claude,[Je,Dt]=y.useState(!1),vt=y.useCallback(()=>{C(),Dt(!0)},[C]);y.useEffect(()=>{v||Dt(!1)},[v]);const It=y.useCallback(()=>Dt(!1),[]),it=nwe(he),Lt=lye({version:he,loadVersion:Se}),{upgradeFailure:Ft}=Lt,dt=ewe({stateRef:n,tourOpen:Le,releaseNotes:je}),St=iwe({modalOpenRef:dt.modalOpenRef}),{openTool:rt,setSummaryFor:ys,setContextFor:Ws,openContext:ws,setKeyHelpOpen:Yn,setUsageHistoryOpen:Xn,setBrowserWatchOpen:wn,keyHelpOpenRef:At,modalOpenRef:an}=dt,Ne=xwe(),Te=uye(),{watchOn:We,watchUnseen:pt}=Te,at=Eye(),[Zn,Hs]=y.useState(0),{presentCats:zs,hiddenCats:On,toggleCat:xn,catBarRef:Jr,catBarOccluded:Vs}=bye(n),yr=y.useRef(null),[wr,xr]=y.useState(0),Bt=rae({stateRef:n,rerender:r,pruneSelectionToBoard:b,setContextFor:Ws,setSummaryFor:ys}),Qr=Kge(De.claude||De.codex),Gs=aye(Qr,Bt),vr=Tye({enabled:De.claude,lanStatus:at.lanStatus,now:Bt}),ot=_ye({now:Bt,stateRef:n,version:he,notice:ae,noticeOpen:ge,upgradeFailure:Ft,paused:J.paused}),{askRestart:Ya,loadAutoRestartPrefs:br}=ot,xs=vye(),{setTheme:vs,palette:ea}=xs,kr=Nye(),Pn=tce(),{applyViewport:Jt,moveCamera:Ks,fitLeft:qt,cameraEpochRef:we,lastFitTimeRef:Ye}=Pn,lt=mce(Pn),{pinnedRef:ht,positionsRef:dn,lastLayoutSigRef:bs,handleRelayout:ta,rearrangeUndo:Nl}=lt,Xa=y.useRef(null),Ys=y.useRef(()=>{}),Sl=ye!==null,Qo=y.useRef(0),na=y.useCallback(()=>{Qo.current=Date.now()},[]),{canvasRef:Xs,canvasSize:_l,paneSizeRef:st}=sue(ft),El=jwe(qt),{autoFitDisabledRef:Cl,disableAutoFit:Za}=El,ei=y.useRef(!1),{measuredRef:Zs,measuredVersionRef:Fu,sizeVersion:Tl,domSizeVersion:ti}=rue(ei),{removedNodes:Jn,removedAgentIds:hn,removeNode:Js,removeSelectedNode:sa,removalNotice:ra,hideSessions:Qs,bringBack:Rl,bringBackAll:Bu,forgetRemovals:Ja}=Oce({stateRef:n,pinnedRef:ht,positionsRef:dn,canvasRef:Xs,clearSelection:j,primarySelectedId:m});Vce({stateRef:n,removedNodes:Jn,hideSessions:Qs,ready:Sl,keepSessionId:m?((Yu=n.current.agents.get(m))==null?void 0:Yu.sessionId)??m:null});const Al=Ace({stateRef:n,now:Bt,removedAgentIds:hn,sizeVersion:Tl,domSizeVersion:ti});gce(Al,lt),Lce({layoutSig:Al,rf:e,stateRef:n,measuredRef:Zs,pinnedRef:ht,positionsRef:dn,paneSizeRef:st,lastInteractRef:Qo,autoFitDisabledRef:Cl,lastFitTimeRef:Ye,fitLeft:qt});const Ml=aue(),{bubbling:ni,endBubble:qu,onBubble:Sp}=Qse(),[jr,Qa]=y.useState(!1),Nr=Zse(),{beginTrashDrag:si,trackTrashDrag:_p,endTrashDrag:Ep}=Nr,ri=ore({stateRef:n,measuredRef:Zs,measuredVersionRef:Fu,canvasRef:Xs}),{lodRef:ai,applyZoom:$l}=ri,Il=eue({applyViewport:Jt,lastFitTimeRef:Ye,cameraEpochRef:we,disableAutoFit:Za,markInteract:na,canvasRef:Xs,applyZoom:$l}),vn=m?n.current.agents.get(m):null,eo=o&&vn!=null,ks=wue({sessionListShown:O,usageShown:Ma(M),machineShown:Ma(q),accountsShown:ut,detailShown:eo,primarySelectedId:m,canvasRef:Xs}),{railInsetRef:to,availableWidth:no,availableHeight:so}=Xle({canvasRef:Xs,canvasSize:_l,machinePhase:q,usagePhase:M,usagePanelOpen:c,detailShown:eo}),Ll=Mce({stateRef:n,now:Bt,availableWidth:no,availableHeight:so,layout:lt,measuredRef:Zs,onBubble:Sp,settled:Ml,dragging:jr,layoutSig:Al,selectedIds:p,openContext:ws,historyReplayed:Sl,removedNodes:Jn,removedAgentIds:hn,dragTick:Zn,dragPatchRef:yr,dragMoveTick:wr}),{nodes:Qt,edges:aa}=Ll,ro=zn(m);yce({nodes:Qt,edges:aa,settled:Ml,dragging:jr,availableWidth:no,availableHeight:so,layout:lt,camera:Pn,rf:e,measuredRef:Zs,stateRef:n,lastFocusRef:Xa,primarySelectedIdRef:ro,focusAgentRef:Ys,autoFitDisabledRef:Cl});const oa=twe({stateRef:n,pinnedRef:ht,measuredRef:Zs,positionsRef:dn,lastLayoutSigRef:bs,forgetRemovals:Ja,clearSelection:j,rerender:r,modalOpenRef:an}),{requestClear:Uu}=oa,Ol=xue({nodes:Qt,stateRef:n,pinnedRef:ht,positionsRef:dn,draggingRef:ei,dragPatchRef:yr,setDragging:Qa,setDragMoveTick:xr,setDragTick:Hs,endBubble:qu,markInteract:na,disableAutoFit:Za,beginTrashDrag:si,trackTrashDrag:_p,endTrashDrag:Ep,removeNode:Js}),Pl=y.useCallback(()=>qt(500),[qt]),Sr=zn(Qt),{focusAgent:_r,stepAgent:Wu,focusSession:ia}=sce({canvasRef:Xs,stateRef:n,measuredRef:Zs,nodesRef:Sr,railInsetRef:to,moveCamera:Ks,disableAutoFit:Za,lastFocusRef:Xa,focusAgentRef:Ys,selectAgent:w,primarySelectedIdRef:ro}),Cp=tue({clearSelection:j,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:eo,focusAgent:_r,draggingRef:ei,lodRef:ai}),Tp=rce({nodesRef:Sr,stateRef:n,canvasRef:Xs,railInsetRef:to}),Dl=zn(sa),Fl=y.useRef(null),Hu=y.useCallback(Qn=>{hn.has(Qn)&&Rl([Qn]),ia(Qn)},[hn,Rl,ia]),Rp=oue();gue({pointerFocusRef:Rp,nodesRef:Sr,stateRef:n,primarySelectedIdRef:ro,providersRef:He,soundOnRef:K,keyHelpOpenRef:At,modalOpenRef:an,waitingCursorRef:Fl,removeSelectedRef:Dl,activateSoundRef:P,clearSelection:j,selectAgent:w,focusAgent:_r,stepAgent:Wu,focusSession:ia,requestClear:Uu,handleRelayout:ta,undoRearrange:Nl.undo,handleFit:Pl,togglePause:le,toggleSessionList:S,toggleAccountsPanel:E,setDetailOpen:i,setUsageHistoryOpen:Xn,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:wn,setKeyHelpOpen:Yn,setTheme:vs,openSettings:Y});const zu=n.current.agents.size,la=y.useMemo(()=>Fk(n.current.agents.values()),[n.current,n.current.revision]);Pce({stateRef:n,waitingSessions:la,removedAgentIds:hn,removedNodes:Jn,bringBack:Rl}),Zce({stateRef:n,waitingSessions:la,live:ue});const Bl=Xye({waitingSessions:la,watchUnseen:pt,incidents:Gs}),ql=Jye({waitingSessions:la,liveSince:ye,focusSession:ia}),{loadNotifyPrefs:Ap}=ql;mwe({loadAutoRestartPrefs:br,loadNotifyPrefs:Ap,loadReportsPrefs:Ne.loadReportsPrefs});const Er=R1(Jue),[Vu,oi]=y.useState(!1),[Mp,Gu]=y.useState(!1),$p=y.useCallback(()=>Gu(!1),[]),Ku=y.useCallback(()=>oi(!1),[]),er=ede({providers:De,sessionListOpen:k,toggleSessionList:S,accountsPanelOpen:v,toggleAccountsPanel:E,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:Xn,watchOn:We,watchUnseen:pt,setBrowserWatchOpen:wn,setTrafficRadarOpen:dt.setTrafficRadarOpen,openSettings:Y,onFeedback:dt.openFeedback,radioOpen:Vu,setRadioOpen:oi,openToolActivity:()=>Gu(!0),toggles:ks.toggles}),[Ip,Lp]=y.useState(0),Op=y.useCallback(Qn=>{Hu(Qn),Er&&R()},[Hu,Er,R]),Pp=y.useCallback(()=>{k||S(),requestAnimationFrame(()=>{var Qn;return(Qn=document.querySelector("#session-list .sl-row"))==null?void 0:Qn.focus()})},[k,S]);return a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(tY,{}),a.jsx(_de,{versionCheck:_e,welcome:qe,desktopUpdate:me,pause:J,announcements:Bl,notify:ql,waitingSessions:la,waitingCursorRef:Fl,focusSession:ia,live:ue,now:Bt,incidents:Gs,queueNamed:Er?0:Ip}),!Er&&a.jsx(jde,{waitingSessions:la,waitingCursorRef:Fl,focusSession:ia,now:Bt,onFit:Lp,onMore:Pp}),vn&&a.jsx(Ede,{selected:vn,now:Bt,selectedIds:p,focusAgent:_r,clearSelection:j}),!Er&&a.jsx("div",{className:"actions",children:a.jsx(Xue,{items:er.utilities})})]}),Er?a.jsx(Yue,{items:[...er.left,...er.right[0],er.utilities[0]],more:[...er.right.slice(1).flat(),er.utilities[1]]}):a.jsx(eI,{side:"left",label:"Left column",groups:[er.left]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ra?`${ra.label} removed from the board.`:""}),a.jsx(Zde,{restart:ot,versionCheck:_e,upgrade:Lt,oldNameNotice:it,rating:St,onFeedback:dt.openFeedback,everConnected:pe,live:ue,paused:ne}),(O||ut)&&a.jsxs(Hse,{width:Ze,children:[ut&&a.jsx(Wse,{leaving:z_(v,L),onReport:dt.openFeedback,onRoster:vr.observe,onClose:()=>{ks.accounts(),$()},lanWanted:Je,onLanShown:It}),O&&a.jsx(mY,{leaving:z_(k,U),state:n.current,now:Bt,selectedIds:p,onSelect:Op,onClose:()=>{ks.sessionList(),I()},removedIds:hn,onBringBackAll:Bu})]}),a.jsxs(Mde,{canvasRef:Xs,bubbling:ni,dragging:jr,trash:Nr,zoom:ri,viewport:Il,stateRef:n,peek:Tp,children:[zu===0&&(!ue&&re?a.jsx(bue,{reservedRight:to.current}):a.jsx(kue,{live:ue,everConnected:pe,providers:De,workspace:Ae,onTour:Qe,reservedRight:to.current})),(zs.length>1||On.size>0)&&a.jsx(Cde,{catBarRef:Jr,catBarOccluded:Vs,presentCats:zs,hiddenCats:On,toggleCat:xn}),a.jsx(eY,{graph:Ll,layout:lt,viewport:Il,clicks:Cp,drag:Ol,appearance:xs,fm:kr,radioOpen:Vu,onRadioClose:Ku,autoFit:El,pause:J,stateRef:n,measuredRef:Zs,hiddenCats:On,now:Bt,openTool:rt,focusAgent:_r,requestClear:Uu,setKeyHelpOpen:Yn})]}),!Er&&a.jsx(eI,{side:"right",label:"Right panels",groups:er.right}),Mp&&a.jsx(GY,{onClose:$p}),Ma(M)&&a.jsx(eZ,{state:n.current,now:Bt,providers:De,incidents:Gs,liveSince:ye,leaving:M==="leaving",onClose:()=>{ks.usage(),d(!1)}}),Ma(q)&&a.jsx(FZ,{usageOpen:c,leaving:q==="leaving",onClose:()=>{ks.machine(),f(!1)}}),o&&vn?a.jsx(Oue,{selected:vn,now:Bt,openTool:rt,setSummaryFor:ys,stateRef:n,removeSelectedNode:sa,onClose:()=>{ks.detail(),i(!1)}}):null,a.jsx(xge,{dialogs:dt,welcome:qe,desktopUpdate:me,versionCheck:_e,restart:ot,upgrade:Lt,lanPairs:at,attention:vr,clearFlow:oa,watchBadge:Te,announcements:Bl,appearance:xs,providers:De,stateRef:n,agentCount:zu,menus:X,sound:D,tones:G,customTones:B,notify:ql,panelDoors:{accounts:C,localNetwork:vt}})]})}try{H7(window.localStorage)}catch{}const _we=vF.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);_we.render(a.jsx(Nwe,{}));export{fl as A,Fa as B,J1 as C,WG as D,Qf as E,Fwe as F,S1 as G,dl as H,NV as I,Awe as J,Twe as K,Rwe as L,Hf as M,S7 as N,dye as O,Cwe as P,HG as Q,rP as R,Sme as V,lP as a,gt as b,Da as c,xt as d,Ur as e,Xe as f,Mwe as g,Ps as h,$we as i,a as j,fu as k,Kn as l,yre as m,Iwe as n,fpe as o,r0 as p,Lwe as q,y as r,An as s,Owe as t,ct as u,Pwe as v,Ko as w,hpe as x,Dwe as y,Xf as z};
|