ccdeck 3.53.1 → 3.53.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -126,7 +126,7 @@ ${e.sessionTitle}`:e.sessionTitle:e.cwd,g=gA(e),f=m.useRef(null),v=m.useRef(null
126
126
  ${t("board.node.modelCovers")}
127
127
  ${g.join(`
128
128
  `)}`:mu(e.model,e.effort)),T=Om(e.sessionName,e.sessionTitle),E=sU(e),q=(E==null?void 0:E.note)??null,F=E?E.key:null,z=tte(F),H=E!=null&&!z,I=(q==null?void 0:q.kind)==="recap",L=tee(e);return s.jsxs("div",{className:i,style:{"--session-hue":c},children:[s.jsx("span",{className:"accent-stripe"}),s.jsx(Rr,{type:"target",position:at.Left,style:{background:"transparent",border:"none"}}),s.jsxs("div",{className:"head",children:[s.jsxs("div",{className:"title",children:[s.jsx(gne,{state:a}),s.jsx("span",{className:"label",title:p,children:e.label}),e.restoredFromLog&&s.jsx("span",{className:"synth-tag",title:e.provider==="claude"?t("board.node.restoredRegistry"):t("board.node.restoredLog"),children:t("board.node.restored")}),e.synthetic&&s.jsx("span",{className:"synth-tag",title:t("board.node.synthesised"),children:"?"}),E&&F&&s.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":I?t("board.node.recapLabel"):q?t("board.node.noteLabel",{tag:Cl(q.kind)}):t("board.node.notePlan"),"aria-expanded":H,title:t(I?H?"board.node.hideRecap":"board.node.showRecap":q?H?"board.node.hideNote":"board.node.showNote":H?"board.node.hidePlan":"board.node.showPlan"),onClick:M=>{M.stopPropagation(),ete(F)},children:s.jsx(Dg,{recap:I})})]}),s.jsx("div",{className:"head-right",children:u&&e.onOpenContext&&s.jsx($ee,{currentContextTokens:d,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),s.jsxs("div",{className:"sub",title:xee(e,t),children:[s.jsxs("span",{className:"sub-details",ref:f,children:[j.kind&&s.jsx("span",{children:Lm(e,t)}),e.childCount>0&&s.jsxs("span",{className:"spawn-badge",title:yee(e.childCount,t),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"&&s.jsxs("span",{className:"sub-folder",ref:v,children:[j.kind?"· ":"",e.cwdBasename]}),e.model?s.jsxs("span",{className:"model-chip","data-family":_m(e.model),title:A,children:[qm(e.model,j.effort?e.effort:void 0),g.length>0?` +${g.length}`:""]}):e.provider==="codex"?s.jsx("span",{className:"model-chip",title:t("board.node.codexNoModel"),children:"Codex"}):null]}),s.jsxs("span",{className:"time",title:e.synthetic?t("board.node.joinedLate",{time:new Date(e.startedAt).toLocaleTimeString(n)}):t("board.node.started",{time:new Date(e.startedAt).toLocaleTimeString(n)}),children:[e.synthetic?"≥ ":"",s.jsx(pne,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&T.face&&s.jsx("div",{className:"session-name",title:T.tooltip,children:T.face}),e.kind==="root"&&e.stopFailure&&s.jsx(mne,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&s.jsx(rne,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&s.jsx(fne,{waiting:e.waiting}),(()=>{const M=U2(e);return M?s.jsxs("div",{className:"approval-blind-row",title:M.detail,children:[s.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),s.jsx("span",{className:"approval-blind-said",children:M.label})]}):null})(),(()=>{const M=$s(e.plan);return M&&e.plan?s.jsx(une,{plan:M,items:e.plan.items}):null})(),(e.tools.length>0||(((_=e.outputs)==null?void 0:_.length)??0)>0)&&s.jsx(bne,{tools:e.tools,outputs:e.outputs}),s.jsxs("div",{className:"meta",children:[s.jsxs("span",{children:[s.jsx("b",{children:e.toolCount})," ",t("board.meta.tools",{count:e.toolCount})]}),r>0&&s.jsxs("span",{className:"failed-meta",title:t("board.meta.errTitle",{count:r}),children:[s.jsx("b",{children:r})," ",t("board.meta.err")]}),o>0&&s.jsxs("span",{className:"inflight-meta",children:[s.jsx("b",{children:o})," ",t("board.meta.inflight")]}),e.usage.inputTokens+e.usage.outputTokens>0&&s.jsxs("span",{className:"tokens-meta",title:`${t("board.meta.tokensTitle",{input:e.usage.inputTokens,output:e.usage.outputTokens,cacheR:e.usage.cacheReadTokens,cacheC:e.usage.cacheCreateTokens})}${(e.usage.reasoningOutputTokens??0)>0?` ${t("board.meta.reasoning",{n:e.usage.reasoningOutputTokens??0})}`:""}`,children:[s.jsx("b",{children:Ft(e.usage.inputTokens+e.usage.outputTokens)})," ",t("board.meta.tok")]}),(L==null?void 0:L.kind)==="unpriced"&&s.jsx("span",{className:"cost-unpriced",title:L.tt,children:t("insights.cost.notPriced")}),(L==null?void 0:L.kind)==="spent"&&s.jsx("span",{className:"cost-meta",title:L.tt,children:s.jsxs("b",{children:[At(L.total),L.floor?"+":""]})})]}),s.jsx(hne,{data:e,title:e.kind==="root"?T.face:void 0}),s.jsx(Rr,{type:"source",position:at.Right,style:{background:"transparent",border:"none"}})]})}const dne=m.memo(lne);function une({plan:e,items:t}){const n=ae();return s.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:Am(t),children:[s.jsx("span",{className:"plan-meter","aria-hidden":!0,style:{"--plan-done":e.done/e.total}}),s.jsxs("span",{className:"plan-count",children:[e.done,"/",e.total]}),s.jsx("span",{className:"plan-step",children:e.allDone||!e.current?n("board.state.done"):s.jsxs(s.Fragment,{children:[e.next&&s.jsx("span",{className:"plan-next",children:n("board.plan.next")}),e.current]})})]})}function hne({data:e,title:t}){const n=ae(),a=e.kind==="root"&&Zn(e.waiting),i=lte(e,e.branch,{sayWaiting:o=>Pg(o,n),describeCall:o=>({name:kA(o.name).label,subject:Ote(o.name,o.input)})},n);return s.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":a?"":void 0,"data-signal":i?"":void 0,"aria-hidden":!0,children:[s.jsxs("div",{className:"lod-id",children:[s.jsx(hU,{kind:gN(Zc(e))}),s.jsx("span",{className:"lod-name",children:e.label}),i&&s.jsx("span",{className:"lod-inline","data-tone":i.tone,children:i.short}),a&&s.jsx(yA,{})]}),t&&s.jsx("div",{className:"lod-title",children:t}),i&&s.jsxs("div",{className:"lod-signal","data-tone":i.tone,children:[s.jsx("span",{className:"lod-long",children:i.long}),s.jsx("span",{className:"lod-short",children:i.short})]})]})}function pne({start:e,end:t}){const n=Vs(1e3);return s.jsx(s.Fragment,{children:ul(e,t,n)})}function gne({state:e}){const t=ae();return s.jsx("span",{className:`state-pill state-${e}`,children:yo(e,t)})}function mne({data:e,stop:t}){const n=ae();return s.jsxs("div",{className:"stop-row",title:bee(t,e.job!=null,n),"data-kind":t.kind,children:[s.jsx("span",{className:"waiting-dot","aria-hidden":!0}),s.jsx("span",{className:"stop-said",children:W2(t,n)}),s.jsx(one,{data:e})]})}function fne({waiting:e}){const t=ae(),n=Vs(1e3),a=Zn(e),i=dl(e,t);return s.jsxs("div",{className:a?"waiting-row permission":"waiting-row idle",title:`${i}
129
- ${t("board.node.blockedFor",{time:ul(e.since,void 0,n)})}`,children:[a?s.jsx("span",{className:"ap-pulse","aria-hidden":!0}):s.jsx("span",{className:"waiting-dot","aria-hidden":!0}),s.jsx("span",{className:"waiting-said",children:Pg(e,t)}),s.jsx("b",{children:ul(e.since,void 0,n)})]})}function bne({tools:e,outputs:t}){const n=ae(),a=Vs(1e3),{counts:i,title:o}=Bte(e,t,a,n),r=Ov/Xc;return s.jsxs("div",{className:"tool-spark-row",title:o,children:[s.jsx("svg",{className:"tool-spark",width:Ov,height:ug,viewBox:`0 0 ${Ov} ${ug}`,"aria-hidden":!0,children:i.map((c,d)=>{const u=Wte(c),p=d===Xc-1&&c>0,f=`tool-spark-bar${c>0?" active":""}${p?" latest":""}`;return s.jsx("rect",{x:d*r+.4,y:ug-u,width:Math.max(.5,r-1),height:u,rx:.8,className:f},p?`landed:${c}`:d)})}),s.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function vne({enableAutoFitAndRefit:e}){const t=ae();return s.jsxs("div",{className:"autofit-chip",children:[s.jsx("span",{className:"autofit-state",title:t("accounts.autoFit.offTip"),children:t("accounts.autoFit.off")}),s.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:t("accounts.autoFit.resumeTip"),"aria-label":t("accounts.autoFit.resumeLabel"),children:t("accounts.autoFit.resume")})]})}const AA="agent-dag.single-key-shortcuts";function CU(e){return e!=="0"}function SU(e){return e.length===1}function kne(e,t){return!t&&SU(e)}function Yn(e,t,n){return n?`${e} (${t})`:e}let xr=null;const Md=new Set;function NU(){for(const e of Md)e()}function kN(){return xr===null&&(xr=CU(ht(AA))),xr}function wne(e){xr!==e&&(xr=e,pt(AA,e?"1":"0"),NU())}function _1(e){if(e.key!==AA)return;const t=CU(e.newValue);t!==xr&&(xr=t,NU())}function yne(e){var t;return Md.add(e),Md.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",_1)),()=>{var n;Md.delete(e),Md.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",_1))}}function Bg(e,t=C){const n=Math.max(0,Math.floor(e));return t("board.pill.events",{count:n})}const q1=99;function xne(e){const t=Math.max(0,Math.floor(e));return t>q1?`${q1}+`:String(t)}const Cne=(e=C)=>e("board.pill.pause");function Sne(e,t=C){const n=e.singleKeys??!0;if(!e.paused)return Yn(t("board.pill.title.pause"),"Space",n);const a=Math.max(0,Math.floor(e.dropped??0));return a>0?Yn(t("board.pill.title.full",{held:Bg(e.held,t),count:a}),"Space",n):e.held<=0?Yn(t("board.pill.title.nothing"),"Space",n):Yn(t("board.pill.title.arrived",{held:Bg(e.held,t)}),"Space",n)}function Nne(e,t=C){return e.connected||!e.paused?null:t("board.pill.outage")}const jU=e=>e("board.pill.pausedFull"),jne=(e,t,n)=>t>0?jU(n):e>0?n("board.pill.pausedCount",{held:xne(e)}):n("board.pill.paused");function Ane(e,t=C){const n=Math.max(0,Math.floor(e.dropped??0)),a=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:jne(e.held,n,t),widest:jU(t),title:Yn(n>0?t("board.pill.title.connectedFull",{held:Bg(e.held,t)}):e.held>0?t("board.pill.title.connectedHeld",{held:Bg(e.held,t)}):t("board.pill.title.connectedNone"),"Space",a)}:{tone:"live",resting:!0,label:t("board.pill.live"),widest:t("board.pill.live"),title:t("board.pill.title.live")}:{tone:"dead",resting:!1,label:t("board.pill.offline"),widest:t("board.pill.offline"),title:e.paused?t("board.pill.title.offlinePaused"):t("board.pill.title.offline")}}function Qn(){return m.useSyncExternalStore(yne,kN,kN)}const Tne=e=>e.transform[2]>=e.maxZoom,Rne=e=>e.transform[2]<=e.minZoom;function Ene({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:a,togglePause:i,handleRelayout:o,requestClear:r,setKeyHelpOpen:c}){const d=ae(),u=bl(),p=Tt(Tne),g=Tt(Rne),f=Qn();return s.jsxs(d8,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[s.jsx(Fa,{onClick:()=>{p||u.zoomIn()},title:d("board.controls.zoomIn"),"aria-label":d("board.controls.zoomIn"),"aria-disabled":p||void 0,children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:s.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),s.jsx(Fa,{onClick:()=>{g||u.zoomOut()},title:d("board.controls.zoomOut"),"aria-label":d("board.controls.zoomOut"),"aria-disabled":g||void 0,children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:s.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),s.jsx(Fa,{onClick:t,title:d(e?"board.controls.recenterOn":"board.controls.recenterAuto"),"aria-label":d("board.controls.recenter"),"data-nudge":e?"":void 0,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),s.jsx(Fa,{"data-group-start":"",onClick:i,title:Sne({paused:n,held:a.size,dropped:a.dropped,singleKeys:f},d),"aria-label":Cne(d),"aria-pressed":n,children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:s.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),s.jsx(Fa,{onClick:o,title:Yn(d("board.controls.arrange"),"R",f),"aria-label":d("board.controls.arrangeLabel"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),s.jsx(Fa,{"data-group-start":"","data-danger":"",onClick:()=>r("button"),title:Yn(d("board.controls.clear"),"C",f),"aria-label":d("board.controls.clearLabel"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),s.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"}),s.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"}),s.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),s.jsx(Fa,{"data-group-start":"",onClick:()=>c(v=>!v),title:f?Yn(d("board.controls.keys"),"?",!0):d("board.controls.keysOff"),"aria-label":d("board.controls.keysLabel"),"aria-haspopup":"dialog",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.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"}),s.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const _ne="modulepreload",qne=function(e){return"/"+e},z1={},Pr=function(t,n,a){let i=Promise.resolve();if(n&&n.length>0){let r=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};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"));i=r(n.map(u=>{if(u=qne(u),u in z1)return;z1[u]=!0;const p=u.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${g}`))return;const f=document.createElement("link");if(f.rel=p?"stylesheet":_ne,p||(f.as="script"),f.crossOrigin="",f.href=u,d&&f.setAttribute("nonce",d),document.head.appendChild(f),p)return new Promise((v,k)=>{f.addEventListener("load",v),f.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(r){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=r,window.dispatchEvent(c),!c.defaultPrevented)throw r}return i.then(r=>{for(const c of r||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},L1="agent-dag.fm-custom-stations",O1="agent-dag.fm-muted",wN="custom:",zne=/^UC[A-Za-z0-9_-]{22}$/,Lne=/^[A-Za-z0-9_-]{11}$/,AU=/^[A-Za-z0-9_-]{1,80}$/,One=/\.(mp3|aac|ogg)$/i,Pne=/\.m3u8$/i,Mne=2048,TU=80;function pl(e){return`${wN}${e}`}function Hm(e){if(!e.startsWith(wN))return null;const t=e.slice(wN.length);return AU.test(t)?t:null}function P1(e){return Hm(e)??e}function TA(e){var r,c;const t=e.trim();if(t.length>Mne)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const a=n.toString(),i=n.hostname.toLowerCase();if(i==="youtube.com"||i==="www.youtube.com"||i==="m.youtube.com"){if(n.port)return null;const d=(r=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:r[1];if(d&&zne.test(d))return{kind:"youtube-channel",url:a,channel:d};const u=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(u&&/^[A-Za-z0-9._-]{1,64}$/.test(u))return{kind:"youtube-handle",url:a,handle:u};if(n.pathname==="/watch"){const p=n.searchParams.get("v")??"";if(Lne.test(p))return{kind:"youtube-video",url:a,video:p}}return null}return Pne.test(n.pathname)?{kind:"direct-audio",url:a,format:"hls"}:One.test(n.pathname)?{kind:"direct-audio",url:a,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:a,format:"audio"}}function Ine(e){return e==="1"}function Dne(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,a=[];for(const i of t){if(!i||typeof i!="object")continue;const o=typeof i.id=="string"?i.id:"",r=typeof i.name=="string"?i.name.trim():"",c=typeof i.url=="string"?i.url.trim():"",d=TA(c);if(!AU.test(o)||n.has(o)||!r||r.length>TU||!d)continue;n.add(o);const u=RU(i.radio);a.push({id:o,name:r,url:d.url,...u?{radio:u}:{}})}return a}function Fne(e,t,n){const a=Hm(e??"");return a&&t.some(i=>i.id===a)?pl(a):n(e)}function Une(e,t){return e===pl(t)?"claude-fm":e}function RU(e){if(!e||typeof e!="object")return null;const t=e,n=(i,o)=>typeof t[i]=="string"?t[i].slice(0,o):"",a=(i,o)=>typeof t[i]=="number"&&Number.isFinite(t[i])&&Math.abs(t[i])<=o?t[i]: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:a("lat",90),lon:a("lon",180)}}const yN="https://www.youtube-nocookie.com";function Bne(e,t,n){const a=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${yN}/embed/${n?encodeURIComponent(n):"live_stream"}?${a.toString()}`}function Ac(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function Hne(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const Wne=[1],Gne=[0,2],$ne=[2,5,100,101,150,153];function Vne(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:a}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const i=typeof a=="number"?a:Number(a==null?void 0:a.errorCode);return Number.isFinite(i)?{kind:"error",code:i}:null}if(n==="onStateChange"||n==="infoDelivery"){const i=typeof a=="number"?a:a==null?void 0:a.playerState;return typeof i!="number"||!Number.isFinite(i)?null:Wne.includes(i)?{kind:"playing",playing:!0}:i===3?{kind:"buffering"}:Gne.includes(i)?{kind:"playing",playing:!1}:null}return null}const wd=new Set;let M1="";function I1(e){const t=new Date().toISOString().slice(0,10);if(t!==M1&&(wd.clear(),M1=t),!wd.has(e)){wd.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&wd.delete(e)}catch{wd.delete(e)}}}const D1=864e5,Kne=6e4;function An(e,t=!0){m.useEffect(()=>{if(!t)return;I1(e);let n;const a=()=>{n=setTimeout(()=>{I1(e),a()},D1-Date.now()%D1+Kne)};return a(),()=>clearTimeout(n)},[e,t])}const Jne={"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 Yne({fetchImpl:e,enabled:t=!0,volume:n,muted:a,source:i,playRequest:o,customStation:r,onAvailabilityChange:c}){var O;const[d,u]=m.useState(null),[p,g]=m.useState(!1),[f,v]=m.useState(!1),[k,y]=m.useState(!1),[N,w]=m.useState(!1);An("claude-fm",k);const S=m.useRef(o),j=m.useRef(null),A=m.useRef(null),T=m.useRef(void 0),E=m.useRef(null),q=m.useCallback(()=>{var M;clearTimeout(T.current),(M=A.current)==null||M.destroy(),A.current=null;const _=j.current;_&&(_.pause(),_.removeAttribute("src"),_.load(),j.current=null)},[]),F=m.useCallback(_=>{var M,U;(U=(M=E.current)==null?void 0:M.contentWindow)==null||U.postMessage(_,yN)},[]),z=m.useRef(n);z.current=n;const H=m.useRef(a);H.current=a;const I=m.useCallback((_,M,U)=>{q();const G=new Audio;G.preload="none",G.volume=z.current/100,G.muted=H.current,j.current=G,v(!0),y(!1),w(!1);let W=!1;const $=()=>j.current===G,Y=()=>{clearTimeout(T.current),q(),v(!1),y(!1),w(!1)},B=()=>{$()&&(Y(),g(!0),c==null||c(U,!0))},V=D=>{if($()&&!(D instanceof DOMException&&D.name==="AbortError")){if(D instanceof DOMException&&D.name==="NotAllowedError"){Y();return}B()}};T.current=setTimeout(()=>{$()&&!W&&B()},15e3),G.addEventListener("playing",()=>{$()&&(clearTimeout(T.current),W=!0,y(!0),w(!1),c==null||c(U,!1))});const Z=()=>{$()&&(y(!1),w(W),clearTimeout(T.current),T.current=setTimeout(()=>{$()&&B()},15e3))};G.addEventListener("waiting",Z),G.addEventListener("stalled",Z),G.addEventListener("ended",()=>{$()&&Y()}),G.addEventListener("error",B,{once:!0}),M&&!G.canPlayType("application/vnd.apple.mpegurl")?Pr(async()=>{const{default:D}=await import("./hls-BFpXDghs.js");return{default:D}},[]).then(({default:D})=>{if(!$())return;if(!D.isSupported()){B();return}const K=new D;A.current=K,K.on(D.Events.ERROR,(X,Q)=>{Q.fatal&&B()}),K.on(D.Events.MEDIA_ATTACHED,()=>K.loadSource(_)),K.on(D.Events.MANIFEST_PARSED,()=>{G.play().catch(V)}),K.attachMedia(G)},B):(G.src=_,G.play().catch(V))},[c,q]);m.useEffect(()=>{f&&(F(Ac("setVolume",[n])),F(Ac(a?"mute":"unMute")),j.current&&(j.current.volume=n/100,j.current.muted=a))},[n,a,f,F]),m.useEffect(()=>{var Y;let _=!0;const M=e??fetch,U=S.current!==o;if(S.current=o,u(null),g(!1),w(!1),v(U),y(!1),q(),!t){v(!1),y(!1);return}const G=r&&pl(r.id)===i?TA(r.url):null;if(G){if(G.kind==="direct-audio"){const B=G.format==="hls"||((Y=r==null?void 0:r.radio)==null?void 0:Y.hls)===!0;return u({live:!0,channel:"",audio:G.url,hls:B}),c==null||c(i,!1),U&&I(G.url,B,i),()=>{_=!1}}return M(`/api/fm-station?url=${encodeURIComponent(G.url)}`).then(B=>B.ok?B.json():null).then(B=>{_&&(B!=null&&B.channel||B!=null&&B.video?(u({live:!0,channel:B.channel??"",video:B.video??void 0}),c==null||c(i,!1)):(g(!0),v(!1),y(!1),w(!1),c==null||c(i,!0)))}).catch(()=>{_&&(g(!0),v(!1),y(!1),w(!1),c==null||c(i,!0))}),()=>{_=!1}}if(Hm(i))return g(!0),c==null||c(i,!0),()=>{_=!1};const W=i,$=Jne[W];if($)M($).then(B=>B.ok?B.json():null).then(B=>{_&&(B!=null&&B.video&&u({live:!0,channel:"",video:B.video}),B!=null&&B.video||(g(!0),v(!1),y(!1)),c==null||c(i,!(B!=null&&B.video)))}).catch(()=>{_&&(g(!0),v(!1),y(!1),c==null||c(i,!0))});else if(W!=="claude-fm"){const B=W.replace("lofi-","");M(`/api/lofi-girl?station=${encodeURIComponent(B)}`).then(V=>V.ok?V.json():null).then(V=>{_&&(V!=null&&V.video&&u({live:!0,channel:"",video:V.video}),V!=null&&V.video||(g(!0),v(!1),y(!1)),c==null||c(i,!(V!=null&&V.video)))}).catch(()=>{_&&(g(!0),v(!1),y(!1),c==null||c(i,!0))})}else M("/api/claude-fm").then(B=>B.ok?B.json():null).then(B=>{if(!_)return;const V=!!(B!=null&&B.live&&(B!=null&&B.channel));V&&u({live:!0,channel:B.channel}),V||(g(!0),v(!1),y(!1)),c==null||c(i,!V)}).catch(()=>{_&&(g(!0),v(!1),y(!1),c==null||c(i,!0))});return()=>{_=!1}},[r==null?void 0:r.id,r==null?void 0:r.url,(O=r==null?void 0:r.radio)==null?void 0:O.hls,t,e,c,o,i,I,q]),m.useEffect(()=>()=>q(),[q]),m.useEffect(()=>{if(!f||d!=null&&d.audio)return;let _;const M=()=>{clearTimeout(_),_=void 0,v(!1),y(!1),w(!1),g(!0),c==null||c(i,!0)},U=()=>{_??(_=setTimeout(M,15e3))};U();const G=W=>{var Y;if(W.origin!==yN||W.source!==((Y=E.current)==null?void 0:Y.contentWindow))return;const $=Vne(W.data);if($){if($.kind==="ready"){F(Ac("setVolume",[z.current])),F(Ac(H.current?"mute":"unMute")),F(Ac("playVideo"));return}if($.kind==="blocked"){clearTimeout(_),_=void 0,v(!1),y(!1),w(!1);return}if($.kind==="buffering"){y(!1),w(!0),U();return}if($.kind==="playing"){clearTimeout(_),_=void 0,y($.playing),w(!1),$.playing||v(!1);return}$ne.includes($.code)&&M()}};return window.addEventListener("message",G),()=>{clearTimeout(_),window.removeEventListener("message",G)}},[f,d==null?void 0:d.audio,o,c,F,i]);const L=m.useCallback(()=>{if(d){if(d.audio){if(f){q(),v(!1),y(!1),w(!1);return}I(d.audio,d.hls===!0,i);return}if(!f){v(!0),y(!1),w(!1);return}F(Ac("pauseVideo")),v(!1),y(!1),w(!1)}},[d,f,k,i,F,I,q]);return m.useMemo(()=>({probe:d,dead:p,armed:f,playing:k,buffering:N,frame:E,say:F,press:L}),[d,p,f,k,N,F,L])}const F1="agent-dag.radio-favorites",U1="agent-dag.radio-recent",B1="agent-dag.radio-catalogue";function Zne(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const a=n,i=typeof a.id=="string"?a.id:"",o=typeof a.name=="string"?a.name.trim().slice(0,80):"",r=typeof a.url=="string"?TA(a.url):null,c=RU(a.radio??a);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(i)||!o||!c||!r||r.kind!=="direct-audio"||t.has(i)?[]:(t.add(i),[{id:i,name:o,url:r.url,radio:c}])})}function H1(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 Xne(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function WEe(e,t,n=Math.random){const a=e.filter(i=>i.id!==t);return a.length?a[Math.min(a.length-1,Math.floor(Math.max(0,n())*a.length))]:null}function GEe(e,t,n){if(!e.length)return null;const a=e.findIndex(o=>o.id===t),i=e[a<0?n===1?0:e.length-1:(a+n+e.length)%e.length];return i.id===t?null:i}function EU(e,t,n){const a=e.findIndex(i=>i.id===t);for(let i=1;i<=e.length;i++){const o=e[(a+i)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function $Ee(e,t){if(!e.length)return null;const n=[...e].sort((i,o)=>i.id.localeCompare(o.id));let a=0;for(const i of t)a=Math.imul(a,31)+i.charCodeAt(0)>>>0;return n[a%n.length]}function VEe(e,t,n,a,i){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!a||e.radio.tags.toLowerCase().includes(a.toLowerCase()))&&(!i||e.radio.language.toLowerCase().includes(i.toLowerCase()))}function Qne(){const[e,t]=m.useState(()=>H1(ht(F1))),[n,a]=m.useState(()=>H1(ht(U1))),[i,o]=m.useState(()=>{try{return Zne(JSON.parse(ht(B1)??"[]"))}catch{return[]}});m.useEffect(()=>{pt(F1,JSON.stringify(e))},[e]),m.useEffect(()=>{pt(U1,JSON.stringify(n))},[n]);const r=m.useCallback(u=>a(p=>Xne(p,u)),[]),c=m.useCallback(u=>t(p=>p.includes(u)?p.filter(g=>g!==u):[...p,u].slice(-100)),[]),d=m.useCallback(u=>{o(u),pt(B1,JSON.stringify(u))},[]);return{favorites:e,recent:n,catalogue:i,remember:r,toggleFavorite:c,updateCatalogue:d}}function eae(e,t,n,a){const i=EU(e,t,n);if(!i)return()=>{};const o=setTimeout(()=>{n.add(t),a(i)},1e3);return()=>clearTimeout(o)}const Wm=148,W1=6e3,tae=16e3,_U=46,fo=34;function nae(e,t,n=Wm){let a=-Math.round(t()*n);if(Math.abs(a-e)<fo){const i=e-fo>=-n?-fo:fo;a=Math.max(-n,Math.min(0,Math.round(e+i)))}return{to:a,ms:Math.round(Math.abs(a-e)*_U)}}function aae(e){return Math.round(W1+e()*(tae-W1))}const G1=[{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 sae(e){const t=G1.reduce((a,i)=>a+i.weight,0);let n=e()*t;for(const a of G1)if(n-=a.weight,n<0)return a.kind;return"stroll"}const iae=720,oae=260,rae=620,cae=220,$1=520,qU=1600,V1=7e3,lae=15e3,K1=6e3,dae=14e3;function Tc(e,t,n=Wm){let a=-Math.round(t()*n);if(Math.abs(a-e)<fo){const i=e-fo>=-n?-fo:fo;a=Math.max(-n,Math.min(0,Math.round(e+i)))}return a}const kn=(e,t)=>Math.round(Math.abs(t-e)*_U),uae=120,Lp=0;function hae(e,t){const n=a=>({kind:"litter",at:t,...a});return[{x:t,prop:n({}),act:"walk",ms:kn(e,t)},{x:t,prop:n({}),act:"stoop",ms:iae},{x:Lp,prop:n({held:!0}),act:"carry",ms:kn(t,Lp)},{x:Lp,prop:n({held:!0}),act:"windup",ms:oae},{x:Lp,prop:n({held:!0,leaving:!0}),act:"toss",ms:rae}]}function pae(e,t){const n=t>e?1:-1,a=t-n*Math.min(15,Math.abs(t-e)),i=(o={})=>({kind:"ball",at:t,...o});return[{x:a,prop:i(),act:"walk",ms:kn(e,a)},{x:a,prop:i(),act:"windup",ms:cae,facing:n>0?"right":"left"},{x:a,prop:i({leaving:!0}),act:"kick",ms:$1,facing:n>0?"right":"left"},{x:a,prop:i({leaving:!0}),act:"stand",ms:qU-$1}]}const zU=640;function gae(e,t,n){const a=Math.max(-70,Math.min(-20,t)),i={x:a,prop:null,facing:"left"};return[{x:a,prop:null,act:"walk",ms:kn(e,a)},{...i,act:"sit",ms:600},{...i,act:"cast",ms:900},{...i,act:"fish",ms:6e3+Math.round(n()*4e3)},{...i,act:"reel",ms:1200},{...i,act:"stow",ms:500},{...i,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:kn(a,0)}]}function mae(e,t,n){const a=Math.max(-110,Math.min(-30,t)),i={x:a,prop:null};return[{...i,act:"walk",ms:kn(e,a)},{...i,act:"skip-ready",ms:500},{...i,act:"skip",ms:zU*(6+Math.floor(n()*5))},{...i,act:"skip-rest",ms:600},{...i,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:kn(a,0)}]}function fae(e,t,n){return[{x:t,prop:null,act:"walk",ms:kn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(K1+n()*(dae-K1))},{x:t,prop:null,act:"stand",ms:400}]}function bae(e,t,n){t=Math.max(-110,Math.min(0,t));const a=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:kn(e,t)},{x:t,prop:a(),act:"watch",ms:Math.round(V1+n()*(lae-V1))},{x:t,prop:a(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Mv(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 vae=1500,kae=e=>Math.round(1e3*Math.sqrt(2*e/vae)),wae=115,yae=e=>Math.round(e/wae*1e3),xae=620,Cae=200,Sae=760,Nae=600,jae=240;function Aae(e,t,n){const i=-(t.ledgeSpan??Wm),o=kae(t.ledgeH),r=yae(t.ledgeH),c=n(),d=n(),u=-Math.round(c*t.floorSpan),p=-Math.round(d*t.floorSpan);return[{x:i,act:"walk",prop:null,ms:kn(e,i)},{x:i,act:"peer",prop:null,ms:xae},{x:i,act:"fall",prop:null,ms:o,place:"floor"},{x:i,act:"land",prop:null,ms:Cae,place:"floor"},{x:u,act:"walk",prop:null,ms:kn(i,u),place:"floor",floorFrac:c},{x:p,act:"walk",prop:null,ms:kn(u,p),place:"floor",floorFrac:d},{x:i,act:"walk",prop:null,ms:kn(p,i),place:"floor"},{x:i,act:"lasso",prop:null,ms:Sae,place:"floor"},{x:i,act:"rope-throw",prop:null,ms:Nae,place:"floor"},{x:i,act:"rope-catch",prop:null,ms:jae,place:"floor"},{x:i,act:"climb",prop:null,ms:r},{x:i,act:"pull-up",prop:null,ms:480}]}function Tae(e,t,n){const a=(n==null?void 0:n.ledgeSpan)??Wm;switch(sae(t)){case"tidy":return hae(e,Tc(e,t,a));case"kick":return pae(e,Tc(e,t,a));case"sit":return fae(e,Tc(e,t,a),t);case"watch":return bae(e,Tc(e,t,a),t);case"fish":return gae(e,Tc(e,t,a),t);case"skip":return mae(e,Tc(e,t,a),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return Aae(e,n,t)}}const o=nae(e,t,a);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const Rae=420;function Eae(e,t,n){const a=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(Rae,Math.max(0,a))}const _ae=260,qae=200;function zae(e,t,n){const a=(p,g=kn(e,p))=>({x:p,prop:null,act:"walk",ms:g,place:"floor"});if(!n||n.height<=0)return[a(t)];const i=Math.min(e,t);if(Math.max(e,t)<=n.left||i>=n.right)return[a(t)];const r=t>e,c=r?n.left:n.right,d=r?n.right:n.left,u={place:"floor",riser:n.height,prop:null};return[a(c,kn(e,c)),{...u,x:c,act:"mount",ms:_ae},{...u,x:d,act:"walk",ms:kn(c,d)},{x:d,prop:null,act:"dismount",ms:qae,place:"floor"},{x:t,prop:null,act:"walk",ms:kn(d,t),place:"floor"}]}const LU=["bob","sway","groove"],J1=9e3,Lae=16e3,OU=1e3,Oae=.08;function Pae(e,t){const n=LU.filter(o=>o!==e),a=n[Math.min(n.length-1,Math.floor(t()*n.length))],i=(t()*2-1)*Oae;return{dance:a,beatMs:Math.round(OU*(1+i))}}function Mae(e){return Math.round(J1+e()*(Lae-J1))}const RA=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],Y1=18,Iae=RA.length,PU="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",MU="M12 9H14V6H13V3H11V2H9V4H12Z",EA=new Set(["a","c","p"]);function qo(e=RA){const t=[];return e.forEach((n,a)=>{let i=0;for(;i<n.length;){const o=n[i];if(o==="."){i+=1;continue}let r=1;for(;i+r<n.length&&n[i+r]===o;)r+=1;t.push({x:i,y:a,w:r,cell:o}),i+=r}}),t}const Dae=[".xx.","xxxx",".xx."],Fae=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],Uae=["...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."],Iv={litter:Dae,ball:Fae,scope:Uae},Bae=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],Hae=3,Wae=-1,xN=11,Z1=9;function X1(e){let t=null,n=null,a=0,i=0,o=!1;const r=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(i=performance.now(),t=setTimeout(()=>{t=null;const u=n;n=null,u==null||u()},a))},d=()=>{e.hidden&&t!==null?(a=Math.max(0,a-(performance.now()-i)),r()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(u,p){o||(r(),n=u,a=Math.max(0,p),c())},dispose(){o=!0,r(),n=null,e.removeEventListener("visibilitychange",d)}}}function Gae(e,t,n){const[a,i]=m.useState(0),[o,r]=m.useState(0),[c,d]=m.useState(null),[u,p]=m.useState(null),[g,f]=m.useState({x:0,drop:0}),[v,k]=m.useState("ledge"),[y,N]=m.useState("left"),[w,S]=m.useState(0),j=m.useRef(null),[A,T]=m.useState(()=>document.hidden);m.useEffect(()=>{const L=new Set,O=()=>{var _;if(document.hidden){for(const M of((_=j.current)==null?void 0:_.getAnimations({subtree:!0}))??[])if(M.playState==="running"||M.pending){const U=M.currentTime;M.pause(),U!==null&&(M.currentTime=U),L.add(M)}}else{for(const M of L)M.playState==="paused"&&M.play();L.clear()}T(document.hidden)};return O(),document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},[e,t]);const[E,q]=m.useState(null),[F,z]=m.useState(OU),[H,I]=m.useState(()=>{var L;return((L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return m.useEffect(()=>{var _;const L=(_=window.matchMedia)==null?void 0:_.call(window,"(prefers-reduced-motion: reduce)");if(!L)return;const O=()=>I(L.matches);return O(),L.addEventListener("change",O),()=>L.removeEventListener("change",O)},[]),m.useEffect(()=>{var Q;if(!e||t||H)return;const L=X1(document);let O=0;i(ee=>O=ee);let _=null,M=0,U=0;const G=ee=>{var he,ce;const[ne,...de]=ee;if(!ne){_=null,d(null),p(null),D();return}d(ne.act),p(ne.prop),k(ne.place??"ledge"),S(ne.riser??0);const ge=O,le=V(ne);if(ne.act==="kick"){const oe=(ce=(he=j.current)==null?void 0:he.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ce.getBoundingClientRect();oe&&f({x:Eae(oe.x,Mv(ne,ge,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-oe.y+24)})}U=ne.act==="walk"?Math.max(kn(ge,le),uae):ne.ms,ne.act==="carry"&&(U=kn(ge,le)),r(U),N(oe=>Mv({...ne,x:le},ge,oe)),i(le),O=le,_=ne,M=Date.now(),L.schedule(()=>G(de),U)},W=()=>{const ee=j.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite"),de=ee==null?void 0:ee.parentElement;if(!ee||!ne||!de)return null;const ge=ee.getBoundingClientRect(),le=de.getBoundingClientRect(),he=le.right-ge.right,ce=le.width-he*2-ne.offsetWidth;return ce>0?ce:null},$=()=>{const ee=j.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!ne?0:Math.max(0,ee.getBoundingClientRect().width-ne.offsetWidth)},Y=()=>{const ee=j.current,ne=ee==null?void 0:ee.querySelector(".fm-walker"),de=W();if(!ee||!ne||de==null)return;const ge=ee.getBoundingClientRect().bottom-ne.getBoundingClientRect().bottom;if(ge>0)return{ledgeH:ge,floorSpan:de,ledgeSpan:$()}},B=()=>{const ee=j.current,ne=document.querySelector(".canvas-notices");if(!ee||!ne)return null;const de=ee.getBoundingClientRect(),ge=ne.getBoundingClientRect();return ge.width<=0||ge.height<=0?null:{left:ge.left-de.right,right:ge.right-de.right,height:ge.height}},V=ee=>{const ne=(ee.place??"ledge")==="floor",de=ne?W()??$():$(),ge=ne&&ee.floorFrac!=null?-Math.round(ee.floorFrac*de):ee.x;return Math.max(-de,Math.min(0,ge))},Z=()=>{if(!_)return;const ee=V(_);ee!==O&&(r(Math.max(0,M+U-Date.now())),N(ne=>Mv({..._,x:ee},O,ne)),i(ee),O=ee)},D=()=>{L.schedule(()=>{const ee=Tae(O,Math.random,Y()),ne=ee.some(le=>le.place==="floor")?B():null;let de=O;const ge=ee.flatMap(le=>{const he=de;if(de=le.x,!(le.place==="floor"&&le.act==="walk"))return[le];const ce=zae(he,le.x,ne),oe=ce.length-1;return le.floorFrac==null?ce:ce.map((ve,ke)=>ke===oe?{...ve,floorFrac:le.floorFrac}:ve)});G(ge)},aae(Math.random))},K=(Q=j.current)==null?void 0:Q.parentElement,X=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return K&&X&&X.observe(K),D(),()=>{L.dispose(),X==null||X.disconnect(),k("ledge"),i(ee=>Math.max(-$(),Math.min(0,ee))),r(0),d(null),p(null),S(0)}},[e,t,H]),m.useEffect(()=>{if(!n||H){q(null);return}const L=X1(document),O=_=>{const M=Pae(_,Math.random);q(M.dance),z(M.beatMs),L.schedule(()=>O(M.dance),Mae(Math.random))};return O(null),()=>L.dispose()},[n,H]),{scene:j,suspended:A,x:a,walkMs:o,act:c,prop:u,ballFlight:g,place:v,facing:y,riser:w,dance:E,beatMs:F}}const Dv={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Hg=qo().filter(e=>!EA.has(e.cell)),$ae=qo().filter(e=>EA.has(e.cell)),Q1=Hg.filter(e=>e.cell==="e"),Vae=qo(Bae),Kae=Hg.filter(e=>e.y<xN&&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),Jae={left:Hg.filter(e=>e.y>=xN&&e.x<Z1),right:Hg.filter(e=>e.y>=xN&&e.x>=Z1)},Yae=m.memo(function({act:t,facing:n}){return s.jsxs("svg",{viewBox:`0 0 ${Y1} ${Iae}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsx("g",{className:"fm-gear",children:s.jsx("g",{className:"fm-gear-motion",children:$ae.map(a=>s.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:Dv[a.cell]},`g${a.y}-${a.x}`))})}),s.jsxs("g",{className:"fm-body",children:[Q1.map(a=>s.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:"var(--accent)"},`eye-bed-${a.x}`)),Kae.map(a=>s.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:Dv[a.cell]},`b${a.y}-${a.x}`)),s.jsxs("g",{className:"fm-arms",children:[s.jsx("rect",{x:4,y:8,width:2,height:2}),s.jsx("rect",{x:12,y:8,width:1,height:2}),s.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),Q1.map(a=>s.jsx("rect",{x:a.x-(a.x>=Y1/2?1:0)+(n==="right"?1:0),y:a.y,width:a.w,height:1,className:"fm-eye"},`eye-${a.x}`))]}),s.jsx("g",{className:"fm-hat",children:Vae.map(a=>s.jsx("rect",{x:Hae+a.x,y:Wae+a.y,width:a.w,height:1,className:a.cell==="k"?"fm-hatband":void 0},`h${a.y}-${a.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&s.jsxs("g",{className:"fm-grip",children:[s.jsx("path",{className:"fm-grip-left",d:PU}),s.jsx("path",{className:"fm-grip-right",d:MU})]}),(t==="land"||t==="dismount")&&s.jsxs("g",{className:"fm-crouch-legs",children:[s.jsx("path",{d:"M6 11H8V13H6Z"}),s.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&s.jsxs("g",{className:"fm-seated-legs",children:[s.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),s.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(a=>s.jsx("g",{className:"fm-leg","data-side":a,children:Jae[a].map(i=>s.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:Dv[i.cell]},`${a}${i.y}-${i.x}`))},a))]})}),Zae=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],Xae=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],Ls={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},Qae={p:"fm-pad"},fu=qo(Zae),ese=qo(Xae);function CN(e,t,n){return e.map(a=>({...a,x:Math.max(t,a.x),w:Math.max(0,Math.min(n,a.x+a.w)-Math.max(t,a.x))})).filter(a=>a.w>0)}const tse=CN(fu.filter(e=>e.y>=8),12,18),nse=fu.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),e_=fu.filter(e=>e.cell==="e"),ase={left:CN(fu.filter(e=>e.y>=11),0,9),right:CN(fu.filter(e=>e.y>=11),9,12)},sse=m.memo(function({act:t,facing:n}){const a=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",i=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return s.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[s.jsx("g",{className:"fm-body","data-part":"tail",children:tse.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ls[r.cell]},`t${r.y}-${r.x}`))}),s.jsx("g",{className:"fm-gear",children:s.jsx("g",{className:"fm-gear-motion",children:ese.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Qae[r.cell]},`g${r.y}-${r.x}`))})}),s.jsxs("g",{className:"fm-body",children:[nse.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ls[r.cell]},`b${r.y}-${r.x}`)),e_.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ls.f},`bed${r.x}`)),s.jsxs("g",{className:"fm-arms",fill:Ls.f,children:[s.jsx("rect",{x:4,y:8,width:2,height:2}),s.jsx("rect",{x:12,y:8,width:1,height:2})]}),e_.map(r=>s.jsx("rect",{x:r.x+(n==="right"?1:0)-(r.x>=9?1:0),y:r.y,width:r.w,height:1,className:"fm-eye",style:{fill:Ls.n}},`e${r.x}`))]}),a&&s.jsxs("g",{className:"fm-grip",style:{fill:Ls.f},children:[s.jsx("path",{className:"fm-grip-left",d:PU}),s.jsx("path",{className:"fm-grip-right",d:MU})]}),i&&s.jsxs("g",{className:"fm-crouch-legs",style:{fill:Ls.f},children:[s.jsx("path",{d:"M6 11H8V13H6Z"}),s.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&s.jsxs("g",{className:"fm-seated-legs",style:{fill:Ls.f},children:[s.jsx("path",{className:"fm-seated-far",style:{fill:Ls.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),s.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>s.jsx("g",{className:"fm-leg","data-side":r,children:ase[r].map(c=>s.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:Ls[c.cell]},`${c.y}-${c.x}`))},r))]})}),ise=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],fi={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},ose={p:"fm-pad"},Wg=qo(ise),rse=qo(RA).filter(e=>EA.has(e.cell)),t_=Wg.filter(e=>e.cell==="e"),cse=Wg.filter(e=>e.y<12&&e.cell!=="e"),lse={left:Wg.filter(e=>e.y>=12&&e.x<9),right:Wg.filter(e=>e.y>=12&&e.x>=9)},dse=m.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",a=t==="land"||t==="dismount",i=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return s.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[s.jsx("g",{className:"fm-gear",children:s.jsx("g",{className:"fm-gear-motion",children:rse.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:ose[o.cell]},`g${o.y}-${o.x}`))})}),s.jsxs("g",{className:"fm-body",children:[cse.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:fi[o.cell]},`b${o.y}-${o.x}`)),t_.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:fi.w},`bed${o.x}`)),s.jsxs("g",{className:"fm-arms",fill:fi.d,children:[s.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),s.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),t_.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:fi.e}},`e${o.x}`))]}),n&&s.jsxs("g",{className:"fm-grip",style:{fill:fi.h},children:[s.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),s.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),a&&s.jsxs("g",{className:"fm-crouch-legs",style:{fill:fi.b},children:[s.jsx("path",{d:"M5 12H8V13H5Z"}),s.jsx("path",{d:"M10 12H13V13H10Z"})]}),i&&s.jsxs("g",{className:"fm-seated-legs",style:{fill:fi.b},children:[s.jsx("path",{className:"fm-seated-far",style:{fill:fi.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),s.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>s.jsx("g",{className:"fm-leg","data-side":o,children:lse[o].map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:fi.b},`${r.y}-${r.x}`))},o))]})});function IU({character:e,act:t,facing:n}){return e==="penguin"?s.jsx(dse,{act:t,facing:n}):e==="fox"?s.jsx(sse,{act:t,facing:n}):s.jsx(Yae,{act:t,facing:n})}const use={"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 DU(e,t,n=C){return t&&pl(t.id)===e?t.name:Hm(e)?n("radio.fm.custom"):use[e]}function Fv(e,t){var a;const n=((a=e[0])==null?void 0:a.length)??0;return s.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:qo(e).map(i=>s.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:i.cell==="s"?"var(--fm-prop-shadow, var(--bg))":i.cell==="l"?"var(--fm-prop-light, var(--text))":i.cell==="a"?"var(--accent)":void 0},`${t}${i.y}-${i.x}`))})}const n_={litter:Fv(Iv.litter,"litter"),ball:Fv(Iv.ball,"ball"),scope:Fv(Iv.scope,"scope")};function hse(e,t=C){try{return new URL(e).host}catch{return t("radio.fm.server")}}const pse=m.memo(function({player:t,source:n,customStation:a,character:i="deck"}){const o=ae(),{probe:r,dead:c,playing:d,press:u}=t,{scene:p,suspended:g,x:f,walkMs:v,act:k,prop:y,ballFlight:N,place:w,facing:S,riser:j,dance:A,beatMs:T}=Gae(r,c,d);if(!r||c)return null;const E=DU(n,a,o),q=r.audio?hse(r.audio,o):"YouTube";return s.jsxs("div",{ref:p,className:"fm","data-suspended":g?"":void 0,"data-place":w,style:{"--fm-beat":`${T}ms`},children:[y&&!y.held&&s.jsx("div",{className:"fm-prop","data-prop":y.kind,"data-leaving":y.leaving?"":void 0,style:{"--fm-prop-x":`${y.at}px`,"--fm-roll-to":`${N.x}px`,"--fm-ball-drop":`${N.drop}px`,"--fm-ball-flight-ms":`${qU}ms`,"--fm-ball-turn":S==="right"?"1080deg":"-1080deg"},children:n_[y.kind]}),(k==="lasso"||k==="rope-throw"||k==="rope-catch"||k==="climb"||k==="pull-up")&&s.jsxs("div",{className:"fm-rope","data-act":k,style:{"--fm-rope-x":`${f}px`,"--fm-rope-ms":`${v}ms`},children:[s.jsx("div",{className:"fm-rope-line"}),s.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),s.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),s.jsxs("div",{className:"fm-walker","data-act":k??void 0,"data-place":w,"data-facing":S,style:{"--fm-x":`${f}px`,"--fm-walk-ms":`${v}ms`,"--fm-riser":`${j}px`,"--fm-skip-beat":`${zU}ms`},children:[(y==null?void 0:y.held)&&s.jsx("div",{className:"fm-held","data-prop":y.kind,"data-toss":y.leaving?"":void 0,children:n_[y.kind]}),["cast","fish","reel","stow"].includes(k)&&s.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsxs("g",{children:[s.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),s.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),s.jsxs("g",{className:"fm-fishing-line",children:[s.jsx("path",{d:"M8 2V26"}),s.jsxs("g",{className:"fm-float",children:[s.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),s.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),s.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(k)&&s.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),s.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),s.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),s.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),s.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),s.jsx("button",{type:"button",className:"fm-sprite","data-playing":d?"":void 0,"data-dance":d?A??LU[0]:void 0,onClick:u,title:d?o("radio.fm.stop",{label:E}):o("radio.fm.playTitle",{label:E,from:q}),"aria-label":d?o("radio.fm.stop",{label:E}):o("radio.fm.play",{label:E}),children:s.jsx(IU,{character:i,act:k,facing:S})})]})]})});function gse({player:e,label:t}){const{probe:n,armed:a,frame:i,say:o}=e;return n?s.jsx(s.Fragment,{children:a&&!n.audio&&(n.channel||n.video)&&s.jsx("iframe",{ref:i,className:"fm-frame",title:t,src:Bne(n.channel,window.location.origin,n.video),onLoad:()=>o(Hne()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const mse={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 fse({name:e}){return s.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:s.jsx("path",{d:mse[e]})})}function bse({opening:e=!1}){const t=ae(),[n,a]=m.useState(()=>document.hidden);return m.useEffect(()=>{const i=()=>a(document.hidden);return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[]),s.jsxs("div",{className:"radio-tuning",role:"status","data-paused":n||void 0,children:[s.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:[s.jsxs("g",{className:"radio-tuning-tower",children:[s.jsx("circle",{cx:"40",cy:"24",r:"4"}),s.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),s.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),s.jsxs("g",{className:"radio-tuning-send",children:[s.jsx("path",{d:"M75 26q7 8 0 16"}),s.jsx("path",{d:"M102 26q7 8 0 16"}),s.jsx("path",{d:"M129 26q7 8 0 16"})]}),s.jsxs("g",{className:"radio-tuning-receiver",children:[s.jsx("path",{d:"M165 49l30-22"}),s.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),s.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),s.jsx("circle",{cx:"202",cy:"65",r:"7"}),s.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),s.jsx("strong",{children:t(e?"radio.loading.opening":"radio.loading.tuning")}),s.jsx("span",{children:t(e?"radio.loading.ready":"radio.loading.finding")})]})}function vse({onClose:e}){const t=ae(),[n]=m.useState(()=>{var i;return((i=document.activeElement)==null?void 0:i.matches(":focus-visible"))??!1}),a=_t(e);return s.jsxs("div",{ref:a,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":t("radio.loading.opening"),"data-keyboard-interaction":n||void 0,onKeyDown:zee,children:[s.jsx("button",{type:"button",className:"icon-btn","aria-label":t("radio.close"),onClick:e,children:s.jsx(fse,{name:"close"})}),s.jsx(bse,{opening:!0})]})}const kse=m.lazy(()=>Pr(()=>import("./RadioPanel-yTqDyeoT.js"),[]));function wse({fm:e,characterEnabled:t,character:n,open:a,onClose:i}){const[o,r]=m.useState(!1),c=ae(),[d,u]=m.useState("connecting"),p=c(`radio.disabled.${d}`),g=Qne(),[f,v]=m.useState(null),k=m.useRef(new Set);m.useEffect(()=>{const z=new AbortController;return fetch("/api/music-config",{signal:z.signal}).then(H=>H.ok?H.json():null).then(H=>{z.signal.aborted||(r((H==null?void 0:H.enabled)===!0),u(H?"off":"unreachable"))}).catch(()=>{z.signal.aborted||u("unreachable")}),()=>z.abort()},[a]);const y=e.customFmStations.find(z=>pl(z.id)===e.fmSource),N=y!=null&&y.radio?y:void 0,w=Yne({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:y,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),S=DU(e.fmSource,y,c),j=o&&N&&w.dead&&e.fmPlayRequest>0?EU(f??g.catalogue,N.id,k.current):null,{remember:A}=g,T=(y==null?void 0:y.id)??e.fmSource;m.useEffect(()=>{w.playing&&A(T)},[T,w.playing,A]);const E=i,q=qt(i),F=m.useCallback((z,H=!1)=>{var _;if(!o)return;H||k.current.clear();const I=pl(z.id),L=I===e.fmSource;if(L&&w.armed&&!w.dead){w.press();return}const O=L&&!!y&&(y.url!==z.url||((_=y.radio)==null?void 0:_.hls)!==z.radio.hls);e.addFmStation(z,!0),L&&!w.dead&&!O?w.press():e.pickFmSource(I,O),fetch(`/api/radio-click?id=${encodeURIComponent(z.id)}`).catch(()=>{})},[o,y,e.addFmStation,e.fmSource,e.pickFmSource,w.armed,w.dead,w.press]);return m.useEffect(()=>{w.playing&&!w.dead&&k.current.clear()},[w.playing,w.dead]),m.useEffect(()=>{if(!(!o||!N||!w.dead||e.fmPlayRequest===0))return eae(f??g.catalogue,N.id,k.current,z=>F(z,!0))},[o,N==null?void 0:N.id,w.dead,e.fmPlayRequest,f,g.catalogue,F]),s.jsxs(s.Fragment,{children:[t&&s.jsx(pse,{character:n,player:w,source:e.fmSource,customStation:y}),s.jsx(gse,{player:w,label:S}),a&&Lt.createPortal(s.jsx("div",{className:"modal-backdrop radio-backdrop",...q,children:s.jsx(m.Suspense,{fallback:s.jsx(vse,{onClose:E}),children:s.jsx(kse,{fm:e,player:w,library:g,selected:N,label:S,enabled:o,disabledReason:p,autoNext:j==null?void 0:j.name,onPick:F,onQueueChange:v,onClose:E})})}),document.body)]})}function yse({data:e}){const t=ae(),n=Vs(3e4),a=e.note,i=e.plan??null,o=(a==null?void 0:a.kind)==="recap",r=Fg((a==null?void 0:a.at)??(i==null?void 0:i.at)??n,n),c=`${o?"recap-note":`recap-note is-status status-${(a==null?void 0:a.kind)??"plan"}`}${i?" has-plan":""}`,d=o||!a?void 0:Dm(a),u=$s(i),p=a?Cl(a.kind):`${t("board.detail.plan").toLowerCase()} ${u?`${u.done}/${u.total}`:""}`.trim();return s.jsxs("div",{className:c,role:"note","aria-label":o?t("board.node.recapLabel"):t("board.node.noteLabel",{tag:p}),"aria-description":d,style:{"--session-hue":e.hue},children:[s.jsxs("div",{className:"recap-note-head",title:d,children:[s.jsxs("span",{className:"recap-note-mark",children:[s.jsx(Dg,{recap:o}),p]}),s.jsx("span",{className:"recap-note-age",title:r.title,children:r.label}),s.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":t(o?"board.node.hideRecap":a?"board.node.hideNote":"board.node.hidePlan"),title:t("board.note.hideTitle"),onClick:g=>{g.stopPropagation(),Qee(e.noteKey)},children:"×"})]}),a&&s.jsx("p",{className:"recap-note-text",title:dte(a.text,d),children:a.text}),(a==null?void 0:a.reply)&&s.jsx("p",{className:"recap-note-reply",title:t("board.list.reply",{reply:a.reply}),children:t("board.list.reply",{reply:a.reply})}),i&&s.jsx(a_,{plan:i,head:a!=null}),s.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[s.jsxs("div",{className:"lod-id",children:[s.jsxs("span",{className:"recap-note-mark",children:[s.jsx(Dg,{recap:o}),p]}),s.jsx("span",{className:"recap-face-age",children:r.label})]}),a&&s.jsx("p",{className:"recap-face-text",children:a.text}),i&&s.jsx(a_,{plan:i,head:a!=null,face:!0})]}),s.jsx(Rr,{type:"source",position:at.Right,style:{background:"transparent",border:"none"}})]})}const xse={completed:"board.state.done",in_progress:"board.detail.now",pending:"board.detail.todo"};function a_({plan:e,head:t,face:n=!1}){const a=ae(),i=$s(e);if(!i)return null;const o=tQ(e.items);return s.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:Am(e.items),children:[t&&s.jsxs("div",{className:"recap-note-plan-head",children:[a("board.detail.plan")," ",s.jsxs("span",{className:"recap-note-plan-count",children:[i.done,"/",i.total,i.allDone?` · ${a("board.state.done")}`:""]})]}),!i.allDone&&s.jsxs("ol",{className:"plan-list",children:[o.shown.map((r,c)=>s.jsxs("li",{className:"plan-item","data-status":r.status,children:[s.jsx("span",{className:"plan-mark","aria-hidden":!0}),!n&&s.jsxs("span",{className:"vis-hidden",children:[a(xse[r.status]),a("board.detail.colon")]}),s.jsx("span",{className:"plan-text",children:r.status==="in_progress"&&r.active?r.active:r.text}),r.status==="in_progress"&&s.jsx("span",{className:"plan-now","aria-hidden":!0,children:a("board.detail.now")})]},r.id??`${c}:${r.text}`)),(o.before>0||o.after>0)&&s.jsx("li",{className:"recap-note-plan-more",children:[o.before>0?a("board.note.earlier",{n:o.before}):null,o.after>0?a("board.note.more",{n:o.after}):null].filter(Boolean).join(" · ")})]})]})}function Co(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function zo(e){return/mac|iphone|ipad/i.test(e)}const Gg=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function Cse(e,t,n){return{positions:Gg(e.positions),pinned:Gg(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function Sse(e,t){t.positions.clear();for(const[n,a]of Gg(e.positions))t.positions.set(n,a);t.pinned.clear();for(const[n,a]of Gg(e.pinned))t.pinned.set(n,a);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const s_=7e3,Nse=2e3,jse=140,Ase=(e=C)=>e("board.rearrange.text"),Tse=(e=C)=>e("board.rearrange.said"),i_=(e=C)=>e("board.rearrange.restored"),Rse={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function Ese(e,t=Rse){let n=null,a=null,i=0,o=s_;const r=new Set,c=()=>{a!==null&&t.clear(a),a=null},d=()=>{c(),!(n===null||r.size>0)&&(i=t.now()+o,a=t.set(()=>{a=null,u()},o))};function u(){c(),r.clear(),n!==null&&(n=null,e(!1))}return{open(p){const g=n===null;n=p,o=s_,d(),g&&e(!0)},take(){const p=n;return u(),p},close:u,hold(p){n!==null&&(r.size===0&&a!==null&&(o=Math.max(0,i-t.now()),c()),r.add(p))},release(p){!r.delete(p)||r.size>0||n===null||(o=Math.max(o,Nse),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function _se(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function qse(e){return zo(e)?"⌘Z":"Ctrl+Z"}function zse({undo:e}){const t=ae(),{open:n,said:a,undo:i,dismiss:o,hold:r,release:c}=e,d=Uc(n,jse),u=m.useRef(null);return m.useEffect(()=>n?jn.push(o,0,"popover"):void 0,[n,o]),m.useEffect(()=>{var g;if(n)return;const p=u.current;p&&p.contains(document.activeElement)&&((g=p.closest("main"))==null||g.focus({preventScroll:!0}))},[n]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:a}),mo(d)&&s.jsxs("div",{ref:u,className:d==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>r("hover"),onPointerLeave:()=>c("hover"),onFocus:()=>r("focus"),onBlur:p=>{p.currentTarget.contains(p.relatedTarget)||c("focus")},children:[s.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:Ase(t)}),s.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:i,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:[t("board.rearrange.undo"),s.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:qse(Co())})]})]})]})}function Lse({sourceX:e,sourceY:t,targetX:n,targetY:a,sourcePosition:i,targetPosition:o,style:r}){const[c]=Vj({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:a,targetPosition:o,curvature:.35});return s.jsxs("g",{className:"recap-tie",style:r,children:[s.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),s.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),s.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),s.jsx("circle",{className:"recap-tie-end",cx:n,cy:a,r:3.5})]})}function SN(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function $g(e,t){const n=SN(e);return n?n.slice(-t):e.slice(-t)}function FU(e,t,n=4){const a=SN(e);if(!a)return $g(e,n);let i=n;for(const o of t){if(o===e)continue;const r=SN(o);let c=0;for(;c<a.length&&c<r.length&&a[a.length-1-c]===r[r.length-1-c];)c++;i=Math.max(i,c+1)}return a.slice(-i)}function UU(e,t=C){const n=[e.tipWorkspace,e.planLine?t("board.cluster.plan",{plan:e.planLine}):void 0,e.tipRest||void 0].filter(Boolean).join(mr);return`${e.alarm?t("board.cluster.waitingOnYou"):""}${n}
129
+ ${t("board.node.blockedFor",{time:ul(e.since,void 0,n)})}`,children:[a?s.jsx("span",{className:"ap-pulse","aria-hidden":!0}):s.jsx("span",{className:"waiting-dot","aria-hidden":!0}),s.jsx("span",{className:"waiting-said",children:Pg(e,t)}),s.jsx("b",{children:ul(e.since,void 0,n)})]})}function bne({tools:e,outputs:t}){const n=ae(),a=Vs(1e3),{counts:i,title:o}=Bte(e,t,a,n),r=Ov/Xc;return s.jsxs("div",{className:"tool-spark-row",title:o,children:[s.jsx("svg",{className:"tool-spark",width:Ov,height:ug,viewBox:`0 0 ${Ov} ${ug}`,"aria-hidden":!0,children:i.map((c,d)=>{const u=Wte(c),p=d===Xc-1&&c>0,f=`tool-spark-bar${c>0?" active":""}${p?" latest":""}`;return s.jsx("rect",{x:d*r+.4,y:ug-u,width:Math.max(.5,r-1),height:u,rx:.8,className:f},p?`landed:${c}`:d)})}),s.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function vne({enableAutoFitAndRefit:e}){const t=ae();return s.jsxs("div",{className:"autofit-chip",children:[s.jsx("span",{className:"autofit-state",title:t("accounts.autoFit.offTip"),children:t("accounts.autoFit.off")}),s.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:t("accounts.autoFit.resumeTip"),"aria-label":t("accounts.autoFit.resumeLabel"),children:t("accounts.autoFit.resume")})]})}const AA="agent-dag.single-key-shortcuts";function CU(e){return e!=="0"}function SU(e){return e.length===1}function kne(e,t){return!t&&SU(e)}function Yn(e,t,n){return n?`${e} (${t})`:e}let xr=null;const Md=new Set;function NU(){for(const e of Md)e()}function kN(){return xr===null&&(xr=CU(ht(AA))),xr}function wne(e){xr!==e&&(xr=e,pt(AA,e?"1":"0"),NU())}function _1(e){if(e.key!==AA)return;const t=CU(e.newValue);t!==xr&&(xr=t,NU())}function yne(e){var t;return Md.add(e),Md.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",_1)),()=>{var n;Md.delete(e),Md.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",_1))}}function Bg(e,t=C){const n=Math.max(0,Math.floor(e));return t("board.pill.events",{count:n})}const q1=99;function xne(e){const t=Math.max(0,Math.floor(e));return t>q1?`${q1}+`:String(t)}const Cne=(e=C)=>e("board.pill.pause");function Sne(e,t=C){const n=e.singleKeys??!0;if(!e.paused)return Yn(t("board.pill.title.pause"),"Space",n);const a=Math.max(0,Math.floor(e.dropped??0));return a>0?Yn(t("board.pill.title.full",{held:Bg(e.held,t),count:a}),"Space",n):e.held<=0?Yn(t("board.pill.title.nothing"),"Space",n):Yn(t("board.pill.title.arrived",{held:Bg(e.held,t)}),"Space",n)}function Nne(e,t=C){return e.connected||!e.paused?null:t("board.pill.outage")}const jU=e=>e("board.pill.pausedFull"),jne=(e,t,n)=>t>0?jU(n):e>0?n("board.pill.pausedCount",{held:xne(e)}):n("board.pill.paused");function Ane(e,t=C){const n=Math.max(0,Math.floor(e.dropped??0)),a=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:jne(e.held,n,t),widest:jU(t),title:Yn(n>0?t("board.pill.title.connectedFull",{held:Bg(e.held,t)}):e.held>0?t("board.pill.title.connectedHeld",{held:Bg(e.held,t)}):t("board.pill.title.connectedNone"),"Space",a)}:{tone:"live",resting:!0,label:t("board.pill.live"),widest:t("board.pill.live"),title:t("board.pill.title.live")}:{tone:"dead",resting:!1,label:t("board.pill.offline"),widest:t("board.pill.offline"),title:e.paused?t("board.pill.title.offlinePaused"):t("board.pill.title.offline")}}function Qn(){return m.useSyncExternalStore(yne,kN,kN)}const Tne=e=>e.transform[2]>=e.maxZoom,Rne=e=>e.transform[2]<=e.minZoom;function Ene({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:a,togglePause:i,handleRelayout:o,requestClear:r,setKeyHelpOpen:c}){const d=ae(),u=bl(),p=Tt(Tne),g=Tt(Rne),f=Qn();return s.jsxs(d8,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[s.jsx(Fa,{onClick:()=>{p||u.zoomIn()},title:d("board.controls.zoomIn"),"aria-label":d("board.controls.zoomIn"),"aria-disabled":p||void 0,children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:s.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),s.jsx(Fa,{onClick:()=>{g||u.zoomOut()},title:d("board.controls.zoomOut"),"aria-label":d("board.controls.zoomOut"),"aria-disabled":g||void 0,children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:s.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),s.jsx(Fa,{onClick:t,title:d(e?"board.controls.recenterOn":"board.controls.recenterAuto"),"aria-label":d("board.controls.recenter"),"data-nudge":e?"":void 0,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),s.jsx(Fa,{"data-group-start":"",onClick:i,title:Sne({paused:n,held:a.size,dropped:a.dropped,singleKeys:f},d),"aria-label":Cne(d),"aria-pressed":n,children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:s.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),s.jsx(Fa,{onClick:o,title:Yn(d("board.controls.arrange"),"R",f),"aria-label":d("board.controls.arrangeLabel"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),s.jsx(Fa,{"data-group-start":"","data-danger":"",onClick:()=>r("button"),title:Yn(d("board.controls.clear"),"C",f),"aria-label":d("board.controls.clearLabel"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),s.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"}),s.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"}),s.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),s.jsx(Fa,{"data-group-start":"",onClick:()=>c(v=>!v),title:f?Yn(d("board.controls.keys"),"?",!0):d("board.controls.keysOff"),"aria-label":d("board.controls.keysLabel"),"aria-haspopup":"dialog",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[s.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"}),s.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const _ne="modulepreload",qne=function(e){return"/"+e},z1={},Pr=function(t,n,a){let i=Promise.resolve();if(n&&n.length>0){let r=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};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"));i=r(n.map(u=>{if(u=qne(u),u in z1)return;z1[u]=!0;const p=u.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${g}`))return;const f=document.createElement("link");if(f.rel=p?"stylesheet":_ne,p||(f.as="script"),f.crossOrigin="",f.href=u,d&&f.setAttribute("nonce",d),document.head.appendChild(f),p)return new Promise((v,k)=>{f.addEventListener("load",v),f.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(r){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=r,window.dispatchEvent(c),!c.defaultPrevented)throw r}return i.then(r=>{for(const c of r||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},L1="agent-dag.fm-custom-stations",O1="agent-dag.fm-muted",wN="custom:",zne=/^UC[A-Za-z0-9_-]{22}$/,Lne=/^[A-Za-z0-9_-]{11}$/,AU=/^[A-Za-z0-9_-]{1,80}$/,One=/\.(mp3|aac|ogg)$/i,Pne=/\.m3u8$/i,Mne=2048,TU=80;function pl(e){return`${wN}${e}`}function Hm(e){if(!e.startsWith(wN))return null;const t=e.slice(wN.length);return AU.test(t)?t:null}function P1(e){return Hm(e)??e}function TA(e){var r,c;const t=e.trim();if(t.length>Mne)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const a=n.toString(),i=n.hostname.toLowerCase();if(i==="youtube.com"||i==="www.youtube.com"||i==="m.youtube.com"){if(n.port)return null;const d=(r=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:r[1];if(d&&zne.test(d))return{kind:"youtube-channel",url:a,channel:d};const u=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(u&&/^[A-Za-z0-9._-]{1,64}$/.test(u))return{kind:"youtube-handle",url:a,handle:u};if(n.pathname==="/watch"){const p=n.searchParams.get("v")??"";if(Lne.test(p))return{kind:"youtube-video",url:a,video:p}}return null}return Pne.test(n.pathname)?{kind:"direct-audio",url:a,format:"hls"}:One.test(n.pathname)?{kind:"direct-audio",url:a,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:a,format:"audio"}}function Ine(e){return e==="1"}function Dne(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,a=[];for(const i of t){if(!i||typeof i!="object")continue;const o=typeof i.id=="string"?i.id:"",r=typeof i.name=="string"?i.name.trim():"",c=typeof i.url=="string"?i.url.trim():"",d=TA(c);if(!AU.test(o)||n.has(o)||!r||r.length>TU||!d)continue;n.add(o);const u=RU(i.radio);a.push({id:o,name:r,url:d.url,...u?{radio:u}:{}})}return a}function Fne(e,t,n){const a=Hm(e??"");return a&&t.some(i=>i.id===a)?pl(a):n(e)}function Une(e,t){return e===pl(t)?"claude-fm":e}function RU(e){if(!e||typeof e!="object")return null;const t=e,n=(i,o)=>typeof t[i]=="string"?t[i].slice(0,o):"",a=(i,o)=>typeof t[i]=="number"&&Number.isFinite(t[i])&&Math.abs(t[i])<=o?t[i]: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:a("lat",90),lon:a("lon",180)}}const yN="https://www.youtube-nocookie.com";function Bne(e,t,n){const a=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${yN}/embed/${n?encodeURIComponent(n):"live_stream"}?${a.toString()}`}function Ac(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function Hne(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const Wne=[1],Gne=[0,2],$ne=[2,5,100,101,150,153];function Vne(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:a}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const i=typeof a=="number"?a:Number(a==null?void 0:a.errorCode);return Number.isFinite(i)?{kind:"error",code:i}:null}if(n==="onStateChange"||n==="infoDelivery"){const i=typeof a=="number"?a:a==null?void 0:a.playerState;return typeof i!="number"||!Number.isFinite(i)?null:Wne.includes(i)?{kind:"playing",playing:!0}:i===3?{kind:"buffering"}:Gne.includes(i)?{kind:"playing",playing:!1}:null}return null}const wd=new Set;let M1="";function I1(e){const t=new Date().toISOString().slice(0,10);if(t!==M1&&(wd.clear(),M1=t),!wd.has(e)){wd.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&wd.delete(e)}catch{wd.delete(e)}}}const D1=864e5,Kne=6e4;function An(e,t=!0){m.useEffect(()=>{if(!t)return;I1(e);let n;const a=()=>{n=setTimeout(()=>{I1(e),a()},D1-Date.now()%D1+Kne)};return a(),()=>clearTimeout(n)},[e,t])}const Jne={"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 Yne({fetchImpl:e,enabled:t=!0,volume:n,muted:a,source:i,playRequest:o,customStation:r,onAvailabilityChange:c}){var O;const[d,u]=m.useState(null),[p,g]=m.useState(!1),[f,v]=m.useState(!1),[k,y]=m.useState(!1),[N,w]=m.useState(!1);An("claude-fm",k);const S=m.useRef(o),j=m.useRef(null),A=m.useRef(null),T=m.useRef(void 0),E=m.useRef(null),q=m.useCallback(()=>{var M;clearTimeout(T.current),(M=A.current)==null||M.destroy(),A.current=null;const _=j.current;_&&(_.pause(),_.removeAttribute("src"),_.load(),j.current=null)},[]),F=m.useCallback(_=>{var M,U;(U=(M=E.current)==null?void 0:M.contentWindow)==null||U.postMessage(_,yN)},[]),z=m.useRef(n);z.current=n;const H=m.useRef(a);H.current=a;const I=m.useCallback((_,M,U)=>{q();const G=new Audio;G.preload="none",G.volume=z.current/100,G.muted=H.current,j.current=G,v(!0),y(!1),w(!1);let W=!1;const $=()=>j.current===G,Y=()=>{clearTimeout(T.current),q(),v(!1),y(!1),w(!1)},B=()=>{$()&&(Y(),g(!0),c==null||c(U,!0))},V=D=>{if($()&&!(D instanceof DOMException&&D.name==="AbortError")){if(D instanceof DOMException&&D.name==="NotAllowedError"){Y();return}B()}};T.current=setTimeout(()=>{$()&&!W&&B()},15e3),G.addEventListener("playing",()=>{$()&&(clearTimeout(T.current),W=!0,y(!0),w(!1),c==null||c(U,!1))});const Z=()=>{$()&&(y(!1),w(W),clearTimeout(T.current),T.current=setTimeout(()=>{$()&&B()},15e3))};G.addEventListener("waiting",Z),G.addEventListener("stalled",Z),G.addEventListener("ended",()=>{$()&&Y()}),G.addEventListener("error",B,{once:!0}),M&&!G.canPlayType("application/vnd.apple.mpegurl")?Pr(async()=>{const{default:D}=await import("./hls-BFpXDghs.js");return{default:D}},[]).then(({default:D})=>{if(!$())return;if(!D.isSupported()){B();return}const K=new D;A.current=K,K.on(D.Events.ERROR,(X,Q)=>{Q.fatal&&B()}),K.on(D.Events.MEDIA_ATTACHED,()=>K.loadSource(_)),K.on(D.Events.MANIFEST_PARSED,()=>{G.play().catch(V)}),K.attachMedia(G)},B):(G.src=_,G.play().catch(V))},[c,q]);m.useEffect(()=>{f&&(F(Ac("setVolume",[n])),F(Ac(a?"mute":"unMute")),j.current&&(j.current.volume=n/100,j.current.muted=a))},[n,a,f,F]),m.useEffect(()=>{var Y;let _=!0;const M=e??fetch,U=S.current!==o;if(S.current=o,u(null),g(!1),w(!1),v(U),y(!1),q(),!t){v(!1),y(!1);return}const G=r&&pl(r.id)===i?TA(r.url):null;if(G){if(G.kind==="direct-audio"){const B=G.format==="hls"||((Y=r==null?void 0:r.radio)==null?void 0:Y.hls)===!0;return u({live:!0,channel:"",audio:G.url,hls:B}),c==null||c(i,!1),U&&I(G.url,B,i),()=>{_=!1}}return M(`/api/fm-station?url=${encodeURIComponent(G.url)}`).then(B=>B.ok?B.json():null).then(B=>{_&&(B!=null&&B.channel||B!=null&&B.video?(u({live:!0,channel:B.channel??"",video:B.video??void 0}),c==null||c(i,!1)):(g(!0),v(!1),y(!1),w(!1),c==null||c(i,!0)))}).catch(()=>{_&&(g(!0),v(!1),y(!1),w(!1),c==null||c(i,!0))}),()=>{_=!1}}if(Hm(i))return g(!0),c==null||c(i,!0),()=>{_=!1};const W=i,$=Jne[W];if($)M($).then(B=>B.ok?B.json():null).then(B=>{_&&(B!=null&&B.video&&u({live:!0,channel:"",video:B.video}),B!=null&&B.video||(g(!0),v(!1),y(!1)),c==null||c(i,!(B!=null&&B.video)))}).catch(()=>{_&&(g(!0),v(!1),y(!1),c==null||c(i,!0))});else if(W!=="claude-fm"){const B=W.replace("lofi-","");M(`/api/lofi-girl?station=${encodeURIComponent(B)}`).then(V=>V.ok?V.json():null).then(V=>{_&&(V!=null&&V.video&&u({live:!0,channel:"",video:V.video}),V!=null&&V.video||(g(!0),v(!1),y(!1)),c==null||c(i,!(V!=null&&V.video)))}).catch(()=>{_&&(g(!0),v(!1),y(!1),c==null||c(i,!0))})}else M("/api/claude-fm").then(B=>B.ok?B.json():null).then(B=>{if(!_)return;const V=!!(B!=null&&B.live&&(B!=null&&B.channel));V&&u({live:!0,channel:B.channel}),V||(g(!0),v(!1),y(!1)),c==null||c(i,!V)}).catch(()=>{_&&(g(!0),v(!1),y(!1),c==null||c(i,!0))});return()=>{_=!1}},[r==null?void 0:r.id,r==null?void 0:r.url,(O=r==null?void 0:r.radio)==null?void 0:O.hls,t,e,c,o,i,I,q]),m.useEffect(()=>()=>q(),[q]),m.useEffect(()=>{if(!f||d!=null&&d.audio)return;let _;const M=()=>{clearTimeout(_),_=void 0,v(!1),y(!1),w(!1),g(!0),c==null||c(i,!0)},U=()=>{_??(_=setTimeout(M,15e3))};U();const G=W=>{var Y;if(W.origin!==yN||W.source!==((Y=E.current)==null?void 0:Y.contentWindow))return;const $=Vne(W.data);if($){if($.kind==="ready"){F(Ac("setVolume",[z.current])),F(Ac(H.current?"mute":"unMute")),F(Ac("playVideo"));return}if($.kind==="blocked"){clearTimeout(_),_=void 0,v(!1),y(!1),w(!1);return}if($.kind==="buffering"){y(!1),w(!0),U();return}if($.kind==="playing"){clearTimeout(_),_=void 0,y($.playing),w(!1),$.playing||v(!1);return}$ne.includes($.code)&&M()}};return window.addEventListener("message",G),()=>{clearTimeout(_),window.removeEventListener("message",G)}},[f,d==null?void 0:d.audio,o,c,F,i]);const L=m.useCallback(()=>{if(d){if(d.audio){if(f){q(),v(!1),y(!1),w(!1);return}I(d.audio,d.hls===!0,i);return}if(!f){v(!0),y(!1),w(!1);return}F(Ac("pauseVideo")),v(!1),y(!1),w(!1)}},[d,f,k,i,F,I,q]);return m.useMemo(()=>({probe:d,dead:p,armed:f,playing:k,buffering:N,frame:E,say:F,press:L}),[d,p,f,k,N,F,L])}const F1="agent-dag.radio-favorites",U1="agent-dag.radio-recent",B1="agent-dag.radio-catalogue";function Zne(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const a=n,i=typeof a.id=="string"?a.id:"",o=typeof a.name=="string"?a.name.trim().slice(0,80):"",r=typeof a.url=="string"?TA(a.url):null,c=RU(a.radio??a);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(i)||!o||!c||!r||r.kind!=="direct-audio"||t.has(i)?[]:(t.add(i),[{id:i,name:o,url:r.url,radio:c}])})}function H1(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 Xne(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function WEe(e,t,n=Math.random){const a=e.filter(i=>i.id!==t);return a.length?a[Math.min(a.length-1,Math.floor(Math.max(0,n())*a.length))]:null}function GEe(e,t,n){if(!e.length)return null;const a=e.findIndex(o=>o.id===t),i=e[a<0?n===1?0:e.length-1:(a+n+e.length)%e.length];return i.id===t?null:i}function EU(e,t,n){const a=e.findIndex(i=>i.id===t);for(let i=1;i<=e.length;i++){const o=e[(a+i)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function $Ee(e,t){if(!e.length)return null;const n=[...e].sort((i,o)=>i.id.localeCompare(o.id));let a=0;for(const i of t)a=Math.imul(a,31)+i.charCodeAt(0)>>>0;return n[a%n.length]}function VEe(e,t,n,a,i){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!a||e.radio.tags.toLowerCase().includes(a.toLowerCase()))&&(!i||e.radio.language.toLowerCase().includes(i.toLowerCase()))}function Qne(){const[e,t]=m.useState(()=>H1(ht(F1))),[n,a]=m.useState(()=>H1(ht(U1))),[i,o]=m.useState(()=>{try{return Zne(JSON.parse(ht(B1)??"[]"))}catch{return[]}});m.useEffect(()=>{pt(F1,JSON.stringify(e))},[e]),m.useEffect(()=>{pt(U1,JSON.stringify(n))},[n]);const r=m.useCallback(u=>a(p=>Xne(p,u)),[]),c=m.useCallback(u=>t(p=>p.includes(u)?p.filter(g=>g!==u):[...p,u].slice(-100)),[]),d=m.useCallback(u=>{o(u),pt(B1,JSON.stringify(u))},[]);return{favorites:e,recent:n,catalogue:i,remember:r,toggleFavorite:c,updateCatalogue:d}}function eae(e,t,n,a){const i=EU(e,t,n);if(!i)return()=>{};const o=setTimeout(()=>{n.add(t),a(i)},1e3);return()=>clearTimeout(o)}const Wm=148,W1=6e3,tae=16e3,_U=46,fo=34;function nae(e,t,n=Wm){let a=-Math.round(t()*n);if(Math.abs(a-e)<fo){const i=e-fo>=-n?-fo:fo;a=Math.max(-n,Math.min(0,Math.round(e+i)))}return{to:a,ms:Math.round(Math.abs(a-e)*_U)}}function aae(e){return Math.round(W1+e()*(tae-W1))}const G1=[{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 sae(e){const t=G1.reduce((a,i)=>a+i.weight,0);let n=e()*t;for(const a of G1)if(n-=a.weight,n<0)return a.kind;return"stroll"}const iae=720,oae=260,rae=620,cae=220,$1=520,qU=1600,V1=7e3,lae=15e3,K1=6e3,dae=14e3;function Tc(e,t,n=Wm){let a=-Math.round(t()*n);if(Math.abs(a-e)<fo){const i=e-fo>=-n?-fo:fo;a=Math.max(-n,Math.min(0,Math.round(e+i)))}return a}const kn=(e,t)=>Math.round(Math.abs(t-e)*_U),uae=120,Lp=0;function hae(e,t){const n=a=>({kind:"litter",at:t,...a});return[{x:t,prop:n({}),act:"walk",ms:kn(e,t)},{x:t,prop:n({}),act:"stoop",ms:iae},{x:Lp,prop:n({held:!0}),act:"carry",ms:kn(t,Lp)},{x:Lp,prop:n({held:!0}),act:"windup",ms:oae},{x:Lp,prop:n({held:!0,leaving:!0}),act:"toss",ms:rae}]}function pae(e,t){const n=t>e?1:-1,a=t-n*Math.min(15,Math.abs(t-e)),i=(o={})=>({kind:"ball",at:t,...o});return[{x:a,prop:i(),act:"walk",ms:kn(e,a)},{x:a,prop:i(),act:"windup",ms:cae,facing:n>0?"right":"left"},{x:a,prop:i({leaving:!0}),act:"kick",ms:$1,facing:n>0?"right":"left"},{x:a,prop:i({leaving:!0}),act:"stand",ms:qU-$1}]}const zU=640;function gae(e,t,n){const a=Math.max(-70,Math.min(-20,t)),i={x:a,prop:null,facing:"left"};return[{x:a,prop:null,act:"walk",ms:kn(e,a)},{...i,act:"sit",ms:600},{...i,act:"cast",ms:900},{...i,act:"fish",ms:6e3+Math.round(n()*4e3)},{...i,act:"reel",ms:1200},{...i,act:"stow",ms:500},{...i,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:kn(a,0)}]}function mae(e,t,n){const a=Math.max(-110,Math.min(-30,t)),i={x:a,prop:null};return[{...i,act:"walk",ms:kn(e,a)},{...i,act:"skip-ready",ms:500},{...i,act:"skip",ms:zU*(6+Math.floor(n()*5))},{...i,act:"skip-rest",ms:600},{...i,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:kn(a,0)}]}function fae(e,t,n){return[{x:t,prop:null,act:"walk",ms:kn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(K1+n()*(dae-K1))},{x:t,prop:null,act:"stand",ms:400}]}function bae(e,t,n){t=Math.max(-110,Math.min(0,t));const a=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:kn(e,t)},{x:t,prop:a(),act:"watch",ms:Math.round(V1+n()*(lae-V1))},{x:t,prop:a(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Mv(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 vae=1500,kae=e=>Math.round(1e3*Math.sqrt(2*e/vae)),wae=115,yae=e=>Math.round(e/wae*1e3),xae=620,Cae=200,Sae=760,Nae=600,jae=240;function Aae(e,t,n){const i=-(t.ledgeSpan??Wm),o=kae(t.ledgeH),r=yae(t.ledgeH),c=n(),d=n(),u=-Math.round(c*t.floorSpan),p=-Math.round(d*t.floorSpan);return[{x:i,act:"walk",prop:null,ms:kn(e,i)},{x:i,act:"peer",prop:null,ms:xae},{x:i,act:"fall",prop:null,ms:o,place:"floor"},{x:i,act:"land",prop:null,ms:Cae,place:"floor"},{x:u,act:"walk",prop:null,ms:kn(i,u),place:"floor",floorFrac:c},{x:p,act:"walk",prop:null,ms:kn(u,p),place:"floor",floorFrac:d},{x:i,act:"walk",prop:null,ms:kn(p,i),place:"floor"},{x:i,act:"lasso",prop:null,ms:Sae,place:"floor"},{x:i,act:"rope-throw",prop:null,ms:Nae,place:"floor"},{x:i,act:"rope-catch",prop:null,ms:jae,place:"floor"},{x:i,act:"climb",prop:null,ms:r},{x:i,act:"pull-up",prop:null,ms:480}]}function Tae(e,t,n){const a=(n==null?void 0:n.ledgeSpan)??Wm;switch(sae(t)){case"tidy":return hae(e,Tc(e,t,a));case"kick":return pae(e,Tc(e,t,a));case"sit":return fae(e,Tc(e,t,a),t);case"watch":return bae(e,Tc(e,t,a),t);case"fish":return gae(e,Tc(e,t,a),t);case"skip":return mae(e,Tc(e,t,a),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return Aae(e,n,t)}}const o=nae(e,t,a);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const Rae=420;function Eae(e,t,n){const a=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(Rae,Math.max(0,a))}const _ae=260,qae=200;function zae(e,t,n){const a=(p,g=kn(e,p))=>({x:p,prop:null,act:"walk",ms:g,place:"floor"});if(!n||n.height<=0)return[a(t)];const i=Math.min(e,t);if(Math.max(e,t)<=n.left||i>=n.right)return[a(t)];const r=t>e,c=r?n.left:n.right,d=r?n.right:n.left,u={place:"floor",riser:n.height,prop:null};return[a(c,kn(e,c)),{...u,x:c,act:"mount",ms:_ae},{...u,x:d,act:"walk",ms:kn(c,d)},{x:d,prop:null,act:"dismount",ms:qae,place:"floor"},{x:t,prop:null,act:"walk",ms:kn(d,t),place:"floor"}]}const LU=["bob","sway","groove"],J1=9e3,Lae=16e3,OU=1e3,Oae=.08;function Pae(e,t){const n=LU.filter(o=>o!==e),a=n[Math.min(n.length-1,Math.floor(t()*n.length))],i=(t()*2-1)*Oae;return{dance:a,beatMs:Math.round(OU*(1+i))}}function Mae(e){return Math.round(J1+e()*(Lae-J1))}const RA=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],Y1=18,Iae=RA.length,PU="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",MU="M12 9H14V6H13V3H11V2H9V4H12Z",EA=new Set(["a","c","p"]);function qo(e=RA){const t=[];return e.forEach((n,a)=>{let i=0;for(;i<n.length;){const o=n[i];if(o==="."){i+=1;continue}let r=1;for(;i+r<n.length&&n[i+r]===o;)r+=1;t.push({x:i,y:a,w:r,cell:o}),i+=r}}),t}const Dae=[".xx.","xxxx",".xx."],Fae=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],Uae=["...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."],Iv={litter:Dae,ball:Fae,scope:Uae},Bae=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],Hae=3,Wae=-1,xN=11,Z1=9;function X1(e){let t=null,n=null,a=0,i=0,o=!1;const r=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(i=performance.now(),t=setTimeout(()=>{t=null;const u=n;n=null,u==null||u()},a))},d=()=>{e.hidden&&t!==null?(a=Math.max(0,a-(performance.now()-i)),r()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(u,p){o||(r(),n=u,a=Math.max(0,p),c())},dispose(){o=!0,r(),n=null,e.removeEventListener("visibilitychange",d)}}}function Gae(e,t,n){const[a,i]=m.useState(0),[o,r]=m.useState(0),[c,d]=m.useState(null),[u,p]=m.useState(null),[g,f]=m.useState({x:0,drop:0}),[v,k]=m.useState("ledge"),[y,N]=m.useState("left"),[w,S]=m.useState(0),j=m.useRef(null),[A,T]=m.useState(()=>document.hidden);m.useEffect(()=>{const L=new Set,O=()=>{var _;if(document.hidden){for(const M of((_=j.current)==null?void 0:_.getAnimations({subtree:!0}))??[])if(M.playState==="running"||M.pending){const U=M.currentTime;M.pause(),U!==null&&(M.currentTime=U),L.add(M)}}else{for(const M of L)M.playState==="paused"&&M.play();L.clear()}T(document.hidden)};return O(),document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},[e,t]);const[E,q]=m.useState(null),[F,z]=m.useState(OU),[H,I]=m.useState(()=>{var L;return((L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return m.useEffect(()=>{var _;const L=(_=window.matchMedia)==null?void 0:_.call(window,"(prefers-reduced-motion: reduce)");if(!L)return;const O=()=>I(L.matches);return O(),L.addEventListener("change",O),()=>L.removeEventListener("change",O)},[]),m.useEffect(()=>{var Q;if(!e||t||H)return;const L=X1(document);let O=0;i(ee=>O=ee);let _=null,M=0,U=0;const G=ee=>{var he,ce;const[ne,...de]=ee;if(!ne){_=null,d(null),p(null),D();return}d(ne.act),p(ne.prop),k(ne.place??"ledge"),S(ne.riser??0);const ge=O,le=V(ne);if(ne.act==="kick"){const oe=(ce=(he=j.current)==null?void 0:he.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ce.getBoundingClientRect();oe&&f({x:Eae(oe.x,Mv(ne,ge,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-oe.y+24)})}U=ne.act==="walk"?Math.max(kn(ge,le),uae):ne.ms,ne.act==="carry"&&(U=kn(ge,le)),r(U),N(oe=>Mv({...ne,x:le},ge,oe)),i(le),O=le,_=ne,M=Date.now(),L.schedule(()=>G(de),U)},W=()=>{const ee=j.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite"),de=ee==null?void 0:ee.parentElement;if(!ee||!ne||!de)return null;const ge=ee.getBoundingClientRect(),le=de.getBoundingClientRect(),he=le.right-ge.right,ce=le.width-he*2-ne.offsetWidth;return ce>0?ce:null},$=()=>{const ee=j.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!ne?0:Math.max(0,ee.getBoundingClientRect().width-ne.offsetWidth)},Y=()=>{const ee=j.current,ne=ee==null?void 0:ee.querySelector(".fm-walker"),de=W();if(!ee||!ne||de==null)return;const ge=ee.getBoundingClientRect().bottom-ne.getBoundingClientRect().bottom;if(ge>0)return{ledgeH:ge,floorSpan:de,ledgeSpan:$()}},B=()=>{const ee=j.current,ne=document.querySelector(".canvas-notices");if(!ee||!ne)return null;const de=ee.getBoundingClientRect(),ge=ne.getBoundingClientRect();return ge.width<=0||ge.height<=0?null:{left:ge.left-de.right,right:ge.right-de.right,height:ge.height}},V=ee=>{const ne=(ee.place??"ledge")==="floor",de=ne?W()??$():$(),ge=ne&&ee.floorFrac!=null?-Math.round(ee.floorFrac*de):ee.x;return Math.max(-de,Math.min(0,ge))},Z=()=>{if(!_)return;const ee=V(_);ee!==O&&(r(Math.max(0,M+U-Date.now())),N(ne=>Mv({..._,x:ee},O,ne)),i(ee),O=ee)},D=()=>{L.schedule(()=>{const ee=Tae(O,Math.random,Y()),ne=ee.some(le=>le.place==="floor")?B():null;let de=O;const ge=ee.flatMap(le=>{const he=de;if(de=le.x,!(le.place==="floor"&&le.act==="walk"))return[le];const ce=zae(he,le.x,ne),oe=ce.length-1;return le.floorFrac==null?ce:ce.map((ve,ke)=>ke===oe?{...ve,floorFrac:le.floorFrac}:ve)});G(ge)},aae(Math.random))},K=(Q=j.current)==null?void 0:Q.parentElement,X=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return K&&X&&X.observe(K),D(),()=>{L.dispose(),X==null||X.disconnect(),k("ledge"),i(ee=>Math.max(-$(),Math.min(0,ee))),r(0),d(null),p(null),S(0)}},[e,t,H]),m.useEffect(()=>{if(!n||H){q(null);return}const L=X1(document),O=_=>{const M=Pae(_,Math.random);q(M.dance),z(M.beatMs),L.schedule(()=>O(M.dance),Mae(Math.random))};return O(null),()=>L.dispose()},[n,H]),{scene:j,suspended:A,x:a,walkMs:o,act:c,prop:u,ballFlight:g,place:v,facing:y,riser:w,dance:E,beatMs:F}}const Dv={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Hg=qo().filter(e=>!EA.has(e.cell)),$ae=qo().filter(e=>EA.has(e.cell)),Q1=Hg.filter(e=>e.cell==="e"),Vae=qo(Bae),Kae=Hg.filter(e=>e.y<xN&&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),Jae={left:Hg.filter(e=>e.y>=xN&&e.x<Z1),right:Hg.filter(e=>e.y>=xN&&e.x>=Z1)},Yae=m.memo(function({act:t,facing:n}){return s.jsxs("svg",{viewBox:`0 0 ${Y1} ${Iae}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsx("g",{className:"fm-gear",children:s.jsx("g",{className:"fm-gear-motion",children:$ae.map(a=>s.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:Dv[a.cell]},`g${a.y}-${a.x}`))})}),s.jsxs("g",{className:"fm-body",children:[Q1.map(a=>s.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:"var(--accent)"},`eye-bed-${a.x}`)),Kae.map(a=>s.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:Dv[a.cell]},`b${a.y}-${a.x}`)),s.jsxs("g",{className:"fm-arms",children:[s.jsx("rect",{x:4,y:8,width:2,height:2}),s.jsx("rect",{x:12,y:8,width:1,height:2}),s.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),Q1.map(a=>s.jsx("rect",{x:a.x-(a.x>=Y1/2?1:0)+(n==="right"?1:0),y:a.y,width:a.w,height:1,className:"fm-eye"},`eye-${a.x}`))]}),s.jsx("g",{className:"fm-hat",children:Vae.map(a=>s.jsx("rect",{x:Hae+a.x,y:Wae+a.y,width:a.w,height:1,className:a.cell==="k"?"fm-hatband":void 0},`h${a.y}-${a.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&s.jsxs("g",{className:"fm-grip",children:[s.jsx("path",{className:"fm-grip-left",d:PU}),s.jsx("path",{className:"fm-grip-right",d:MU})]}),(t==="land"||t==="dismount")&&s.jsxs("g",{className:"fm-crouch-legs",children:[s.jsx("path",{d:"M6 11H8V13H6Z"}),s.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&s.jsxs("g",{className:"fm-seated-legs",children:[s.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),s.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(a=>s.jsx("g",{className:"fm-leg","data-side":a,children:Jae[a].map(i=>s.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:Dv[i.cell]},`${a}${i.y}-${i.x}`))},a))]})}),Zae=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],Xae=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],Ls={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},Qae={p:"fm-pad"},fu=qo(Zae),ese=qo(Xae);function CN(e,t,n){return e.map(a=>({...a,x:Math.max(t,a.x),w:Math.max(0,Math.min(n,a.x+a.w)-Math.max(t,a.x))})).filter(a=>a.w>0)}const tse=CN(fu.filter(e=>e.y>=8),12,18),nse=fu.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),e_=fu.filter(e=>e.cell==="e"),ase={left:CN(fu.filter(e=>e.y>=11),0,9),right:CN(fu.filter(e=>e.y>=11),9,12)},sse=m.memo(function({act:t,facing:n}){const a=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",i=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return s.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[s.jsx("g",{className:"fm-body","data-part":"tail",children:tse.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ls[r.cell]},`t${r.y}-${r.x}`))}),s.jsx("g",{className:"fm-gear",children:s.jsx("g",{className:"fm-gear-motion",children:ese.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Qae[r.cell]},`g${r.y}-${r.x}`))})}),s.jsxs("g",{className:"fm-body",children:[nse.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ls[r.cell]},`b${r.y}-${r.x}`)),e_.map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:Ls.f},`bed${r.x}`)),s.jsxs("g",{className:"fm-arms",fill:Ls.f,children:[s.jsx("rect",{x:4,y:8,width:2,height:2}),s.jsx("rect",{x:12,y:8,width:1,height:2})]}),e_.map(r=>s.jsx("rect",{x:r.x+(n==="right"?1:0)-(r.x>=9?1:0),y:r.y,width:r.w,height:1,className:"fm-eye",style:{fill:Ls.n}},`e${r.x}`))]}),a&&s.jsxs("g",{className:"fm-grip",style:{fill:Ls.f},children:[s.jsx("path",{className:"fm-grip-left",d:PU}),s.jsx("path",{className:"fm-grip-right",d:MU})]}),i&&s.jsxs("g",{className:"fm-crouch-legs",style:{fill:Ls.f},children:[s.jsx("path",{d:"M6 11H8V13H6Z"}),s.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&s.jsxs("g",{className:"fm-seated-legs",style:{fill:Ls.f},children:[s.jsx("path",{className:"fm-seated-far",style:{fill:Ls.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),s.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>s.jsx("g",{className:"fm-leg","data-side":r,children:ase[r].map(c=>s.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:Ls[c.cell]},`${c.y}-${c.x}`))},r))]})}),ise=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],fi={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},ose={p:"fm-pad"},Wg=qo(ise),rse=qo(RA).filter(e=>EA.has(e.cell)),t_=Wg.filter(e=>e.cell==="e"),cse=Wg.filter(e=>e.y<12&&e.cell!=="e"),lse={left:Wg.filter(e=>e.y>=12&&e.x<9),right:Wg.filter(e=>e.y>=12&&e.x>=9)},dse=m.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",a=t==="land"||t==="dismount",i=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return s.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[s.jsx("g",{className:"fm-gear",children:s.jsx("g",{className:"fm-gear-motion",children:rse.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:ose[o.cell]},`g${o.y}-${o.x}`))})}),s.jsxs("g",{className:"fm-body",children:[cse.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:fi[o.cell]},`b${o.y}-${o.x}`)),t_.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:fi.w},`bed${o.x}`)),s.jsxs("g",{className:"fm-arms",fill:fi.d,children:[s.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),s.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),t_.map(o=>s.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:fi.e}},`e${o.x}`))]}),n&&s.jsxs("g",{className:"fm-grip",style:{fill:fi.h},children:[s.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),s.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),a&&s.jsxs("g",{className:"fm-crouch-legs",style:{fill:fi.b},children:[s.jsx("path",{d:"M5 12H8V13H5Z"}),s.jsx("path",{d:"M10 12H13V13H10Z"})]}),i&&s.jsxs("g",{className:"fm-seated-legs",style:{fill:fi.b},children:[s.jsx("path",{className:"fm-seated-far",style:{fill:fi.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),s.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>s.jsx("g",{className:"fm-leg","data-side":o,children:lse[o].map(r=>s.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:fi.b},`${r.y}-${r.x}`))},o))]})});function IU({character:e,act:t,facing:n}){return e==="penguin"?s.jsx(dse,{act:t,facing:n}):e==="fox"?s.jsx(sse,{act:t,facing:n}):s.jsx(Yae,{act:t,facing:n})}const use={"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 DU(e,t,n=C){return t&&pl(t.id)===e?t.name:Hm(e)?n("radio.fm.custom"):use[e]}function Fv(e,t){var a;const n=((a=e[0])==null?void 0:a.length)??0;return s.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:qo(e).map(i=>s.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:i.cell==="s"?"var(--fm-prop-shadow, var(--bg))":i.cell==="l"?"var(--fm-prop-light, var(--text))":i.cell==="a"?"var(--accent)":void 0},`${t}${i.y}-${i.x}`))})}const n_={litter:Fv(Iv.litter,"litter"),ball:Fv(Iv.ball,"ball"),scope:Fv(Iv.scope,"scope")};function hse(e,t=C){try{return new URL(e).host}catch{return t("radio.fm.server")}}const pse=m.memo(function({player:t,source:n,customStation:a,character:i="deck"}){const o=ae(),{probe:r,dead:c,playing:d,press:u}=t,{scene:p,suspended:g,x:f,walkMs:v,act:k,prop:y,ballFlight:N,place:w,facing:S,riser:j,dance:A,beatMs:T}=Gae(r,c,d);if(!r||c)return null;const E=DU(n,a,o),q=r.audio?hse(r.audio,o):"YouTube";return s.jsxs("div",{ref:p,className:"fm","data-suspended":g?"":void 0,"data-place":w,style:{"--fm-beat":`${T}ms`},children:[y&&!y.held&&s.jsx("div",{className:"fm-prop","data-prop":y.kind,"data-leaving":y.leaving?"":void 0,style:{"--fm-prop-x":`${y.at}px`,"--fm-roll-to":`${N.x}px`,"--fm-ball-drop":`${N.drop}px`,"--fm-ball-flight-ms":`${qU}ms`,"--fm-ball-turn":S==="right"?"1080deg":"-1080deg"},children:n_[y.kind]}),(k==="lasso"||k==="rope-throw"||k==="rope-catch"||k==="climb"||k==="pull-up")&&s.jsxs("div",{className:"fm-rope","data-act":k,style:{"--fm-rope-x":`${f}px`,"--fm-rope-ms":`${v}ms`},children:[s.jsx("div",{className:"fm-rope-line"}),s.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),s.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),s.jsxs("div",{className:"fm-walker","data-act":k??void 0,"data-place":w,"data-facing":S,style:{"--fm-x":`${f}px`,"--fm-walk-ms":`${v}ms`,"--fm-riser":`${j}px`,"--fm-skip-beat":`${zU}ms`},children:[(y==null?void 0:y.held)&&s.jsx("div",{className:"fm-held","data-prop":y.kind,"data-toss":y.leaving?"":void 0,children:n_[y.kind]}),["cast","fish","reel","stow"].includes(k)&&s.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsxs("g",{children:[s.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),s.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),s.jsxs("g",{className:"fm-fishing-line",children:[s.jsx("path",{d:"M8 2V26"}),s.jsxs("g",{className:"fm-float",children:[s.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),s.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),s.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(k)&&s.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[s.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),s.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),s.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),s.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),s.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),s.jsx("button",{type:"button",className:"fm-sprite","data-playing":d?"":void 0,"data-dance":d?A??LU[0]:void 0,onClick:u,title:d?o("radio.fm.stop",{label:E}):o("radio.fm.playTitle",{label:E,from:q}),"aria-label":d?o("radio.fm.stop",{label:E}):o("radio.fm.play",{label:E}),children:s.jsx(IU,{character:i,act:k,facing:S})})]})]})});function gse({player:e,label:t}){const{probe:n,armed:a,frame:i,say:o}=e;return n?s.jsx(s.Fragment,{children:a&&!n.audio&&(n.channel||n.video)&&s.jsx("iframe",{ref:i,className:"fm-frame",title:t,src:Bne(n.channel,window.location.origin,n.video),onLoad:()=>o(Hne()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const mse={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 fse({name:e}){return s.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:s.jsx("path",{d:mse[e]})})}function bse({opening:e=!1}){const t=ae(),[n,a]=m.useState(()=>document.hidden);return m.useEffect(()=>{const i=()=>a(document.hidden);return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[]),s.jsxs("div",{className:"radio-tuning",role:"status","data-paused":n||void 0,children:[s.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:[s.jsxs("g",{className:"radio-tuning-tower",children:[s.jsx("circle",{cx:"40",cy:"24",r:"4"}),s.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),s.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),s.jsxs("g",{className:"radio-tuning-send",children:[s.jsx("path",{d:"M75 26q7 8 0 16"}),s.jsx("path",{d:"M102 26q7 8 0 16"}),s.jsx("path",{d:"M129 26q7 8 0 16"})]}),s.jsxs("g",{className:"radio-tuning-receiver",children:[s.jsx("path",{d:"M165 49l30-22"}),s.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),s.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),s.jsx("circle",{cx:"202",cy:"65",r:"7"}),s.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),s.jsx("strong",{children:t(e?"radio.loading.opening":"radio.loading.tuning")}),s.jsx("span",{children:t(e?"radio.loading.ready":"radio.loading.finding")})]})}function vse({onClose:e}){const t=ae(),[n]=m.useState(()=>{var i;return((i=document.activeElement)==null?void 0:i.matches(":focus-visible"))??!1}),a=_t(e);return s.jsxs("div",{ref:a,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":t("radio.loading.opening"),"data-keyboard-interaction":n||void 0,onKeyDown:zee,children:[s.jsx("button",{type:"button",className:"icon-btn","aria-label":t("radio.close"),onClick:e,children:s.jsx(fse,{name:"close"})}),s.jsx(bse,{opening:!0})]})}const kse=m.lazy(()=>Pr(()=>import("./RadioPanel-Sgo5WNTi.js"),[]));function wse({fm:e,characterEnabled:t,character:n,open:a,onClose:i}){const[o,r]=m.useState(!1),c=ae(),[d,u]=m.useState("connecting"),p=c(`radio.disabled.${d}`),g=Qne(),[f,v]=m.useState(null),k=m.useRef(new Set);m.useEffect(()=>{const z=new AbortController;return fetch("/api/music-config",{signal:z.signal}).then(H=>H.ok?H.json():null).then(H=>{z.signal.aborted||(r((H==null?void 0:H.enabled)===!0),u(H?"off":"unreachable"))}).catch(()=>{z.signal.aborted||u("unreachable")}),()=>z.abort()},[a]);const y=e.customFmStations.find(z=>pl(z.id)===e.fmSource),N=y!=null&&y.radio?y:void 0,w=Yne({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:y,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),S=DU(e.fmSource,y,c),j=o&&N&&w.dead&&e.fmPlayRequest>0?EU(f??g.catalogue,N.id,k.current):null,{remember:A}=g,T=(y==null?void 0:y.id)??e.fmSource;m.useEffect(()=>{w.playing&&A(T)},[T,w.playing,A]);const E=i,q=qt(i),F=m.useCallback((z,H=!1)=>{var _;if(!o)return;H||k.current.clear();const I=pl(z.id),L=I===e.fmSource;if(L&&w.armed&&!w.dead){w.press();return}const O=L&&!!y&&(y.url!==z.url||((_=y.radio)==null?void 0:_.hls)!==z.radio.hls);e.addFmStation(z,!0),L&&!w.dead&&!O?w.press():e.pickFmSource(I,O),fetch(`/api/radio-click?id=${encodeURIComponent(z.id)}`).catch(()=>{})},[o,y,e.addFmStation,e.fmSource,e.pickFmSource,w.armed,w.dead,w.press]);return m.useEffect(()=>{w.playing&&!w.dead&&k.current.clear()},[w.playing,w.dead]),m.useEffect(()=>{if(!(!o||!N||!w.dead||e.fmPlayRequest===0))return eae(f??g.catalogue,N.id,k.current,z=>F(z,!0))},[o,N==null?void 0:N.id,w.dead,e.fmPlayRequest,f,g.catalogue,F]),s.jsxs(s.Fragment,{children:[t&&s.jsx(pse,{character:n,player:w,source:e.fmSource,customStation:y}),s.jsx(gse,{player:w,label:S}),a&&Lt.createPortal(s.jsx("div",{className:"modal-backdrop radio-backdrop",...q,children:s.jsx(m.Suspense,{fallback:s.jsx(vse,{onClose:E}),children:s.jsx(kse,{fm:e,player:w,library:g,selected:N,label:S,enabled:o,disabledReason:p,autoNext:j==null?void 0:j.name,onPick:F,onQueueChange:v,onClose:E})})}),document.body)]})}function yse({data:e}){const t=ae(),n=Vs(3e4),a=e.note,i=e.plan??null,o=(a==null?void 0:a.kind)==="recap",r=Fg((a==null?void 0:a.at)??(i==null?void 0:i.at)??n,n),c=`${o?"recap-note":`recap-note is-status status-${(a==null?void 0:a.kind)??"plan"}`}${i?" has-plan":""}`,d=o||!a?void 0:Dm(a),u=$s(i),p=a?Cl(a.kind):`${t("board.detail.plan").toLowerCase()} ${u?`${u.done}/${u.total}`:""}`.trim();return s.jsxs("div",{className:c,role:"note","aria-label":o?t("board.node.recapLabel"):t("board.node.noteLabel",{tag:p}),"aria-description":d,style:{"--session-hue":e.hue},children:[s.jsxs("div",{className:"recap-note-head",title:d,children:[s.jsxs("span",{className:"recap-note-mark",children:[s.jsx(Dg,{recap:o}),p]}),s.jsx("span",{className:"recap-note-age",title:r.title,children:r.label}),s.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":t(o?"board.node.hideRecap":a?"board.node.hideNote":"board.node.hidePlan"),title:t("board.note.hideTitle"),onClick:g=>{g.stopPropagation(),Qee(e.noteKey)},children:"×"})]}),a&&s.jsx("p",{className:"recap-note-text",title:dte(a.text,d),children:a.text}),(a==null?void 0:a.reply)&&s.jsx("p",{className:"recap-note-reply",title:t("board.list.reply",{reply:a.reply}),children:t("board.list.reply",{reply:a.reply})}),i&&s.jsx(a_,{plan:i,head:a!=null}),s.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[s.jsxs("div",{className:"lod-id",children:[s.jsxs("span",{className:"recap-note-mark",children:[s.jsx(Dg,{recap:o}),p]}),s.jsx("span",{className:"recap-face-age",children:r.label})]}),a&&s.jsx("p",{className:"recap-face-text",children:a.text}),i&&s.jsx(a_,{plan:i,head:a!=null,face:!0})]}),s.jsx(Rr,{type:"source",position:at.Right,style:{background:"transparent",border:"none"}})]})}const xse={completed:"board.state.done",in_progress:"board.detail.now",pending:"board.detail.todo"};function a_({plan:e,head:t,face:n=!1}){const a=ae(),i=$s(e);if(!i)return null;const o=tQ(e.items);return s.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:Am(e.items),children:[t&&s.jsxs("div",{className:"recap-note-plan-head",children:[a("board.detail.plan")," ",s.jsxs("span",{className:"recap-note-plan-count",children:[i.done,"/",i.total,i.allDone?` · ${a("board.state.done")}`:""]})]}),!i.allDone&&s.jsxs("ol",{className:"plan-list",children:[o.shown.map((r,c)=>s.jsxs("li",{className:"plan-item","data-status":r.status,children:[s.jsx("span",{className:"plan-mark","aria-hidden":!0}),!n&&s.jsxs("span",{className:"vis-hidden",children:[a(xse[r.status]),a("board.detail.colon")]}),s.jsx("span",{className:"plan-text",children:r.status==="in_progress"&&r.active?r.active:r.text}),r.status==="in_progress"&&s.jsx("span",{className:"plan-now","aria-hidden":!0,children:a("board.detail.now")})]},r.id??`${c}:${r.text}`)),(o.before>0||o.after>0)&&s.jsx("li",{className:"recap-note-plan-more",children:[o.before>0?a("board.note.earlier",{n:o.before}):null,o.after>0?a("board.note.more",{n:o.after}):null].filter(Boolean).join(" · ")})]})]})}function Co(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function zo(e){return/mac|iphone|ipad/i.test(e)}const Gg=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function Cse(e,t,n){return{positions:Gg(e.positions),pinned:Gg(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function Sse(e,t){t.positions.clear();for(const[n,a]of Gg(e.positions))t.positions.set(n,a);t.pinned.clear();for(const[n,a]of Gg(e.pinned))t.pinned.set(n,a);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const s_=7e3,Nse=2e3,jse=140,Ase=(e=C)=>e("board.rearrange.text"),Tse=(e=C)=>e("board.rearrange.said"),i_=(e=C)=>e("board.rearrange.restored"),Rse={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function Ese(e,t=Rse){let n=null,a=null,i=0,o=s_;const r=new Set,c=()=>{a!==null&&t.clear(a),a=null},d=()=>{c(),!(n===null||r.size>0)&&(i=t.now()+o,a=t.set(()=>{a=null,u()},o))};function u(){c(),r.clear(),n!==null&&(n=null,e(!1))}return{open(p){const g=n===null;n=p,o=s_,d(),g&&e(!0)},take(){const p=n;return u(),p},close:u,hold(p){n!==null&&(r.size===0&&a!==null&&(o=Math.max(0,i-t.now()),c()),r.add(p))},release(p){!r.delete(p)||r.size>0||n===null||(o=Math.max(o,Nse),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function _se(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function qse(e){return zo(e)?"⌘Z":"Ctrl+Z"}function zse({undo:e}){const t=ae(),{open:n,said:a,undo:i,dismiss:o,hold:r,release:c}=e,d=Uc(n,jse),u=m.useRef(null);return m.useEffect(()=>n?jn.push(o,0,"popover"):void 0,[n,o]),m.useEffect(()=>{var g;if(n)return;const p=u.current;p&&p.contains(document.activeElement)&&((g=p.closest("main"))==null||g.focus({preventScroll:!0}))},[n]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:a}),mo(d)&&s.jsxs("div",{ref:u,className:d==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>r("hover"),onPointerLeave:()=>c("hover"),onFocus:()=>r("focus"),onBlur:p=>{p.currentTarget.contains(p.relatedTarget)||c("focus")},children:[s.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:Ase(t)}),s.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:i,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:[t("board.rearrange.undo"),s.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:qse(Co())})]})]})]})}function Lse({sourceX:e,sourceY:t,targetX:n,targetY:a,sourcePosition:i,targetPosition:o,style:r}){const[c]=Vj({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:a,targetPosition:o,curvature:.35});return s.jsxs("g",{className:"recap-tie",style:r,children:[s.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),s.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),s.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),s.jsx("circle",{className:"recap-tie-end",cx:n,cy:a,r:3.5})]})}function SN(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function $g(e,t){const n=SN(e);return n?n.slice(-t):e.slice(-t)}function FU(e,t,n=4){const a=SN(e);if(!a)return $g(e,n);let i=n;for(const o of t){if(o===e)continue;const r=SN(o);let c=0;for(;c<a.length&&c<r.length&&a[a.length-1-c]===r[r.length-1-c];)c++;i=Math.max(i,c+1)}return a.slice(-i)}function UU(e,t=C){const n=[e.tipWorkspace,e.planLine?t("board.cluster.plan",{plan:e.planLine}):void 0,e.tipRest||void 0].filter(Boolean).join(mr);return`${e.alarm?t("board.cluster.waitingOnYou"):""}${n}
130
130
  ${t("board.cluster.zoomTo")}
131
131
  ${t("board.cluster.dragWrapper")}`}const mr=" · ",Ose=32,Pse=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function o_(e){return Pse.test(e)?2:1}function r_(e,t=Ose){const n=[...e];let a=0;for(const r of n)a+=o_(r);if(a<=t)return e;const i=[];let o=0;for(const r of n){const c=o_(r);if(o+c>t-1)break;i.push(r),o+=c}for(;i.length&&/[\s\-_.:/]/.test(i[i.length-1]);)i.pop();return`${i.join("")}…`}function Mse(e,t,n,a,i=[],{branch:o,plan:r,alarm:c=!1}={}){const d=(t==null?void 0:t.trim())??"",u=a?FU(n,i):void 0,p=[e,d||void 0,u].filter(Boolean),g=[o,d||void 0,u].filter(Boolean).join(mr);return{label:r_(e),name:d?r_(d):void 0,shortId:u,fullLabel:p.join(mr),title:UU({alarm:c,tipWorkspace:e,tipRest:g,planLine:r}),tipWorkspace:e,tipRest:g}}const fr=18,NN=26,_A=12,bu=240,qA=130,jN=fr*2+NN+_A,Ise=72,Qc=jN+Ise,pg=24,BU=70,Vg=fr*2+pg,gl=Qc;function HU(e,t){var a;let n=bu;for(const i of e)n=Math.max(n,((a=t.get(i.id))==null?void 0:a.width)??bu);return n}const el=420,gg=300,Kg=130,WU=160,GU=1;function Dse(e,t,n,a){return Math.min(GU,n/Math.max(1,e),a/Math.max(1,t))}function Tn(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function Gm(e,t=()=>!0){const n=new Map;for(const a of e){if(!t(a))continue;const i=Tn(a),o=n.get(i);o?o.push(a):n.set(i,[a])}return n}function Fse(e,t){return((t==null?void 0:t.get(e))??0)>0?el:0}function Use(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function vu(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??bu,h:(n==null?void 0:n.height)??qA}}function Sl(e,t,n){const a=vu(e,t);return{w:a.w+Fse(e,n),h:Math.max(a.h,Use(e,n))}}function Bse(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const Hse=240,$U=16;function VU(e,t){return(e+Hse)*(t||1)}function Wse(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 Gse(e,t,n,a){return{position:"absolute",left:e.x+$U,top:e.y-_A/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:a??VU(e.w,t),"--session-hue":n}}function $se(e){const t=new Map;for(const i of e){if(i.type!=="agent"&&i.type!=="recapNote")continue;const o=i.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||i.width==null||i.height==null)continue;const r=i.position.x,c=i.position.y,d=r+i.width,u=c+i.height,p=t.get(Tn(i)),g=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:Vse(o);p?(p.minX=Math.min(p.minX,r),p.minY=Math.min(p.minY,c),p.maxX=Math.max(p.maxX,d),p.maxY=Math.max(p.maxY,u),g&&(p.label=g.label??p.label,p.name=g.name,p.alarm=g.alarm,p.branch=g.branch,p.plan=g.plan,p.planLine=g.planLine)):t.set(Tn(i),{minX:r,minY:c,maxX:d,maxY:u,label:(g==null?void 0:g.label)??o.sessionId,name:g==null?void 0:g.name,alarm:(g==null?void 0:g.alarm)??!1,branch:g==null?void 0:g.branch,plan:g==null?void 0:g.plan,planLine:g==null?void 0:g.planLine})}const n=new Map;for(const[i,o]of t){const r=n.get(o.label);r?r.push(i):n.set(o.label,[i])}const a=[];for(const[i,o]of t){const r=n.get(o.label)??[],c=r.length>1;a.push({sessionId:i,...Mse(o.label,o.name,i,c,r,{branch:o.branch,plan:o.planLine,alarm:o.alarm}),x:o.minX-fr,y:o.minY-fr-NN,w:o.maxX-o.minX+fr*2,h:o.maxY-o.minY+fr*2+NN,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null,...o.plan?{plan:o.plan,planLine:o.planLine}:null})}return a}function Vse(e){if(e.kind!=="root")return null;const t=e.branch,n=$s(e.plan);return{label:e.label,name:Om(e.sessionName,e.sessionTitle).face,alarm:Zn(e.waiting),branch:t&&t.total>0?oU(t):void 0,plan:n?`plan ${n.done}/${n.total}`:void 0,planLine:n?dA(n):void 0}}function Kse(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const a=e[n],i=t[n];if(a.sessionId!==i.sessionId||a.label!==i.label||a.name!==i.name||a.shortId!==i.shortId||a.alarm!==i.alarm||a.branch!==i.branch||a.plan!==i.plan||a.planLine!==i.planLine||a.fullLabel!==i.fullLabel||a.title!==i.title||a.x!==i.x||a.y!==i.y||a.w!==i.w||a.h!==i.h)return!1}return!0}const Jse=20,bi=4,Yse=64,Zse=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function Xse(e,t,n,a){const i=t.zoom||1,o=VU(e.w,i);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const r=(e.x+$U)*i+t.x,c=e.y*i+t.y-_A,d=c+Jse;let u=Math.min(o,n.width-bi-r),p=r<bi||c<bi||d>n.height-bi;for(const g of a)if(!(g.top-bi>=d||g.bottom+bi<=c)&&!(g.right+bi<=r)){if(g.left-bi<=r){p=!0;break}u=Math.min(u,g.left-bi-r)}return u<Yse&&(p=!0),{maxWidth:Math.max(0,u),hidden:p}}function Qse(e){const t=e.getBoundingClientRect(),n=[];for(const a of e.ownerDocument.querySelectorAll(Zse)){const i=a.getBoundingClientRect(),o=Math.max(i.left,t.left)-t.left,r=Math.max(i.top,t.top)-t.top,c=Math.min(i.right,t.right)-t.left,d=Math.min(i.bottom,t.bottom)-t.top;c-o<1||d-r<1||n.push({left:Math.round(o),top:Math.round(r),right:Math.round(c),bottom:Math.round(d)})}return n}function eie(e,t){return e.length===t.length&&e.every((n,a)=>{const i=t[a];return n.left===i.left&&n.top===i.top&&n.right===i.right&&n.bottom===i.bottom})}const tie=500;function KU({focus:e,setTimeout:t,clearTimeout:n,ms:a=tie}){let i=null;const o=()=>{i!==null&&(n(i),i=null)};return{hold(r){o(),i=t(()=>{i=null;try{e(r)}catch{}},a)},cancel:o}}function nie(e){return $se(e.nodeInternals.values())}const aie=e=>e.width,sie=e=>e.height,iie=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function oie({onFocusSession:e}){const t=ae(),{x:n,y:a,zoom:i}=VF(),o=Tt(nie,Kse),r=Tt(aie),c=Tt(sie),d={width:r,height:c},u=m.useRef(null),p=Tt(iie),[g,f]=m.useState([]);m.useLayoutEffect(()=>{var q;const A=(q=u.current)==null?void 0:q.parentElement;if(!A)return;const T=Qse(A),E=requestAnimationFrame(()=>{f(F=>eie(F,T)?F:T)});return()=>cancelAnimationFrame(E)});const v=m.useRef(e);v.current=e;const[k]=m.useState(()=>KU({focus:A=>{var T;return(T=v.current)==null?void 0:T.call(v,A)},setTimeout:(A,T)=>window.setTimeout(A,T),clearTimeout:A=>window.clearTimeout(A)}));if(m.useEffect(()=>()=>k.cancel(),[k]),o.length<=1)return null;const y=A=>{try{e==null||e(A)}catch{}},N=(A,T)=>{A.detail>0&&vl()?k.hold(T):y(T)},w={transform:`translate(${n}px, ${a}px) scale(${i})`},S=s.jsx("div",{className:"session-clusters",style:w,ref:u,children:o.map(A=>{const T=pu(A.sessionId),E=Wse(A,T);return s.jsx("div",{className:"cluster-card",style:E,"aria-hidden":!0},A.sessionId)})}),j=p&&Lt.createPortal(s.jsx("div",{className:"cluster-labels nopan",children:o.map(A=>{const T=pu(A.sessionId),E=Xse(A,{x:n,y:a,zoom:i},d,g),q=Gse(A,i,T,E.maxWidth);return s.jsxs("button",{type:"button",className:"cluster-label","data-alarm":A.alarm?"":void 0,"data-offpane":E.hidden?"":void 0,style:q,title:UU(A,t),onClick:F=>N(F,A.sessionId),children:[A.alarm?s.jsxs(s.Fragment,{children:[s.jsx(yA,{}),s.jsx("span",{className:"cluster-label-said",children:t("board.cluster.waitingOnYou")})]}):null,A.label,A.plan?s.jsx("span",{className:"cluster-label-plan",children:mr+t("board.cluster.planCount",{progress:A.plan.replace(/^plan /,"")})}):null,A.branch?s.jsx("span",{className:"cluster-label-branch",children:mr+A.branch}):null,A.name?s.jsx("span",{className:"cluster-label-name",children:mr+A.name}):null,A.shortId?s.jsx("span",{className:"cluster-label-id",children:mr+A.shortId}):null]},A.sessionId)})}),p);return s.jsxs(s.Fragment,{children:[S,j]})}function rie({data:e}){return s.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const JU=600,cie=4,lie=36,Jg=14,die=60,uie=6,c_=220,hie=96,pie=28;function gie(e,t){return Math.max(hie,61+[...t].length*6.8)}function mie(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function fie(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/JU)}function bie(e,t){const n=[],a=new Set;for(let i=e.length-1;i>=0&&n.length<t;i--){const o=e[i];a.has(o.id)||(a.add(o.id),n.push(o))}return n.reverse()}function vie(e,t,n,a,i,o){const r=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>JU)continue;const d=a.get(c.id)??n.get(c.id);if(!d)continue;const u=bie(c.tools,cie);if(u.length===0)continue;const p=c.exitAt??null,g=i.get(c.id),f=Math.max((g==null?void 0:g.width)??c_,c_),v=(g==null?void 0:g.height)??130,k=d.x,y=d.y,N=k+f,w=y+v/2;u.forEach((S,j)=>{const A=j*lie,T=k+f+die,E=y+uie+A,q=fie(o,p),F=S.inputPreview??"",z=mie(S),H=q<.999,I=kA(S.name);r.push({id:`${c.id}::${S.id}`,toolId:S.id,agentId:c.id,toolName:S.name,name:I.label,emoji:I.emoji,status:z,category:rU(S.name),mcpHue:I.hue,inputPreview:F,fade:q,fading:H,worldX:T,worldY:E,anchorX:N,anchorY:w,spawnDx:N-T,spawnDy:w-(E+Jg)});const L=uU(S.name,S.input);if(L){const O=gie(S.name,I.label),_=T+O+pie,M=E,U=T+O,G=E+Jg;r.push({id:`sub:${c.id}::${S.id}`,toolId:S.id,agentId:c.id,toolName:S.name,name:Ite(L.label,L.category),fullName:L.label,emoji:L.emoji,isSub:!0,status:z,category:L.category,inputPreview:L.detail??F,fade:q,fading:H,worldX:_,worldY:M,anchorX:U,anchorY:G,spawnDx:U-_,spawnDy:0})}})}return r}function kie({agents:e,visibleAgentIds:t,positions:n,pinned:a,measured:i,spotlight:o,hiddenCategories:r,now:c,onOpenTool:d}){const u=vie(e,t,n,a,i,c),p=r&&r.size>0?u.filter(g=>!r.has(g.category)):u;return s.jsx(wie,{bursts:p,spotlight:o,onOpenTool:d})}function wie({bursts:e,spotlight:t,onOpenTool:n}){const a=e.map(o=>{const r=o.anchorX,c=o.anchorY,d=o.worldX+6,u=o.worldY+Jg,p=Math.max(1,d-r),g=Math.min(1,Math.abs(u-c)/p),f=r+p*(.55-.22*g),v=c+(u-c)*.12,k=d-p*.25,y=t!=null&&!t.has(o.agentId),N=o.fade*(y?.14:1);return s.jsx("path",{d:`M ${r} ${c} C ${f} ${v}, ${k} ${u}, ${d} ${u}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:N,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),i=e.map(o=>s.jsx(Cie,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return s.jsx(yie,{connectors:a,bubbles:i})}function yie({connectors:e,bubbles:t}){const{x:n,y:a,zoom:i}=VF();return s.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*Jg}px`},children:[s.jsx("svg",{className:"tool-bursts-svg",children:s.jsx("g",{transform:`translate(${n} ${a}) scale(${i})`,children:e})}),s.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${a}px) scale(${i})`},children:t})]})}function xie(e,t){const n=e.b,a=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===a.id&&n.toolId===a.toolId&&n.worldX===a.worldX&&n.worldY===a.worldY&&n.spawnDx===a.spawnDx&&n.spawnDy===a.spawnDy&&n.status===a.status&&n.fading===a.fading&&n.category===a.category&&n.mcpHue===a.mcpHue&&n.isSub===a.isSub&&n.emoji===a.emoji&&n.name===a.name&&n.fullName===a.fullName&&n.toolName===a.toolName&&n.inputPreview===a.inputPreview}const Cie=m.memo(function({b:t,dim:n,onOpenTool:a}){const i={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,r=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=a!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},u=n?" dim":"";return s.jsx("div",{className:"tool-burst-wrap",style:i,children:s.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${u}`,style:d,title:r,onClick:c?()=>a(t.agentId,t.toolId):void 0,children:[s.jsx("span",{className:"tb-emoji",children:t.emoji}),s.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&s.jsx("span",{className:"tb-spin"}),t.status==="done"&&s.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&s.jsx("span",{className:"tb-mark err",children:"×"})]})})},xie),Sie={width:140,height:105},Nie={agent:dne,sessionGroup:rie,recapNote:yse},jie={recapTie:Lse},l_=400;function Aie({graph:e,layout:t,viewport:n,clicks:a,drag:i,appearance:o,fm:r,radioOpen:c,onRadioClose:d,autoFit:u,pause:p,stateRef:g,measuredRef:f,hiddenCats:v,now:k,openTool:y,focusAgent:N,requestClear:w,setKeyHelpOpen:S}){const j=ae(),{allNodes:A,edges:T,visibleAgentIds:E,spotlightSet:q}=e,{positionsRef:F,pinnedRef:z,handleRelayout:H,rearrangeUndo:I}=t,{restoredViewport:L,onMoveStart:O,onMove:_}=n,{onNodeClick:M,onPaneClick:U,onNodeDoubleClick:G,onNodeMouseEnter:W,onNodeMouseLeave:$}=a,{onNodeDragStart:Y,onNodeDrag:B,onNodeDragStop:V}=i,{palette:Z,minimapNodeFill:D,characterEnabled:K}=o,{autoFitDisabled:X,enableAutoFitAndRefit:Q}=u,{paused:ee,pauseGate:ne,togglePause:de}=p;return s.jsxs($F,{nodes:A,edges:T,nodeTypes:Nie,edgesFocusable:!1,edgeTypes:jie,fitView:!L,fitViewOptions:{padding:.25,duration:cN({durationMs:l_,documentHidden:document.hidden})?l_:0},minZoom:XF,maxZoom:QF,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:M,onPaneClick:U,onNodeDoubleClick:G,onNodeMouseEnter:W,onNodeMouseLeave:$,onMoveStart:O,onMove:_,onNodeDragStart:(ge,le,he)=>{I.dismiss(),Y(ge,le,he)},onNodeDrag:B,onNodeDragStop:V,children:[s.jsx(f8,{gap:28,size:1,color:Z["--grid-line"]}),s.jsx(oie,{onFocusSession:N}),s.jsx(kie,{agents:g.current.agents,visibleAgentIds:E,positions:F.current,pinned:z.current,measured:f.current,spotlight:q,hiddenCategories:v,now:k,onOpenTool:y}),s.jsxs("div",{className:"canvas-notices",children:[X&&s.jsx(vne,{enableAutoFitAndRefit:Q}),s.jsx(zse,{undo:I})]}),s.jsx(Ene,{autoFitDisabled:X,enableAutoFitAndRefit:Q,paused:ee,pauseGate:ne,togglePause:de,handleRelayout:H,requestClear:w,setKeyHelpOpen:S}),s.jsx(a8,{ariaLabel:j("board.minimap"),style:Sie,zoomable:!0,pannable:!0,nodeColor:D,nodeStrokeWidth:2,maskColor:Z["--minimap-mask"],maskStrokeColor:Z["--line"]}),s.jsx(wse,{fm:r,character:o.character,characterEnabled:K,open:c,onClose:d})]})}function Tie(){const e=ae(),t=window.ccdeckWindow;return m.useEffect(()=>{if(!t)return;const n=()=>{const i=document.querySelector(".topbar");if(!i)return;const o=getComputedStyle(i),r=c=>{var u;const d=(u=c.match(/\d+/g))==null?void 0:u.slice(0,3);return(d==null?void 0:d.length)===3?`#${d.map(p=>Number(p).toString(16).padStart(2,"0")).join("")}`:"#191a1c"};t.colors({color:r(o.backgroundColor),symbolColor:r(o.color)}).catch(()=>{})};n();const a=new MutationObserver(n);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>a.disconnect()},[t]),!t||t.platform==="darwin"?null:s.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":e("shell.appMenu"),title:e("shell.appMenu"),"aria-haspopup":"menu",onClick:()=>{t.menu().catch(()=>{})},children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})})}const Rie=600;function $m(e,t){return!(e.exitAt!=null&&t-e.exitAt>Rie||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3&&!e.stopFailure)}function Eie(e,t){const n=new Set;for(const a of e.agents.values())$m(a,t)&&n.add(a.id);return n}function _ie(e,t,n=0){return e.right+n>t.left&&e.left-n<t.right&&e.bottom+n>t.top&&e.top-n<t.bottom}function qie(e,t,n=0){if(!e)return!1;for(const a of t)if(_ie(e,a,n))return!0;return!1}function d_(e){return e.waiting?Zn(e.waiting)?0:1:e.state==="active"?2:3}function YU(e,t){var a;const n=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,r=fa(i).total,c=i.endedAt??i.startedAt;for(const g of e.agents.values()){if(g.sessionId!==i.sessionId||g.kind==="root")continue;o+=g.toolCount,r+=fa(g).total;const f=g.endedAt??g.startedAt;f>c&&(c=f)}const d=bA(i),u=(d==null?void 0:d.kind)==="recap"?{text:d.text,at:d.at}:null,p=d&&d.kind!=="recap"?d:null;n.push({sessionId:i.sessionId,label:i.label||i.cwdBasename||C("board.kind.session"),cwdBasename:i.cwdBasename,state:Zc(i),waiting:i.waiting,recap:u,status:p,modelId:i.model,effort:i.effort,plan:$s(i.plan),planTitle:Am(((a=i.plan)==null?void 0:a.items)??[]),toolCount:o,cost:r,startedAt:i.startedAt,lastActivity:c})}return n.sort((i,o)=>{const r=d_(i),c=d_(o);return r!==c?r-c:i.waiting&&o.waiting?i.waiting.since-o.waiting.since:o.lastActivity-i.lastActivity}),n}function zie(e,t){return[e.text,e.reply?t("board.list.suggestedReply",{reply:e.reply}):"",Dm(e)].filter(Boolean).join(`
132
132
  `)}function ku(e,t,n){const a=(t??n)-e;if(a<1e3)return"<1s";const i=Math.floor(a/1e3);if(i<60)return`${i}s`;const o=Math.floor(i/60);return o<60?`${o}m`:`${Math.floor(o/60)}h ${o%60}m`}function Lie({state:e,now:t,selectedIds:n,onSelect:a,onClose:i,removedIds:o,onBringBackAll:r,leaving:c=!1}){const d=ae(),u=Ea(),p=Qn(),g=m.useMemo(()=>YU(e),[e,e.revision,t]),f=g.filter(k=>k.state==="active").length,v=g.filter(k=>Zn(k.waiting)).length;return s.jsxs("aside",{className:`session-list${c?" leaving":""}`,id:"session-list","aria-label":d("board.list.title"),children:[s.jsxs("div",{className:"sl-header",children:[s.jsxs("h2",{children:[d("board.list.title")," ",s.jsx("span",{className:"sl-count",children:g.length})]}),v>0&&s.jsx("span",{className:"sl-waiting-count",children:d("board.list.waitingCount",{n:v})}),f>0&&s.jsx("span",{className:"sl-live-count",children:d("board.list.liveCount",{n:f})}),s.jsx("button",{className:"glyph-btn sl-close",onClick:i,title:Yn(d("board.list.hideSidebar"),"L",p),"aria-label":d("board.list.hide"),children:"‹"})]}),s.jsxs("ul",{className:"sl-rows",children:[g.length===0&&s.jsx("li",{className:"sl-empty",children:d("board.list.empty")}),g.map(k=>{var w;const y=n.has(k.sessionId),N=(o==null?void 0:o.has(k.sessionId))??!1;return s.jsx("li",{className:"sl-row-item",children:s.jsxs("button",{type:"button",className:`sl-row state-${k.state}${y?" selected":""}${N?" removed":""}`,"aria-current":y?"true":void 0,onClick:()=>a(k.sessionId),title:N?d("board.list.bring",{label:k.label}):d("board.list.focus",{label:k.label}),children:[s.jsx("span",{className:`sl-dot state-${k.state}`,"aria-hidden":!0}),s.jsx("span",{className:"vis-hidden",children:yo(k.state,d)}),s.jsxs("div",{className:"sl-row-body",children:[s.jsxs("div",{className:"sl-row-head",children:[s.jsx("span",{className:"sl-label",children:k.label}),N&&s.jsx("span",{className:"sl-removed",children:d("board.list.offBoard")}),k.modelId&&s.jsx("span",{className:"model-chip","data-family":_m(k.modelId),title:mu(k.modelId,k.effort),children:qm(k.modelId,k.effort)})]}),s.jsxs("div",{className:"sl-row-meta",children:[s.jsxs("span",{title:d("board.list.toolCalls"),children:[s.jsx("b",{children:k.toolCount})," ",d("board.meta.tools",{count:k.toolCount})]}),k.cost>0&&s.jsx("span",{className:"sl-cost",title:d("insights.board.sessionSpend"),children:s.jsx("b",{children:At(k.cost)})}),k.waiting?s.jsxs("span",{className:"sl-waiting",title:[dl(k.waiting,d),$2(k.waiting,dl(k.waiting,d),d),d(Zn(k.waiting)?"board.list.blockedSince":"board.list.turnSince",{since:new Date(k.waiting.since).toLocaleTimeString(u),started:new Date(k.startedAt).toLocaleString(u)})].filter(Boolean).join(`
@@ -148,11 +148,11 @@ ${Am(e.plan.items)}`]}),s.jsx("p",{className:"node-peek-hint",children:a("insigh
148
148
  ${c("board.detail.modelCovers")}
149
149
  ${j.join(`
150
150
  `)}`:mu(e.model,e.effort),children:[qm(e.model,e.effort),j.length>0?` +${j.length}`:""]})]})})()]}),g&&s.jsxs("div",{className:"hero-cost",children:[s.jsxs("div",{className:"hero-cost-headline",children:[s.jsx("span",{className:"hero-cost-value",children:At(p.total)}),s.jsx("span",{className:"hero-cost-label",children:c("board.detail.spend")})]}),s.jsx(KA,{cost:p})]}),s.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&a&&s.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>a(e.sessionId),title:c("board.detail.recapTitle"),children:c("board.detail.recap")}),i&&s.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>i(e.sessionId),title:c("board.detail.exportTitle"),children:c("board.detail.export")}),o&&s.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:o,title:e.kind==="root"?c("board.detail.removeRoot",{list:Yn(c("board.detail.listLower"),"L",r)}):c("board.detail.removeSub",{list:Yn(c("board.detail.listUpper"),"L",r)}),children:c("board.detail.remove")})]})]}),s.jsx(cne,{agent:e}),(()=>{const j=bA(e);if(!j)return null;const A=Fg(j.at,t),T=j.kind==="recap"?c("board.detail.recapHeading"):Cl(j.kind).replace(/^./,E=>E.toUpperCase());return s.jsxs("section",{className:"detail-section",children:[s.jsxs("h3",{children:[T," ",s.jsx("span",{className:"section-count",title:A.title,children:A.label})]}),s.jsx("p",{className:"detail-recap",title:Dm(j),children:j.text}),j.reply&&s.jsx("p",{className:"detail-recap detail-note-reply",children:c("board.detail.suggestedReply",{reply:j.reply})})]})})(),(()=>{const j=$s(e.plan);return!j||!e.plan?null:s.jsxs("section",{className:"detail-section",children:[s.jsxs("h3",{children:[c("board.detail.plan")," ",s.jsxs("span",{className:"section-count","aria-hidden":!0,children:[j.done,"/",j.total]}),s.jsx("span",{className:"vis-hidden",children:c("board.detail.planDone",{done:j.done,total:j.total})})]}),e.plan.note&&s.jsx("p",{className:"detail-plan-note",children:e.plan.note}),s.jsx("ol",{className:"plan-list",children:e.plan.items.map((A,T)=>s.jsxs("li",{className:"plan-item","data-status":A.status,children:[s.jsx("span",{className:"plan-mark","aria-hidden":!0}),s.jsxs("span",{className:"vis-hidden",children:[c(ICe[A.status]),c("board.detail.colon")]}),s.jsx("span",{className:"plan-text",children:A.status==="in_progress"&&A.active?A.active:A.text}),A.status==="in_progress"&&s.jsx("span",{className:"plan-now","aria-hidden":!0,children:c("board.detail.now")})]},A.id??`${T}:${A.text}`))})]})})(),e.tools.length>0&&s.jsxs("section",{className:"detail-section",children:[s.jsx("h3",{children:c("board.detail.activity")}),s.jsxs("div",{className:"activity-row",children:[s.jsxs("div",{className:"activity-counters",children:[s.jsxs("span",{className:"ac-item",children:[s.jsx("b",{children:e.toolCount})," ",c("board.detail.calls")]}),y>0&&s.jsxs("span",{className:"ac-item ac-live",children:[s.jsx("b",{children:y})," ",c("board.state.live")]}),k>0&&s.jsxs("span",{className:"ac-item ac-err",children:[s.jsx("b",{children:k})," ",c("board.meta.err")]})]}),s.jsx("div",{className:"cat-strip",children:N.map(([j,A])=>{const T=j==="mcp"?w:null,E=T==null?void 0:T.hue,q=c("board.detail.catCalls",{count:A,cat:Mg(j,c)});return s.jsxs("span",{className:`cat-chip cat-${j}${E!=null?" mcp-hue":""}`,style:E!=null?{"--mcp-hue":E}:void 0,title:T?c("board.detail.catAllTo",{calls:q,server:T.label}):q,children:[s.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:cW[j]}),s.jsx("span",{className:"cat-name",children:Mg(j,c)}),s.jsx("span",{className:"cat-count",children:A}),T&&s.jsx("span",{className:"cat-server",children:T.label})]},j)})})]})]}),f>0&&s.jsxs("section",{className:"detail-section",children:[s.jsx("h3",{children:c("board.detail.tokens")}),s.jsxs("div",{className:"tokens-grid",children:[s.jsxs("div",{children:[s.jsx("span",{className:"k",children:c("board.tokens.in")}),s.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:Ft(e.usage.inputTokens)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"k",children:c("board.tokens.out")}),s.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:Ft(e.usage.outputTokens)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"k",children:c("board.tokens.cacheR")}),s.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:Ft(e.usage.cacheReadTokens)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"k",children:c("board.tokens.cacheC")}),s.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:Ft(e.usage.cacheCreateTokens)})]})]})]}),s.jsxs("section",{className:"detail-section",children:[s.jsx("h3",{children:c("board.detail.identity")}),s.jsxs("div",{children:[e.cwd&&s.jsxs("div",{className:"row",children:[s.jsx("span",{className:"k",children:"cwd"}),s.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),s.jsxs("div",{className:"row",children:[s.jsx("span",{className:"k",children:c("board.kind.session")}),s.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&s.jsxs("div",{className:"row",children:[s.jsx("span",{className:"k",children:c("board.detail.parent")}),s.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&s.jsxs("section",{className:"detail-section",children:[s.jsxs("h3",{children:[c("board.detail.prompts")," ",s.jsx("span",{className:"section-count",children:g2(e.prompts).length})]}),s.jsx("div",{className:"prompts",children:OCe(e.prompts).reverse().map(({pr:j,key:A})=>{const T=Fg(j.at,t),E=jm(j.text);return E?s.jsxs("details",{className:"prompt-entry prompt-injected",children:[s.jsxs("summary",{children:[s.jsx("span",{className:"prompt-time",title:T.title,children:T.label}),s.jsx("span",{className:"prompt-injected-label",children:E.label})]}),E.detail&&s.jsx("div",{className:"prompt-injected-detail",children:E.detail})]},A):s.jsxs("div",{className:"prompt-entry",children:[s.jsx("div",{className:"prompt-time",title:T.title,children:T.label}),s.jsx("div",{className:"prompt-text",children:j.text})]},A)})})]}),s.jsxs("section",{className:"detail-section",children:[s.jsxs("h3",{children:[c("board.detail.toolCalls")," ",s.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&s.jsx("div",{className:"empty",children:c("board.detail.noTools")}),s.jsx("div",{children:e.tools.slice().reverse().map(j=>s.jsx(MCe,{call:j,onClick:()=>n(e.id,j.id)},j.id))})]})]})}function OCe(e){const t=new Map;return e.map(n=>{const a=t.get(n.at)??0;return t.set(n.at,a+1),{pr:n,key:a===0?String(n.at):`${n.at}:${a}`}})}const PCe={inflight:"board.toolStatus.inflight",done:"board.toolStatus.done",err:"board.toolStatus.err"};function MCe({call:e,onClick:t}){const n=ae(),a=e.endedAt==null?"inflight":e.ok===!1?"err":"done",i=V2(e,"…");return s.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[s.jsxs("span",{className:"name",children:[s.jsx("span",{className:`status-dot ${a}`,"aria-hidden":!0}),s.jsx("span",{className:"vis-hidden",children:n(PCe[a])}),e.name]}),s.jsx("span",{style:{color:"var(--muted)"},children:i})]})}const ICe={completed:"board.state.done",in_progress:"board.detail.now",pending:"board.detail.todo"};function DCe(e,t){const n=ECe(e,t,new Date().toISOString());if(!n)return;const a=JSON.stringify(n,null,2),i=new Blob([a],{type:"application/json"}),o=URL.createObjectURL(i),r=document.createElement("a");r.href=o,r.download=_Ce(n.label,t),document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function FCe({selected:e,now:t,openTool:n,setSummaryFor:a,onClose:i,stateRef:o,removeSelectedNode:r}){const c=ae();An("detail-panel");const d=Qn();return s.jsxs("aside",{className:"detail","aria-label":c("board.detailPanel.title"),children:[s.jsx("button",{type:"button",className:"glyph-btn detail-close",title:c("board.detailPanel.close"),"aria-label":c("board.detailPanel.closeLabel"),onClick:i,children:"×"}),s.jsx(LCe,{agent:e,now:t,onOpenTool:n,onShowSummary:a,onExportSession:u=>DCe(o.current,u),onRemove:r,singleKeys:d})]})}const UCe={"Boards, sprints, and issues":"integrations.provider.jira.detail","Jira Cloud, or Jira Server / Data Center 8.14 and newer.":"integrations.provider.jira.blurb","Repositories, pull requests, and Actions":"integrations.provider.github.detail","github.com, read-only, with a personal access token.":"integrations.provider.github.blurb","Projects, merge requests, and pipelines":"integrations.provider.gitlab.detail","GitLab.com or your own instance, read-only.":"integrations.provider.gitlab.blurb","Which Jira":"integrations.field.whichJira","Jira URL":"integrations.field.jiraUrl","The address you open Jira at, with its path if it has one (…/jira). https only.":"integrations.field.jiraUrlHint","Site URL":"integrations.field.siteUrl","The address you open Jira at. Your site name alone is enough.":"integrations.field.siteUrlHint","Atlassian account email":"integrations.field.email","Personal access token":"integrations.field.pat","API token":"integrations.field.apiToken","Paste the token":"integrations.field.pasteToken","Paste the API token":"integrations.field.pasteApiToken","Which GitLab":"integrations.field.whichGitlab","Self-managed":"integrations.field.selfManaged","GitLab URL":"integrations.field.gitlabUrl","The address you open GitLab at, with its path if it has one. https only.":"integrations.field.gitlabUrlHint"};function Hd(e,t){const n=t===void 0?void 0:UCe[t];return n?e(n):t}function BCe(e,t,n=C){const a=n(e?"board.rail.watch.on":"board.rail.watch.off");return t>0?`${a}
151
- ${n("board.rail.unreadCount",{n:t})}`:a}function ng(e,t){return t.map(n=>({...n,group:e}))}function HCe({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:a,toggleAccountsPanel:i,accountsPanelId:o="accounts-panel",codexPanelOpen:r=!1,toggleCodexPanel:c=()=>{},usagePanelOpen:d,setUsagePanelOpen:u,machinePanelOpen:p,setMachinePanelOpen:g,setUsageHistoryOpen:f,watchOn:v,watchUnseen:k,setBrowserWatchOpen:y,setTrafficRadarOpen:N,setRadioOpen:w,openToolActivity:S,openSettings:j,onFeedback:A,toggles:T,openCapacity:E,integrations:q=[],openExploreIntegrations:F,openQuickOpen:z}){const H=Goe(Co()),I=zo(Co()),L={id:"session-list",label:C("board.rail.sessionList"),short:C("board.rail.sessionList.short"),key:{cap:"L",aria:"L",single:!0},ariaLabel:C("board.rail.sessionList"),glyph:s.jsx(nB,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:T.sessionList},O={id:"accounts",label:C("board.rail.accounts"),short:C("board.rail.accounts"),key:{cap:"A",aria:"A",single:!0},ariaLabel:C("board.rail.accounts"),hint:e.codex?void 0:C("board.rail.accounts.hint"),glyph:s.jsx(aB,{}),kind:"panel",open:a,controls:o,onPress:i,buttonRef:T.accounts},_=E?[{id:"account-capacity",label:C("board.rail.capacity"),short:C("board.rail.capacity.short"),ariaLabel:C("board.rail.capacity"),detail:C("board.rail.capacity.detail"),glyph:s.jsx(aoe,{}),kind:"dialog",onPress:()=>E("accounts")},{id:"reset-calendar",label:C("board.rail.calendar"),short:C("board.rail.calendar.short"),ariaLabel:C("board.rail.calendar"),detail:C("board.rail.calendar.detail"),glyph:s.jsx(soe,{}),kind:"dialog",onPress:()=>E("calendar")}]:[],M={id:"codex-accounts",label:"Codex accounts",short:"Codex",ariaLabel:"Codex accounts",glyph:s.jsx(poe,{}),kind:"panel",open:r,controls:"codex-accounts-panel",onPress:c,buttonRef:T.codex},U={id:"usage",label:C("board.rail.usage"),short:C("board.rail.usage"),key:{cap:"U",aria:"U",single:!0},ariaLabel:C("board.rail.usage"),glyph:s.jsx(Gie,{}),kind:"panel",open:d,controls:"usage-panel",onPress:()=>u(X=>!X),buttonRef:T.usage},G={id:"machine",label:C("board.rail.machine"),short:C("board.rail.machine"),key:{cap:"S",aria:"S",single:!0},ariaLabel:C("board.rail.machine"),hint:C("board.rail.machine.hint"),glyph:s.jsx(Vie,{}),kind:"panel",open:p,controls:"system-panel",onPress:()=>g(X=>!X),buttonRef:T.machine},W={id:"history",label:C("board.rail.history"),short:C("board.rail.history.short"),key:{cap:"H",aria:"H",single:!0},ariaLabel:C("board.rail.history"),glyph:s.jsx($ie,{}),kind:"dialog",onPress:()=>f(X=>!X)},$={id:"browser-watch",label:C("board.rail.browserWatch"),short:C("board.rail.browserWatch.short"),key:{cap:"B",aria:"B",single:!0},ariaLabel:`${C("board.rail.browserWatch")}${C("board.listSep")}${C(v?"board.rail.watching":"board.rail.notWatching")}${k>0?`${C("board.listSep")}${C("board.rail.unreadCount",{n:k})}`:""}`,detail:BCe(v,k,C),glyph:s.jsx(Jie,{watching:v===!0||k>0}),kind:"dialog",onPress:()=>y(X=>!X),badge:k},Y={id:"settings",label:C("board.rail.settings"),short:C("board.rail.settings.short"),key:{cap:H,aria:"Control+, Meta+,",single:!1},ariaLabel:C("board.rail.settings"),glyph:s.jsx(Yie,{}),kind:"dialog",onPress:()=>j()},B={id:"quick-open",label:C("board.rail.search"),short:C("board.rail.search"),key:{cap:Hie(I),aria:I?"Meta+K":"Control+K",single:!1},ariaLabel:C("board.rail.search"),detail:C("board.rail.search.detail"),glyph:s.jsx(iB,{}),kind:"dialog",onPress:z},V={id:"feedback",label:C("board.rail.feedback"),short:C("board.rail.feedback"),menu:C("board.rail.feedback.menu"),ariaLabel:C("board.rail.feedback.menu"),glyph:s.jsx(Zie,{}),kind:"dialog",onPress:A},Z=S?[{id:"tool-activity",label:C("board.rail.tools.activity"),short:C("board.rail.tools.short"),ariaLabel:C("board.rail.tools.activity"),glyph:s.jsx(noe,{}),kind:"dialog",detail:C("board.rail.tools.detail"),onPress:()=>S("tools")},{id:"skill-activity",label:C("board.rail.skills"),short:C("board.rail.skills.short"),ariaLabel:C("board.rail.skills"),glyph:s.jsx(sB,{}),kind:"dialog",detail:C("board.rail.skills.detail"),onPress:()=>S("skills")}]:[],D=N?[{id:"traffic-radar",label:C("board.rail.radar"),short:C("board.rail.radar.short"),ariaLabel:C("board.rail.radar"),glyph:s.jsx(Kie,{}),kind:"dialog",detail:C("board.rail.radar.detail"),onPress:()=>N(!0)}]:[],K=w?[{id:"radio",label:C("board.rail.radio"),short:C("board.rail.radio"),ariaLabel:C("board.rail.radio"),glyph:s.jsx(toe,{}),kind:"dialog",detail:C("board.rail.radio.detail"),onPress:()=>w(!0)}]:[];return{left:e.claude?[O,L]:e.codex?[M,L]:[L],codexDoor:e.claude&&e.codex?[M]:[],leftStripe:[...e.claude?[ng(e.codex?C("board.rail.accounts"):C("board.rail.group.accounts"),[O,..._])]:[],...e.codex&&!e.claude?[[M]]:[],[L]],capacity:e.claude?_:[],right:[ng(C("board.rail.group.usage"),[U,G]),ng(C("board.rail.group.activity"),[W,...Z]),ng(C("board.rail.group.watchers"),[$,...D]),K].filter(X=>X.length>0),utilities:[Y,V],search:B,explore:F?[{id:"explore-integrations",label:C("board.rail.explore"),short:C("board.rail.explore.short"),ariaLabel:C("board.rail.explore"),glyph:s.jsx(Wie,{}),kind:"dialog",onPress:F}]:[],integrations:q.map(({provider:X,onPress:Q})=>({id:`integration-${X.kind}`,label:X.label,short:X.label,ariaLabel:X.label,detail:Hd(C,X.detail),key:X.shortcut?{cap:X.shortcut.toUpperCase(),aria:X.shortcut.toUpperCase(),single:!0}:void 0,glyph:s.jsx(X.Glyph,{}),kind:"dialog",onPress:Q}))}}function ag(e,t){return e.split(/\{(\w+)\}/).map((a,i)=>i%2===0?a:s.jsx(m.Fragment,{children:a in t?t[a]:`{${a}}`},i))}const um=[{value:"bug",get label(){return C("shell.feedback.kind.bug")},get question(){return C("shell.feedback.q.bug")},get placeholder(){return C("shell.feedback.ph.bug")}},{value:"idea",get label(){return C("shell.feedback.kind.idea")},get question(){return C("shell.feedback.q.idea")},get placeholder(){return C("shell.feedback.ph.idea")}},{value:"other",get label(){return C("shell.feedback.kind.other")},get question(){return C("shell.feedback.q.other")},get placeholder(){return C("shell.feedback.ph.other")}}];function dW(e){return um.find(t=>t.value===e)??um[0]}const wj=3,ES=120,uW=1e4,hW=200,WCe=()=>C("shell.feedback.missing");function RI(e){return e.trim()!==""}function GCe(e){var o;const t=e.trim();if(t==="")return"";const n=EI(t.split(/\r?\n/,1)[0]),a=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,i=_S(a).length>=wj?_S(a):_S(n);return VCe(i.length>=wj?i:EI(t))}function $Ce(e,t){const n=GCe(t);return n.length>=wj?n:C("shell.feedback.titleKind",{kind:dW(e).label,text:n})}function EI(e){return e.replace(/\s+/g," ").trim()}function _S(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function VCe(e){if(e.length<=ES)return e;const t=e.slice(0,ES-1),n=t.lastIndexOf(" ");return`${(n>=ES/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function KCe({kind:e,body:t,contact:n}){const a={kind:e,title:$Ce(e,t),body:t.trim()};return n.trim()!==""&&(a.contact=n.trim()),a}function JCe(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 YCe={darwin:"macOS",win32:"Windows",linux:"Linux"};function ZCe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),a=t===-1?"":e.slice(t+1),i=YCe[n]??n;return a?`${i} · ${a}`:i}function XCe(e){return e?`ccdeck ${e.appVersion} · ${ZCe(e.platform)}`:null}const QCe=()=>C("shell.feedback.factsWith"),eSe=()=>C("shell.feedback.factsUnknown"),tSe=()=>C("shell.feedback.addDetails"),nSe=()=>C("shell.feedback.contact"),aSe=()=>C("shell.feedback.contactPh"),sSe=()=>C("shell.feedback.contactHint"),iSe=()=>[C("shell.feedback.where1"),C("shell.feedback.where2")];function oSe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function GT(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function rSe(e){return zo(e)?["⌘","Enter"]:["Ctrl","Enter"]}function cSe(e){return[...e].length===1}const pW=()=>C("shell.feedback.sent");function lSe(e){const t=/^At most (\d+) images\.$/.exec(e);if(t)return C("shell.feedback.problem.count",{n:t[1]});const n=/^Image (\d+) is over (\d+) MB\.$/.exec(e);if(n)return C("shell.feedback.problem.size",{n:n[1],mb:n[2]});const a=/^Image (\d+) is not a PNG or a JPEG\.$/.exec(e);return a?C("shell.feedback.problem.format",{n:a[1]}):e}function _I(e,t,n){if(t==="vetoed")return C("shell.feedback.fail.vetoed");if(e===429||t==="too_many")return C("shell.feedback.fail.tooMany");if(e===413||t==="too_large")return C("shell.feedback.fail.tooLarge");const a=n==null?void 0:n.images;return e===400&&Array.isArray(a)&&typeof a[0]=="string"?C("shell.feedback.fail.image",{reason:lSe(a[0])}):C(e===400?"shell.feedback.fail.rejected":"shell.feedback.fail.unreachable")}function dSe(e){return e==="sending"?C("shell.feedback.sending"):e==="sent"?pW():""}const qI=1400,uSe=160,gW=m.createContext({values:{}});function mW(){return m.useContext(gW)}function hSe(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const zI=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function pSe({def:e,existing:t,busy:n,error:a,onSubmit:i,onCancel:o,onDirtyChange:r}){var _,M;const c=ae(),d=m.useId(),[u,p]=m.useState(()=>Object.fromEntries(e.fields.map(U=>{var G,W,$;return[U.name,U.secret?"":((G=U.initial)==null?void 0:G.call(U,t))??(U.type==="choice"?(($=(W=U.options)==null?void 0:W[0])==null?void 0:$.value)??"":"")]}))),[g,f]=m.useState((t==null?void 0:t.name)??""),v=m.useRef(null),k=m.useRef(new Map),y=!!t,N=m.useRef(u),w=m.useRef(g);m.useEffect(()=>{r==null||r(g!==w.current||Object.keys(u).some(U=>u[U]!==N.current[U]))},[g,u,r]);const S=e.fields.filter(U=>U.type==="choice").every(U=>u[U.name]===N.current[U.name]),j=y&&t.tokenSaved&&S,A=(U,G)=>{n||p(W=>({...W,[U]:G}))},T=U=>{var W;if(U.preventDefault(),n)return;const G={};for(const $ of e.fields)zI($,u)&&(G[$.name]=(u[$.name]??"").trim());(W=U.currentTarget.querySelector('button[type="submit"]'))==null||W.focus(),i(G,g.trim()),p($=>Object.fromEntries(Object.entries($).map(([Y,B])=>{var V;return[Y,(V=e.fields.find(Z=>Z.name===Y))!=null&&V.secret?"":B]})))},E=m.useMemo(()=>{const U=u.baseUrl??"";try{return U?new URL(/^[a-z]+:\/\//i.test(U)?U:`https://${U}`).host:""}catch{return""}},[u.baseUrl]),q=m.useMemo(()=>({values:u,existing:t}),[u,t]),F=e.fields.filter(U=>zI(U,u)),z=(_=F.find(U=>!U.secret&&U.type!=="choice"))==null?void 0:_.name,H=(M=F.find(U=>U.secret))==null?void 0:M.name,I=a!=null&&a.field&&F.some(U=>U.name===a.field&&U.type!=="choice")?a.field:null,L=`${d}-error`;m.useEffect(()=>{var G,W,$;const U=y?H:z??H;U&&((G=k.current.get(U))==null||G.focus()),($=(W=v.current)==null?void 0:W.scrollIntoView)==null||$.call(W,{block:"nearest"})},[y]),m.useEffect(()=>{var U;I&&((U=k.current.get(I))==null||U.focus())},[a,I]);const O=a&&s.jsxs(s.Fragment,{children:[a.message,a.detail&&s.jsxs("span",{className:"ig-form-detail",children:[" ",c("integrations.failure.said",{provider:e.label,said:a.detail})]}),a.kind==="rate-limit"&&a.retryAfter?s.jsxs("span",{children:[" ",c("integrations.form.retryIn",{n:a.retryAfter})]}):null]});return s.jsx(gW.Provider,{value:q,children:s.jsxs("form",{ref:v,className:"ig-form",onSubmit:T,"aria-labelledby":`${d}-title`,noValidate:!0,children:[s.jsxs("header",{className:"ig-managed-header",children:[s.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:s.jsx(e.Glyph,{})}),s.jsxs("div",{className:"ig-managed-identity",children:[s.jsx("h2",{className:"ig-form-title",id:`${d}-title`,children:y?c("integrations.form.edit",{name:t.name}):c("integrations.form.connect",{provider:e.label})}),y&&s.jsx("p",{children:c("integrations.form.connectionOf",{provider:e.label})})]})]}),F.map(U=>{const G=hSe(U,u),W={...G,label:Hd(c,G.label),hint:Hd(c,G.hint),placeholder:Hd(c,G.placeholder)},$=(a==null?void 0:a.field)===W.name,Y=[W.hint?`${d}-${W.name}-hint`:"",$?L:""].filter(Boolean).join(" ")||void 0;if(W.type==="choice")return s.jsxs("fieldset",{className:"fb-kinds","aria-invalid":$||void 0,children:[s.jsx("legend",{className:"vis-hidden",children:W.label}),(W.options??[]).map(Z=>s.jsxs("label",{className:"fb-kind",children:[s.jsx("input",{type:"radio",name:`${d}-${W.name}`,value:Z.value,checked:u[W.name]===Z.value,"aria-disabled":n||void 0,onChange:()=>A(W.name,Z.value),onKeyDown:D=>{GT(D.nativeEvent)&&D.preventDefault()}}),Hd(c,Z.label)]},Z.value))]},W.name);const B=W.secret&&j,V=`${d}-${W.name}`;return s.jsxs("div",{className:"fb-field",children:[s.jsxs("label",{className:"fb-field-label",htmlFor:V,children:[W.label,W.optional&&s.jsxs("span",{className:"fb-optional",children:[" ",c("integrations.form.optional")]})]}),s.jsx("input",{id:V,className:`ap-manage-input ig-input${W.secret?" ig-mono":""}`,ref:Z=>{Z?k.current.set(W.name,Z):k.current.delete(W.name)},type:W.type,inputMode:W.type==="url"?"url":W.type==="email"?"email":void 0,autoComplete:W.autoComplete??"off",spellCheck:!1,value:u[W.name]??"",onChange:Z=>A(W.name,Z.target.value),placeholder:B?c("integrations.form.keepSaved"):W.placeholder,readOnly:n,"aria-invalid":$||void 0,"aria-describedby":Y,"aria-required":!W.optional&&!B||void 0}),W.hint&&s.jsx("span",{className:"ig-hint",id:`${d}-${W.name}-hint`,children:W.hint}),$&&I===W.name&&s.jsx("span",{className:"ig-form-error",id:L,role:"alert",children:O})]},W.name)}),s.jsxs("details",{className:"ig-help ig-token-help",children:[s.jsx("summary",{children:c("integrations.form.howTo",{provider:e.label})}),e.tokenHelp]}),s.jsxs("div",{className:"fb-field",children:[s.jsxs("label",{className:"fb-field-label",htmlFor:`${d}-name`,children:[c("integrations.form.name")," ",s.jsx("span",{className:"fb-optional",children:c("integrations.form.optional")})]}),s.jsx("input",{id:`${d}-name`,className:"ap-manage-input ig-input",type:"text",autoComplete:"off",maxLength:120,readOnly:n,value:g,onChange:U=>f(U.target.value),placeholder:E||e.label})]}),a&&!I&&s.jsx("p",{className:"ig-form-error",id:L,role:"alert",children:O}),s.jsxs("div",{className:"ig-form-actions",children:[s.jsx("button",{type:"submit",className:"btn primary","aria-disabled":n,"aria-busy":n,children:c(n?"integrations.form.checking":y?"integrations.form.save":"integrations.form.connectBtn")}),s.jsx("button",{type:"button",className:"btn","aria-disabled":n||void 0,onClick:()=>{n||o()},children:c("integrations.cancel")})]})]})})}const gSe="https://id.atlassian.com/manage-profile/security/api-tokens",mSe="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",fSe="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",bSe=[{scope:"read:jira-work",why:"issues, comments, search",whyKey:"integrations.token.why.work"},{scope:"read:jira-user",why:"your account and avatars",whyKey:"integrations.token.why.user"},{scope:"read:board-scope:jira-software",why:"boards and backlogs",whyKey:"integrations.token.why.board"},{scope:"read:board-scope.admin:jira-software",why:"a board's estimation and quick filters",whyKey:"integrations.token.why.boardAdmin"},{scope:"read:sprint:jira-software",why:"sprints",whyKey:"integrations.token.why.sprint"},{scope:"read:epic:jira-software",why:"epic names and colours",whyKey:"integrations.token.why.epic"},{scope:"read:issue-details:jira",why:"issue lists",whyKey:"integrations.token.why.issueDetails"},{scope:"read:jql:jira",why:"filtered lists",whyKey:"integrations.token.why.jql"}];function vSe(e){const t=e.trim();if(!t)return null;try{const n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`),a=n.hostname==="localhost"||n.hostname==="127.0.0.1";return n.protocol!=="https:"&&!a||!n.hostname.includes(".")&&!a?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens`}catch{return null}}function kSe(){const e=ae(),{values:t}=mW(),n=t.deployment==="cloud",a=n?null:vSe(t.baseUrl??"");let i="";try{i=a?new URL(a).host:""}catch{}return s.jsxs(s.Fragment,{children:[n?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:ag(e("integrations.token.cloud.intro"),{link:s.jsx("a",{href:gSe,target:"_blank",rel:"noreferrer noopener",children:"id.atlassian.com → Security → API tokens"}),scoped:s.jsx("em",{children:e("integrations.token.cloud.scoped")})})}),s.jsx("ul",{className:"ig-scopes",children:bSe.map(o=>s.jsxs("li",{children:[s.jsx("code",{children:o.scope})," ",s.jsx("span",{children:e(o.whyKey)})]},o.scope))}),s.jsx("p",{children:s.jsx("a",{href:mSe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.cloud.docs")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:ag(e("integrations.token.server.intro"),{profile:s.jsx("strong",{children:"Profile"}),pats:s.jsx("strong",{children:"Personal Access Tokens"}),create:s.jsx("strong",{children:"Create token"}),page:a?ag(e("integrations.token.server.page"),{link:s.jsx("a",{href:a,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.openOn",{host:i})})}):""})}),s.jsx("p",{children:s.jsx("a",{href:fSe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.docs")})})]}),s.jsx("p",{className:"ig-dim",children:e("integrations.token.reads")}),n&&s.jsx("p",{className:"ig-dim",children:ag(e("integrations.token.scopedWrite"),{rank:s.jsx("code",{children:"write:issue:jira-software"}),sprint:s.jsx("code",{children:"write:sprint:jira-software"}),backlog:s.jsx("code",{children:"write:board-scope:jira-software"})})})]})}function qS(e,t,n="classic"){if(e==="github")return n==="classic"?"https://github.com/settings/tokens/new?scopes=repo,read:org&description=ccdeck":"https://github.com/settings/personal-access-tokens/new";const a=(t??"").trim()||"https://gitlab.com";let i;try{i=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(a)?a:`https://${a}`)}catch{return null}return i.protocol!=="https:"&&i.protocol!=="http:"||!i.hostname.includes(".")&&i.hostname!=="localhost"?null:`${i.origin}${i.pathname.replace(/\/+$/,"")}/-/user_settings/personal_access_tokens?name=ccdeck&scopes=read_api`}function LI(e,t){return e.split(/(\{\w+\})/).map((n,a)=>{var o;const i=(o=/^\{(\w+)\}$/.exec(n))==null?void 0:o[1];return i&&i in t?s.jsx("span",{children:t[i]},a):n})}function zS({href:e,children:t}){return e?s.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",s.jsx(fl,{})]}):null}function fW({kind:e,baseUrl:t}){const{values:n}=mW(),a=ae();if(e==="github")return s.jsxs("div",{className:"fg-token-help",children:[s.jsx("p",{children:a("forge.token.gh.intro")}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx("strong",{children:a("forge.token.gh.classicName")})," ",LI(a("forge.token.gh.classic"),{repo:s.jsx("code",{children:"repo"}),org:s.jsx("code",{children:"read:org"})})," ",s.jsx(zS,{href:qS("github"),children:a("forge.token.makeOne")})]}),s.jsxs("li",{children:[s.jsx("strong",{children:a("forge.token.gh.fineName")})," ",a("forge.token.gh.fine")," ",s.jsx(zS,{href:qS("github",null,"fine-grained"),children:a("forge.token.makeOne")})]})]}),s.jsx("p",{children:a("forge.token.gh.approval")})]});const i=qS("gitlab",t??(n.where==="self"?n.baseUrl:null));return s.jsxs("div",{className:"fg-token-help",children:[s.jsxs("p",{children:[LI(a("forge.token.gl.scope"),{scope:s.jsx("code",{children:"read_api"})})," ",s.jsx(zS,{href:i,children:a("forge.token.makeOn",{host:i?new URL(i).host:"GitLab"})})]}),s.jsx("p",{children:a("forge.token.gl.expire")})]})}const bW={name:"token",type:"password",secret:!0,get label(){return C("forge.field.token")},get placeholder(){return C("forge.field.tokenPlaceholder")}},wSe=[bW],OI=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},ySe=[{name:"where",type:"choice",get label(){return C("forge.field.which")},get options(){return[{value:"cloud",label:"GitLab.com"},{value:"self",label:C("forge.field.selfManaged")}]},initial:e=>OI(e)?"self":"cloud"},{name:"baseUrl",type:"url",placeholder:"https://gitlab.example.com",get label(){return C("forge.field.url")},get hint(){return C("forge.field.urlHint")},when:{field:"where",is:["self"]},initial:e=>OI(e)?e.baseUrl:""},bW],xSe=m.createElement(fW,{kind:"github"}),CSe=m.createElement(fW,{kind:"gitlab"}),SSe=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},NSe={kind:"jira",label:"Jira",Glyph:ooe,shortcut:"I",detail:"Boards, sprints, and issues",blurb:"Jira Cloud, or Jira Server / Data Center 8.14 and newer.",fields:[{name:"deployment",label:"Which Jira",type:"choice",options:[{value:"server",label:"Jira Server / Data Center"},{value:"cloud",label:"Jira Cloud"}],initial:SSe},{name:"baseUrl",label:"Jira URL",type:"url",initial:e=>(e==null?void 0:e.baseUrl)??"",variants:{field:"deployment",by:{server:{label:"Jira URL",placeholder:"https://jira.example.com",hint:"The address you open Jira at, with its path if it has one (…/jira). https only."},cloud:{label:"Site URL",placeholder:"your-site.atlassian.net",hint:"The address you open Jira at. Your site name alone is enough."}}}},{name:"email",label:"Atlassian account email",type:"email",placeholder:"you@example.com",autoComplete:"username",secret:!0,when:{field:"deployment",is:["cloud"]}},{name:"token",label:"Personal access token",type:"password",secret:!0,variants:{field:"deployment",by:{server:{label:"Personal access token",placeholder:"Paste the token"},cloud:{label:"API token",placeholder:"Paste the API token"}}}}],tokenHelp:m.createElement(kSe)},jSe={kind:"github",label:"GitHub",Glyph:roe,detail:"Repositories, pull requests, and Actions",blurb:"github.com, read-only, with a personal access token.",fields:wSe,tokenHelp:xSe},ASe={kind:"gitlab",label:"GitLab",Glyph:coe,detail:"Projects, merge requests, and pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:ySe,tokenHelp:CSe},yj={jira:NSe,github:jSe,gitlab:ASe},$T=()=>Object.values(yj).filter(e=>!!e);function Wd(e){return(Object.hasOwn(yj,e)?yj[e]:void 0)??null}function Lf(e,t){const n=a=>typeof t=="string"?t:t(a);return m.lazy(()=>e().catch(a=>(console.warn(`ccdeck could not load ${typeof t=="string"?t:"a dialog"}`,a),{default:i=>s.jsx(TSe,{name:n(i),onClose:i.onClose})})))}function TSe({name:e,onClose:t}){const n=ae(),a=m.useRef(null),i=_t(t,{focusRef:a}),o=qt(t);return s.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:s.jsxs("div",{ref:i,className:"modal dialog-missing",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":n("shell.closeEsc"),title:n("shell.closeEsc"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[s.jsx("p",{className:"dm-note",children:n("shell.lazy.didNotLoad",{name:e})}),s.jsxs("div",{className:"dm-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:t,children:n("shell.close")}),s.jsx("button",{type:"button",ref:a,className:"btn primary",onClick:()=>window.location.reload(),children:n("shell.reload")})]})]})]})})}const vW=()=>Pr(()=>import("./IntegrationModal-tKQbB-JM.js"),[]);function RSe(){vW().catch(()=>{})}const ESe=Lf(vW,e=>{var t;return((t=Wd(e.kind))==null?void 0:t.label)??C("integrations.modal.tracker")});function _Se({onClose:e}){return m.useEffect(()=>jn.push(e,0,"dialog"),[e]),null}function qSe(e){return s.jsx(m.Suspense,{fallback:s.jsx(_Se,{onClose:e.onClose}),children:s.jsx(ESe,{...e})})}const PI={"The deck failed while reading the tracker.":"integrations.srv.deckFailed","The answer was larger than the deck accepts.":"integrations.srv.tooLarge","Enter a token.":"integrations.srv.enterToken","Enter an API token.":"integrations.srv.enterApiToken","Enter a personal access token.":"integrations.srv.enterPat","The token has a space in it. Paste it again.":"integrations.srv.tokenSpace","Enter the email address of your Atlassian account.":"integrations.srv.enterEmail","Choose Jira Cloud or Jira Server / Data Center.":"integrations.srv.chooseDeployment","Enter your Jira site URL.":"integrations.srv.enterSiteUrl","Enter your Jira URL.":"integrations.srv.enterJiraUrl","Enter your GitLab's address.":"integrations.srv.enterGitlabUrl","Your Jira site URL is not a valid URL.":"integrations.srv.badSiteUrl","Your Jira URL is not a valid URL.":"integrations.srv.badJiraUrl","Your GitLab's address is not a valid URL.":"integrations.srv.badGitlabUrl","Leave the user name and password out of the address.":"integrations.srv.urlUser","Use an https:// address. Plain http is only accepted for a server on this machine.":"integrations.srv.httpsOnly","Use an https:// address.":"integrations.srv.httpsAddress","That connection is not there any more.":"integrations.srv.connectionGone","No token is saved for this connection. Edit it and enter one.":"integrations.srv.noTokenEdit","No token is saved for this connection. Reconnect it in Settings.":"integrations.srv.noTokenReconnect","Enter a comment of up to 10,000 characters.":"integrations.srv.commentLength","This Jira write is outside the connection's token origins.":"integrations.srv.writeOutside","Jira redirected the comment. Refresh the issue before sending again.":"integrations.srv.commentRedirected","The comment could not be confirmed. Refresh the issue before sending again.":"integrations.srv.commentUnconfirmed","Jira redirected the write. It was not replayed; refresh the board before trying again.":"integrations.srv.writeRedirected","Jira's rank result was too large. Refresh the board to check its position.":"integrations.srv.rankTooLarge","Jira did not confirm every requested issue update. Some issues may have changed; refresh the board to check them.":"integrations.srv.updateUnconfirmed","Jira did not confirm the write. Refresh the board to check the issue.":"integrations.srv.writeUnconfirmed","Jira refused the move: the account or token needs permission to edit and schedule this issue.":"integrations.srv.moveRefused","Jira did not return its available transitions.":"integrations.srv.transitionsMissing","Choose a valid transition.":"integrations.srv.transitionChoose","This transition is unavailable or requires additional fields in Jira.":"integrations.srv.transitionUnavailable","Jira redirected the transition. Refresh the issue before trying again.":"integrations.srv.transitionRedirected","Jira did not confirm the transition. Refresh the issue.":"integrations.srv.transitionUnconfirmed","There is no Jira REST API at this address. Check the URL — some servers live under a path such as /jira.":"integrations.srv.noRestApi","This is a Jira Cloud site. Choose Jira Cloud and connect with your email and an API token.":"integrations.srv.isCloud","This is Jira Server or Data Center, not Cloud. Choose Jira Server / Data Center and use a personal access token.":"integrations.srv.isServer","Jira did not accept this email and API token, on the site or through api.atlassian.com. Check both, and that the token has not expired.":"integrations.srv.emailTokenRefused","Jira wants a CAPTCHA after too many failed sign-ins. Sign in to Jira once in your browser, then test the connection again.":"integrations.srv.captcha","Jira did not accept this personal access token: it answered as an anonymous visitor. Check that the token is right and has not expired or been revoked.":"integrations.srv.patAnonymous","That quick filter is not on this board any more. Refresh the board.":"integrations.srv.quickFilterGone","Jira writes are unavailable because this system cannot safely coordinate them.":"integrations.srv.writesUnavailable","Supply either one issueKey or 2–50 ordered issueKeys and a sprint or backlog target.":"integrations.srv.moveWhere","Supply unique, valid issue keys (2–50 for a batch).":"integrations.srv.moveKeys","Not a valid issue key or move target.":"integrations.srv.moveTarget","Use at most one other issue as the rank anchor.":"integrations.srv.moveAnchor","The issues and anchor must all belong to this board.":"integrations.srv.moveSameBoard","The issues and rank anchor must be top-level issues.":"integrations.srv.moveTopLevel","Only top-level non-epic issues with a known status can be moved.":"integrations.srv.moveEpicStatus","Done issues cannot be moved to the backlog because Jira hides them there. Change the status first.":"integrations.srv.moveDone","Every issue must be in the backlog or one active or future sprint.":"integrations.srv.moveSource","The source and target must be active or future sprints on this board.":"integrations.srv.moveSprints","An issue's source changed or is a closed sprint. Refresh the board.":"integrations.srv.moveSourceChanged","Could not determine the destination's last issue. Refresh and try again.":"integrations.srv.moveLastIssue","Could not verify the destination order. Refresh and try again.":"integrations.srv.moveOrder","The destination is too large to determine the last issue. Refresh and try again.":"integrations.srv.moveDestinationLarge","The rank anchor must be in the target group. Refresh the board.":"integrations.srv.moveAnchorGroup","This server runs Jira of an unknown version. Personal access tokens need Jira Server or Data Center 8.14 or newer, so the deck cannot connect to it.":"integrations.srv.serverOldUnknown","too many redirects":"forge.srv.redirects","answer too large":"forge.srv.answerLarge","answer cut off":"forge.srv.answerCut","unreadable JSON":"forge.srv.badJson","log too large to read the end of":"forge.srv.logLarge","image too large":"forge.srv.imageLarge","image cut off":"forge.srv.imageCut","that cursor is not a page of this list":"forge.srv.cursorPage","that cursor is not one of this list":"forge.srv.cursorList"},zSe=[[/^The deck could not verify (Jira|GitHub|GitLab)'s HTTPS certificate \((.+?)\)\. Check that the address is right and that the server's certificate is valid for it\.$/,"integrations.srv.tlsCert",["provider","code"]],[/^(Jira|GitHub|GitLab) did not answer in time\.$/,"integrations.srv.timeout",["provider"]],[/^The deck could not find (Jira|GitHub|GitLab)'s address\. Check the URL and your network\.$/,"integrations.srv.noAddress",["provider"]],[/^The deck could not reach (Jira|GitHub|GitLab) \((.+?)\)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReachCode",["provider","code"]],[/^The deck could not reach (Jira|GitHub|GitLab)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReach",["provider"]],[/^(Jira|GitHub|GitLab) did not accept these credentials\.$/,"integrations.srv.noCredentials",["provider"]],[/^(Jira|GitHub|GitLab) no longer accepts the saved token\. It may have expired or been revoked — reconnect with a new one\.$/,"integrations.srv.tokenGone",["provider"]],[/^(Jira|GitHub|GitLab) refused: the account or token is not allowed to read this\.$/,"integrations.srv.notAllowed",["provider"]],[/^(Jira|GitHub|GitLab) is limiting requests\. Try again in (\d+) s\.$/,"integrations.srv.limiting",["provider","n"]],[/^(Jira|GitHub|GitLab) has no such page or record, or this account cannot see it\.$/,"integrations.srv.noSuchPage",["provider"]],[/^(Jira|GitHub|GitLab) refused the request\.$/,"integrations.srv.refusedRequest",["provider"]],[/^(Jira|GitHub|GitLab) is not answering right now \((\d+)\)\. Try again shortly\.$/,"integrations.srv.notAnswering",["provider","status"]],[/^(Jira|GitHub|GitLab) answered (\d+)\.$/,"integrations.srv.answered",["provider","status"]],[/^The deck only sends this connection's token to (.+)\.$/,"integrations.srv.tokenOrigins",["origins"]],[/^(Jira|GitHub|GitLab) redirected to (\S+?), and the deck does not send the token there\. Check the address you connected\.$/,"integrations.srv.redirectedAway",["provider","origin"]],[/^(Jira|GitHub|GitLab) redirected too many times\.$/,"integrations.srv.redirectedMany",["provider"]],[/^(Jira|GitHub|GitLab) answered with something that is not JSON\. Check that the address is the \1 site itself\.$/,"integrations.srv.notJson",["provider"]],[/^The deck will not send a token to (\S+?)\.$/,"integrations.srv.noTokenTo",["origin"]],[/^This server runs Jira (.+?)\. Personal access tokens need Jira Server or Data Center 8\.14 or newer, so the deck cannot connect to it\.$/,"integrations.srv.serverOld",["version"]],[/^(Jira|GitHub|GitLab) is not available on this deck\.$/,"integrations.srv.notOnDeck",["provider"]],[/^(\S+?) did not answer in time$/,"forge.srv.timeout",["origin"]],[/^(\S+?): the certificate is not trusted \((.+?)\)$/,"forge.srv.cert",["origin","code"]],[/^(\S+?): no answer$/,"forge.srv.noAnswer",["origin"]],[/^(\S+?) is not a host this connection reads from$/,"forge.srv.notHost",["origin"]],[/^(\S+?) sent this read to (\S+?), not to this connection's address$/,"forge.srv.sentElsewhere",["origin","next"]],[/^(\S+?) answered (.+?), not the API$/,"forge.srv.notApi",["origin","type"]],[/^not an image \((.+?)\)$/,"forge.srv.notImage",["type"]]];function LSe(e,t=C){if(!e)return"";const n=e.replace(/\u2019/g,"'"),a=Object.hasOwn(PI,n)?PI[n]:void 0;if(a)return t(a);for(const[i,o,r]of zSe){const c=i.exec(n);if(!c)continue;const d={};return r.forEach((u,p)=>{d[u]=c[p+1]}),t(o,d)}return e}function OSe(e){if(!e||typeof e!="object")return;const t=e;if(!(typeof t.operationId!="string"||!/^[0-9a-f-]{36}$/.test(t.operationId)||typeof t.connectionId!="string"||!["comment","status","move"].includes(t.kind)||!["pending","uncertain","confirmed"].includes(t.state))&&!(t.kind==="move"?!Array.isArray(t.issueKeys)||!t.issueKeys.every(n=>typeof n=="string"):typeof t.issueKey!="string"))return t}class $a extends Ln{constructor(n,a,i={}){super(a);Ma(this,"kind");Ma(this,"operation");Ma(this,"status");Ma(this,"retryAfter");Ma(this,"field");Ma(this,"detail");Ma(this,"refreshRequired");Ma(this,"outcomes");Ma(this,"moveOutcome");this.name="IntegrationFailure",this.kind=n,Object.assign(this,i)}}async function kW(e){try{const t=await e.json(),n=t==null?void 0:t.error,a=OSe(t==null?void 0:t.operation);if((t==null?void 0:t.code)==="jira_write_guard_conflict")return new $a("upstream",C("integrations.error.writeAwaiting"),{status:e.status,operation:a});if(n&&typeof n.kind=="string"&&typeof n.message=="string"){const i=Array.isArray(t.outcomes)?t.outcomes.slice(0,50).filter(c=>{if(!c||typeof c!="object")return!1;const d=c;return typeof d.issueKey=="string"&&/^[A-Z][A-Z0-9_]{0,40}-[1-9]\d{0,11}$/.test(d.issueKey)&&["moved","unchanged","unknown"].includes(String(d.membership))&&["ranked","unchanged","failed","unknown"].includes(String(d.rank))}).map(c=>({issueKey:c.issueKey,membership:c.membership,rank:c.rank})):[],o=t.outcome,r=o&&["moved","unchanged","unknown"].includes(o.membership)&&["ranked","unchanged","failed","unknown"].includes(o.rank)?{membership:o.membership,rank:o.rank}:void 0;return new $a(n.kind,LSe(n.message),{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail,...t.refresh===!0?{refreshRequired:!0}:{},...i.length?{outcomes:i}:{},...r?{moveOutcome:r}:{},...a?{operation:a}:{}})}}catch{}return new $a(e.status===401?"auth":"upstream",C("integrations.error.deckAnswered",{status:e.status}))}async function Zu(e,t={}){const{timeoutMs:n=3e4,...a}=t;return wW(a.signal,n,async i=>{let o;try{o=await fetch(e,{...a,signal:i,headers:a.body?{"Content-Type":"application/json",...a.headers??{}}:a.headers})}catch(r){throw i.aborted?r:new $a("network",C("integrations.error.unreachable"))}if(!o.ok)throw await kW(o);return o.json()})}async function wW(e,t,n){const a=new AbortController,i=window.setTimeout(()=>a.abort(),t),o=()=>a.abort(e==null?void 0:e.reason);e==null||e.addEventListener("abort",o,{once:!0}),e!=null&&e.aborted&&o();try{return a.signal.throwIfAborted(),await n(a.signal)}catch(r){throw e!=null&&e.aborted?e.reason??r:a.signal.aborted?new $a("network",C("integrations.error.timeout")):r}finally{window.clearTimeout(i),e==null||e.removeEventListener("abort",o)}}const yW=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function ZEe(e){const t=yW(e);return(n,a)=>fetch(`${t}${n.replace(/^\/+/,"")}`,a)}function XEe(e){const t=yW(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function QEe(e,t){if(!t)return null;try{const n=new URL(t);return n.username||n.password||n.protocol!=="https:"&&n.protocol!=="http:"?null:n.origin===new URL(e.baseUrl).origin?n.href:null}catch{return null}}function e1e(e){const t=new URLSearchParams;for(const[a,i]of Object.entries(e))i===void 0||i===""||i===!1||t.set(a,i===!0?"1":String(i));const n=t.toString();return n?`?${n}`:""}async function t1e(e,t,{signal:n,timeoutMs:a=45e3}={}){return wW(n,a,async i=>{let o;try{o=await e(t,{signal:i,headers:{Accept:"application/json"}})}catch(r){throw i.aborted?r:new $a("network",C("integrations.error.unreachable"))}if(!o.ok)throw await kW(o);try{return await o.json()}catch(r){throw i.aborted?r:new $a("upstream",C("integrations.error.notJson"))}})}let Ni={connections:null,providers:[],error:""};const Vc=new Set;let sg=null,Rd=null,sl=null,MI=0;const PSe=5e3,MSe=3;function hm(e){Ni={...Ni,...e},Vc.forEach(t=>t(Ni))}function Of(){return Rd||(Rd=(async()=>{try{const e=await Zu("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new $a("upstream",C("integrations.error.notList"));hm({connections:t,providers:n,error:""})}catch(e){hm({error:So(e,C("integrations.error.readConnections"))}),Ni.connections===null&&Vc.size>0&&sl===null&&MI<MSe&&(sl=window.setTimeout(()=>{sl=null,Of()},PSe*2**MI++))}finally{Rd=null}})(),Rd)}function ISe(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function II(){ISe(Ni)&&Of()}function VT(e){const t=Ni.connections??[],n=t.findIndex(a=>a.id===e.id);hm({connections:n<0?[...t,e]:t.map(a=>a.id===e.id?e:a)})}function DSe(e){hm({connections:(Ni.connections??[]).filter(t=>t.id!==e)})}function Xu(){const[e,t]=m.useState(Ni);return m.useEffect(()=>{Vc.add(t),t(Ni);const n=()=>{document.visibilityState==="visible"&&II()};return Vc.size===1&&(Of(),sg=window.setInterval(II,6e4),document.addEventListener("visibilitychange",n)),()=>{Vc.delete(t),Vc.size===0&&(sg!==null&&window.clearInterval(sg),sg=null,sl!==null&&window.clearTimeout(sl),sl=null,document.removeEventListener("visibilitychange",n))}},[]),e}function pm(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function Qu(e){return e.connections===null?new Set:new Set(e.providers.filter(t=>(t==null?void 0:t.available)===!0).map(t=>t.kind))}function yi(e,t){return Qu(e).has(t)}function xj(e,t){return yi(e,t)&&pm(e,t).length>0}function KT(e){return Qu(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function FSe(e,t,n){const a=await Zu("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return VT(a.connection),a.connection}async function USe(e,t){const n=await Zu(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return VT(n.connection),n}async function BSe(e){const t=await Zu(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return VT(t.connection),t.connection}async function HSe(e){await Zu(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),DSe(e)}function or(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function n1e(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length?(t.length===1?t[0].slice(0,2):`${t[0][0]}${t[t.length-1][0]}`).toUpperCase():"?"}let gm=null,mm=null;function DI(e){mm=null,gm=e}function WSe(e){gm=null,mm=e}function GSe(){const e=mm;return mm=null,e}function $Se(){const e=gm;return gm=null,e}const VSe={jira:"integrations.explore.cap.jira",github:"integrations.explore.cap.github",gitlab:"integrations.explore.cap.gitlab"},KSe={jira:"integrations.explore.access.jira",github:"integrations.explore.access.read",gitlab:"integrations.explore.access.read"};function JSe(){return Array.from(document.querySelectorAll('[data-rail-item="explore-integrations"], [data-rail-item="more"]')).find(e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0)??null}function YSe({integrations:e,onClose:t,onOpen:n,onConnect:a,onManage:i}){const o=ae(),r=_t(t,{restoreFocusFallback:JSe}),c=qt(t),d=$T().filter(g=>e.providers.some(f=>f.kind===g.kind)||pm(e,g.kind).length>0),u=d.filter(g=>xj(e,g.kind)).length,p=g=>{t(),g()};return Lt.createPortal(s.jsx("div",{className:"modal-backdrop",role:"presentation",...c,children:s.jsxs("div",{ref:r,className:"modal explore-integrations",role:"dialog","aria-modal":"true","aria-labelledby":"explore-integrations-title","aria-describedby":"explore-integrations-description",children:[s.jsxs("div",{className:"modal-head explore-head",children:[s.jsx("h2",{id:"explore-integrations-title",children:o("integrations.explore.title")}),s.jsx("button",{type:"button",className:"glyph-btn","aria-label":o("integrations.explore.closeAria"),title:o("integrations.closeEsc"),onClick:t,children:"×"})]}),s.jsxs("div",{className:"explore-body",children:[s.jsx("p",{id:"explore-integrations-description",className:"explore-intro",children:o("integrations.explore.intro")}),e.error&&s.jsxs("p",{className:"explore-status",role:"alert",children:[e.error," ",o("integrations.explore.stale")]}),e.connections===null?s.jsx("p",{className:"explore-status",role:"status",children:e.error?o("integrations.explore.statusUnavailable"):o("integrations.explore.reading")}):d.length===0?s.jsx("p",{className:"explore-status",role:"status",children:o("integrations.explore.none")}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"explore-caption",children:[s.jsx("span",{children:o("integrations.explore.available")}),s.jsx("span",{children:o("integrations.explore.connectedCount",{n:u})})]}),s.jsx("ul",{className:"explore-providers",children:d.map(g=>{const f=yi(e,g.kind),v=xj(e,g.kind),k=pm(e,g.kind)[0];return s.jsxs("li",{className:"explore-provider",children:[s.jsx("span",{className:"explore-glyph","aria-hidden":!0,children:s.jsx(g.Glyph,{})}),s.jsxs("div",{className:"explore-info",children:[s.jsx("h3",{children:g.label}),s.jsx("p",{children:o(VSe[g.kind])}),s.jsxs("span",{className:"explore-connection","data-connected":v||void 0,children:[o(f?v?"integrations.explore.connected":"integrations.explore.notConnected":"integrations.explore.unavailableOnDeck")," · ",o(KSe[g.kind])]})]}),s.jsx("div",{className:"explore-actions",children:v?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"btn","aria-label":o("integrations.explore.openAria",{label:g.label}),onClick:()=>p(()=>n(g.kind)),children:[o("integrations.explore.open")," ",s.jsx(fl,{})]}),s.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":o("integrations.manageProvider",{label:g.label}),onClick:()=>p(()=>i(k==null?void 0:k.id)),children:o("integrations.manage")})]}):f?s.jsx("button",{type:"button",className:"btn primary","aria-label":o("integrations.form.connect",{provider:g.label}),onClick:()=>p(()=>a(g.kind)),children:o("integrations.form.connectBtn")}):k?s.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":o("integrations.manageProvider",{label:g.label}),onClick:()=>p(()=>i(k.id)),children:o("integrations.manage")}):s.jsx("span",{className:"explore-unavailable",children:o("integrations.explore.notAvailable")})})]},g.kind)})})]})]}),s.jsxs("div",{className:"explore-footer",children:[s.jsx("span",{children:o("integrations.explore.footer")}),s.jsxs("button",{type:"button",className:"btn explore-text-action",onClick:()=>p(()=>i()),children:[o("integrations.explore.manageInSettings")," ",s.jsx(fl,{})]})]})]})}),document.body)}function ZSe({widths:e,room:t,gap:n,more:a}){let i=0,o=0;for(let r=0;r<e.length;r++){i+=(r>0?n:0)+e[r];const c=r+1<e.length?n+a:0;if(i+c>t)break;o=r+1}return o}function xW(e,t=C){return e.tool?e.tool.name:e.kind==="asked"?t("board.queue.question"):t("board.queue.permission")}const XSe=20;function QSe(e,t=XSe){if(e.length<=t)return e;const n=Math.floor((t-1)*.4),a=t-1-n;return`${e.slice(0,a)}…${e.slice(e.length-n)}`}function eNe(e,t=C){const n=Math.floor(Math.max(0,e)/6e4);if(n<1)return t("board.queue.lessThanMinute");if(n<60)return t("board.queue.minutes",{count:n});const a=Math.floor(n/60),i=n%60;return i===0?t("board.queue.hours",{count:a}):t("board.queue.hoursMinutes",{h:t("board.queue.hours",{count:a}),m:t("board.queue.minutes",{count:i})})}function tNe(e,t,n,a=C){var r;const i=eNe(n,a),o=t.tool?"board.queue.entry.tool":t.kind==="asked"?"board.queue.entry.answer":"board.queue.entry.permission";return a(o,{label:e,wait:i,tool:((r=t.tool)==null?void 0:r.name)??""})}function nNe(e,t=C){const n=dl(e,t),a=$2(e,n,t);return a?`${n}
151
+ ${n("board.rail.unreadCount",{n:t})}`:a}function ng(e,t){return t.map(n=>({...n,group:e}))}function HCe({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:a,toggleAccountsPanel:i,accountsPanelId:o="accounts-panel",codexPanelOpen:r=!1,toggleCodexPanel:c=()=>{},usagePanelOpen:d,setUsagePanelOpen:u,machinePanelOpen:p,setMachinePanelOpen:g,setUsageHistoryOpen:f,watchOn:v,watchUnseen:k,setBrowserWatchOpen:y,setTrafficRadarOpen:N,setRadioOpen:w,openToolActivity:S,openSettings:j,onFeedback:A,toggles:T,openCapacity:E,integrations:q=[],openExploreIntegrations:F,openQuickOpen:z}){const H=Goe(Co()),I=zo(Co()),L={id:"session-list",label:C("board.rail.sessionList"),short:C("board.rail.sessionList.short"),key:{cap:"L",aria:"L",single:!0},ariaLabel:C("board.rail.sessionList"),glyph:s.jsx(nB,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:T.sessionList},O={id:"accounts",label:C("board.rail.accounts"),short:C("board.rail.accounts"),key:{cap:"A",aria:"A",single:!0},ariaLabel:C("board.rail.accounts"),hint:e.codex?void 0:C("board.rail.accounts.hint"),glyph:s.jsx(aB,{}),kind:"panel",open:a,controls:o,onPress:i,buttonRef:T.accounts},_=E?[{id:"account-capacity",label:C("board.rail.capacity"),short:C("board.rail.capacity.short"),ariaLabel:C("board.rail.capacity"),detail:C("board.rail.capacity.detail"),glyph:s.jsx(aoe,{}),kind:"dialog",onPress:()=>E("accounts")},{id:"reset-calendar",label:C("board.rail.calendar"),short:C("board.rail.calendar.short"),ariaLabel:C("board.rail.calendar"),detail:C("board.rail.calendar.detail"),glyph:s.jsx(soe,{}),kind:"dialog",onPress:()=>E("calendar")}]:[],M={id:"codex-accounts",label:"Codex accounts",short:"Codex",ariaLabel:"Codex accounts",glyph:s.jsx(poe,{}),kind:"panel",open:r,controls:"codex-accounts-panel",onPress:c,buttonRef:T.codex},U={id:"usage",label:C("board.rail.usage"),short:C("board.rail.usage"),key:{cap:"U",aria:"U",single:!0},ariaLabel:C("board.rail.usage"),glyph:s.jsx(Gie,{}),kind:"panel",open:d,controls:"usage-panel",onPress:()=>u(X=>!X),buttonRef:T.usage},G={id:"machine",label:C("board.rail.machine"),short:C("board.rail.machine"),key:{cap:"S",aria:"S",single:!0},ariaLabel:C("board.rail.machine"),hint:C("board.rail.machine.hint"),glyph:s.jsx(Vie,{}),kind:"panel",open:p,controls:"system-panel",onPress:()=>g(X=>!X),buttonRef:T.machine},W={id:"history",label:C("board.rail.history"),short:C("board.rail.history.short"),key:{cap:"H",aria:"H",single:!0},ariaLabel:C("board.rail.history"),glyph:s.jsx($ie,{}),kind:"dialog",onPress:()=>f(X=>!X)},$={id:"browser-watch",label:C("board.rail.browserWatch"),short:C("board.rail.browserWatch.short"),key:{cap:"B",aria:"B",single:!0},ariaLabel:`${C("board.rail.browserWatch")}${C("board.listSep")}${C(v?"board.rail.watching":"board.rail.notWatching")}${k>0?`${C("board.listSep")}${C("board.rail.unreadCount",{n:k})}`:""}`,detail:BCe(v,k,C),glyph:s.jsx(Jie,{watching:v===!0||k>0}),kind:"dialog",onPress:()=>y(X=>!X),badge:k},Y={id:"settings",label:C("board.rail.settings"),short:C("board.rail.settings.short"),key:{cap:H,aria:"Control+, Meta+,",single:!1},ariaLabel:C("board.rail.settings"),glyph:s.jsx(Yie,{}),kind:"dialog",onPress:()=>j()},B={id:"quick-open",label:C("board.rail.search"),short:C("board.rail.search"),key:{cap:Hie(I),aria:I?"Meta+K":"Control+K",single:!1},ariaLabel:C("board.rail.search"),detail:C("board.rail.search.detail"),glyph:s.jsx(iB,{}),kind:"dialog",onPress:z},V={id:"feedback",label:C("board.rail.feedback"),short:C("board.rail.feedback"),menu:C("board.rail.feedback.menu"),ariaLabel:C("board.rail.feedback.menu"),glyph:s.jsx(Zie,{}),kind:"dialog",onPress:A},Z=S?[{id:"tool-activity",label:C("board.rail.tools.activity"),short:C("board.rail.tools.short"),ariaLabel:C("board.rail.tools.activity"),glyph:s.jsx(noe,{}),kind:"dialog",detail:C("board.rail.tools.detail"),onPress:()=>S("tools")},{id:"skill-activity",label:C("board.rail.skills"),short:C("board.rail.skills.short"),ariaLabel:C("board.rail.skills"),glyph:s.jsx(sB,{}),kind:"dialog",detail:C("board.rail.skills.detail"),onPress:()=>S("skills")}]:[],D=N?[{id:"traffic-radar",label:C("board.rail.radar"),short:C("board.rail.radar.short"),ariaLabel:C("board.rail.radar"),glyph:s.jsx(Kie,{}),kind:"dialog",detail:C("board.rail.radar.detail"),onPress:()=>N(!0)}]:[],K=w?[{id:"radio",label:C("board.rail.radio"),short:C("board.rail.radio"),ariaLabel:C("board.rail.radio"),glyph:s.jsx(toe,{}),kind:"dialog",detail:C("board.rail.radio.detail"),onPress:()=>w(!0)}]:[];return{left:e.claude?[O,L]:e.codex?[M,L]:[L],codexDoor:e.claude&&e.codex?[M]:[],leftStripe:[...e.claude?[ng(e.codex?C("board.rail.accounts"):C("board.rail.group.accounts"),[O,..._])]:[],...e.codex&&!e.claude?[[M]]:[],[L]],capacity:e.claude?_:[],right:[ng(C("board.rail.group.usage"),[U,G]),ng(C("board.rail.group.activity"),[W,...Z]),ng(C("board.rail.group.watchers"),[$,...D]),K].filter(X=>X.length>0),utilities:[Y,V],search:B,explore:F?[{id:"explore-integrations",label:C("board.rail.explore"),short:C("board.rail.explore.short"),ariaLabel:C("board.rail.explore"),glyph:s.jsx(Wie,{}),kind:"dialog",onPress:F}]:[],integrations:q.map(({provider:X,onPress:Q})=>({id:`integration-${X.kind}`,label:X.label,short:X.label,ariaLabel:X.label,detail:Hd(C,X.detail),key:X.shortcut?{cap:X.shortcut.toUpperCase(),aria:X.shortcut.toUpperCase(),single:!0}:void 0,glyph:s.jsx(X.Glyph,{}),kind:"dialog",onPress:Q}))}}function ag(e,t){return e.split(/\{(\w+)\}/).map((a,i)=>i%2===0?a:s.jsx(m.Fragment,{children:a in t?t[a]:`{${a}}`},i))}const um=[{value:"bug",get label(){return C("shell.feedback.kind.bug")},get question(){return C("shell.feedback.q.bug")},get placeholder(){return C("shell.feedback.ph.bug")}},{value:"idea",get label(){return C("shell.feedback.kind.idea")},get question(){return C("shell.feedback.q.idea")},get placeholder(){return C("shell.feedback.ph.idea")}},{value:"other",get label(){return C("shell.feedback.kind.other")},get question(){return C("shell.feedback.q.other")},get placeholder(){return C("shell.feedback.ph.other")}}];function dW(e){return um.find(t=>t.value===e)??um[0]}const wj=3,ES=120,uW=1e4,hW=200,WCe=()=>C("shell.feedback.missing");function RI(e){return e.trim()!==""}function GCe(e){var o;const t=e.trim();if(t==="")return"";const n=EI(t.split(/\r?\n/,1)[0]),a=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,i=_S(a).length>=wj?_S(a):_S(n);return VCe(i.length>=wj?i:EI(t))}function $Ce(e,t){const n=GCe(t);return n.length>=wj?n:C("shell.feedback.titleKind",{kind:dW(e).label,text:n})}function EI(e){return e.replace(/\s+/g," ").trim()}function _S(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function VCe(e){if(e.length<=ES)return e;const t=e.slice(0,ES-1),n=t.lastIndexOf(" ");return`${(n>=ES/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function KCe({kind:e,body:t,contact:n}){const a={kind:e,title:$Ce(e,t),body:t.trim()};return n.trim()!==""&&(a.contact=n.trim()),a}function JCe(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 YCe={darwin:"macOS",win32:"Windows",linux:"Linux"};function ZCe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),a=t===-1?"":e.slice(t+1),i=YCe[n]??n;return a?`${i} · ${a}`:i}function XCe(e){return e?`ccdeck ${e.appVersion} · ${ZCe(e.platform)}`:null}const QCe=()=>C("shell.feedback.factsWith"),eSe=()=>C("shell.feedback.factsUnknown"),tSe=()=>C("shell.feedback.addDetails"),nSe=()=>C("shell.feedback.contact"),aSe=()=>C("shell.feedback.contactPh"),sSe=()=>C("shell.feedback.contactHint"),iSe=()=>[C("shell.feedback.where1"),C("shell.feedback.where2")];function oSe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function GT(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function rSe(e){return zo(e)?["⌘","Enter"]:["Ctrl","Enter"]}function cSe(e){return[...e].length===1}const pW=()=>C("shell.feedback.sent");function lSe(e){const t=/^At most (\d+) images\.$/.exec(e);if(t)return C("shell.feedback.problem.count",{n:t[1]});const n=/^Image (\d+) is over (\d+) MB\.$/.exec(e);if(n)return C("shell.feedback.problem.size",{n:n[1],mb:n[2]});const a=/^Image (\d+) is not a PNG or a JPEG\.$/.exec(e);return a?C("shell.feedback.problem.format",{n:a[1]}):e}function _I(e,t,n){if(t==="vetoed")return C("shell.feedback.fail.vetoed");if(e===429||t==="too_many")return C("shell.feedback.fail.tooMany");if(e===413||t==="too_large")return C("shell.feedback.fail.tooLarge");const a=n==null?void 0:n.images;return e===400&&Array.isArray(a)&&typeof a[0]=="string"?C("shell.feedback.fail.image",{reason:lSe(a[0])}):C(e===400?"shell.feedback.fail.rejected":"shell.feedback.fail.unreachable")}function dSe(e){return e==="sending"?C("shell.feedback.sending"):e==="sent"?pW():""}const qI=1400,uSe=160,gW=m.createContext({values:{}});function mW(){return m.useContext(gW)}function hSe(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const zI=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function pSe({def:e,existing:t,busy:n,error:a,onSubmit:i,onCancel:o,onDirtyChange:r}){var _,M;const c=ae(),d=m.useId(),[u,p]=m.useState(()=>Object.fromEntries(e.fields.map(U=>{var G,W,$;return[U.name,U.secret?"":((G=U.initial)==null?void 0:G.call(U,t))??(U.type==="choice"?(($=(W=U.options)==null?void 0:W[0])==null?void 0:$.value)??"":"")]}))),[g,f]=m.useState((t==null?void 0:t.name)??""),v=m.useRef(null),k=m.useRef(new Map),y=!!t,N=m.useRef(u),w=m.useRef(g);m.useEffect(()=>{r==null||r(g!==w.current||Object.keys(u).some(U=>u[U]!==N.current[U]))},[g,u,r]);const S=e.fields.filter(U=>U.type==="choice").every(U=>u[U.name]===N.current[U.name]),j=y&&t.tokenSaved&&S,A=(U,G)=>{n||p(W=>({...W,[U]:G}))},T=U=>{var W;if(U.preventDefault(),n)return;const G={};for(const $ of e.fields)zI($,u)&&(G[$.name]=(u[$.name]??"").trim());(W=U.currentTarget.querySelector('button[type="submit"]'))==null||W.focus(),i(G,g.trim()),p($=>Object.fromEntries(Object.entries($).map(([Y,B])=>{var V;return[Y,(V=e.fields.find(Z=>Z.name===Y))!=null&&V.secret?"":B]})))},E=m.useMemo(()=>{const U=u.baseUrl??"";try{return U?new URL(/^[a-z]+:\/\//i.test(U)?U:`https://${U}`).host:""}catch{return""}},[u.baseUrl]),q=m.useMemo(()=>({values:u,existing:t}),[u,t]),F=e.fields.filter(U=>zI(U,u)),z=(_=F.find(U=>!U.secret&&U.type!=="choice"))==null?void 0:_.name,H=(M=F.find(U=>U.secret))==null?void 0:M.name,I=a!=null&&a.field&&F.some(U=>U.name===a.field&&U.type!=="choice")?a.field:null,L=`${d}-error`;m.useEffect(()=>{var G,W,$;const U=y?H:z??H;U&&((G=k.current.get(U))==null||G.focus()),($=(W=v.current)==null?void 0:W.scrollIntoView)==null||$.call(W,{block:"nearest"})},[y]),m.useEffect(()=>{var U;I&&((U=k.current.get(I))==null||U.focus())},[a,I]);const O=a&&s.jsxs(s.Fragment,{children:[a.message,a.detail&&s.jsxs("span",{className:"ig-form-detail",children:[" ",c("integrations.failure.said",{provider:e.label,said:a.detail})]}),a.kind==="rate-limit"&&a.retryAfter?s.jsxs("span",{children:[" ",c("integrations.form.retryIn",{n:a.retryAfter})]}):null]});return s.jsx(gW.Provider,{value:q,children:s.jsxs("form",{ref:v,className:"ig-form",onSubmit:T,"aria-labelledby":`${d}-title`,noValidate:!0,children:[s.jsxs("header",{className:"ig-managed-header",children:[s.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:s.jsx(e.Glyph,{})}),s.jsxs("div",{className:"ig-managed-identity",children:[s.jsx("h2",{className:"ig-form-title",id:`${d}-title`,children:y?c("integrations.form.edit",{name:t.name}):c("integrations.form.connect",{provider:e.label})}),y&&s.jsx("p",{children:c("integrations.form.connectionOf",{provider:e.label})})]})]}),F.map(U=>{const G=hSe(U,u),W={...G,label:Hd(c,G.label),hint:Hd(c,G.hint),placeholder:Hd(c,G.placeholder)},$=(a==null?void 0:a.field)===W.name,Y=[W.hint?`${d}-${W.name}-hint`:"",$?L:""].filter(Boolean).join(" ")||void 0;if(W.type==="choice")return s.jsxs("fieldset",{className:"fb-kinds","aria-invalid":$||void 0,children:[s.jsx("legend",{className:"vis-hidden",children:W.label}),(W.options??[]).map(Z=>s.jsxs("label",{className:"fb-kind",children:[s.jsx("input",{type:"radio",name:`${d}-${W.name}`,value:Z.value,checked:u[W.name]===Z.value,"aria-disabled":n||void 0,onChange:()=>A(W.name,Z.value),onKeyDown:D=>{GT(D.nativeEvent)&&D.preventDefault()}}),Hd(c,Z.label)]},Z.value))]},W.name);const B=W.secret&&j,V=`${d}-${W.name}`;return s.jsxs("div",{className:"fb-field",children:[s.jsxs("label",{className:"fb-field-label",htmlFor:V,children:[W.label,W.optional&&s.jsxs("span",{className:"fb-optional",children:[" ",c("integrations.form.optional")]})]}),s.jsx("input",{id:V,className:`ap-manage-input ig-input${W.secret?" ig-mono":""}`,ref:Z=>{Z?k.current.set(W.name,Z):k.current.delete(W.name)},type:W.type,inputMode:W.type==="url"?"url":W.type==="email"?"email":void 0,autoComplete:W.autoComplete??"off",spellCheck:!1,value:u[W.name]??"",onChange:Z=>A(W.name,Z.target.value),placeholder:B?c("integrations.form.keepSaved"):W.placeholder,readOnly:n,"aria-invalid":$||void 0,"aria-describedby":Y,"aria-required":!W.optional&&!B||void 0}),W.hint&&s.jsx("span",{className:"ig-hint",id:`${d}-${W.name}-hint`,children:W.hint}),$&&I===W.name&&s.jsx("span",{className:"ig-form-error",id:L,role:"alert",children:O})]},W.name)}),s.jsxs("details",{className:"ig-help ig-token-help",children:[s.jsx("summary",{children:c("integrations.form.howTo",{provider:e.label})}),e.tokenHelp]}),s.jsxs("div",{className:"fb-field",children:[s.jsxs("label",{className:"fb-field-label",htmlFor:`${d}-name`,children:[c("integrations.form.name")," ",s.jsx("span",{className:"fb-optional",children:c("integrations.form.optional")})]}),s.jsx("input",{id:`${d}-name`,className:"ap-manage-input ig-input",type:"text",autoComplete:"off",maxLength:120,readOnly:n,value:g,onChange:U=>f(U.target.value),placeholder:E||e.label})]}),a&&!I&&s.jsx("p",{className:"ig-form-error",id:L,role:"alert",children:O}),s.jsxs("div",{className:"ig-form-actions",children:[s.jsx("button",{type:"submit",className:"btn primary","aria-disabled":n,"aria-busy":n,children:c(n?"integrations.form.checking":y?"integrations.form.save":"integrations.form.connectBtn")}),s.jsx("button",{type:"button",className:"btn","aria-disabled":n||void 0,onClick:()=>{n||o()},children:c("integrations.cancel")})]})]})})}const gSe="https://id.atlassian.com/manage-profile/security/api-tokens",mSe="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",fSe="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",bSe=[{scope:"read:jira-work",why:"issues, comments, search",whyKey:"integrations.token.why.work"},{scope:"read:jira-user",why:"your account and avatars",whyKey:"integrations.token.why.user"},{scope:"read:board-scope:jira-software",why:"boards and backlogs",whyKey:"integrations.token.why.board"},{scope:"read:board-scope.admin:jira-software",why:"a board's estimation and quick filters",whyKey:"integrations.token.why.boardAdmin"},{scope:"read:sprint:jira-software",why:"sprints",whyKey:"integrations.token.why.sprint"},{scope:"read:epic:jira-software",why:"epic names and colours",whyKey:"integrations.token.why.epic"},{scope:"read:issue-details:jira",why:"issue lists",whyKey:"integrations.token.why.issueDetails"},{scope:"read:jql:jira",why:"filtered lists",whyKey:"integrations.token.why.jql"}];function vSe(e){const t=e.trim();if(!t)return null;try{const n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`),a=n.hostname==="localhost"||n.hostname==="127.0.0.1";return n.protocol!=="https:"&&!a||!n.hostname.includes(".")&&!a?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens`}catch{return null}}function kSe(){const e=ae(),{values:t}=mW(),n=t.deployment==="cloud",a=n?null:vSe(t.baseUrl??"");let i="";try{i=a?new URL(a).host:""}catch{}return s.jsxs(s.Fragment,{children:[n?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:ag(e("integrations.token.cloud.intro"),{link:s.jsx("a",{href:gSe,target:"_blank",rel:"noreferrer noopener",children:"id.atlassian.com → Security → API tokens"}),scoped:s.jsx("em",{children:e("integrations.token.cloud.scoped")})})}),s.jsx("ul",{className:"ig-scopes",children:bSe.map(o=>s.jsxs("li",{children:[s.jsx("code",{children:o.scope})," ",s.jsx("span",{children:e(o.whyKey)})]},o.scope))}),s.jsx("p",{children:s.jsx("a",{href:mSe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.cloud.docs")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:ag(e("integrations.token.server.intro"),{profile:s.jsx("strong",{children:"Profile"}),pats:s.jsx("strong",{children:"Personal Access Tokens"}),create:s.jsx("strong",{children:"Create token"}),page:a?ag(e("integrations.token.server.page"),{link:s.jsx("a",{href:a,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.openOn",{host:i})})}):""})}),s.jsx("p",{children:s.jsx("a",{href:fSe,target:"_blank",rel:"noreferrer noopener",children:e("integrations.token.server.docs")})})]}),s.jsx("p",{className:"ig-dim",children:e("integrations.token.reads")}),n&&s.jsx("p",{className:"ig-dim",children:ag(e("integrations.token.scopedWrite"),{rank:s.jsx("code",{children:"write:issue:jira-software"}),sprint:s.jsx("code",{children:"write:sprint:jira-software"}),backlog:s.jsx("code",{children:"write:board-scope:jira-software"})})})]})}function qS(e,t,n="classic"){if(e==="github")return n==="classic"?"https://github.com/settings/tokens/new?scopes=repo,read:org&description=ccdeck":"https://github.com/settings/personal-access-tokens/new";const a=(t??"").trim()||"https://gitlab.com";let i;try{i=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(a)?a:`https://${a}`)}catch{return null}return i.protocol!=="https:"&&i.protocol!=="http:"||!i.hostname.includes(".")&&i.hostname!=="localhost"?null:`${i.origin}${i.pathname.replace(/\/+$/,"")}/-/user_settings/personal_access_tokens?name=ccdeck&scopes=read_api`}function LI(e,t){return e.split(/(\{\w+\})/).map((n,a)=>{var o;const i=(o=/^\{(\w+)\}$/.exec(n))==null?void 0:o[1];return i&&i in t?s.jsx("span",{children:t[i]},a):n})}function zS({href:e,children:t}){return e?s.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",s.jsx(fl,{})]}):null}function fW({kind:e,baseUrl:t}){const{values:n}=mW(),a=ae();if(e==="github")return s.jsxs("div",{className:"fg-token-help",children:[s.jsx("p",{children:a("forge.token.gh.intro")}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx("strong",{children:a("forge.token.gh.classicName")})," ",LI(a("forge.token.gh.classic"),{repo:s.jsx("code",{children:"repo"}),org:s.jsx("code",{children:"read:org"})})," ",s.jsx(zS,{href:qS("github"),children:a("forge.token.makeOne")})]}),s.jsxs("li",{children:[s.jsx("strong",{children:a("forge.token.gh.fineName")})," ",a("forge.token.gh.fine")," ",s.jsx(zS,{href:qS("github",null,"fine-grained"),children:a("forge.token.makeOne")})]})]}),s.jsx("p",{children:a("forge.token.gh.approval")})]});const i=qS("gitlab",t??(n.where==="self"?n.baseUrl:null));return s.jsxs("div",{className:"fg-token-help",children:[s.jsxs("p",{children:[LI(a("forge.token.gl.scope"),{scope:s.jsx("code",{children:"read_api"})})," ",s.jsx(zS,{href:i,children:a("forge.token.makeOn",{host:i?new URL(i).host:"GitLab"})})]}),s.jsx("p",{children:a("forge.token.gl.expire")})]})}const bW={name:"token",type:"password",secret:!0,get label(){return C("forge.field.token")},get placeholder(){return C("forge.field.tokenPlaceholder")}},wSe=[bW],OI=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},ySe=[{name:"where",type:"choice",get label(){return C("forge.field.which")},get options(){return[{value:"cloud",label:"GitLab.com"},{value:"self",label:C("forge.field.selfManaged")}]},initial:e=>OI(e)?"self":"cloud"},{name:"baseUrl",type:"url",placeholder:"https://gitlab.example.com",get label(){return C("forge.field.url")},get hint(){return C("forge.field.urlHint")},when:{field:"where",is:["self"]},initial:e=>OI(e)?e.baseUrl:""},bW],xSe=m.createElement(fW,{kind:"github"}),CSe=m.createElement(fW,{kind:"gitlab"}),SSe=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},NSe={kind:"jira",label:"Jira",Glyph:ooe,shortcut:"I",detail:"Boards, sprints, and issues",blurb:"Jira Cloud, or Jira Server / Data Center 8.14 and newer.",fields:[{name:"deployment",label:"Which Jira",type:"choice",options:[{value:"server",label:"Jira Server / Data Center"},{value:"cloud",label:"Jira Cloud"}],initial:SSe},{name:"baseUrl",label:"Jira URL",type:"url",initial:e=>(e==null?void 0:e.baseUrl)??"",variants:{field:"deployment",by:{server:{label:"Jira URL",placeholder:"https://jira.example.com",hint:"The address you open Jira at, with its path if it has one (…/jira). https only."},cloud:{label:"Site URL",placeholder:"your-site.atlassian.net",hint:"The address you open Jira at. Your site name alone is enough."}}}},{name:"email",label:"Atlassian account email",type:"email",placeholder:"you@example.com",autoComplete:"username",secret:!0,when:{field:"deployment",is:["cloud"]}},{name:"token",label:"Personal access token",type:"password",secret:!0,variants:{field:"deployment",by:{server:{label:"Personal access token",placeholder:"Paste the token"},cloud:{label:"API token",placeholder:"Paste the API token"}}}}],tokenHelp:m.createElement(kSe)},jSe={kind:"github",label:"GitHub",Glyph:roe,detail:"Repositories, pull requests, and Actions",blurb:"github.com, read-only, with a personal access token.",fields:wSe,tokenHelp:xSe},ASe={kind:"gitlab",label:"GitLab",Glyph:coe,detail:"Projects, merge requests, and pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:ySe,tokenHelp:CSe},yj={jira:NSe,github:jSe,gitlab:ASe},$T=()=>Object.values(yj).filter(e=>!!e);function Wd(e){return(Object.hasOwn(yj,e)?yj[e]:void 0)??null}function Lf(e,t){const n=a=>typeof t=="string"?t:t(a);return m.lazy(()=>e().catch(a=>(console.warn(`ccdeck could not load ${typeof t=="string"?t:"a dialog"}`,a),{default:i=>s.jsx(TSe,{name:n(i),onClose:i.onClose})})))}function TSe({name:e,onClose:t}){const n=ae(),a=m.useRef(null),i=_t(t,{focusRef:a}),o=qt(t);return s.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:s.jsxs("div",{ref:i,className:"modal dialog-missing",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":n("shell.closeEsc"),title:n("shell.closeEsc"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[s.jsx("p",{className:"dm-note",children:n("shell.lazy.didNotLoad",{name:e})}),s.jsxs("div",{className:"dm-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:t,children:n("shell.close")}),s.jsx("button",{type:"button",ref:a,className:"btn primary",onClick:()=>window.location.reload(),children:n("shell.reload")})]})]})]})})}const vW=()=>Pr(()=>import("./IntegrationModal-1m1mQQhW.js"),[]);function RSe(){vW().catch(()=>{})}const ESe=Lf(vW,e=>{var t;return((t=Wd(e.kind))==null?void 0:t.label)??C("integrations.modal.tracker")});function _Se({onClose:e}){return m.useEffect(()=>jn.push(e,0,"dialog"),[e]),null}function qSe(e){return s.jsx(m.Suspense,{fallback:s.jsx(_Se,{onClose:e.onClose}),children:s.jsx(ESe,{...e})})}const PI={"The deck failed while reading the tracker.":"integrations.srv.deckFailed","The answer was larger than the deck accepts.":"integrations.srv.tooLarge","Enter a token.":"integrations.srv.enterToken","Enter an API token.":"integrations.srv.enterApiToken","Enter a personal access token.":"integrations.srv.enterPat","The token has a space in it. Paste it again.":"integrations.srv.tokenSpace","Enter the email address of your Atlassian account.":"integrations.srv.enterEmail","Choose Jira Cloud or Jira Server / Data Center.":"integrations.srv.chooseDeployment","Enter your Jira site URL.":"integrations.srv.enterSiteUrl","Enter your Jira URL.":"integrations.srv.enterJiraUrl","Enter your GitLab's address.":"integrations.srv.enterGitlabUrl","Your Jira site URL is not a valid URL.":"integrations.srv.badSiteUrl","Your Jira URL is not a valid URL.":"integrations.srv.badJiraUrl","Your GitLab's address is not a valid URL.":"integrations.srv.badGitlabUrl","Leave the user name and password out of the address.":"integrations.srv.urlUser","Use an https:// address. Plain http is only accepted for a server on this machine.":"integrations.srv.httpsOnly","Use an https:// address.":"integrations.srv.httpsAddress","That connection is not there any more.":"integrations.srv.connectionGone","No token is saved for this connection. Edit it and enter one.":"integrations.srv.noTokenEdit","No token is saved for this connection. Reconnect it in Settings.":"integrations.srv.noTokenReconnect","Enter a comment of up to 10,000 characters.":"integrations.srv.commentLength","This Jira write is outside the connection's token origins.":"integrations.srv.writeOutside","Jira redirected the comment. Refresh the issue before sending again.":"integrations.srv.commentRedirected","The comment could not be confirmed. Refresh the issue before sending again.":"integrations.srv.commentUnconfirmed","Jira redirected the write. It was not replayed; refresh the board before trying again.":"integrations.srv.writeRedirected","Jira's rank result was too large. Refresh the board to check its position.":"integrations.srv.rankTooLarge","Jira did not confirm every requested issue update. Some issues may have changed; refresh the board to check them.":"integrations.srv.updateUnconfirmed","Jira did not confirm the write. Refresh the board to check the issue.":"integrations.srv.writeUnconfirmed","Jira refused the move: the account or token needs permission to edit and schedule this issue.":"integrations.srv.moveRefused","Jira did not return its available transitions.":"integrations.srv.transitionsMissing","Choose a valid transition.":"integrations.srv.transitionChoose","This transition is unavailable or requires additional fields in Jira.":"integrations.srv.transitionUnavailable","Jira redirected the transition. Refresh the issue before trying again.":"integrations.srv.transitionRedirected","Jira did not confirm the transition. Refresh the issue.":"integrations.srv.transitionUnconfirmed","There is no Jira REST API at this address. Check the URL — some servers live under a path such as /jira.":"integrations.srv.noRestApi","This is a Jira Cloud site. Choose Jira Cloud and connect with your email and an API token.":"integrations.srv.isCloud","This is Jira Server or Data Center, not Cloud. Choose Jira Server / Data Center and use a personal access token.":"integrations.srv.isServer","Jira did not accept this email and API token, on the site or through api.atlassian.com. Check both, and that the token has not expired.":"integrations.srv.emailTokenRefused","Jira wants a CAPTCHA after too many failed sign-ins. Sign in to Jira once in your browser, then test the connection again.":"integrations.srv.captcha","Jira did not accept this personal access token: it answered as an anonymous visitor. Check that the token is right and has not expired or been revoked.":"integrations.srv.patAnonymous","That quick filter is not on this board any more. Refresh the board.":"integrations.srv.quickFilterGone","Jira writes are unavailable because this system cannot safely coordinate them.":"integrations.srv.writesUnavailable","Supply either one issueKey or 2–50 ordered issueKeys and a sprint or backlog target.":"integrations.srv.moveWhere","Supply unique, valid issue keys (2–50 for a batch).":"integrations.srv.moveKeys","Not a valid issue key or move target.":"integrations.srv.moveTarget","Use at most one other issue as the rank anchor.":"integrations.srv.moveAnchor","The issues and anchor must all belong to this board.":"integrations.srv.moveSameBoard","The issues and rank anchor must be top-level issues.":"integrations.srv.moveTopLevel","Only top-level non-epic issues with a known status can be moved.":"integrations.srv.moveEpicStatus","Done issues cannot be moved to the backlog because Jira hides them there. Change the status first.":"integrations.srv.moveDone","Every issue must be in the backlog or one active or future sprint.":"integrations.srv.moveSource","The source and target must be active or future sprints on this board.":"integrations.srv.moveSprints","An issue's source changed or is a closed sprint. Refresh the board.":"integrations.srv.moveSourceChanged","Could not determine the destination's last issue. Refresh and try again.":"integrations.srv.moveLastIssue","Could not verify the destination order. Refresh and try again.":"integrations.srv.moveOrder","The destination is too large to determine the last issue. Refresh and try again.":"integrations.srv.moveDestinationLarge","The rank anchor must be in the target group. Refresh the board.":"integrations.srv.moveAnchorGroup","This server runs Jira of an unknown version. Personal access tokens need Jira Server or Data Center 8.14 or newer, so the deck cannot connect to it.":"integrations.srv.serverOldUnknown","too many redirects":"forge.srv.redirects","answer too large":"forge.srv.answerLarge","answer cut off":"forge.srv.answerCut","unreadable JSON":"forge.srv.badJson","log too large to read the end of":"forge.srv.logLarge","image too large":"forge.srv.imageLarge","image cut off":"forge.srv.imageCut","that cursor is not a page of this list":"forge.srv.cursorPage","that cursor is not one of this list":"forge.srv.cursorList"},zSe=[[/^The deck could not verify (Jira|GitHub|GitLab)'s HTTPS certificate \((.+?)\)\. Check that the address is right and that the server's certificate is valid for it\.$/,"integrations.srv.tlsCert",["provider","code"]],[/^(Jira|GitHub|GitLab) did not answer in time\.$/,"integrations.srv.timeout",["provider"]],[/^The deck could not find (Jira|GitHub|GitLab)'s address\. Check the URL and your network\.$/,"integrations.srv.noAddress",["provider"]],[/^The deck could not reach (Jira|GitHub|GitLab) \((.+?)\)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReachCode",["provider","code"]],[/^The deck could not reach (Jira|GitHub|GitLab)\. Check the URL, your network or VPN\.$/,"integrations.srv.cannotReach",["provider"]],[/^(Jira|GitHub|GitLab) did not accept these credentials\.$/,"integrations.srv.noCredentials",["provider"]],[/^(Jira|GitHub|GitLab) no longer accepts the saved token\. It may have expired or been revoked — reconnect with a new one\.$/,"integrations.srv.tokenGone",["provider"]],[/^(Jira|GitHub|GitLab) refused: the account or token is not allowed to read this\.$/,"integrations.srv.notAllowed",["provider"]],[/^(Jira|GitHub|GitLab) is limiting requests\. Try again in (\d+) s\.$/,"integrations.srv.limiting",["provider","n"]],[/^(Jira|GitHub|GitLab) has no such page or record, or this account cannot see it\.$/,"integrations.srv.noSuchPage",["provider"]],[/^(Jira|GitHub|GitLab) refused the request\.$/,"integrations.srv.refusedRequest",["provider"]],[/^(Jira|GitHub|GitLab) is not answering right now \((\d+)\)\. Try again shortly\.$/,"integrations.srv.notAnswering",["provider","status"]],[/^(Jira|GitHub|GitLab) answered (\d+)\.$/,"integrations.srv.answered",["provider","status"]],[/^The deck only sends this connection's token to (.+)\.$/,"integrations.srv.tokenOrigins",["origins"]],[/^(Jira|GitHub|GitLab) redirected to (\S+?), and the deck does not send the token there\. Check the address you connected\.$/,"integrations.srv.redirectedAway",["provider","origin"]],[/^(Jira|GitHub|GitLab) redirected too many times\.$/,"integrations.srv.redirectedMany",["provider"]],[/^(Jira|GitHub|GitLab) answered with something that is not JSON\. Check that the address is the \1 site itself\.$/,"integrations.srv.notJson",["provider"]],[/^The deck will not send a token to (\S+?)\.$/,"integrations.srv.noTokenTo",["origin"]],[/^This server runs Jira (.+?)\. Personal access tokens need Jira Server or Data Center 8\.14 or newer, so the deck cannot connect to it\.$/,"integrations.srv.serverOld",["version"]],[/^(Jira|GitHub|GitLab) is not available on this deck\.$/,"integrations.srv.notOnDeck",["provider"]],[/^(\S+?) did not answer in time$/,"forge.srv.timeout",["origin"]],[/^(\S+?): the certificate is not trusted \((.+?)\)$/,"forge.srv.cert",["origin","code"]],[/^(\S+?): no answer$/,"forge.srv.noAnswer",["origin"]],[/^(\S+?) is not a host this connection reads from$/,"forge.srv.notHost",["origin"]],[/^(\S+?) sent this read to (\S+?), not to this connection's address$/,"forge.srv.sentElsewhere",["origin","next"]],[/^(\S+?) answered (.+?), not the API$/,"forge.srv.notApi",["origin","type"]],[/^not an image \((.+?)\)$/,"forge.srv.notImage",["type"]]];function LSe(e,t=C){if(!e)return"";const n=e.replace(/\u2019/g,"'"),a=Object.hasOwn(PI,n)?PI[n]:void 0;if(a)return t(a);for(const[i,o,r]of zSe){const c=i.exec(n);if(!c)continue;const d={};return r.forEach((u,p)=>{d[u]=c[p+1]}),t(o,d)}return e}function OSe(e){if(!e||typeof e!="object")return;const t=e;if(!(typeof t.operationId!="string"||!/^[0-9a-f-]{36}$/.test(t.operationId)||typeof t.connectionId!="string"||!["comment","status","move"].includes(t.kind)||!["pending","uncertain","confirmed"].includes(t.state))&&!(t.kind==="move"?!Array.isArray(t.issueKeys)||!t.issueKeys.every(n=>typeof n=="string"):typeof t.issueKey!="string"))return t}class $a extends Ln{constructor(n,a,i={}){super(a);Ma(this,"kind");Ma(this,"operation");Ma(this,"status");Ma(this,"retryAfter");Ma(this,"field");Ma(this,"detail");Ma(this,"refreshRequired");Ma(this,"outcomes");Ma(this,"moveOutcome");this.name="IntegrationFailure",this.kind=n,Object.assign(this,i)}}async function kW(e){try{const t=await e.json(),n=t==null?void 0:t.error,a=OSe(t==null?void 0:t.operation);if((t==null?void 0:t.code)==="jira_write_guard_conflict")return new $a("upstream",C("integrations.error.writeAwaiting"),{status:e.status,operation:a});if(n&&typeof n.kind=="string"&&typeof n.message=="string"){const i=Array.isArray(t.outcomes)?t.outcomes.slice(0,50).filter(c=>{if(!c||typeof c!="object")return!1;const d=c;return typeof d.issueKey=="string"&&/^[A-Z][A-Z0-9_]{0,40}-[1-9]\d{0,11}$/.test(d.issueKey)&&["moved","unchanged","unknown"].includes(String(d.membership))&&["ranked","unchanged","failed","unknown"].includes(String(d.rank))}).map(c=>({issueKey:c.issueKey,membership:c.membership,rank:c.rank})):[],o=t.outcome,r=o&&["moved","unchanged","unknown"].includes(o.membership)&&["ranked","unchanged","failed","unknown"].includes(o.rank)?{membership:o.membership,rank:o.rank}:void 0;return new $a(n.kind,LSe(n.message),{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail,...t.refresh===!0?{refreshRequired:!0}:{},...i.length?{outcomes:i}:{},...r?{moveOutcome:r}:{},...a?{operation:a}:{}})}}catch{}return new $a(e.status===401?"auth":"upstream",C("integrations.error.deckAnswered",{status:e.status}))}async function Zu(e,t={}){const{timeoutMs:n=3e4,...a}=t;return wW(a.signal,n,async i=>{let o;try{o=await fetch(e,{...a,signal:i,headers:a.body?{"Content-Type":"application/json",...a.headers??{}}:a.headers})}catch(r){throw i.aborted?r:new $a("network",C("integrations.error.unreachable"))}if(!o.ok)throw await kW(o);return o.json()})}async function wW(e,t,n){const a=new AbortController,i=window.setTimeout(()=>a.abort(),t),o=()=>a.abort(e==null?void 0:e.reason);e==null||e.addEventListener("abort",o,{once:!0}),e!=null&&e.aborted&&o();try{return a.signal.throwIfAborted(),await n(a.signal)}catch(r){throw e!=null&&e.aborted?e.reason??r:a.signal.aborted?new $a("network",C("integrations.error.timeout")):r}finally{window.clearTimeout(i),e==null||e.removeEventListener("abort",o)}}const yW=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function ZEe(e){const t=yW(e);return(n,a)=>fetch(`${t}${n.replace(/^\/+/,"")}`,a)}function XEe(e){const t=yW(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function QEe(e,t){if(!t)return null;try{const n=new URL(t);return n.username||n.password||n.protocol!=="https:"&&n.protocol!=="http:"?null:n.origin===new URL(e.baseUrl).origin?n.href:null}catch{return null}}function e1e(e){const t=new URLSearchParams;for(const[a,i]of Object.entries(e))i===void 0||i===""||i===!1||t.set(a,i===!0?"1":String(i));const n=t.toString();return n?`?${n}`:""}async function t1e(e,t,{signal:n,timeoutMs:a=45e3}={}){return wW(n,a,async i=>{let o;try{o=await e(t,{signal:i,headers:{Accept:"application/json"}})}catch(r){throw i.aborted?r:new $a("network",C("integrations.error.unreachable"))}if(!o.ok)throw await kW(o);try{return await o.json()}catch(r){throw i.aborted?r:new $a("upstream",C("integrations.error.notJson"))}})}let Ni={connections:null,providers:[],error:""};const Vc=new Set;let sg=null,Rd=null,sl=null,MI=0;const PSe=5e3,MSe=3;function hm(e){Ni={...Ni,...e},Vc.forEach(t=>t(Ni))}function Of(){return Rd||(Rd=(async()=>{try{const e=await Zu("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new $a("upstream",C("integrations.error.notList"));hm({connections:t,providers:n,error:""})}catch(e){hm({error:So(e,C("integrations.error.readConnections"))}),Ni.connections===null&&Vc.size>0&&sl===null&&MI<MSe&&(sl=window.setTimeout(()=>{sl=null,Of()},PSe*2**MI++))}finally{Rd=null}})(),Rd)}function ISe(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function II(){ISe(Ni)&&Of()}function VT(e){const t=Ni.connections??[],n=t.findIndex(a=>a.id===e.id);hm({connections:n<0?[...t,e]:t.map(a=>a.id===e.id?e:a)})}function DSe(e){hm({connections:(Ni.connections??[]).filter(t=>t.id!==e)})}function Xu(){const[e,t]=m.useState(Ni);return m.useEffect(()=>{Vc.add(t),t(Ni);const n=()=>{document.visibilityState==="visible"&&II()};return Vc.size===1&&(Of(),sg=window.setInterval(II,6e4),document.addEventListener("visibilitychange",n)),()=>{Vc.delete(t),Vc.size===0&&(sg!==null&&window.clearInterval(sg),sg=null,sl!==null&&window.clearTimeout(sl),sl=null,document.removeEventListener("visibilitychange",n))}},[]),e}function pm(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function Qu(e){return e.connections===null?new Set:new Set(e.providers.filter(t=>(t==null?void 0:t.available)===!0).map(t=>t.kind))}function yi(e,t){return Qu(e).has(t)}function xj(e,t){return yi(e,t)&&pm(e,t).length>0}function KT(e){return Qu(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function FSe(e,t,n){const a=await Zu("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return VT(a.connection),a.connection}async function USe(e,t){const n=await Zu(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return VT(n.connection),n}async function BSe(e){const t=await Zu(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return VT(t.connection),t.connection}async function HSe(e){await Zu(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),DSe(e)}function or(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function n1e(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length?(t.length===1?t[0].slice(0,2):`${t[0][0]}${t[t.length-1][0]}`).toUpperCase():"?"}let gm=null,mm=null;function DI(e){mm=null,gm=e}function WSe(e){gm=null,mm=e}function GSe(){const e=mm;return mm=null,e}function $Se(){const e=gm;return gm=null,e}const VSe={jira:"integrations.explore.cap.jira",github:"integrations.explore.cap.github",gitlab:"integrations.explore.cap.gitlab"},KSe={jira:"integrations.explore.access.jira",github:"integrations.explore.access.read",gitlab:"integrations.explore.access.read"};function JSe(){return Array.from(document.querySelectorAll('[data-rail-item="explore-integrations"], [data-rail-item="more"]')).find(e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0)??null}function YSe({integrations:e,onClose:t,onOpen:n,onConnect:a,onManage:i}){const o=ae(),r=_t(t,{restoreFocusFallback:JSe}),c=qt(t),d=$T().filter(g=>e.providers.some(f=>f.kind===g.kind)||pm(e,g.kind).length>0),u=d.filter(g=>xj(e,g.kind)).length,p=g=>{t(),g()};return Lt.createPortal(s.jsx("div",{className:"modal-backdrop",role:"presentation",...c,children:s.jsxs("div",{ref:r,className:"modal explore-integrations",role:"dialog","aria-modal":"true","aria-labelledby":"explore-integrations-title","aria-describedby":"explore-integrations-description",children:[s.jsxs("div",{className:"modal-head explore-head",children:[s.jsx("h2",{id:"explore-integrations-title",children:o("integrations.explore.title")}),s.jsx("button",{type:"button",className:"glyph-btn","aria-label":o("integrations.explore.closeAria"),title:o("integrations.closeEsc"),onClick:t,children:"×"})]}),s.jsxs("div",{className:"explore-body",children:[s.jsx("p",{id:"explore-integrations-description",className:"explore-intro",children:o("integrations.explore.intro")}),e.error&&s.jsxs("p",{className:"explore-status",role:"alert",children:[e.error," ",o("integrations.explore.stale")]}),e.connections===null?s.jsx("p",{className:"explore-status",role:"status",children:e.error?o("integrations.explore.statusUnavailable"):o("integrations.explore.reading")}):d.length===0?s.jsx("p",{className:"explore-status",role:"status",children:o("integrations.explore.none")}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"explore-caption",children:[s.jsx("span",{children:o("integrations.explore.available")}),s.jsx("span",{children:o("integrations.explore.connectedCount",{n:u})})]}),s.jsx("ul",{className:"explore-providers",children:d.map(g=>{const f=yi(e,g.kind),v=xj(e,g.kind),k=pm(e,g.kind)[0];return s.jsxs("li",{className:"explore-provider",children:[s.jsx("span",{className:"explore-glyph","aria-hidden":!0,children:s.jsx(g.Glyph,{})}),s.jsxs("div",{className:"explore-info",children:[s.jsx("h3",{children:g.label}),s.jsx("p",{children:o(VSe[g.kind])}),s.jsxs("span",{className:"explore-connection","data-connected":v||void 0,children:[o(f?v?"integrations.explore.connected":"integrations.explore.notConnected":"integrations.explore.unavailableOnDeck")," · ",o(KSe[g.kind])]})]}),s.jsx("div",{className:"explore-actions",children:v?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"btn","aria-label":o("integrations.explore.openAria",{label:g.label}),onClick:()=>p(()=>n(g.kind)),children:[o("integrations.explore.open")," ",s.jsx(fl,{})]}),s.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":o("integrations.manageProvider",{label:g.label}),onClick:()=>p(()=>i(k==null?void 0:k.id)),children:o("integrations.manage")})]}):f?s.jsx("button",{type:"button",className:"btn primary","aria-label":o("integrations.form.connect",{provider:g.label}),onClick:()=>p(()=>a(g.kind)),children:o("integrations.form.connectBtn")}):k?s.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":o("integrations.manageProvider",{label:g.label}),onClick:()=>p(()=>i(k.id)),children:o("integrations.manage")}):s.jsx("span",{className:"explore-unavailable",children:o("integrations.explore.notAvailable")})})]},g.kind)})})]})]}),s.jsxs("div",{className:"explore-footer",children:[s.jsx("span",{children:o("integrations.explore.footer")}),s.jsxs("button",{type:"button",className:"btn explore-text-action",onClick:()=>p(()=>i()),children:[o("integrations.explore.manageInSettings")," ",s.jsx(fl,{})]})]})]})}),document.body)}function ZSe({widths:e,room:t,gap:n,more:a}){let i=0,o=0;for(let r=0;r<e.length;r++){i+=(r>0?n:0)+e[r];const c=r+1<e.length?n+a:0;if(i+c>t)break;o=r+1}return o}function xW(e,t=C){return e.tool?e.tool.name:e.kind==="asked"?t("board.queue.question"):t("board.queue.permission")}const XSe=20;function QSe(e,t=XSe){if(e.length<=t)return e;const n=Math.floor((t-1)*.4),a=t-1-n;return`${e.slice(0,a)}…${e.slice(e.length-n)}`}function eNe(e,t=C){const n=Math.floor(Math.max(0,e)/6e4);if(n<1)return t("board.queue.lessThanMinute");if(n<60)return t("board.queue.minutes",{count:n});const a=Math.floor(n/60),i=n%60;return i===0?t("board.queue.hours",{count:a}):t("board.queue.hoursMinutes",{h:t("board.queue.hours",{count:a}),m:t("board.queue.minutes",{count:i})})}function tNe(e,t,n,a=C){var r;const i=eNe(n,a),o=t.tool?"board.queue.entry.tool":t.kind==="asked"?"board.queue.entry.answer":"board.queue.entry.permission";return a(o,{label:e,wait:i,tool:((r=t.tool)==null?void 0:r.name)??""})}function nNe(e,t=C){const n=dl(e,t),a=$2(e,n,t);return a?`${n}
152
152
  ${a}`:n}const aNe=new Set(["idle","checking","current","downloading","ready","error"]);function FI(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!aNe.has(t.status))return null;const n=typeof t.version=="string"&&t.version.trim()?t.version.trim():null;return t.status==="ready"&&!n?null:{status:t.status,version:n}}function sNe(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function CW(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Ru=()=>C("shell.desktop.restartToUpdate"),SW=3e4;function NW(e=typeof navigator>"u"?"":navigator.userAgent){return/\bMac OS X\b|\bMacintosh\b/.test(e)?C("shell.desktop.menuMac"):C("shell.desktop.menuTray")}function iNe(e,t){const n=`v${e} → v${t}`;return{text:n,label:C("shell.desktop.chipLabel",{text:n}),title:C("shell.desktop.chipTitle",{to:t,action:Ru()})}}function jW(e,t=!1){return{text:t?C("shell.notes.restarting"):Ru(),label:t?void 0:C("shell.desktop.restartLabel",{action:Ru(),to:e}),title:C("shell.desktop.restartTitle",{to:e})}}function oNe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function AW(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const a=NW(n),i=Ru(),o=C("shell.desktop.way",{action:i,menu:a});switch(e){case"app_disconnected":return C("shell.desktop.fail.app_disconnected",{way:o});case"update_not_ready":return C("shell.desktop.fail.update_not_ready",{version:t,action:i,menu:a});case"timeout":return C("shell.desktop.fail.timeout",{seconds:SW/1e3,way:o});case"refused":return C("shell.desktop.fail.refused",{way:o});case"unreachable":return C("shell.desktop.fail.unreachable",{way:o})}}function UI(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?C("shell.ago.now"):t<3600?C("shell.ago.m",{n:Math.floor(t/60)}):t<86400?C("shell.ago.h",{n:Math.floor(t/3600)}):C("shell.ago.d",{n:Math.floor(t/86400)})}function rNe(e){const t=Math.max(0,Math.round(e/1e3));if(t<5)return C("shell.ago.now");if(t<60)return C("shell.ago.sec",{n:t});const n=Math.round(t/60);return n<60?C("shell.ago.min",{n}):C("shell.ago.hrSpelled",{n:Math.round(n/60)})}const cNe=()=>C("shell.chip.checksOff"),LS=()=>C("shell.chip.notesClick");function lNe(e){if(e.checkDisabled)return C("shell.chip.titleOff",{off:cNe(),click:LS()});if(e.checking)return C("shell.chip.titleBusy",{asking:C("shell.chip.asking"),click:LS()});const t=e.latest?C("shell.chip.npmHas",{latest:e.latest}):e.latestPending?C("shell.chip.pendingTag",{pending:e.latestPending}):C("shell.chip.notReached"),n=e.checkFailedAgo?` · ${C("shell.chip.couldNotReach",{ago:e.checkFailedAgo})}`:e.checkedAgo?` · ${C("shell.chip.checked",{ago:e.checkedAgo})}`:"";return C("shell.chip.title",{state:t,age:n,click:LS()})}function dNe(e){const t=C("shell.chip.label",{running:e.running});return e.checkDisabled?C("shell.chip.labelOff",{base:t}):e.checking?C("shell.chip.labelChecking",{base:t}):e.checkFailedAgo?C("shell.chip.labelFailed",{base:t,ago:e.checkFailedAgo}):C("shell.chip.labelPlain",{base:t})}function uNe(e){const t=e.kind==="restart"?C("shell.chip.noticeRestart",{to:e.to}):C("shell.chip.noticeUpgrade",{to:e.to}),n=e.open?C("shell.chip.noticeShow"):C("shell.chip.noticeShowBanner");return C("shell.chip.noticeLabel",{from:e.from,what:t,does:n})}function TW(e){return e?`${e.kind}:${e.to}`:""}function hNe(e,t){return e!=null&&t!==TW(e)}function pNe({readyAppUpdate:e,notice:t,noticeOpen:n,version:a,chipVersion:i,versionChecking:o,now:r,openReleaseNotes:c,showNotice:d,loadVersion:u,restartToUpdate:p,updateRestarting:g=!1}){return Ea(),s.jsx(s.Fragment,{children:e?(()=>{const f=iNe(CW()??i,e.version),v=p&&jW(e.version,g);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"v ready",onClick:c,"aria-haspopup":"dialog","aria-label":f.label,title:f.title,children:[f.text,s.jsx("span",{className:"v-dot","aria-hidden":!0})]}),v&&s.jsx("button",{type:"button",className:"v ready v-update",onClick:()=>p(e.version),"aria-busy":g||void 0,"aria-label":v.label,title:v.title,children:v.text})]})})():t?s.jsxs("button",{type:"button",className:"v stale",onClick:()=>{c(),d()},"aria-haspopup":"dialog","aria-label":uNe({...t,open:n}),title:t.kind==="restart"?C("shell.chip.runningRestart",{from:t.from,to:t.to}):C("shell.chip.runningUpgrade",{from:t.from,to:t.to}),children:["v",t.from,s.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const f={running:i,latest:a==null?void 0:a.latest,latestPending:a==null?void 0:a.latestPending,checkedAgo:a!=null&&a.checkedAt?UI(r-a.checkedAt):null,checkFailedAgo:a!=null&&a.checkFailedAt&&a.checkFailedAt>(a.checkedAt??0)?UI(r-a.checkFailedAt):null,checkDisabled:a==null?void 0:a.checkDisabled,checking:o};return s.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{c(),u(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":dNe(f),title:lNe(f),children:["v",f.running]})})()})}function gNe({live:e,paused:t,pauseGate:n}){const a=ae(),i=Qn();return s.jsx("span",{className:"status",children:(()=>{const o=Ane({connected:e,paused:t,held:n.size,dropped:n.dropped,singleKeys:i},a);return o.resting?null:s.jsx("span",{className:`pill ${o.tone}`,title:o.title,children:s.jsxs("span",{className:"pill-box",children:[s.jsx("span",{className:"pill-widest","aria-hidden":!0,children:o.widest}),s.jsx("span",{className:"pill-label",children:o.label})]})})})()})}function mNe(e,t,n){return`${e.label} — ${xW(e.waiting,n)} · ${ku(e.waiting.since,void 0,t)}`}function RW(e,t,n){const a=e.slice(0,6).map(i=>mNe(i,t,n));return e.length>6&&a.push(n("board.queue.andMore",{n:e.length-6})),a.join(`
153
153
  `)}function fNe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:a,named:i}){const o=ae(),r=Qn(),c=Nl("below"),d=e.slice(i),u=e.length;return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{t.current=e[0].id,n(e[0].id)},"aria-label":o("board.queue.waitingForYou",{count:u}),"aria-keyshortcuts":r?"W":void 0,...c.bind({label:o("board.queue.longest"),keys:r?"W":void 0,detail:d.length>0?RW(d,a,o):void 0}),children:[s.jsx("span",{className:"ap-pulse","aria-hidden":!0}),s.jsx("b",{children:u})," ",o("board.queue.waiting")]}),c.node]})}function BI({w:e,now:t}){const n=ae();return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"we-name",children:QSe(e.label)}),s.jsx("span",{className:"we-wait",children:ku(e.waiting.since,void 0,t)}),s.jsxs("span",{className:"we-what",children:["· ",xW(e.waiting,n)]})]})}const bNe=12,vNe=2e3,kNe=4;function wNe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:a,onFit:i,onMore:o}){const r=ae(),c=Qn(),d=Nl("below"),u=m.useRef(null),p=m.useRef(null),[g,f]=m.useState(0),v=e.map(w=>w.id).join(`
154
154
  `);m.useLayoutEffect(()=>{const w=u.current,S=p.current;if(!w||!S)return;const j=()=>{const T=Array.from(S.children),E=T.pop();f(ZSe({widths:T.map(q=>q.getBoundingClientRect().width),room:w.clientWidth-bNe,gap:kNe,more:(E==null?void 0:E.getBoundingClientRect().width)??0}))};if(j(),typeof ResizeObserver>"u")return;const A=new ResizeObserver(j);return A.observe(w),A.observe(S),()=>A.disconnect()},[v]);const k=e.slice(0,g),y=e.slice(g);m.useEffect(()=>{i(k.length)},[k.length,i]);const N=w=>{t.current=w,n(w)};return s.jsxs("div",{className:"wait-names",ref:u,children:[s.jsxs("ul",{className:"wait-list",children:[k.map(w=>s.jsx("li",{"data-fresh":a-w.waiting.since<vNe||void 0,children:s.jsx("button",{type:"button",className:"wait-entry",onClick:()=>N(w.id),"aria-label":tNe(w.label,w.waiting,a-w.waiting.since,r),...d.bind({label:w.label,detail:nNe(w.waiting,r)}),children:s.jsx(BI,{w,now:a})})},w.id)),k.length>0&&y.length>0&&s.jsx("li",{children:s.jsx("button",{type:"button",className:"wait-more",onClick:o,"aria-label":r("board.queue.moreLabel",{n:y.length}),"aria-keyshortcuts":c?"L":void 0,...d.bind({label:r("board.queue.openList"),keys:c?"L":void 0,detail:RW(y,a,r)}),children:r("board.note.more",{n:y.length})})})]}),e.length>0&&s.jsxs("span",{className:"wait-ruler",ref:p,"aria-hidden":!0,children:[e.map(w=>s.jsx("span",{className:"wait-entry",children:s.jsx(BI,{w,now:a})},w.id)),s.jsx("span",{className:"wait-more",children:r("board.note.more",{n:e.length})})]}),d.node]})}const yNe={on:"board.notify.means.on",blocked:"board.notify.means.blocked"};function xNe(e,t=C){return e==="on"?t("board.notify.said.on"):e==="blocked"?t("board.notify.said.blocked"):""}function CNe({notifySaid:e}){const t=ae();return s.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:t(yNe[e]),children:t(e==="on"?"board.notify.on":"board.notify.blocked")})}function SNe({versionCheck:e,welcome:t,desktopUpdate:n,pause:a,announcements:i,notify:o,waitingSessions:r,waitingCursorRef:c,focusSession:d,live:u,now:p,incidents:g,queueNamed:f}){const{version:v,notice:k,noticeOpen:y,showNotice:N,versionChecking:w,loadVersion:S}=e,{chipVersion:j,openReleaseNotes:A}=t,{readyAppUpdate:T,desktopUpdateRestarting:E,desktopUpdateFailure:q,askDesktopUpdateRestart:F}=n,z=m.useRef(!1);m.useEffect(()=>{E||!z.current||(z.current=!1,q&&A())},[E,q,A]);const H=W=>{z.current=!0,F(W)},{paused:I,pauseGate:L}=a,O=ae(),{blockedSaid:_,watchSaid:M,incidentSaid:U}=i,{notifySaid:G}=o;return s.jsxs("div",{className:"readout",children:[s.jsxs("div",{className:"brand",children:[s.jsx("img",{className:"logo logo-on-dark",src:zle,width:19,height:16,alt:""}),s.jsx("img",{className:"logo logo-on-light",src:Lle,width:19,height:16,alt:""}),s.jsx("h1",{children:Pt}),s.jsx(pNe,{readyAppUpdate:T,notice:k,noticeOpen:y,version:v,chipVersion:j,versionChecking:w,now:p,openReleaseNotes:A,showNotice:N,loadVersion:S,restartToUpdate:H,updateRestarting:E})]}),s.jsx(gNe,{live:u,paused:I,pauseGate:L}),s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:_}),s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M}),s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:U}),s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:xNe(G,O)}),s.jsx(Wle,{incidents:g}),r.length>0&&s.jsx(fNe,{waitingSessions:r,waitingCursorRef:c,focusSession:d,now:p,named:f}),G&&s.jsx(CNe,{notifySaid:G})]})}function NNe({selected:e,now:t,selectedIds:n,focusAgent:a,clearSelection:i}){const o=ae(),r=Qn(),c=fa(e),d=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"&&!e.synthetic?pA(c.total,d):null,p=n.size-1;return s.jsxs("button",{type:"button",className:"selected-ribbon",title:`${Yn(o("board.ribbon.zoom",{label:e.label}),"Z",r)}${c.total>0?`
155
- ${o("board.ribbon.spent",{cost:At(c.total)})}${u?` · ${u}`:""}`:""}`,onClick:()=>{try{a(e.id)}catch{}},children:[s.jsx("span",{className:`state-pill state-${e.state}`,children:yo(e.state,o)}),s.jsx("span",{className:"selected-label",children:e.label}),c.total>0&&s.jsxs("span",{className:"selected-cost",children:[At(c.total),u?s.jsxs("span",{className:"selected-rate",children:[" · ",u]}):null]}),p>0&&s.jsxs("span",{className:"selected-extra",children:["+",p]}),s.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:g=>{g.stopPropagation(),i()},children:"×"})]})}function jNe({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:a,toggleCat:i}){const o=ae();return s.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":o("board.cat.filter"),children:n.map(r=>{const c=a.has(r);return s.jsxs("button",{type:"button",className:`cat-filter${c?" off":""}`,onClick:()=>i(r),"aria-pressed":!c,title:o(c?"board.cat.show":"board.cat.hide",{cat:Mg(r,o)}),children:[s.jsx(zCe,{cat:r}),s.jsx("span",{className:"cat-name",children:Mg(r,o)})]},r)})})}const ANe=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function TNe(e){var n,a;const t=e.target;!(t!=null&&t.closest)||t.closest(ANe)!==e.currentTarget||(e.preventDefault(),(a=(n=document.activeElement)==null?void 0:n.blur)==null||a.call(n))}function RNe({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:a}){const i=ae(),o=Qn();return s.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[s.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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"})}),s.jsxs("span",{className:"drag-trash-copy",children:[s.jsx("span",{className:"drag-trash-text",children:t==="over"?s.jsxs(s.Fragment,{children:[i("board.trash.release")," ",s.jsx("strong",{className:"drag-trash-name",children:a||i("board.trash.thisCard")})]}):i("board.trash.drop")}),s.jsx("span",{className:"drag-trash-hint",children:t==="over"?i("board.trash.bringsBack",{list:Yn(i("board.detail.listUpper"),"L",o)}):i("board.trash.keepsRunning")})]})]})}function ENe({canvasRef:e,bubbling:t,dragging:n,trash:a,zoom:i,viewport:o,stateRef:r,peek:c,children:d}){const{trashDragging:u,trashState:p,trashPhase:g,trashZoneRef:f,trashLabel:v}=a,{lod:k,lodRef:y}=i,{markCanvasInput:N}=o,{peekAgent:w,peekLabel:S,peekRecap:j,peekBounds:A}=c;return s.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${u&&p==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:TNe,onPointerDownCapture:N,onPointerUpCapture:N,onWheelCapture:N,onFocusCapture:T=>{const E=T.target;if(!FT(E)||y.current==null||y.current==="detail")return;const q=E.getAttribute("data-id");q&&r.current.agents.has(q)&&E.matches(":focus-visible")&&G4(q,E,"focus")},onBlurCapture:T=>{var q,F;const E=(F=(q=T.target).getAttribute)==null?void 0:F.call(q,"data-id");E&&To(E)},children:[d,mo(g)&&s.jsx(RNe,{trashZoneRef:f,trashState:p,trashPhase:g,trashLabel:v}),s.jsx(ixe,{agentFor:w,recapFor:j,labelFor:S,bounds:A})]})}function _Ne({restarting:e,restartMode:t,live:n,paused:a}){const i=ae();return s.jsxs("div",{className:"conn-banner",role:"alert",children:[s.jsx("span",{className:"conn-dot"}),e?t==="npx"?i("shell.banner.fetchingNpx"):i("shell.banner.restartingProduct",{product:Pt}):(()=>{const o=Nne({connected:n,paused:a});return s.jsxs(s.Fragment,{children:[i("shell.banner.lost",{product:Pt}),o&&s.jsx("span",{className:"conn-sub",children:o})]})})()]})}function qNe({oldName:e,version:t,dismissOldName:n}){const a=ae();return s.jsxs("div",{className:"ver-banner",role:"status",children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{children:a("shell.banner.oldName",{old:e,product:Pt})}),t!=null&&t.renameFix?s.jsx("span",{className:"ver-sub",children:t.renameFix}):null,s.jsx("button",{type:"button","aria-label":a("shell.dismiss"),className:"ver-close",onClick:n,children:"×"})]})}const EW=()=>C("shell.rating.thanks"),zNe=Array.from({length:11},(e,t)=>t);function LNe(e){return e===0?C("shell.rating.score0"):e===10?C("shell.rating.score10"):C("shell.rating.score",{n:e})}const ONe=6;function PNe(e){const t=m.useRef(null);return m.useLayoutEffect(()=>{const n=t.current,a=n==null?void 0:n.closest(".app");if(!n||!a)return;const i=()=>a.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);i();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(i);return o==null||o.observe(n),()=>{o==null||o.disconnect(),a.style.removeProperty("--rating-h")}},[e]),t}function MNe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function INe({phase:e,score:t,onAnswer:n,onLater:a,onClose:i,onFeedback:o,onHold:r}){ae();const c=PNe(e),d=m.useRef(null),u=m.useRef(null),p=m.useRef(!1);m.useEffect(()=>{var f,v;e!=="thanks"||!p.current||(p.current=!1,Xn(((f=document.activeElement)==null?void 0:f.tagName)??null)&&((v=d.current??u.current)==null||v.focus()))},[e]);const g=f=>{var v;(v=c.current)!=null&&v.contains(document.activeElement)&&MNe(),f()};return e==="thanks"?s.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>r(!0),onBlur:f=>{f.currentTarget.contains(f.relatedTarget)||r(!1)},children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{children:EW()}),t!==null&&t<=ONe?s.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:C("shell.rating.better")}):null,s.jsx("button",{ref:u,type:"button","aria-label":C("shell.dismiss"),className:"ver-close",onClick:()=>g(i),children:"×"})]}):s.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{id:"rating-question",children:C("shell.rating.question")}),s.jsx("span",{className:"rating-scale",children:zNe.map(f=>s.jsx("button",{type:"button",className:"rating-pick","aria-label":LNe(f),onClick:v=>{p.current=v.detail===0||v.currentTarget.matches(":focus-visible"),n(f)},children:f},f))}),s.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:C("shell.rating.ends")}),s.jsx("button",{type:"button",className:"ver-act",onClick:()=>g(a),children:C("shell.rating.later")})]})}const DNe=3e4;function FNe({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function UNe({bundle:e,running:t,pending:n,lastTried:a}){return t?FNe({bundle:e,running:t,lastTried:a})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function BNe(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function HNe({asked:e,reported:t}){return t?t!==e:!1}function _W(e){const t=e.thresholdMs??DNe;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 WNe(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 GNe(e,t){return e?t==null?C("shell.banner.autoIdle"):C("shell.banner.autoIn",{time:WNe(t)}):C("shell.banner.autoOff")}function HI(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function $Ne(e,t=!1){return e<=0&&t?{label:C("shell.banner.restartAnyway"),clause:C("shell.banner.clausePaused")}:e<=0?{label:C("shell.banner.restartNow"),clause:C("shell.banner.clauseIdle")}:{label:C("shell.banner.restartAnyway"),clause:C("shell.banner.clauseAgents",{count:e})}}function VNe(e){const t=_W(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 Cj={get git_checkout(){return C("shell.banner.block.git_checkout")},get npx(){return C("shell.banner.block.npx")},get one_off(){return C("shell.banner.block.one_off")},get not_writable(){return C("shell.banner.block.not_writable")},get opted_out(){return C("shell.banner.block.opted_out")},get retired_name(){return C("shell.banner.block.retired_name")}};function KNe({notice:e,version:t,dismissNotice:n,upgradeState:a,startUpgrade:i,copyCommand:o,cmdCopied:r,autoRestart:c,toggleAutoRestart:d,askRestart:u,restartCopy:p,restartFuseMs:g,restarting:f}){var k,y,N;const v=ae();return s.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[s.jsx("span",{className:`ver-dot${g==null?"":" armed"}`}),e.kind==="restart"?s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:v("shell.banner.installedStale",{to:e.to,from:e.from})}),t!=null&&t.canRestart?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"ver-act",onClick:()=>u(),...ga(f),title:v("shell.banner.restartTitle"),children:f?v("shell.banner.restarting"):p.label}),!f&&s.jsx("span",{className:"ver-sub",children:p.clause}),s.jsxs("label",{className:"ver-auto",children:[s.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":v("shell.banner.autoRestart"),title:v(c?"shell.banner.autoOnTitle":"shell.banner.autoOffTitle"),children:s.jsx("span",{className:"switch-knob"})}),s.jsx("span",{"aria-hidden":!0,children:GNe(c,g)})]})]}):s.jsx("span",{className:"ver-sub",title:v("shell.banner.restartNeededTitle"),children:v("shell.banner.restartNeeded")})]}):s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:v("shell.banner.isOut",{product:Pt,to:e.to,from:e.from})}),(t==null?void 0:t.upgradeMode)==="install"&&a!=="failed"&&s.jsx("button",{type:"button",className:"ver-act",onClick:i,...ga(a==="running",a==="done"),title:v("shell.banner.installTitle",{command:((k=t==null?void 0:t.upgrade)==null?void 0:k.command)??(t==null?void 0:t.command)??"npm i -g"}),children:v(a==="running"?"shell.banner.installing":a==="done"?"shell.banner.installed":"shell.update.now")}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&s.jsx("button",{type:"button",className:"ver-act",onClick:()=>u({upgrade:!0}),...ga(f),title:v("shell.banner.npxTitle",{command:(t==null?void 0:t.command)??""}),children:v(f?"shell.banner.fetching":a==="failed"?"shell.update.retry":"shell.update.andRestart")}),a==="failed"?s.jsx("span",{className:"ver-sub fail",title:((y=t==null?void 0:t.upgrade)==null?void 0:y.error)??"",children:v("shell.banner.failedLine",{what:(t==null?void 0:t.upgradeMode)==="npx"?v("shell.banner.updateFailed"):v("shell.banner.installFailed"),error:((N=t==null?void 0:t.upgrade)==null?void 0:N.error)??v("shell.banner.unknownError")})}):(t==null?void 0:t.upgradeMode)==="npx"?s.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?v("shell.banner.npxRerun"):Cj.npx}):t!=null&&t.upgradeBlocked?s.jsx("span",{className:"ver-sub",children:un(Cj,t.upgradeBlocked)??v("shell.banner.cannotInstall")}):null,s.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:v("shell.banner.copyTitle"),children:[s.jsx("code",{children:t==null?void 0:t.command}),s.jsx("span",{className:"ver-cmd-hint",children:v(r?"shell.banner.copiedHint":"shell.banner.copyHint")})]})]}),s.jsx("button",{type:"button","aria-label":v("shell.dismiss"),className:"ver-close",onClick:n,children:"×"})]})}function JNe({restart:e,versionCheck:t,upgrade:n,oldNameNotice:a,rating:i,onFeedback:o,everConnected:r,live:c,paused:d}){const u=ae(),{autoRestart:p,toggleAutoRestart:g,restarting:f,restartMode:v,restartedTo:k,askRestart:y,restartCopy:N,restartFuseMs:w}=e,{version:S,notice:j,noticeOpen:A,dismissNotice:T}=t,{upgradeState:E,startUpgrade:q,copyCommand:F,cmdCopied:z}=n,{oldName:H,oldNameOpen:I,dismissOldName:L}=a,{ratingPhase:O,ratingScore:_,answerRating:M,rateLater:U,closeRating:G,holdThanks:W}=i,$=k?s.jsxs("div",{className:"ver-banner done",role:"status",children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{children:u("shell.banner.restartedTo",{version:k})}),s.jsx("span",{className:"ver-sub",children:u("shell.banner.replayed")})]}):r&&!c?s.jsx(_Ne,{restarting:f,restartMode:v,live:c,paused:d}):A&&j?s.jsx(KNe,{notice:j,version:S,dismissNotice:T,upgradeState:E,startUpgrade:q,copyCommand:F,cmdCopied:z,autoRestart:p,toggleAutoRestart:g,askRestart:y,restartCopy:N,restartFuseMs:w,restarting:f}):I&&H?s.jsx(qNe,{oldName:H,version:S,dismissOldName:L}):O!=="hidden"?s.jsx(INe,{phase:O,score:_,onAnswer:M,onLater:U,onClose:G,onFeedback:o,onHold:W}):null;return s.jsxs(s.Fragment,{children:[$,s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O==="thanks"?EW():""})]})}function YNe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function ZNe(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 XNe(e,t){return e<=0?null:t("board.clear.goes.agents",{count:e})}function QNe(e,t,n=C){const a=XNe(e,n),i=(...d)=>[a,...d,n("board.clear.goes.view")].filter(u=>u!==null),o=n("board.clear.final"),r=n("board.clear.confirmAll");if(!t)return{goes:i(n("board.clear.goes.logUnknown")),stays:[],final:o,confirm:r};if(!t.path)return{goes:i(),stays:[],final:n("board.clear.final.noLog",{final:o}),confirm:r};if(!t.mine){const d=t.ownerPort===null?n("board.clear.owner.other"):n("board.clear.owner.port",{port:t.ownerPort}),u=t.decks>2?n("board.clear.owner.shared",{decks:t.decks}):"";return{goes:i(),stays:[n("board.clear.stays.log",{owner:d,shared:u}),n("board.clear.stays.replay")],final:null,confirm:n("board.clear.confirmCanvas")}}if(t.decks<=1)return{goes:i(n("board.clear.goes.logOwn")),stays:[],final:o,confirm:r};const c=t.decks-1;return{goes:i(n("board.clear.goes.logShared",{count:c})),stays:[n("board.clear.stays.shared",{count:c})],final:o,confirm:r}}function eje({agentCount:e,onConfirm:t,onCancel:n}){const a=ae(),i=m.useRef(null),o=_t(n,{focusRef:i,layer:Tee}),r=qt(n),[c,d]=m.useState(null);m.useEffect(()=>{let v=!1;return fetch("/api/clear").then(k=>k.ok?k.json():null).then(k=>{v||d(ZNe(k))}).catch(()=>{}),()=>{v=!0}},[]);const{goes:u,stays:p,final:g,confirm:f}=QNe(e,c,a);return s.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:s.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{className:"status-dot err","aria-hidden":!0}),s.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:a("board.clear.title")})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":a("board.clear.cancelEsc"),title:a("board.clear.cancelEsc"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[s.jsxs("dl",{className:"cc-plan",children:[s.jsx("dt",{children:a("board.clear.goes")}),s.jsx("dd",{children:u.map(v=>s.jsx("span",{children:v},v))}),s.jsx("dt",{children:a("board.clear.stays")}),s.jsx("dd",{children:p.length>0?p.map(v=>s.jsx("span",{children:v},v)):s.jsx("span",{children:a("board.clear.nothing")})})]}),g&&s.jsx("p",{className:"cc-final",children:g}),s.jsxs("div",{className:"cc-actions",children:[s.jsx("button",{type:"button",ref:i,className:"btn",onClick:n,children:a("board.clear.cancel")}),s.jsx("button",{type:"button",className:"btn danger",onClick:t,children:f})]})]})]})})}function Sj(e,t,n){const a=`{${t}}`,i=e.indexOf(a);return i<0?e:s.jsxs(m.Fragment,{children:[e.slice(0,i),n,e.slice(i+a.length)]})}function tje({kind:e,onChange:t}){const n=ae();return s.jsxs("fieldset",{className:"fb-kinds",children:[s.jsx("legend",{className:"vis-hidden",children:n("shell.feedback.kinds")}),um.map(a=>s.jsxs("label",{className:"fb-kind",children:[s.jsx("input",{type:"radio",name:"feedback-kind",value:a.value,checked:e===a.value,onChange:()=>t(a.value),onKeyDown:i=>{GT(i.nativeEvent)&&i.preventDefault()}}),a.label]},a.value))]})}const qW="fb-details";function nje({open:e,onToggle:t}){return ae(),s.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":qW,onClick:t,children:[tSe(),s.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:s.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function aje({open:e,contact:t,onContact:n}){const a=ae(),i=m.useId();return s.jsx("div",{id:qW,className:"fb-details","data-open":e||void 0,children:s.jsx("div",{className:"fb-details-clip",children:s.jsxs("div",{className:"fb-details-body",children:[s.jsxs("div",{className:"fb-field",children:[s.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[nSe(),s.jsx("span",{className:"fb-optional",children:a("shell.feedback.optional")})]}),s.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:hW,autoComplete:"email",placeholder:aSe(),"aria-describedby":i,onChange:o=>n(o.target.value),onKeyDown:o=>{GT(o.nativeEvent)&&o.preventDefault()}}),s.jsx("p",{id:i,className:"fb-hint",children:sSe()})]}),s.jsx("div",{className:"fb-where",children:iSe().map(o=>s.jsx("p",{children:o},o))})]})})})}const br=3,sje=5*1024*1024,ije=12*1024*1024,Nj=8192,oje=64*1024,rje=256*1024,cje=.92,lje=640,zW=.9,dje=.85,uje=6,hje=512*1024,fm={png:"image/png",jpeg:"image/jpeg"},pje={png:"png",jpeg:"jpg"},gje=[137,80,78,71,13,10,26,10],mje=[255,216,255];function LW(e){const t=n=>e.length>=n.length&&n.every((a,i)=>e[i]===a);return t(gje)?"png":t(mje)?"jpeg":null}function fje(e){const t=LW(e);return t==="png"?bje(e):t==="jpeg"?kje(e):null}function bje(e){const t=[73,72,68,82];if(e.length<24||!t.every((a,i)=>e[12+i]===a))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function vje(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function kje(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 a=e[t]<<8|e[t+1];if(a<2)return null;if(vje(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=a}return null}function WI(e,t){return e.bytes>t||e.width>Nj||e.height>Nj}function wje(e){return Math.min(sje,ije-oje-e)}function OW(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function yje(e,t){const n=Nj/Math.max(e.width,e.height),a=e.bytes>t?Math.sqrt(t/e.bytes)*zW:1;return OW(e,Math.min(1,n,a))}async function xje(e,t,n){let a=yje(e,t),i=e.format;for(let o=0;o<uje;o++){const r=await n(a,i,i==="jpeg"?cje:void 0);if(!r)return null;if(r.size<=t)return{...a,blob:r,format:i};if(i==="png"){i="jpeg";continue}if(a=OW(a,Math.min(dje,Math.sqrt(t/r.size)*zW)),Math.max(a.width,a.height)<lje)return null}return null}async function Cje(e,t,n){const a=new Uint8Array(await e.slice(0,hje).arrayBuffer()),i=LW(a);if(!i)return{ok:!1,problem:"type"};if(t<rje)return{ok:!1,problem:"no_room"};const o=e.type===fm[i]?e:new Blob([e],{type:fm[i]}),r=fje(a);if(r&&!WI({...r,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:i};if(!WI(d,t))return{ok:!0,blob:o,resized:null};const u=await xje(d,t,c.encoder);return u?{ok:!0,blob:u.blob,resized:{width:u.width,height:u.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Sje(e){return({width:t,height:n},a,i)=>new Promise(o=>{const r=document.createElement("canvas");r.width=t,r.height=n;const c=r.getContext("2d");if(!c)return o(null);a==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),r.toBlob(d=>{r.width=0,r.height=0,o(d)},fm[a],i)})}const Nje=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Sje(t),release:()=>t.close()}};function jje(e){return e.includes("Files")}function Aje({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Tje(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Rje(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((a,i)=>{const o=a.type===fm.jpeg?"jpeg":"png";n.append("images",a,`image-${i+1}.${pje[o]}`)}),{method:"POST",body:n}}const Eje=()=>C("shell.feedback.addShot"),GI=()=>C("shell.feedback.addHint"),_je=()=>C("shell.feedback.shotsNote"),$I=()=>C("shell.feedback.full"),qje=()=>C("shell.feedback.refusedWhileSending");function zje(e,t,n){const a=n?C("shell.feedback.resized",{width:n.width,height:n.height}):"";return C("shell.feedback.replaceLabel",{n:e+1,name:t,fit:a})}function Lje(e,t){const n=C("shell.feedback.shotsCount",{count:e,max:br});return t>0?C("shell.feedback.shotsResized",{of:n,resized:t}):n}function Oje(e){return C("shell.feedback.leftOut",{count:e})}function Pje(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Mje(e,t){const n=Pje(t);return e==="type"?C("shell.feedback.problem.type",{file:n}):e==="no_room"?C("shell.feedback.problem.noRoom",{file:n}):e==="unreadable"?C("shell.feedback.problem.unreadable",{file:n}):C("shell.feedback.problem.tooLarge",{file:n})}const PW="image/png,image/jpeg";function MW({className:e="fb-glyph"}){return s.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:[s.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),s.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),s.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Ije({images:e,buttonRef:t}){ae();const n=m.useRef(null),a=e.shots.length>=br;return s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:GI(),"aria-describedby":"fb-attach-hint",onClick:()=>{var i;return a?e.sayFull():(i=n.current)==null?void 0:i.click()},children:[s.jsx(MW,{}),Eje()]}),s.jsx("span",{id:"fb-attach-hint",hidden:!0,children:GI()}),s.jsx("input",{ref:n,type:"file",accept:PW,multiple:!0,hidden:!0,onChange:i=>{e.add(Array.from(i.target.files??[])),i.target.value=""}})]})}function Dje({images:e,addRef:t}){const n=ae(),a=m.useRef(new Map),i=m.useRef(null),o=m.useRef(null),r=m.useRef(null),[c,d]=m.useState(null),{shots:u}=e,p=Lje(u.length,u.filter(v=>v.resized).length);m.useLayoutEffect(()=>{var v;c!==null&&((v=c==="add"?t.current:a.current.get(c))==null||v.focus(),d(null))},[c,t]),m.useEffect(()=>{var v;e.problem&&((v=i.current)==null||v.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function g(v){d(Tje(u.map(k=>k.id),v)??"add"),e.remove(v)}function f(v){var k;r.current=v,(k=o.current)==null||k.click()}return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),s.jsx("input",{ref:o,type:"file",accept:PW,hidden:!0,onChange:v=>{const k=r.current;k!==null&&e.replace(k,Array.from(v.target.files??[])),r.current=null,v.target.value=""}}),u.length>0&&s.jsxs("div",{className:"fb-shots",children:[s.jsxs("div",{className:"fb-shots-row",children:[s.jsx("ul",{className:"fb-shots-list",children:u.map((v,k)=>s.jsxs("li",{className:"fb-shot","data-fitting":v.blob?void 0:!0,children:[s.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":zje(k,v.name,v.resized),onClick:()=>f(v.id),children:[s.jsx("img",{className:"fb-shot-img",src:v.url,alt:""}),v.blob?s.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:n("shell.feedback.replace")}):s.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:n("shell.feedback.resizing")})]}),s.jsx("button",{ref:y=>{y?a.current.set(v.id,y):a.current.delete(v.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":n("shell.feedback.removeImage",{n:k+1}),title:n("shell.feedback.removeImage",{n:k+1}),onClick:()=>g(v.id),children:s.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:s.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},v.id))}),s.jsx("span",{className:"fb-shots-count",children:p})]}),s.jsx("p",{className:"fb-hint",children:_je()})]}),e.problem&&s.jsx("p",{ref:i,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Fje(e,t){return e.map((n,a)=>({id:t+a,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function Uje(e,t,n){return n?e.map(a=>a.id===t.id?t:a):[...e,t]}function Bje(e,t,n){return n?e.map(a=>a.id===t?n:a):e.filter(a=>a.id!==t)}function Hje(e){const[t,n]=m.useState(()=>Fje((e==null?void 0:e.ready)??[],1)),[a,i]=m.useState({problem:"",id:0}),o=m.useRef(0),r=m.useCallback(L=>{L&&o.current++,i(O=>L?{problem:L,id:O.id+1}:O.problem?{problem:"",id:O.id}:O)},[]),[c,d]=m.useState(""),u=m.useRef(t),p=m.useRef(null),g=m.useRef(t.length),f=m.useRef(!0),v=m.useRef(new Map),k=m.useRef([]),y=m.useRef(0),N=m.useCallback(L=>{u.current=L(u.current),n(u.current)},[]);m.useEffect(()=>(f.current=!0,()=>{f.current=!1;for(const L of u.current)URL.revokeObjectURL(L.url)}),[]);const w=m.useCallback(async(L,O)=>{const _=u.current.reduce((Z,D)=>{var K;return Z+(D.id===(O==null?void 0:O.id)?0:((K=D.blob)==null?void 0:K.size)??0)},0),M=(O==null?void 0:O.id)??++g.current,U=URL.createObjectURL(L),G={id:M,name:L.name||"image",url:U,blob:null,resized:null},W=y.current;v.current.set(M,L);let $=!1;const Y=()=>{$||($=!0,N(Z=>Uje(Z,G,O!==void 0)))},B=await Cje(L,wje(_),async Z=>(Y(),Nje(Z))).catch(()=>({ok:!1,problem:"unreadable"})),V=u.current.some(Z=>Z.id===M);return!f.current||y.current!==W||!V&&($||O)?(URL.revokeObjectURL(U),O&&URL.revokeObjectURL(O.url),f.current&&v.current.delete(M),""):(v.current.delete(M),B.ok?(Y(),O&&URL.revokeObjectURL(O.url),N(Z=>Z.map(D=>D.id===M?{...D,blob:B.blob,resized:B.resized}:D)),""):(URL.revokeObjectURL(U),$&&N(Z=>Bje(Z,M,O)),Mje(B.problem,L.name||"image")))},[N]),S=m.useCallback(async L=>{r("");const O=y.current,_=[];let M=0,U=0;for(const W of L){if(!f.current||y.current!==O)return;const $=k.current.indexOf(W);if($!==-1&&k.current.splice($,1),u.current.length>=br){M++;continue}const Y=u.current.length,B=await w(W);B&&_.push(B),u.current.length>Y&&U++}if(!f.current||y.current!==O)return;M>0&&_.push(U===0&&_.length===0?$I():Oje(M)),r(_.join(" "));const G=u.current.length;U>0&&d(C("shell.feedback.imagesAdded",{count:U,total:G,max:br}))},[w,r]),j=m.useCallback(async(L,O)=>{r("");const _=u.current.find(G=>G.id===L);if(!_)return S([O]);const M=await w(O,_);if(!f.current)return;r(M);const U=u.current.findIndex(G=>G.id===L);!M&&U!==-1&&d(C("shell.feedback.imageReplaced",{n:U+1,total:u.current.length,max:br}))},[S,w,r]),A=m.useCallback(L=>{const O=y.current;p.current=(p.current??Promise.resolve()).then(()=>y.current===O?L():void 0).catch(()=>{})},[]),T=m.useCallback(L=>{L.length!==0&&(k.current.push(...L),A(()=>S(L)))},[S,A]);m.useEffect(()=>{e&&e.waiting.length>0&&T(e.waiting)},[]);const E=m.useCallback((L,O)=>{const _=O[0];_&&A(()=>j(L,_))},[A,j]),q=m.useCallback(L=>{const O=u.current.find(_=>_.id===L);O&&(URL.revokeObjectURL(O.url),v.current.delete(L),N(_=>_.filter(M=>M.id!==L)),r(""),d(C("shell.feedback.imageRemoved",{count:u.current.length,max:br})))},[N,r]),F=m.useCallback(()=>r($I()),[r]),z=m.useCallback(async()=>{const L=o.current;return await p.current,o.current!==L?null:u.current.flatMap(O=>O.blob?[O.blob]:[])},[]),H=m.useCallback(()=>({ready:u.current.flatMap(L=>L.blob&&!v.current.has(L.id)?[{name:L.name,blob:L.blob,resized:L.resized}]:[]),waiting:[...v.current.values(),...k.current]}),[]),I=m.useCallback(()=>{y.current++;for(const L of u.current)URL.revokeObjectURL(L.url);v.current.clear(),k.current=[],N(()=>[]),r("")},[N,r]);return{shots:t,problem:a.problem,problemId:a.id,announcement:c,add:T,replace:E,remove:q,sayFull:F,ready:z,kept:H,clear:I}}function Wje(){const[e,t]=m.useState(null);return m.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(a=>a.ok?a.json():null).then(a=>{n&&t(JCe(a))}).catch(()=>{}),()=>{n=!1}},[]),e}function Gje(e){const[t,n]=m.useState({state:"idle"}),a=m.useRef(!1),i=m.useRef(null);m.useEffect(()=>()=>{var c;return(c=i.current)==null?void 0:c.abort()},[]);async function o(c){if(!Jn(a.current))return;a.current=!0;const{signal:d}=i.current=new AbortController;n({state:"sending"});try{const u=await e.ready();if(d.aborted)return;if(!u){n({state:"failed",message:qje()});return}const p=await fetch("/api/feedback",{...Rje(KCe(c),u),signal:d}),g=await p.json().catch(()=>null);n(p.ok&&(g!=null&&g.ok)?{state:"sent"}:{state:"failed",message:_I(p.status,g==null?void 0:g.reason,g==null?void 0:g.errors)})}catch{d.aborted||n({state:"failed",message:_I(0,null)})}finally{a.current=!1}}const r=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:r}}function $je(e,t){const[n,a]=m.useState(!1),i=m.useRef(t);return i.current=t,m.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>a(!0),qI),r=window.setTimeout(()=>i.current(),qI+uSe);return()=>{window.clearTimeout(o),window.clearTimeout(r)}},[e]),n}const OS="agent-dag.feedbackDrafts",VI=4;function Vje({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Kje(e){return JSON.stringify([e.kind,e.body])}function Jje(e){return e.ready.length+e.waiting.length}function IW(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Yje(e){return C("shell.feedback.lost",{count:e})}const Zje=()=>C("shell.feedback.discard"),Xje=()=>C("shell.feedback.discardConfirm"),Qje=()=>C("shell.feedback.discardTitle"),KI=()=>C("shell.feedback.discardArmed"),eAe={ready:[],waiting:[]};function tAe(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:a,contact:i,images:o}=t;return!um.some(r=>r.value===n)||typeof a!="string"||a.length>uW||typeof i!="string"||i.length>hW||typeof o!="number"||!Number.isInteger(o)||o<0||o>br?null:[e[0],{kind:n,body:a,contact:i,images:o}]}function nAe(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const r=(o=e())==null?void 0:o.getItem(OS),c=r?JSON.parse(r):[];if(Array.isArray(c))for(const d of c.slice(-VI)){const u=tAe(d);u&&t.set(u[0],{...u[1],images:null,imageCount:u[1].images})}}catch{}return t}function a(){try{const o=e();if(!o)return;const r=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);r.length===0?o.removeItem(OS):o.setItem(OS,JSON.stringify(r))}catch{}}function i(o){n().delete(o)&&a()}return{read(o){const r=n().get(o);return r?{kind:r.kind,body:r.body,contact:r.contact,images:r.images??eAe,imagesLost:r.images?0:r.imageCount}:null},keep(o,r,c){const d=Jje(r.images);if(!IW({body:r.body,contact:r.contact,images:d},c)){i(o);return}const u=n();u.delete(o),u.set(o,{kind:r.kind,body:r.body,contact:r.contact,images:r.images,imageCount:d});for(const p of u.keys()){if(u.size<=VI)break;u.delete(p)}a()},forget:i}}function aAe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const jj=nAe(aAe),sAe=4e3;function iAe(e,t,n,a,i){const o=m.useRef(null);o.current={key:e,seed:t,words:n,images:a,sent:i};const r=m.useCallback(()=>{const c=o.current;!c||c.sent||jj.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);m.useEffect(r,[r,n.kind,n.body,n.contact,a.shots]),m.useEffect(()=>r,[r]),m.useEffect(()=>{i&&jj.forget(e)},[i,e])}const JI="draft";function oAe(e){const[t,n]=m.useState(!1),a=m.useRef(0);m.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),sAe);return()=>window.clearTimeout(o)},[t]);function i(){const o=Date.now(),r=zr({armedFor:t?JI:null,target:JI,armedAt:a.current,now:o,gapMs:qr});if(r==="arm"){n(!0),a.current=o;return}r!=="ignore"&&(n(!1),e())}return{armed:t,press:i}}function DW({onClose:e,initialKind:t,initialBody:n}){const a=ae(),i=m.useRef(null),o=m.useRef(null),r=m.useRef(null),c=m.useRef(null),d=m.useRef(null),u=m.useRef(null),p=m.useRef(null),g=m.useRef(null),f=m.useRef(0),v=_t(e,{focusRef:i}),k=qt(e),y=Vje({initialKind:t,initialBody:n}),N=Kje(y),[w]=m.useState(()=>jj.read(N)),[S,j]=m.useState((w==null?void 0:w.kind)??y.kind),[A,T]=m.useState((w==null?void 0:w.body)??y.body),[E,q]=m.useState((w==null?void 0:w.contact)??""),[F,z]=m.useState((w==null?void 0:w.imagesLost)??0),[H,I]=m.useState(!1),[L,O]=m.useState(!1),[_,M]=m.useState(!1),U=Hje(w==null?void 0:w.images),G=XCe(Wje()),{outcome:W,sending:$,send:Y,clearFailure:B}=Gje(U),V=W.state==="sent",Z=$je(V,e);iAe(N,y,{kind:S,body:A,contact:E},U,V);const D=IW({body:A,contact:E,images:U.shots.length},y),K=oAe(()=>{var Ae;j(y.kind),T(y.body),q(""),z(0),O(!1),U.clear(),B(),(Ae=i.current)==null||Ae.focus()}),X=dW(S),Q=L&&!RI(A),ee=F>0&&U.shots.length===0,ne=[Q&&"fb-body-error",ee&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[de,ge]=rSe(Co());m.useEffect(()=>{var Oe,Ve;const Ae=c.current;if(!Ae)return;const je=Ae.contains(document.activeElement)||Xn(((Oe=document.activeElement)==null?void 0:Oe.tagName)??null);Ae.inert=V,V&&je&&((Ve=o.current)==null||Ve.focus())},[V]),m.useEffect(()=>{var nt,Ye;const Ae=d.current;if(!Ae)return;const je=p.current;if($){const Ce=document.activeElement,ze=Ce!=null&&(Ae.contains(Ce)||Ce===je);g.current=ze?Ce:null,Ae.inert=!0,je&&(je.inert=!0),g.current&&((nt=u.current)==null||nt.focus());return}Ae.inert=!1,je&&(je.inert=!1);const Oe=g.current;g.current=null;const Ve=document.activeElement===u.current||Xn(((Ye=document.activeElement)==null?void 0:Ye.tagName)??null);!V&&Oe&&Ve&&Oe.focus()},[$,V]);function le(Ae){var je;if(Ae.preventDefault(),!RI(A)){O(!0),(je=i.current)==null||je.focus();return}Y({kind:S,body:A,contact:E})}const he=!V&&!$,ce=Ae=>jje(Array.from(Ae.dataTransfer.types));function oe(Ae){!ce(Ae)||!he||(Ae.preventDefault(),f.current++,M(!0))}function ve(Ae){ce(Ae)&&(Ae.preventDefault(),Ae.dataTransfer.dropEffect=he?"copy":"none")}function ke(Ae){ce(Ae)&&(f.current=Math.max(0,f.current-1),f.current===0&&M(!1))}function ye(Ae){ce(Ae)&&(Ae.preventDefault(),f.current=0,M(!1),he&&U.add(Array.from(Ae.dataTransfer.files)))}function Le(Ae){Ae.target!==Ae.currentTarget||!ce(Ae)||(Ae.preventDefault(),Ae.dataTransfer.dropEffect="none")}function Ke(Ae){ce(Ae)&&Ae.preventDefault()}function Qe(Ae){if(!he)return;const je=Array.from(Ae.clipboardData.files),Oe=Ae.target,Ve=Oe instanceof HTMLTextAreaElement||Oe instanceof HTMLInputElement,nt=Array.from(Ae.clipboardData.types).includes("text/plain");Aje({files:je.length,hasText:nt,intoTextField:Ve})&&(Ae.preventDefault(),U.add(je))}return s.jsx("div",{className:"modal-backdrop",...k,role:"presentation",onDragOver:Le,onDrop:Ke,"data-leaving":Z||void 0,children:s.jsxs("div",{ref:v,className:"modal feedback-dialog",onClick:Ae=>Ae.stopPropagation(),onDragEnter:oe,onDragOver:ve,onDragLeave:ke,onDrop:ye,onPaste:Qe,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:a("shell.feedback.title")})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{ref:o,type:"button",className:"glyph-btn",onClick:e,"aria-label":a("shell.closeEsc"),title:a("shell.closeEsc"),children:"×"})})]}),s.jsx("p",{className:"vis-hidden",role:"status",children:K.armed?KI():dSe(W.state)}),s.jsxs("div",{className:"fb-stage",children:[s.jsxs("form",{ref:c,className:"fb-form",onSubmit:le,onKeyDown:Ae=>{oSe(Ae.nativeEvent)&&(Ae.preventDefault(),Ae.currentTarget.requestSubmit())},noValidate:!0,children:[s.jsxs("section",{ref:d,className:"modal-body fb-body",children:[s.jsx(tje,{kind:S,onChange:j}),s.jsxs("div",{className:"fb-compose",children:[s.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),s.jsx("textarea",{ref:i,id:"fb-body",className:"ap-manage-input fb-message",value:A,maxLength:uW,rows:5,placeholder:X.placeholder,onChange:Ae=>T(Ae.target.value),"aria-invalid":Q||void 0,"aria-describedby":ne,required:!0}),Q&&s.jsx("p",{id:"fb-body-error",className:"fb-error",children:WCe()}),s.jsx(Dje,{images:U,addRef:r}),ee&&s.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Yje(F)}),s.jsxs("div",{className:"fb-tools",children:[s.jsx(Ije,{images:U,buttonRef:r}),s.jsx(nje,{open:H,onToggle:()=>I(Ae=>!Ae)})]}),s.jsx(aje,{open:H,contact:E,onContact:q})]}),s.jsx("p",{className:"fb-facts",children:G?Sj(QCe(),"facts",s.jsx("span",{className:"fb-facts-value",children:G})):eSe()}),W.state==="failed"&&s.jsx("p",{className:"fb-error",role:"alert",children:W.message})]}),s.jsxs("div",{className:"fb-foot",children:[D&&s.jsx("button",{ref:p,type:"button",className:`btn danger fb-discard${K.armed?" armed":""}`,onKeyDown:Ae=>{Ae.repeat&&Ae.preventDefault()},onClick:K.press,title:K.armed?KI():Qje(),children:K.armed?Xje():Zje()}),s.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[s.jsx("kbd",{"data-symbol":cSe(de)||void 0,children:de}),s.jsx("kbd",{children:ge})," ",a("shell.feedback.toSend")]}),s.jsx("button",{type:"button",className:"btn",onClick:e,children:a("shell.cancel")}),s.jsx("button",{ref:u,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...ga($),children:s.jsxs("span",{className:"fb-send-label",children:[s.jsx("span",{className:"fb-send-idle",children:a("shell.feedback.send")}),s.jsx("span",{className:"fb-send-busy",children:a("shell.feedback.sending")})]})})]})]}),V&&s.jsxs("div",{className:"fb-done",children:[s.jsx(Tu,{}),s.jsx("p",{className:"fb-done-line",children:pW()})]})]}),s.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":_||void 0,children:s.jsxs("div",{className:"fb-drop-frame",children:[s.jsx(MW,{className:"fb-drop-glyph"}),s.jsx("p",{className:"fb-drop-title",children:a("shell.feedback.dropTitle")}),s.jsx("p",{className:"fb-drop-note",children:a("shell.feedback.dropNote")})]})})]})})}const PS=[{id:"canvas",get title(){return C("settings.key.group.canvas")},rows:[{cap:"Space",get action(){return C("settings.key.pause")},binds:[" "]},{cap:"J",get action(){return C("settings.key.next")},binds:["j","J"]},{cap:"K",get action(){return C("settings.key.prev")},binds:["k","K"]},{cap:"W",get action(){return C("settings.key.waiting")},binds:["w","W"]},{cap:"F",get action(){return C("settings.key.fit")},binds:["f","F"]},{cap:"Z",get action(){return C("settings.key.zoom")},binds:["z","Z"]},{cap:"Delete",get action(){return C("settings.key.delete")},binds:["Delete"]},{cap:"R",get action(){return C("settings.key.rearrange")},binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",get action(){return C("settings.key.undo")},binds:["z","Z"],chord:!0},{cap:"C",get action(){return C("settings.key.clear")},binds:["c","C"]}]},{id:"panels-and-dialogs",get title(){return C("settings.key.group.panels")},rows:[{cap:"Ctrl + K",macCap:"⌘ K",get action(){return C("settings.key.quick")},binds:["k","K"],chord:!0},{cap:"U",get action(){return C("settings.key.usage")},binds:["u","U"]},{cap:"L",get action(){return C("settings.key.sessions")},binds:["l","L"]},{cap:"D",get action(){return C("settings.key.detail")},binds:["d","D"]},{cap:"H",get action(){return C("settings.key.history")},binds:["h","H"]},{cap:"A",get action(){return C("settings.key.accounts")},binds:["a","A"]},{cap:"S",get action(){return C("settings.key.machine")},binds:["s","S"]},{cap:"B",get action(){return C("settings.key.bw")},binds:["b","B"]},{cap:"I",get action(){return C("settings.key.jira")},binds:["i","I"],integration:"jira"},{cap:"?",get action(){return C("settings.key.sheet")},binds:["?"]}]},{id:"settings",get title(){return C("settings.key.group.settings")},rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",get action(){return C("settings.key.all")},binds:[","],chord:!0},{cap:"V",get action(){return C("settings.key.sound")},binds:["v","V"]},{cap:"M",get action(){return C("settings.key.mute")},binds:["m","M"]},{cap:"T",get action(){return C("settings.key.theme")},binds:["t","T"]}]},{id:"focus-and-selection",get title(){return C("settings.key.group.focus")},rows:[{cap:"Tab",get action(){return C("settings.key.tab")},binds:[]},{cap:"Enter",get action(){return C("settings.key.enter")},binds:["Enter"]},{cap:"Shift + Enter",get action(){return C("settings.key.shiftEnter")},binds:["Enter"]},{cap:"Esc",get action(){return C("settings.key.esc")},binds:["Escape"]}]},{id:"mouse",get title(){return C("settings.key.group.mouse")},rows:[{get cap(){return C("settings.key.cap.drag")},get action(){return C("settings.key.drag")},binds:[]},{get cap(){return C("settings.key.cap.shiftClick")},get action(){return C("settings.key.shiftClick")},binds:[]},{get cap(){return C("settings.key.cap.click")},get action(){return C("settings.key.click")},binds:[]},{get cap(){return C("settings.key.cap.doubleClick")},get action(){return C("settings.key.doubleClick")},binds:[]},{get cap(){return C("settings.key.cap.hover")},get action(){return C("settings.key.hover")},binds:[]}]}],rAe=/ ?\([A-Z?]\)/g;function FW(e,t=()=>!0){const n=a=>a.integration===void 0||t(a.integration);return e&&PS.every(a=>a.rows.every(n))?PS:PS.map(a=>({...a,rows:a.rows.filter(n).filter(i=>e||i.chord||!i.binds.some(SU)).map(i=>e?i:{...i,action:i.action.replace(rAe,"")})})).filter(a=>a.rows.length>0)}function cAe(e,t){return e.split(/\{(\w+)\}/g).map((a,i)=>i%2===1&&a in t?s.jsx(m.Fragment,{children:t[a]},i):a===""?null:s.jsx(m.Fragment,{children:i%2===1?`{${a}}`:a},i))}function lAe({onClose:e,onTour:t,onSettings:n}){const a=ae(),i=_t(e),o=qt(e),r=zo(Co()),c=Qn(),d=Xu(),u=FW(c,p=>yi(d,p));return s.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:s.jsxs("div",{ref:i,className:"modal key-help",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":c?void 0:"key-help-off",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:a("settings.key.title")})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":a("settings.key.close"),title:a("settings.key.close"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[!c&&s.jsxs("div",{className:"kh-off",children:[s.jsx("p",{className:"kh-off-text",id:"key-help-off",children:cAe(a("settings.key.offText",{title:"{title}",place:"{place}"}),{title:s.jsx("strong",{children:a("settings.key.offTitle")}),place:s.jsx("span",{className:"kh-place",children:a("settings.key.place")})})}),n&&s.jsx("button",{type:"button",className:"btn",onClick:n,children:a("settings.key.openSettings")})]}),t&&s.jsxs("div",{className:"guide-door",children:[s.jsx("span",{children:a("settings.key.tourText")}),s.jsx("button",{type:"button",className:"btn",onClick:t,children:a("settings.key.tour")})]}),s.jsx("div",{className:"shortcuts",children:u.map(p=>s.jsxs(m.Fragment,{children:[s.jsx("h3",{className:"kh-group",children:p.title}),p.rows.map(g=>s.jsxs("div",{className:"sc",children:[s.jsx("kbd",{children:r&&g.macCap?g.macCap:g.cap}),s.jsx("span",{children:g.action})]},`${p.id}:${g.cap}:${g.action}`))]},p.id))}),c&&s.jsxs("p",{className:"kh-foot",children:[a("settings.key.note")," ",a("settings.key.switchNote",{place:a("settings.key.place")})]})]})]})})}function dAe(e,t){return`${e}#${t}`}function uAe(e,{lan:t,now:n,closed:a}){if(t===void 0)return[];const i=[];for(const o of e??[]){const r=o.reauth;if(!r||r.dismissed||o.origin!=="ccdeck_signin")continue;const c=dAe(r.key,r.since);if(a.has(c)||cpe(r.key,o.email,t,n))continue;const d=o.email??"";i.push({id:c,key:r.key,since:r.since,num:o.num,email:d,name:d||o.alias||C("accounts.accountN",{n:o.num}),alias:d&&o.alias?o.alias:null})}return i}function hAe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(a=>a.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(a.num)===String(t.num))).map(a=>a.id):[]}function UW({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function pAe(e,t=C){return t("accounts.reauth.title",{count:e})}function gAe(e,t=C){return t("accounts.reauth.lead",{count:e})}const mAe=(e=C)=>e("accounts.reauth.expired"),fAe=(e=C)=>e("accounts.reauth.singleNote"),bAe=(e=C)=>e("accounts.reauth.laterTip");function vAe(e,t){const n=(e??[]).filter(i=>i&&typeof i.fp=="string"&&!t.has(i.fp));if(!n.length)return{request:null,waiting:0};const a=[...n].sort((i,o)=>(i.at??0)-(o.at??0));return{request:a[0],waiting:a.length-1}}function kAe({request:e,waiting:t,busy:n,now:a,onAccept:i,onDecline:o,onLater:r}){const c=ae(),d=m.useRef(null),u=_t(r,{focusRef:d}),p=qt(r),g=xo(n,"accept"),f=xo(n,"dismiss");return s.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:s.jsxs("div",{ref:u,className:"modal lan-ask",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("i",{className:"ap-pulse","aria-hidden":!0}),s.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:c("lan.ask.title")})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:r,"aria-label":c("lan.ask.later"),title:c("lan.ask.later"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[s.jsx("p",{id:"lan-ask-who",className:"lan-ask-who",children:s.jsx(Or,{text:c("lan.ask.who",{when:dT(e.at,a)}),parts:{name:s.jsx("strong",{className:"lan-ask-name",children:e.name}),addr:s.jsx("code",{className:"ap-lan-code",children:e.addr})}})}),s.jsx("p",{className:"modal-note",children:c("lan.ask.note")}),s.jsx("p",{className:"lan-ask-fp",children:s.jsx(Or,{text:c("lan.ask.fp"),parts:{fp:s.jsx("code",{className:"ap-lan-code",children:e.fp})}})}),t>0&&s.jsx("p",{className:"lan-ask-more",children:c("lan.ask.more",{count:t})}),s.jsxs("div",{className:"lan-ask-acts",children:[s.jsx("button",{type:"button",ref:d,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:o,title:c("lan.ask.declineTitle"),children:c(n==="dismiss"?"lan.ask.declining":"lan.ask.decline")}),s.jsx("button",{type:"button",className:"btn primary",disabled:g.disabled,"aria-busy":g.busy,onClick:i,title:c("lan.ask.acceptTitle"),children:c(n==="accept"?"lan.ask.accepting":"lan.ask.accept")})]})]})]})})}function wAe(e){const t=m.useRef(!1),n=yAe(e),a=UW({rows:n?1:0,ours:t.current,dialogs:jn.dialogDepth()});return t.current=a,a?n:null}function yAe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:a,deferLanPair:i}){const{request:o,waiting:r}=vAe(e,t.current);return o?s.jsx(kAe,{request:o,waiting:r,busy:n,now:Date.now(),onAccept:()=>void a("accept",o.fp),onDecline:()=>void a("dismiss",o.fp),onLater:()=>i(o.fp)},o.fp):null}function xAe({rows:e,onSignIn:t,onLater:n,firstRef:a}){const i=ae(),o=e.length===1?e[0]:null;return s.jsxs("section",{className:"modal-body",children:[o?s.jsxs(s.Fragment,{children:[s.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:hT(i,"accounts.reauth.leadOne",{name:s.jsxs(s.Fragment,{children:[s.jsx("strong",{className:"reauth-name",children:o.name}),o.alias?s.jsxs("span",{className:"reauth-alias",children:[" (",o.alias,")"]}):null]})})}),s.jsx("p",{className:"reauth-note",children:fAe(i)})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:gAe(e.length,i)}),s.jsx("ul",{className:"reauth-list",children:e.map((r,c)=>s.jsxs("li",{className:"reauth-row",children:[s.jsxs("span",{className:"reauth-who",title:r.alias?`${r.alias} — ${r.name}`:r.name,children:[r.name,r.alias?s.jsxs("span",{className:"reauth-alias",children:[" ",r.alias]}):null]}),s.jsx("span",{className:"reauth-what",children:mAe(i)}),s.jsx("button",{type:"button",className:"btn",ref:c===0?a:void 0,"aria-label":i("accounts.reauth.againAs",{name:r.name}),onClick:()=>t(r),children:i("accounts.reauth.again")})]},r.id))}),s.jsx("p",{className:"reauth-note",children:i("accounts.reauth.keeps")})]}),s.jsxs("div",{className:"reauth-acts",children:[s.jsx("button",{type:"button",className:"btn",title:bAe(i),onClick:n,children:i("accounts.reauth.later")}),o&&s.jsx("button",{type:"button",className:"btn primary",ref:a,onClick:()=>t(o),children:i("accounts.reauth.again")})]})]})}function CAe({rows:e,onSignIn:t,onLater:n}){const a=ae(),i=m.useRef(null),o=_t(n,{focusRef:i}),r=qt(n);return s.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:s.jsxs("div",{ref:o,className:"modal reauth-ask",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:pAe(e.length,a)})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":a("accounts.reauth.laterEsc"),title:a("accounts.reauth.laterEsc"),children:"×"})})]}),s.jsx(xAe,{rows:e,onSignIn:t,onLater:n,firstRef:i})]})})}function SAe({rows:e,signingIn:t,signIn:n,signedIn:a,refresh:i,closeSignIn:o,later:r,pairing:c=!1}){const d=m.useRef(!1),u=jn.dialogDepth()+(c?1:0),p=t!=null||UW({rows:e.length,ours:d.current,dialogs:u});return d.current=p,t?s.jsx($3,{email:t.email||null,onClose:o,onChanged:i,onSignedIn:a}):p?s.jsx(CAe,{rows:e,onSignIn:n,onLater:r},e.length===1?"one":"many"):null}const NAe={"//":["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","author metadata and never a release.","","Editorial metadata: optional //summaries maps a release version to one","specific, verified headline (1–120 characters). No generic marketing claims.","A note may have priority: highlight or required. Choose at most 3 highlights,","only when warranted. Unmarked notes go under More improvements when highlights","exist. Legacy notes stay unabridged; legacy upgrade notes stay visible.","Use required for breaking changes, changed settings, privacy/security impact,","compatibility requirements or mandatory actions. A highlight with any such","impact must also carry a notice with all essential qualifications: highlight","alone is editorial placement, not an instruction to surface it across upgrades.","Required notes and notices stay visible across upgrades, never in a closed section.","Write a short benefit-led title and one useful sentence where possible; keep","opt-outs and limits. Avoid inflated adjectives, filler and generic claims.","Preserve original factual meaning. Never invent capabilities or results.","Retain setup instructions and compatibility minimums. Say only what a user","sees in the app: usage reports, telemetry and environment variables are for","README to explain, not for a note.","Verify each claim against the released diff and tests. No promotion","for invisible fixes. Do not rewrite historical releases to fit the layout.","","Keep highlight titles within 72 characters (excluding a leading emoji) and","benefit descriptions within 240 characters. These limits are validated.","Put essential compatibility, privacy or configuration details in optional","notice text, outside More improvements. Current/upgrade notices stay visible and","have no truncation limit. A notice also keeps its change visible across upgrades.","Optional noticeLabel gives it a short factual heading (1–32 characters), such","as Setup change or Compatibility. It requires notice text; default is Important.","Optional details holds secondary context, shown under the same improvements","disclosure for highlights and beside other notes. Keep the body to one useful","sentence. Never move setup, safety, privacy or compatibility conditions into","details: use notice for those, so they remain visible across upgrades.","The disclosure counts other improvements, not extra details of highlights.","Mark any other mandatory action as required. The manual digest shows only the","running release; Release history opens the full changelog. Upgrade notes keep","required/noticed changes visible and disclose the other notes in that range.","Unclassified legacy upgrade notes stay visible rather than guessing safety.","Before adding editorial metadata to a release, review every note: unmarked","changes will be treated as optional in later upgrades. Never infer safety","from a title, keyword, emoji, position or a shortened description.","","Optional icon is a semantic key: plans, accounts or skills. Use it only when","it matches the change; do not infer icons from versions, titles or emoji.","The modal shows a title's leading emoji; the glyph stands in only for a title","without one."],"//summaries":{"3.53.0":"Codex accounts, with sign-in, switching and Auto-switch","3.52.0":"ccdeck in nine more languages","3.51.0":"Jira integration updates","3.46.0":"Plans, accounts and skills at a glance"},"//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.3","3.48.1","3.49.1","3.53.1"],"3.53.0":[{title:"👥 Codex accounts: sign in, switch and Auto-switch",body:"Add Codex accounts from ccdeck with the official sign-in, see each one's usage, choose the default for new sessions and, if you turn it on, let Auto-switch move to the account with room.",priority:"highlight",noticeLabel:"Codex accounts",notice:"Each account keeps its own Codex folder, and ccdeck never copies, logs or refreshes its tokens. Removing an account moves its folder to codex-profiles-removed instead of deleting it. Auto-switch is off by default and acts only on a reading taken now."},{title:"🔀 One Accounts panel for Claude and Codex",body:"With both CLIs installed, a Claude | Codex switch in the panel's header changes the view, never the account in use, and ccdeck remembers it."},{title:"🕐 Reset times fit in every language",body:"The time until a reset beside each quota bar is no longer cut where a language's words run longer."},{title:"🛠️ Tool and Skill activity work when the deck's folder is gone",body:"Both open again when the folder ccdeck was started from has been deleted."}],"3.52.0":[{title:"🌍 ccdeck in your language",body:"Choose Traditional or Simplified Chinese, German, Japanese, Korean, French, Spanish, Brazilian Portuguese or Romanian in Settings › General › Language. Until you choose, ccdeck follows your browser's language.",priority:"highlight",noticeLabel:"Language",notice:"What's new and text written by Jira, GitHub or GitLab stay as they were written, and anything without a translation shows in English."},{title:"📅 Codex 30-day windows say what a day may cost",body:"A Codex window reported as 30 days is paced over its real length, and its pace note says what a day may cost to last until the reset."}],"3.51.0":[{title:"✏️ Comment and change status in Jira",body:"Add a comment or change an issue’s status from its details in ccdeck.",priority:"highlight",noticeLabel:"Jira edits",notice:"Changes are sent to your connected Jira account and follow its permissions. Jira edits require a supported native build and filesystem; if safe coordination is unavailable, ccdeck refuses the edit and you can still browse your board."},{title:"📍 Jira moves follow your selection",body:"Drag the issue you select, move completed issues between sprints, and place issues at the end by default.",priority:"highlight"},{title:"🛠️ Reduced memory use during long sessions",body:"ccdeck releases more unused memory, and Jira edits recover more reliably when a connection is interrupted."}],"3.50.0":[{title:"🤝 Paired decks no longer each read a shared account's usage",body:"No more rate limits from every machine reading it: one deck reads the account and passes the numbers to the others. Hover the reading's age to see which deck read it."}],"3.49.0":[{title:"🗞️ What's new is shorter and easier to scan",body:"Up to three main changes come first and the rest wait under Show details; Check for updates moved to the dialog's More options menu."},{title:"👥 No warning when one account is in use on several decks",body:"The account row and the desktop no longer flag it, and the Login active on another deck switch is gone from Settings › Notifications; expired logins are still shown.",priority:"required"},{title:"📍 Auto-hidden sessions come back where they were",body:"With Hide finished sessions after on, a session that works again returns to its place, with its new subagents beside it rather than further down the board."},{title:"💻 Windows: About flags an outdated terminal CLI",body:"When the npm ccdeck on PATH is older than the desktop app, Settings › About shows the command that updates it."},{title:"✏️ Texts that fell behind are up to date",body:"Explore integrations says Jira can move issues, and the Radar and Where the time went tips match what the app does."}],"3.48.0":[{title:"🗂️ Jira: move issues between sprints and the backlog",body:"On a Scrum board ordered by Rank, drag issues or use Move to reorder them or send them to another sprint or the backlog, one at a time or up to 50 together. Browsing still only reads."},{title:"🔎 The Jira list is easier to scan",body:"Titles keep more room, a row's preview no longer covers the next row, the issue key shows once in the detail, and Clear filters stays in reach on a phone."},{title:"⌨️ ccdeck tui keeps your Claude accounts on one screen over SSH",body:"Switch accounts, turn Auto-switch on or off, and sign an account in with a link you open in any browser, all from the terminal."},{title:"🎮 Machine shows NVIDIA GPU readings",body:"On Linux and Windows with nvidia-smi: each GPU's utilization, video memory, temperature and power."},{title:"👤 Claude accounts are quieter, and an expired login has a Sign in button",body:"Telemetry is a small shield explained on hover or focus, and an account whose login expired shows Sign in on its own row."},{title:"🩹 Fewer page errors from browser extensions and translation",body:"The Accounts panel recovers when an extension breaks its requests, and Local network keeps working while the browser translates the page."}],"3.47.0":[{title:"⌨️ Quick open: Cmd/Ctrl+K reaches any panel, setting, session or theme by name",body:"Type a few letters to open a panel, land on a setting inside Settings, jump to a session or switch the theme. It is also Search on the bar."},{title:"⚙️ Settings › Claude Code changes Claude Code's own settings from the deck",body:"Twelve settings in five groups, from auto memory and compaction to the Co-Authored-By credit and the update channel, written to your settings.json on this computer."},{title:"📡 Radar monitors all the time, and packet capture is one explained step",body:"There is no Start or Stop any more: Radar finds Claude Code's collector by itself. Where capture needs a permission, Allow packet capture once asks for it on your press only."},{title:"⏱️ Tool activity shows where the time went, and Skill activity who starts your skills",body:"Tool activity splits the turns' time between Claude, this machine and you. Skill activity shows how many skill uses Claude, Codex or you started, overall and per skill."},{title:"📊 Usage remembers how full each quota week ended, and names your Claude plan",body:"Under each 7-day bar a line says how full the last weeks were at their reset. The Claude quota card shows your plan beside its title, as the Codex card does."},{title:"🗂️ Stripes, dialogs and floating panels are organized more evenly",body:"The doors on both edge stripes sit in named groups, dialogs share one frame, and T switches the theme inside any dialog too."},{title:"🪟 The desktop app works on a first run without Node, and integrations got fixes",body:"Usage no longer needs npm, and Claude Code installed while the app is open is picked up. Jira and GitLab avatars load, and panels reopen where you left them."}],"3.46.0":[{title:"🔗 Jira, GitHub and GitLab panels are easier to read and navigate",body:"Jira rows show each issue's status, lists answer the arrow keys and fit a phone, and a failed refresh says “Not updated”."},{title:"📡 Radar finds more Claude Code processes on Linux",body:"It now sees Claude Code started from its versioned install folder, plus connection attempts that got no reply and the telemetry variables it was launched with."},{title:"🗺️ Follow plans at any zoom",body:"See plan progress on session notes and directly on the canvas.",priority:"highlight",icon:"plans",details:"Subagents stay in one column beside their parent."},{title:"✅ Keep your Claude account in sync",body:"After `/login`, Accounts, Switch, Auto-switch and Usage follow your active Claude Code account.",priority:"highlight",icon:"accounts",details:"Auto-switch can also be set up while it is off."},{title:"📊 Account capacity and the Reset calendar have their own buttons",body:"Both open from the left stripe, under Claude accounts, instead of from the small gauge in the accounts panel's header."},{title:"🧩 See which skills your agents use",body:"Review skill activity from the right sidebar, including typed slash commands.",priority:"highlight",notice:"Counting typed slash commands adds a `UserPromptExpansion` hook to Claude Code's `settings.json` on supported versions (2.1.116+). Set `AGENTS_DECK_SKILL_HOOK=0` to opt out.",icon:"skills",noticeLabel:"Setup change"},{title:"📈 Load history keeps the reading you click",body:"Click a minute on a chart to keep its reading. Saved limit resets now show their expiry time, and Tool activity has a clearer icon."}],"3.45.0":[{title:"🔗 Read-only Jira, GitHub and GitLab panels beside your agents",body:"Settings › Integrations connects Jira (Cloud, Server or Data Center), GitHub, and GitLab.com or your own GitLab, each with a token, and a control on the left stripe opens its panel: a Jira board's backlog in Jira's own order, or a project's branches, pull or merge requests, pipelines and issues, with the item beside the list. The panels only read: they never comment, merge, re-run a job or change an issue. The token stays on this machine, in a file only you can read, and goes only to that connection's own API. Nothing is read until you connect a tracker, and then only while its panel is open."},{title:"📤 Each account says what its organization's telemetry sends",body:"A Team or Enterprise organization can turn on Claude Code's telemetry for every member, and Claude Code applies it without asking. Each account of such an organization now carries a line under its name: “Telemetry · usage data”, or “Telemetry · prompts, tool details” in the warning colour when your prompts and tool details are sent too. Its tooltip names the organization and where the data goes. After a switch, Auto-switch's notification and the row's “Now active” note say it too. The deck changes nothing; it learns what the organization turns on from a Claude Code session run on one of its accounts, and until then that account shows no line."},{title:"⚠️ A warning when a paired deck is on the same Claude login",body:"A Claude login renews once, so when two machines use one copied login, the one that renews second is signed out. When a paired deck on Local network says it is on the login this deck is using, the live account's row now says “Also active on” and names that deck, with what to do: use a different account on one of the machines, or sign in on each one separately. A switch onto such a login says so too, and so does one desktop notification per incident, “Login active on another deck” in Settings › Notifications, which is on by default."},{title:"📱 A phone opens one panel at most when the deck loads",body:"On a window 640 px wide or less, a reload used to open Accounts, Usage and the machine panel on top of each other, with none of the board in sight. It now opens at most one of them, preferring Usage over the machine panel, and Accounts and the session list open from the dock. A wider window loads exactly as before, and nothing you chose is forgotten."}],"3.44.0":[{title:"⛔ A turn that stops on an error now shows as stopped",body:"When Claude Code ends a turn on an API error, such as an expired login or a usage limit, it sends StopFailure instead of Stop. The deck now adds StopFailure to the hooks it writes in Claude Code's settings.json, but only when every Claude Code it finds is 2.1.78 or newer; with an older one, or one whose version it cannot read, nothing changes. The card then says “Stopped · login expired”, “Stopped · usage limit” or “Stopped · API error”, and the sessions one expired login stops together arrive as one notification that names them. Each needs a “continue” once a working login is active."},{title:"🔑 Auto-switch leaves an expired login, and nothing switches onto one",body:"When Claude Code has signed a login out and claude-swap's saved copy is dead too, Auto-switch now moves to another account under your home and weekly-reset rules, and its notification says why. Neither Auto-switch nor Switch moves onto a login that is already known to be expired: that account's row says its login expired, with Sign in again, and nothing moves."},{title:"💲 Usage totals say how complete they are",body:"The usage headline is always shown now, by the rule History and the model table already used: an exact total when every cost is known, a known $0 included; the known part with “+” when some tokens could not be priced; and “not priced”, never a bare $0, when no cost is known. Sessions whose cost is a known zero show it too."},{title:"📡 Radar: a resizable inspector, prompt previews and a JSON view",body:"Radar's inspector can be resized and shows prompt previews, highlights and each record as a JSON tree, beside the File view. Settings › Radar has a new Monitor automatically switch. It is off, so Radar still watches only after you press Start, as before; turn it on to have the deck start monitoring by itself."},{title:"🧰 Tool activity opens over the deck, with the first tool's details open",body:"Tool activity now opens as a dialog over the deck instead of a page of its own, with the first tool selected and its details beside the list. Escape closes the details first, then the dialog. On a phone the details open as a sheet."},{title:"🧩 Tool activity counts skills, and the slash commands you type if you opt in",body:"Tool activity's Skills tab ranks the skills your Claude Code and Codex agents used. Counting the slash commands you type needs Claude Code's UserPromptExpansion hook, which the deck adds to settings.json only when you start it with AGENTS_DECK_SKILL_HOOK=1 and every Claude Code it finds is 2.1.116 or newer. Without that variable nothing in settings.json changes."},{title:"▶️ Continue a background session that stopped",body:"A background session that stopped on an error has a Continue button on its card and panel: the deck stops it if Claude Code still lists it, then resumes it in its own folder with “Continue from where you left off.” Continue stopped background sessions, in Settings › General, presses it for you once per stop. It is off until you turn it on."},{title:"⌨️ ccdeck commands for your terminal",body:"ccdeck accounts, ccdeck switch, ccdeck usage, ccdeck sessions and ccdeck open work from any terminal. ccdeck switch --best goes where Auto-switch would, and every switch follows the deck's own rules. Over SSH, ccdeck open prints the line that opens the deck on your own computer. Each command takes --json for scripts."}],"3.43.4":[{title:"🔐 Local network no longer sends the login a deck is signed in to",body:`Two machines on one Claude login race to renew it, and the one that renews second is signed out with “Login expired”. So paired decks no longer receive the login a deck is signed in to right now. Every other login you tick is shared as before, and this one goes out once the deck switches to another account.
155
+ ${o("board.ribbon.spent",{cost:At(c.total)})}${u?` · ${u}`:""}`:""}`,onClick:()=>{try{a(e.id)}catch{}},children:[s.jsx("span",{className:`state-pill state-${e.state}`,children:yo(e.state,o)}),s.jsx("span",{className:"selected-label",children:e.label}),c.total>0&&s.jsxs("span",{className:"selected-cost",children:[At(c.total),u?s.jsxs("span",{className:"selected-rate",children:[" · ",u]}):null]}),p>0&&s.jsxs("span",{className:"selected-extra",children:["+",p]}),s.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:g=>{g.stopPropagation(),i()},children:"×"})]})}function jNe({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:a,toggleCat:i}){const o=ae();return s.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":o("board.cat.filter"),children:n.map(r=>{const c=a.has(r);return s.jsxs("button",{type:"button",className:`cat-filter${c?" off":""}`,onClick:()=>i(r),"aria-pressed":!c,title:o(c?"board.cat.show":"board.cat.hide",{cat:Mg(r,o)}),children:[s.jsx(zCe,{cat:r}),s.jsx("span",{className:"cat-name",children:Mg(r,o)})]},r)})})}const ANe=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function TNe(e){var n,a;const t=e.target;!(t!=null&&t.closest)||t.closest(ANe)!==e.currentTarget||(e.preventDefault(),(a=(n=document.activeElement)==null?void 0:n.blur)==null||a.call(n))}function RNe({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:a}){const i=ae(),o=Qn();return s.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[s.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.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"})}),s.jsxs("span",{className:"drag-trash-copy",children:[s.jsx("span",{className:"drag-trash-text",children:t==="over"?s.jsxs(s.Fragment,{children:[i("board.trash.release")," ",s.jsx("strong",{className:"drag-trash-name",children:a||i("board.trash.thisCard")})]}):i("board.trash.drop")}),s.jsx("span",{className:"drag-trash-hint",children:t==="over"?i("board.trash.bringsBack",{list:Yn(i("board.detail.listUpper"),"L",o)}):i("board.trash.keepsRunning")})]})]})}function ENe({canvasRef:e,bubbling:t,dragging:n,trash:a,zoom:i,viewport:o,stateRef:r,peek:c,children:d}){const{trashDragging:u,trashState:p,trashPhase:g,trashZoneRef:f,trashLabel:v}=a,{lod:k,lodRef:y}=i,{markCanvasInput:N}=o,{peekAgent:w,peekLabel:S,peekRecap:j,peekBounds:A}=c;return s.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${u&&p==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:TNe,onPointerDownCapture:N,onPointerUpCapture:N,onWheelCapture:N,onFocusCapture:T=>{const E=T.target;if(!FT(E)||y.current==null||y.current==="detail")return;const q=E.getAttribute("data-id");q&&r.current.agents.has(q)&&E.matches(":focus-visible")&&G4(q,E,"focus")},onBlurCapture:T=>{var q,F;const E=(F=(q=T.target).getAttribute)==null?void 0:F.call(q,"data-id");E&&To(E)},children:[d,mo(g)&&s.jsx(RNe,{trashZoneRef:f,trashState:p,trashPhase:g,trashLabel:v}),s.jsx(ixe,{agentFor:w,recapFor:j,labelFor:S,bounds:A})]})}function _Ne({restarting:e,restartMode:t,live:n,paused:a}){const i=ae();return s.jsxs("div",{className:"conn-banner",role:"alert",children:[s.jsx("span",{className:"conn-dot"}),e?t==="npx"?i("shell.banner.fetchingNpx"):i("shell.banner.restartingProduct",{product:Pt}):(()=>{const o=Nne({connected:n,paused:a});return s.jsxs(s.Fragment,{children:[i("shell.banner.lost",{product:Pt}),o&&s.jsx("span",{className:"conn-sub",children:o})]})})()]})}function qNe({oldName:e,version:t,dismissOldName:n}){const a=ae();return s.jsxs("div",{className:"ver-banner",role:"status",children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{children:a("shell.banner.oldName",{old:e,product:Pt})}),t!=null&&t.renameFix?s.jsx("span",{className:"ver-sub",children:t.renameFix}):null,s.jsx("button",{type:"button","aria-label":a("shell.dismiss"),className:"ver-close",onClick:n,children:"×"})]})}const EW=()=>C("shell.rating.thanks"),zNe=Array.from({length:11},(e,t)=>t);function LNe(e){return e===0?C("shell.rating.score0"):e===10?C("shell.rating.score10"):C("shell.rating.score",{n:e})}const ONe=6;function PNe(e){const t=m.useRef(null);return m.useLayoutEffect(()=>{const n=t.current,a=n==null?void 0:n.closest(".app");if(!n||!a)return;const i=()=>a.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);i();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(i);return o==null||o.observe(n),()=>{o==null||o.disconnect(),a.style.removeProperty("--rating-h")}},[e]),t}function MNe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function INe({phase:e,score:t,onAnswer:n,onLater:a,onClose:i,onFeedback:o,onHold:r}){ae();const c=PNe(e),d=m.useRef(null),u=m.useRef(null),p=m.useRef(!1);m.useEffect(()=>{var f,v;e!=="thanks"||!p.current||(p.current=!1,Xn(((f=document.activeElement)==null?void 0:f.tagName)??null)&&((v=d.current??u.current)==null||v.focus()))},[e]);const g=f=>{var v;(v=c.current)!=null&&v.contains(document.activeElement)&&MNe(),f()};return e==="thanks"?s.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>r(!0),onBlur:f=>{f.currentTarget.contains(f.relatedTarget)||r(!1)},children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{children:EW()}),t!==null&&t<=ONe?s.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:C("shell.rating.better")}):null,s.jsx("button",{ref:u,type:"button","aria-label":C("shell.dismiss"),className:"ver-close",onClick:()=>g(i),children:"×"})]}):s.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{id:"rating-question",children:C("shell.rating.question")}),s.jsx("span",{className:"rating-scale",children:zNe.map(f=>s.jsx("button",{type:"button",className:"rating-pick","aria-label":LNe(f),onClick:v=>{p.current=v.detail===0||v.currentTarget.matches(":focus-visible"),n(f)},children:f},f))}),s.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:C("shell.rating.ends")}),s.jsx("button",{type:"button",className:"ver-act",onClick:()=>g(a),children:C("shell.rating.later")})]})}const DNe=3e4;function FNe({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function UNe({bundle:e,running:t,pending:n,lastTried:a}){return t?FNe({bundle:e,running:t,lastTried:a})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function BNe(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function HNe({asked:e,reported:t}){return t?t!==e:!1}function _W(e){const t=e.thresholdMs??DNe;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 WNe(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 GNe(e,t){return e?t==null?C("shell.banner.autoIdle"):C("shell.banner.autoIn",{time:WNe(t)}):C("shell.banner.autoOff")}function HI(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function $Ne(e,t=!1){return e<=0&&t?{label:C("shell.banner.restartAnyway"),clause:C("shell.banner.clausePaused")}:e<=0?{label:C("shell.banner.restartNow"),clause:C("shell.banner.clauseIdle")}:{label:C("shell.banner.restartAnyway"),clause:C("shell.banner.clauseAgents",{count:e})}}function VNe(e){const t=_W(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 Cj={get git_checkout(){return C("shell.banner.block.git_checkout")},get npx(){return C("shell.banner.block.npx")},get one_off(){return C("shell.banner.block.one_off")},get not_writable(){return C("shell.banner.block.not_writable")},get opted_out(){return C("shell.banner.block.opted_out")},get retired_name(){return C("shell.banner.block.retired_name")}};function KNe({notice:e,version:t,dismissNotice:n,upgradeState:a,startUpgrade:i,copyCommand:o,cmdCopied:r,autoRestart:c,toggleAutoRestart:d,askRestart:u,restartCopy:p,restartFuseMs:g,restarting:f}){var k,y,N;const v=ae();return s.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[s.jsx("span",{className:`ver-dot${g==null?"":" armed"}`}),e.kind==="restart"?s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:v("shell.banner.installedStale",{to:e.to,from:e.from})}),t!=null&&t.canRestart?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"ver-act",onClick:()=>u(),...ga(f),title:v("shell.banner.restartTitle"),children:f?v("shell.banner.restarting"):p.label}),!f&&s.jsx("span",{className:"ver-sub",children:p.clause}),s.jsxs("label",{className:"ver-auto",children:[s.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":v("shell.banner.autoRestart"),title:v(c?"shell.banner.autoOnTitle":"shell.banner.autoOffTitle"),children:s.jsx("span",{className:"switch-knob"})}),s.jsx("span",{"aria-hidden":!0,children:GNe(c,g)})]})]}):s.jsx("span",{className:"ver-sub",title:v("shell.banner.restartNeededTitle"),children:v("shell.banner.restartNeeded")})]}):s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:v("shell.banner.isOut",{product:Pt,to:e.to,from:e.from})}),(t==null?void 0:t.upgradeMode)==="install"&&a!=="failed"&&s.jsx("button",{type:"button",className:"ver-act",onClick:i,...ga(a==="running",a==="done"),title:v("shell.banner.installTitle",{command:((k=t==null?void 0:t.upgrade)==null?void 0:k.command)??(t==null?void 0:t.command)??"npm i -g"}),children:v(a==="running"?"shell.banner.installing":a==="done"?"shell.banner.installed":"shell.update.now")}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&s.jsx("button",{type:"button",className:"ver-act",onClick:()=>u({upgrade:!0}),...ga(f),title:v("shell.banner.npxTitle",{command:(t==null?void 0:t.command)??""}),children:v(f?"shell.banner.fetching":a==="failed"?"shell.update.retry":"shell.update.andRestart")}),a==="failed"?s.jsx("span",{className:"ver-sub fail",title:((y=t==null?void 0:t.upgrade)==null?void 0:y.error)??"",children:v("shell.banner.failedLine",{what:(t==null?void 0:t.upgradeMode)==="npx"?v("shell.banner.updateFailed"):v("shell.banner.installFailed"),error:((N=t==null?void 0:t.upgrade)==null?void 0:N.error)??v("shell.banner.unknownError")})}):(t==null?void 0:t.upgradeMode)==="npx"?s.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?v("shell.banner.npxRerun"):Cj.npx}):t!=null&&t.upgradeBlocked?s.jsx("span",{className:"ver-sub",children:un(Cj,t.upgradeBlocked)??v("shell.banner.cannotInstall")}):null,s.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:v("shell.banner.copyTitle"),children:[s.jsx("code",{children:t==null?void 0:t.command}),s.jsx("span",{className:"ver-cmd-hint",children:v(r?"shell.banner.copiedHint":"shell.banner.copyHint")})]})]}),s.jsx("button",{type:"button","aria-label":v("shell.dismiss"),className:"ver-close",onClick:n,children:"×"})]})}function JNe({restart:e,versionCheck:t,upgrade:n,oldNameNotice:a,rating:i,onFeedback:o,everConnected:r,live:c,paused:d}){const u=ae(),{autoRestart:p,toggleAutoRestart:g,restarting:f,restartMode:v,restartedTo:k,askRestart:y,restartCopy:N,restartFuseMs:w}=e,{version:S,notice:j,noticeOpen:A,dismissNotice:T}=t,{upgradeState:E,startUpgrade:q,copyCommand:F,cmdCopied:z}=n,{oldName:H,oldNameOpen:I,dismissOldName:L}=a,{ratingPhase:O,ratingScore:_,answerRating:M,rateLater:U,closeRating:G,holdThanks:W}=i,$=k?s.jsxs("div",{className:"ver-banner done",role:"status",children:[s.jsx("span",{className:"ver-dot"}),s.jsx("strong",{children:u("shell.banner.restartedTo",{version:k})}),s.jsx("span",{className:"ver-sub",children:u("shell.banner.replayed")})]}):r&&!c?s.jsx(_Ne,{restarting:f,restartMode:v,live:c,paused:d}):A&&j?s.jsx(KNe,{notice:j,version:S,dismissNotice:T,upgradeState:E,startUpgrade:q,copyCommand:F,cmdCopied:z,autoRestart:p,toggleAutoRestart:g,askRestart:y,restartCopy:N,restartFuseMs:w,restarting:f}):I&&H?s.jsx(qNe,{oldName:H,version:S,dismissOldName:L}):O!=="hidden"?s.jsx(INe,{phase:O,score:_,onAnswer:M,onLater:U,onClose:G,onFeedback:o,onHold:W}):null;return s.jsxs(s.Fragment,{children:[$,s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O==="thanks"?EW():""})]})}function YNe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function ZNe(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 XNe(e,t){return e<=0?null:t("board.clear.goes.agents",{count:e})}function QNe(e,t,n=C){const a=XNe(e,n),i=(...d)=>[a,...d,n("board.clear.goes.view")].filter(u=>u!==null),o=n("board.clear.final"),r=n("board.clear.confirmAll");if(!t)return{goes:i(n("board.clear.goes.logUnknown")),stays:[],final:o,confirm:r};if(!t.path)return{goes:i(),stays:[],final:n("board.clear.final.noLog",{final:o}),confirm:r};if(!t.mine){const d=t.ownerPort===null?n("board.clear.owner.other"):n("board.clear.owner.port",{port:t.ownerPort}),u=t.decks>2?n("board.clear.owner.shared",{decks:t.decks}):"";return{goes:i(),stays:[n("board.clear.stays.log",{owner:d,shared:u}),n("board.clear.stays.replay")],final:null,confirm:n("board.clear.confirmCanvas")}}if(t.decks<=1)return{goes:i(n("board.clear.goes.logOwn")),stays:[],final:o,confirm:r};const c=t.decks-1;return{goes:i(n("board.clear.goes.logShared",{count:c})),stays:[n("board.clear.stays.shared",{count:c})],final:o,confirm:r}}function eje({agentCount:e,onConfirm:t,onCancel:n}){const a=ae(),i=m.useRef(null),o=_t(n,{focusRef:i,layer:Tee}),r=qt(n),[c,d]=m.useState(null);m.useEffect(()=>{let v=!1;return fetch("/api/clear").then(k=>k.ok?k.json():null).then(k=>{v||d(ZNe(k))}).catch(()=>{}),()=>{v=!0}},[]);const{goes:u,stays:p,final:g,confirm:f}=QNe(e,c,a);return s.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:s.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{className:"status-dot err","aria-hidden":!0}),s.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:a("board.clear.title")})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":a("board.clear.cancelEsc"),title:a("board.clear.cancelEsc"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[s.jsxs("dl",{className:"cc-plan",children:[s.jsx("dt",{children:a("board.clear.goes")}),s.jsx("dd",{children:u.map(v=>s.jsx("span",{children:v},v))}),s.jsx("dt",{children:a("board.clear.stays")}),s.jsx("dd",{children:p.length>0?p.map(v=>s.jsx("span",{children:v},v)):s.jsx("span",{children:a("board.clear.nothing")})})]}),g&&s.jsx("p",{className:"cc-final",children:g}),s.jsxs("div",{className:"cc-actions",children:[s.jsx("button",{type:"button",ref:i,className:"btn",onClick:n,children:a("board.clear.cancel")}),s.jsx("button",{type:"button",className:"btn danger",onClick:t,children:f})]})]})]})})}function Sj(e,t,n){const a=`{${t}}`,i=e.indexOf(a);return i<0?e:s.jsxs(m.Fragment,{children:[e.slice(0,i),n,e.slice(i+a.length)]})}function tje({kind:e,onChange:t}){const n=ae();return s.jsxs("fieldset",{className:"fb-kinds",children:[s.jsx("legend",{className:"vis-hidden",children:n("shell.feedback.kinds")}),um.map(a=>s.jsxs("label",{className:"fb-kind",children:[s.jsx("input",{type:"radio",name:"feedback-kind",value:a.value,checked:e===a.value,onChange:()=>t(a.value),onKeyDown:i=>{GT(i.nativeEvent)&&i.preventDefault()}}),a.label]},a.value))]})}const qW="fb-details";function nje({open:e,onToggle:t}){return ae(),s.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":qW,onClick:t,children:[tSe(),s.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:s.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function aje({open:e,contact:t,onContact:n}){const a=ae(),i=m.useId();return s.jsx("div",{id:qW,className:"fb-details","data-open":e||void 0,children:s.jsx("div",{className:"fb-details-clip",children:s.jsxs("div",{className:"fb-details-body",children:[s.jsxs("div",{className:"fb-field",children:[s.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[nSe(),s.jsx("span",{className:"fb-optional",children:a("shell.feedback.optional")})]}),s.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:hW,autoComplete:"email",placeholder:aSe(),"aria-describedby":i,onChange:o=>n(o.target.value),onKeyDown:o=>{GT(o.nativeEvent)&&o.preventDefault()}}),s.jsx("p",{id:i,className:"fb-hint",children:sSe()})]}),s.jsx("div",{className:"fb-where",children:iSe().map(o=>s.jsx("p",{children:o},o))})]})})})}const br=3,sje=5*1024*1024,ije=12*1024*1024,Nj=8192,oje=64*1024,rje=256*1024,cje=.92,lje=640,zW=.9,dje=.85,uje=6,hje=512*1024,fm={png:"image/png",jpeg:"image/jpeg"},pje={png:"png",jpeg:"jpg"},gje=[137,80,78,71,13,10,26,10],mje=[255,216,255];function LW(e){const t=n=>e.length>=n.length&&n.every((a,i)=>e[i]===a);return t(gje)?"png":t(mje)?"jpeg":null}function fje(e){const t=LW(e);return t==="png"?bje(e):t==="jpeg"?kje(e):null}function bje(e){const t=[73,72,68,82];if(e.length<24||!t.every((a,i)=>e[12+i]===a))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function vje(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function kje(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 a=e[t]<<8|e[t+1];if(a<2)return null;if(vje(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=a}return null}function WI(e,t){return e.bytes>t||e.width>Nj||e.height>Nj}function wje(e){return Math.min(sje,ije-oje-e)}function OW(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function yje(e,t){const n=Nj/Math.max(e.width,e.height),a=e.bytes>t?Math.sqrt(t/e.bytes)*zW:1;return OW(e,Math.min(1,n,a))}async function xje(e,t,n){let a=yje(e,t),i=e.format;for(let o=0;o<uje;o++){const r=await n(a,i,i==="jpeg"?cje:void 0);if(!r)return null;if(r.size<=t)return{...a,blob:r,format:i};if(i==="png"){i="jpeg";continue}if(a=OW(a,Math.min(dje,Math.sqrt(t/r.size)*zW)),Math.max(a.width,a.height)<lje)return null}return null}async function Cje(e,t,n){const a=new Uint8Array(await e.slice(0,hje).arrayBuffer()),i=LW(a);if(!i)return{ok:!1,problem:"type"};if(t<rje)return{ok:!1,problem:"no_room"};const o=e.type===fm[i]?e:new Blob([e],{type:fm[i]}),r=fje(a);if(r&&!WI({...r,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:i};if(!WI(d,t))return{ok:!0,blob:o,resized:null};const u=await xje(d,t,c.encoder);return u?{ok:!0,blob:u.blob,resized:{width:u.width,height:u.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Sje(e){return({width:t,height:n},a,i)=>new Promise(o=>{const r=document.createElement("canvas");r.width=t,r.height=n;const c=r.getContext("2d");if(!c)return o(null);a==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),r.toBlob(d=>{r.width=0,r.height=0,o(d)},fm[a],i)})}const Nje=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Sje(t),release:()=>t.close()}};function jje(e){return e.includes("Files")}function Aje({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Tje(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Rje(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((a,i)=>{const o=a.type===fm.jpeg?"jpeg":"png";n.append("images",a,`image-${i+1}.${pje[o]}`)}),{method:"POST",body:n}}const Eje=()=>C("shell.feedback.addShot"),GI=()=>C("shell.feedback.addHint"),_je=()=>C("shell.feedback.shotsNote"),$I=()=>C("shell.feedback.full"),qje=()=>C("shell.feedback.refusedWhileSending");function zje(e,t,n){const a=n?C("shell.feedback.resized",{width:n.width,height:n.height}):"";return C("shell.feedback.replaceLabel",{n:e+1,name:t,fit:a})}function Lje(e,t){const n=C("shell.feedback.shotsCount",{count:e,max:br});return t>0?C("shell.feedback.shotsResized",{of:n,resized:t}):n}function Oje(e){return C("shell.feedback.leftOut",{count:e})}function Pje(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Mje(e,t){const n=Pje(t);return e==="type"?C("shell.feedback.problem.type",{file:n}):e==="no_room"?C("shell.feedback.problem.noRoom",{file:n}):e==="unreadable"?C("shell.feedback.problem.unreadable",{file:n}):C("shell.feedback.problem.tooLarge",{file:n})}const PW="image/png,image/jpeg";function MW({className:e="fb-glyph"}){return s.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:[s.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),s.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),s.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Ije({images:e,buttonRef:t}){ae();const n=m.useRef(null),a=e.shots.length>=br;return s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:GI(),"aria-describedby":"fb-attach-hint",onClick:()=>{var i;return a?e.sayFull():(i=n.current)==null?void 0:i.click()},children:[s.jsx(MW,{}),Eje()]}),s.jsx("span",{id:"fb-attach-hint",hidden:!0,children:GI()}),s.jsx("input",{ref:n,type:"file",accept:PW,multiple:!0,hidden:!0,onChange:i=>{e.add(Array.from(i.target.files??[])),i.target.value=""}})]})}function Dje({images:e,addRef:t}){const n=ae(),a=m.useRef(new Map),i=m.useRef(null),o=m.useRef(null),r=m.useRef(null),[c,d]=m.useState(null),{shots:u}=e,p=Lje(u.length,u.filter(v=>v.resized).length);m.useLayoutEffect(()=>{var v;c!==null&&((v=c==="add"?t.current:a.current.get(c))==null||v.focus(),d(null))},[c,t]),m.useEffect(()=>{var v;e.problem&&((v=i.current)==null||v.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function g(v){d(Tje(u.map(k=>k.id),v)??"add"),e.remove(v)}function f(v){var k;r.current=v,(k=o.current)==null||k.click()}return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),s.jsx("input",{ref:o,type:"file",accept:PW,hidden:!0,onChange:v=>{const k=r.current;k!==null&&e.replace(k,Array.from(v.target.files??[])),r.current=null,v.target.value=""}}),u.length>0&&s.jsxs("div",{className:"fb-shots",children:[s.jsxs("div",{className:"fb-shots-row",children:[s.jsx("ul",{className:"fb-shots-list",children:u.map((v,k)=>s.jsxs("li",{className:"fb-shot","data-fitting":v.blob?void 0:!0,children:[s.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":zje(k,v.name,v.resized),onClick:()=>f(v.id),children:[s.jsx("img",{className:"fb-shot-img",src:v.url,alt:""}),v.blob?s.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:n("shell.feedback.replace")}):s.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:n("shell.feedback.resizing")})]}),s.jsx("button",{ref:y=>{y?a.current.set(v.id,y):a.current.delete(v.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":n("shell.feedback.removeImage",{n:k+1}),title:n("shell.feedback.removeImage",{n:k+1}),onClick:()=>g(v.id),children:s.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:s.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},v.id))}),s.jsx("span",{className:"fb-shots-count",children:p})]}),s.jsx("p",{className:"fb-hint",children:_je()})]}),e.problem&&s.jsx("p",{ref:i,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Fje(e,t){return e.map((n,a)=>({id:t+a,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function Uje(e,t,n){return n?e.map(a=>a.id===t.id?t:a):[...e,t]}function Bje(e,t,n){return n?e.map(a=>a.id===t?n:a):e.filter(a=>a.id!==t)}function Hje(e){const[t,n]=m.useState(()=>Fje((e==null?void 0:e.ready)??[],1)),[a,i]=m.useState({problem:"",id:0}),o=m.useRef(0),r=m.useCallback(L=>{L&&o.current++,i(O=>L?{problem:L,id:O.id+1}:O.problem?{problem:"",id:O.id}:O)},[]),[c,d]=m.useState(""),u=m.useRef(t),p=m.useRef(null),g=m.useRef(t.length),f=m.useRef(!0),v=m.useRef(new Map),k=m.useRef([]),y=m.useRef(0),N=m.useCallback(L=>{u.current=L(u.current),n(u.current)},[]);m.useEffect(()=>(f.current=!0,()=>{f.current=!1;for(const L of u.current)URL.revokeObjectURL(L.url)}),[]);const w=m.useCallback(async(L,O)=>{const _=u.current.reduce((Z,D)=>{var K;return Z+(D.id===(O==null?void 0:O.id)?0:((K=D.blob)==null?void 0:K.size)??0)},0),M=(O==null?void 0:O.id)??++g.current,U=URL.createObjectURL(L),G={id:M,name:L.name||"image",url:U,blob:null,resized:null},W=y.current;v.current.set(M,L);let $=!1;const Y=()=>{$||($=!0,N(Z=>Uje(Z,G,O!==void 0)))},B=await Cje(L,wje(_),async Z=>(Y(),Nje(Z))).catch(()=>({ok:!1,problem:"unreadable"})),V=u.current.some(Z=>Z.id===M);return!f.current||y.current!==W||!V&&($||O)?(URL.revokeObjectURL(U),O&&URL.revokeObjectURL(O.url),f.current&&v.current.delete(M),""):(v.current.delete(M),B.ok?(Y(),O&&URL.revokeObjectURL(O.url),N(Z=>Z.map(D=>D.id===M?{...D,blob:B.blob,resized:B.resized}:D)),""):(URL.revokeObjectURL(U),$&&N(Z=>Bje(Z,M,O)),Mje(B.problem,L.name||"image")))},[N]),S=m.useCallback(async L=>{r("");const O=y.current,_=[];let M=0,U=0;for(const W of L){if(!f.current||y.current!==O)return;const $=k.current.indexOf(W);if($!==-1&&k.current.splice($,1),u.current.length>=br){M++;continue}const Y=u.current.length,B=await w(W);B&&_.push(B),u.current.length>Y&&U++}if(!f.current||y.current!==O)return;M>0&&_.push(U===0&&_.length===0?$I():Oje(M)),r(_.join(" "));const G=u.current.length;U>0&&d(C("shell.feedback.imagesAdded",{count:U,total:G,max:br}))},[w,r]),j=m.useCallback(async(L,O)=>{r("");const _=u.current.find(G=>G.id===L);if(!_)return S([O]);const M=await w(O,_);if(!f.current)return;r(M);const U=u.current.findIndex(G=>G.id===L);!M&&U!==-1&&d(C("shell.feedback.imageReplaced",{n:U+1,total:u.current.length,max:br}))},[S,w,r]),A=m.useCallback(L=>{const O=y.current;p.current=(p.current??Promise.resolve()).then(()=>y.current===O?L():void 0).catch(()=>{})},[]),T=m.useCallback(L=>{L.length!==0&&(k.current.push(...L),A(()=>S(L)))},[S,A]);m.useEffect(()=>{e&&e.waiting.length>0&&T(e.waiting)},[]);const E=m.useCallback((L,O)=>{const _=O[0];_&&A(()=>j(L,_))},[A,j]),q=m.useCallback(L=>{const O=u.current.find(_=>_.id===L);O&&(URL.revokeObjectURL(O.url),v.current.delete(L),N(_=>_.filter(M=>M.id!==L)),r(""),d(C("shell.feedback.imageRemoved",{count:u.current.length,max:br})))},[N,r]),F=m.useCallback(()=>r($I()),[r]),z=m.useCallback(async()=>{const L=o.current;return await p.current,o.current!==L?null:u.current.flatMap(O=>O.blob?[O.blob]:[])},[]),H=m.useCallback(()=>({ready:u.current.flatMap(L=>L.blob&&!v.current.has(L.id)?[{name:L.name,blob:L.blob,resized:L.resized}]:[]),waiting:[...v.current.values(),...k.current]}),[]),I=m.useCallback(()=>{y.current++;for(const L of u.current)URL.revokeObjectURL(L.url);v.current.clear(),k.current=[],N(()=>[]),r("")},[N,r]);return{shots:t,problem:a.problem,problemId:a.id,announcement:c,add:T,replace:E,remove:q,sayFull:F,ready:z,kept:H,clear:I}}function Wje(){const[e,t]=m.useState(null);return m.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(a=>a.ok?a.json():null).then(a=>{n&&t(JCe(a))}).catch(()=>{}),()=>{n=!1}},[]),e}function Gje(e){const[t,n]=m.useState({state:"idle"}),a=m.useRef(!1),i=m.useRef(null);m.useEffect(()=>()=>{var c;return(c=i.current)==null?void 0:c.abort()},[]);async function o(c){if(!Jn(a.current))return;a.current=!0;const{signal:d}=i.current=new AbortController;n({state:"sending"});try{const u=await e.ready();if(d.aborted)return;if(!u){n({state:"failed",message:qje()});return}const p=await fetch("/api/feedback",{...Rje(KCe(c),u),signal:d}),g=await p.json().catch(()=>null);n(p.ok&&(g!=null&&g.ok)?{state:"sent"}:{state:"failed",message:_I(p.status,g==null?void 0:g.reason,g==null?void 0:g.errors)})}catch{d.aborted||n({state:"failed",message:_I(0,null)})}finally{a.current=!1}}const r=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:r}}function $je(e,t){const[n,a]=m.useState(!1),i=m.useRef(t);return i.current=t,m.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>a(!0),qI),r=window.setTimeout(()=>i.current(),qI+uSe);return()=>{window.clearTimeout(o),window.clearTimeout(r)}},[e]),n}const OS="agent-dag.feedbackDrafts",VI=4;function Vje({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Kje(e){return JSON.stringify([e.kind,e.body])}function Jje(e){return e.ready.length+e.waiting.length}function IW(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Yje(e){return C("shell.feedback.lost",{count:e})}const Zje=()=>C("shell.feedback.discard"),Xje=()=>C("shell.feedback.discardConfirm"),Qje=()=>C("shell.feedback.discardTitle"),KI=()=>C("shell.feedback.discardArmed"),eAe={ready:[],waiting:[]};function tAe(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:a,contact:i,images:o}=t;return!um.some(r=>r.value===n)||typeof a!="string"||a.length>uW||typeof i!="string"||i.length>hW||typeof o!="number"||!Number.isInteger(o)||o<0||o>br?null:[e[0],{kind:n,body:a,contact:i,images:o}]}function nAe(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const r=(o=e())==null?void 0:o.getItem(OS),c=r?JSON.parse(r):[];if(Array.isArray(c))for(const d of c.slice(-VI)){const u=tAe(d);u&&t.set(u[0],{...u[1],images:null,imageCount:u[1].images})}}catch{}return t}function a(){try{const o=e();if(!o)return;const r=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);r.length===0?o.removeItem(OS):o.setItem(OS,JSON.stringify(r))}catch{}}function i(o){n().delete(o)&&a()}return{read(o){const r=n().get(o);return r?{kind:r.kind,body:r.body,contact:r.contact,images:r.images??eAe,imagesLost:r.images?0:r.imageCount}:null},keep(o,r,c){const d=Jje(r.images);if(!IW({body:r.body,contact:r.contact,images:d},c)){i(o);return}const u=n();u.delete(o),u.set(o,{kind:r.kind,body:r.body,contact:r.contact,images:r.images,imageCount:d});for(const p of u.keys()){if(u.size<=VI)break;u.delete(p)}a()},forget:i}}function aAe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const jj=nAe(aAe),sAe=4e3;function iAe(e,t,n,a,i){const o=m.useRef(null);o.current={key:e,seed:t,words:n,images:a,sent:i};const r=m.useCallback(()=>{const c=o.current;!c||c.sent||jj.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);m.useEffect(r,[r,n.kind,n.body,n.contact,a.shots]),m.useEffect(()=>r,[r]),m.useEffect(()=>{i&&jj.forget(e)},[i,e])}const JI="draft";function oAe(e){const[t,n]=m.useState(!1),a=m.useRef(0);m.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),sAe);return()=>window.clearTimeout(o)},[t]);function i(){const o=Date.now(),r=zr({armedFor:t?JI:null,target:JI,armedAt:a.current,now:o,gapMs:qr});if(r==="arm"){n(!0),a.current=o;return}r!=="ignore"&&(n(!1),e())}return{armed:t,press:i}}function DW({onClose:e,initialKind:t,initialBody:n}){const a=ae(),i=m.useRef(null),o=m.useRef(null),r=m.useRef(null),c=m.useRef(null),d=m.useRef(null),u=m.useRef(null),p=m.useRef(null),g=m.useRef(null),f=m.useRef(0),v=_t(e,{focusRef:i}),k=qt(e),y=Vje({initialKind:t,initialBody:n}),N=Kje(y),[w]=m.useState(()=>jj.read(N)),[S,j]=m.useState((w==null?void 0:w.kind)??y.kind),[A,T]=m.useState((w==null?void 0:w.body)??y.body),[E,q]=m.useState((w==null?void 0:w.contact)??""),[F,z]=m.useState((w==null?void 0:w.imagesLost)??0),[H,I]=m.useState(!1),[L,O]=m.useState(!1),[_,M]=m.useState(!1),U=Hje(w==null?void 0:w.images),G=XCe(Wje()),{outcome:W,sending:$,send:Y,clearFailure:B}=Gje(U),V=W.state==="sent",Z=$je(V,e);iAe(N,y,{kind:S,body:A,contact:E},U,V);const D=IW({body:A,contact:E,images:U.shots.length},y),K=oAe(()=>{var Ae;j(y.kind),T(y.body),q(""),z(0),O(!1),U.clear(),B(),(Ae=i.current)==null||Ae.focus()}),X=dW(S),Q=L&&!RI(A),ee=F>0&&U.shots.length===0,ne=[Q&&"fb-body-error",ee&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[de,ge]=rSe(Co());m.useEffect(()=>{var Oe,Ve;const Ae=c.current;if(!Ae)return;const je=Ae.contains(document.activeElement)||Xn(((Oe=document.activeElement)==null?void 0:Oe.tagName)??null);Ae.inert=V,V&&je&&((Ve=o.current)==null||Ve.focus())},[V]),m.useEffect(()=>{var nt,Ye;const Ae=d.current;if(!Ae)return;const je=p.current;if($){const Ce=document.activeElement,ze=Ce!=null&&(Ae.contains(Ce)||Ce===je);g.current=ze?Ce:null,Ae.inert=!0,je&&(je.inert=!0),g.current&&((nt=u.current)==null||nt.focus());return}Ae.inert=!1,je&&(je.inert=!1);const Oe=g.current;g.current=null;const Ve=document.activeElement===u.current||Xn(((Ye=document.activeElement)==null?void 0:Ye.tagName)??null);!V&&Oe&&Ve&&Oe.focus()},[$,V]);function le(Ae){var je;if(Ae.preventDefault(),!RI(A)){O(!0),(je=i.current)==null||je.focus();return}Y({kind:S,body:A,contact:E})}const he=!V&&!$,ce=Ae=>jje(Array.from(Ae.dataTransfer.types));function oe(Ae){!ce(Ae)||!he||(Ae.preventDefault(),f.current++,M(!0))}function ve(Ae){ce(Ae)&&(Ae.preventDefault(),Ae.dataTransfer.dropEffect=he?"copy":"none")}function ke(Ae){ce(Ae)&&(f.current=Math.max(0,f.current-1),f.current===0&&M(!1))}function ye(Ae){ce(Ae)&&(Ae.preventDefault(),f.current=0,M(!1),he&&U.add(Array.from(Ae.dataTransfer.files)))}function Le(Ae){Ae.target!==Ae.currentTarget||!ce(Ae)||(Ae.preventDefault(),Ae.dataTransfer.dropEffect="none")}function Ke(Ae){ce(Ae)&&Ae.preventDefault()}function Qe(Ae){if(!he)return;const je=Array.from(Ae.clipboardData.files),Oe=Ae.target,Ve=Oe instanceof HTMLTextAreaElement||Oe instanceof HTMLInputElement,nt=Array.from(Ae.clipboardData.types).includes("text/plain");Aje({files:je.length,hasText:nt,intoTextField:Ve})&&(Ae.preventDefault(),U.add(je))}return s.jsx("div",{className:"modal-backdrop",...k,role:"presentation",onDragOver:Le,onDrop:Ke,"data-leaving":Z||void 0,children:s.jsxs("div",{ref:v,className:"modal feedback-dialog",onClick:Ae=>Ae.stopPropagation(),onDragEnter:oe,onDragOver:ve,onDragLeave:ke,onDrop:ye,onPaste:Qe,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:a("shell.feedback.title")})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{ref:o,type:"button",className:"glyph-btn",onClick:e,"aria-label":a("shell.closeEsc"),title:a("shell.closeEsc"),children:"×"})})]}),s.jsx("p",{className:"vis-hidden",role:"status",children:K.armed?KI():dSe(W.state)}),s.jsxs("div",{className:"fb-stage",children:[s.jsxs("form",{ref:c,className:"fb-form",onSubmit:le,onKeyDown:Ae=>{oSe(Ae.nativeEvent)&&(Ae.preventDefault(),Ae.currentTarget.requestSubmit())},noValidate:!0,children:[s.jsxs("section",{ref:d,className:"modal-body fb-body",children:[s.jsx(tje,{kind:S,onChange:j}),s.jsxs("div",{className:"fb-compose",children:[s.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),s.jsx("textarea",{ref:i,id:"fb-body",className:"ap-manage-input fb-message",value:A,maxLength:uW,rows:5,placeholder:X.placeholder,onChange:Ae=>T(Ae.target.value),"aria-invalid":Q||void 0,"aria-describedby":ne,required:!0}),Q&&s.jsx("p",{id:"fb-body-error",className:"fb-error",children:WCe()}),s.jsx(Dje,{images:U,addRef:r}),ee&&s.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Yje(F)}),s.jsxs("div",{className:"fb-tools",children:[s.jsx(Ije,{images:U,buttonRef:r}),s.jsx(nje,{open:H,onToggle:()=>I(Ae=>!Ae)})]}),s.jsx(aje,{open:H,contact:E,onContact:q})]}),s.jsx("p",{className:"fb-facts",children:G?Sj(QCe(),"facts",s.jsx("span",{className:"fb-facts-value",children:G})):eSe()}),W.state==="failed"&&s.jsx("p",{className:"fb-error",role:"alert",children:W.message})]}),s.jsxs("div",{className:"fb-foot",children:[D&&s.jsx("button",{ref:p,type:"button",className:`btn danger fb-discard${K.armed?" armed":""}`,onKeyDown:Ae=>{Ae.repeat&&Ae.preventDefault()},onClick:K.press,title:K.armed?KI():Qje(),children:K.armed?Xje():Zje()}),s.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[s.jsx("kbd",{"data-symbol":cSe(de)||void 0,children:de}),s.jsx("kbd",{children:ge})," ",a("shell.feedback.toSend")]}),s.jsx("button",{type:"button",className:"btn",onClick:e,children:a("shell.cancel")}),s.jsx("button",{ref:u,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...ga($),children:s.jsxs("span",{className:"fb-send-label",children:[s.jsx("span",{className:"fb-send-idle",children:a("shell.feedback.send")}),s.jsx("span",{className:"fb-send-busy",children:a("shell.feedback.sending")})]})})]})]}),V&&s.jsxs("div",{className:"fb-done",children:[s.jsx(Tu,{}),s.jsx("p",{className:"fb-done-line",children:pW()})]})]}),s.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":_||void 0,children:s.jsxs("div",{className:"fb-drop-frame",children:[s.jsx(MW,{className:"fb-drop-glyph"}),s.jsx("p",{className:"fb-drop-title",children:a("shell.feedback.dropTitle")}),s.jsx("p",{className:"fb-drop-note",children:a("shell.feedback.dropNote")})]})})]})})}const PS=[{id:"canvas",get title(){return C("settings.key.group.canvas")},rows:[{cap:"Space",get action(){return C("settings.key.pause")},binds:[" "]},{cap:"J",get action(){return C("settings.key.next")},binds:["j","J"]},{cap:"K",get action(){return C("settings.key.prev")},binds:["k","K"]},{cap:"W",get action(){return C("settings.key.waiting")},binds:["w","W"]},{cap:"F",get action(){return C("settings.key.fit")},binds:["f","F"]},{cap:"Z",get action(){return C("settings.key.zoom")},binds:["z","Z"]},{cap:"Delete",get action(){return C("settings.key.delete")},binds:["Delete"]},{cap:"R",get action(){return C("settings.key.rearrange")},binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",get action(){return C("settings.key.undo")},binds:["z","Z"],chord:!0},{cap:"C",get action(){return C("settings.key.clear")},binds:["c","C"]}]},{id:"panels-and-dialogs",get title(){return C("settings.key.group.panels")},rows:[{cap:"Ctrl + K",macCap:"⌘ K",get action(){return C("settings.key.quick")},binds:["k","K"],chord:!0},{cap:"U",get action(){return C("settings.key.usage")},binds:["u","U"]},{cap:"L",get action(){return C("settings.key.sessions")},binds:["l","L"]},{cap:"D",get action(){return C("settings.key.detail")},binds:["d","D"]},{cap:"H",get action(){return C("settings.key.history")},binds:["h","H"]},{cap:"A",get action(){return C("settings.key.accounts")},binds:["a","A"]},{cap:"S",get action(){return C("settings.key.machine")},binds:["s","S"]},{cap:"B",get action(){return C("settings.key.bw")},binds:["b","B"]},{cap:"I",get action(){return C("settings.key.jira")},binds:["i","I"],integration:"jira"},{cap:"?",get action(){return C("settings.key.sheet")},binds:["?"]}]},{id:"settings",get title(){return C("settings.key.group.settings")},rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",get action(){return C("settings.key.all")},binds:[","],chord:!0},{cap:"V",get action(){return C("settings.key.sound")},binds:["v","V"]},{cap:"M",get action(){return C("settings.key.mute")},binds:["m","M"]},{cap:"T",get action(){return C("settings.key.theme")},binds:["t","T"]}]},{id:"focus-and-selection",get title(){return C("settings.key.group.focus")},rows:[{cap:"Tab",get action(){return C("settings.key.tab")},binds:[]},{cap:"Enter",get action(){return C("settings.key.enter")},binds:["Enter"]},{cap:"Shift + Enter",get action(){return C("settings.key.shiftEnter")},binds:["Enter"]},{cap:"Esc",get action(){return C("settings.key.esc")},binds:["Escape"]}]},{id:"mouse",get title(){return C("settings.key.group.mouse")},rows:[{get cap(){return C("settings.key.cap.drag")},get action(){return C("settings.key.drag")},binds:[]},{get cap(){return C("settings.key.cap.shiftClick")},get action(){return C("settings.key.shiftClick")},binds:[]},{get cap(){return C("settings.key.cap.click")},get action(){return C("settings.key.click")},binds:[]},{get cap(){return C("settings.key.cap.doubleClick")},get action(){return C("settings.key.doubleClick")},binds:[]},{get cap(){return C("settings.key.cap.hover")},get action(){return C("settings.key.hover")},binds:[]}]}],rAe=/ ?\([A-Z?]\)/g;function FW(e,t=()=>!0){const n=a=>a.integration===void 0||t(a.integration);return e&&PS.every(a=>a.rows.every(n))?PS:PS.map(a=>({...a,rows:a.rows.filter(n).filter(i=>e||i.chord||!i.binds.some(SU)).map(i=>e?i:{...i,action:i.action.replace(rAe,"")})})).filter(a=>a.rows.length>0)}function cAe(e,t){return e.split(/\{(\w+)\}/g).map((a,i)=>i%2===1&&a in t?s.jsx(m.Fragment,{children:t[a]},i):a===""?null:s.jsx(m.Fragment,{children:i%2===1?`{${a}}`:a},i))}function lAe({onClose:e,onTour:t,onSettings:n}){const a=ae(),i=_t(e),o=qt(e),r=zo(Co()),c=Qn(),d=Xu(),u=FW(c,p=>yi(d,p));return s.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:s.jsxs("div",{ref:i,className:"modal key-help",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":c?void 0:"key-help-off",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:a("settings.key.title")})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":a("settings.key.close"),title:a("settings.key.close"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[!c&&s.jsxs("div",{className:"kh-off",children:[s.jsx("p",{className:"kh-off-text",id:"key-help-off",children:cAe(a("settings.key.offText",{title:"{title}",place:"{place}"}),{title:s.jsx("strong",{children:a("settings.key.offTitle")}),place:s.jsx("span",{className:"kh-place",children:a("settings.key.place")})})}),n&&s.jsx("button",{type:"button",className:"btn",onClick:n,children:a("settings.key.openSettings")})]}),t&&s.jsxs("div",{className:"guide-door",children:[s.jsx("span",{children:a("settings.key.tourText")}),s.jsx("button",{type:"button",className:"btn",onClick:t,children:a("settings.key.tour")})]}),s.jsx("div",{className:"shortcuts",children:u.map(p=>s.jsxs(m.Fragment,{children:[s.jsx("h3",{className:"kh-group",children:p.title}),p.rows.map(g=>s.jsxs("div",{className:"sc",children:[s.jsx("kbd",{children:r&&g.macCap?g.macCap:g.cap}),s.jsx("span",{children:g.action})]},`${p.id}:${g.cap}:${g.action}`))]},p.id))}),c&&s.jsxs("p",{className:"kh-foot",children:[a("settings.key.note")," ",a("settings.key.switchNote",{place:a("settings.key.place")})]})]})]})})}function dAe(e,t){return`${e}#${t}`}function uAe(e,{lan:t,now:n,closed:a}){if(t===void 0)return[];const i=[];for(const o of e??[]){const r=o.reauth;if(!r||r.dismissed||o.origin!=="ccdeck_signin")continue;const c=dAe(r.key,r.since);if(a.has(c)||cpe(r.key,o.email,t,n))continue;const d=o.email??"";i.push({id:c,key:r.key,since:r.since,num:o.num,email:d,name:d||o.alias||C("accounts.accountN",{n:o.num}),alias:d&&o.alias?o.alias:null})}return i}function hAe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(a=>a.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(a.num)===String(t.num))).map(a=>a.id):[]}function UW({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function pAe(e,t=C){return t("accounts.reauth.title",{count:e})}function gAe(e,t=C){return t("accounts.reauth.lead",{count:e})}const mAe=(e=C)=>e("accounts.reauth.expired"),fAe=(e=C)=>e("accounts.reauth.singleNote"),bAe=(e=C)=>e("accounts.reauth.laterTip");function vAe(e,t){const n=(e??[]).filter(i=>i&&typeof i.fp=="string"&&!t.has(i.fp));if(!n.length)return{request:null,waiting:0};const a=[...n].sort((i,o)=>(i.at??0)-(o.at??0));return{request:a[0],waiting:a.length-1}}function kAe({request:e,waiting:t,busy:n,now:a,onAccept:i,onDecline:o,onLater:r}){const c=ae(),d=m.useRef(null),u=_t(r,{focusRef:d}),p=qt(r),g=xo(n,"accept"),f=xo(n,"dismiss");return s.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:s.jsxs("div",{ref:u,className:"modal lan-ask",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("i",{className:"ap-pulse","aria-hidden":!0}),s.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:c("lan.ask.title")})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:r,"aria-label":c("lan.ask.later"),title:c("lan.ask.later"),children:"×"})})]}),s.jsxs("section",{className:"modal-body",children:[s.jsx("p",{id:"lan-ask-who",className:"lan-ask-who",children:s.jsx(Or,{text:c("lan.ask.who",{when:dT(e.at,a)}),parts:{name:s.jsx("strong",{className:"lan-ask-name",children:e.name}),addr:s.jsx("code",{className:"ap-lan-code",children:e.addr})}})}),s.jsx("p",{className:"modal-note",children:c("lan.ask.note")}),s.jsx("p",{className:"lan-ask-fp",children:s.jsx(Or,{text:c("lan.ask.fp"),parts:{fp:s.jsx("code",{className:"ap-lan-code",children:e.fp})}})}),t>0&&s.jsx("p",{className:"lan-ask-more",children:c("lan.ask.more",{count:t})}),s.jsxs("div",{className:"lan-ask-acts",children:[s.jsx("button",{type:"button",ref:d,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:o,title:c("lan.ask.declineTitle"),children:c(n==="dismiss"?"lan.ask.declining":"lan.ask.decline")}),s.jsx("button",{type:"button",className:"btn primary",disabled:g.disabled,"aria-busy":g.busy,onClick:i,title:c("lan.ask.acceptTitle"),children:c(n==="accept"?"lan.ask.accepting":"lan.ask.accept")})]})]})]})})}function wAe(e){const t=m.useRef(!1),n=yAe(e),a=UW({rows:n?1:0,ours:t.current,dialogs:jn.dialogDepth()});return t.current=a,a?n:null}function yAe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:a,deferLanPair:i}){const{request:o,waiting:r}=vAe(e,t.current);return o?s.jsx(kAe,{request:o,waiting:r,busy:n,now:Date.now(),onAccept:()=>void a("accept",o.fp),onDecline:()=>void a("dismiss",o.fp),onLater:()=>i(o.fp)},o.fp):null}function xAe({rows:e,onSignIn:t,onLater:n,firstRef:a}){const i=ae(),o=e.length===1?e[0]:null;return s.jsxs("section",{className:"modal-body",children:[o?s.jsxs(s.Fragment,{children:[s.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:hT(i,"accounts.reauth.leadOne",{name:s.jsxs(s.Fragment,{children:[s.jsx("strong",{className:"reauth-name",children:o.name}),o.alias?s.jsxs("span",{className:"reauth-alias",children:[" (",o.alias,")"]}):null]})})}),s.jsx("p",{className:"reauth-note",children:fAe(i)})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:gAe(e.length,i)}),s.jsx("ul",{className:"reauth-list",children:e.map((r,c)=>s.jsxs("li",{className:"reauth-row",children:[s.jsxs("span",{className:"reauth-who",title:r.alias?`${r.alias} — ${r.name}`:r.name,children:[r.name,r.alias?s.jsxs("span",{className:"reauth-alias",children:[" ",r.alias]}):null]}),s.jsx("span",{className:"reauth-what",children:mAe(i)}),s.jsx("button",{type:"button",className:"btn",ref:c===0?a:void 0,"aria-label":i("accounts.reauth.againAs",{name:r.name}),onClick:()=>t(r),children:i("accounts.reauth.again")})]},r.id))}),s.jsx("p",{className:"reauth-note",children:i("accounts.reauth.keeps")})]}),s.jsxs("div",{className:"reauth-acts",children:[s.jsx("button",{type:"button",className:"btn",title:bAe(i),onClick:n,children:i("accounts.reauth.later")}),o&&s.jsx("button",{type:"button",className:"btn primary",ref:a,onClick:()=>t(o),children:i("accounts.reauth.again")})]})]})}function CAe({rows:e,onSignIn:t,onLater:n}){const a=ae(),i=m.useRef(null),o=_t(n,{focusRef:i}),r=qt(n);return s.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:s.jsxs("div",{ref:o,className:"modal reauth-ask",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:pAe(e.length,a)})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":a("accounts.reauth.laterEsc"),title:a("accounts.reauth.laterEsc"),children:"×"})})]}),s.jsx(xAe,{rows:e,onSignIn:t,onLater:n,firstRef:i})]})})}function SAe({rows:e,signingIn:t,signIn:n,signedIn:a,refresh:i,closeSignIn:o,later:r,pairing:c=!1}){const d=m.useRef(!1),u=jn.dialogDepth()+(c?1:0),p=t!=null||UW({rows:e.length,ours:d.current,dialogs:u});return d.current=p,t?s.jsx($3,{email:t.email||null,onClose:o,onChanged:i,onSignedIn:a}):p?s.jsx(CAe,{rows:e,onSignIn:n,onLater:r},e.length===1?"one":"many"):null}const NAe={"//":["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","author metadata and never a release.","","Editorial metadata: optional //summaries maps a release version to one","specific, verified headline (1–120 characters). No generic marketing claims.","A note may have priority: highlight or required. Choose at most 3 highlights,","only when warranted. Unmarked notes go under More improvements when highlights","exist. Legacy notes stay unabridged; legacy upgrade notes stay visible.","Use required for breaking changes, changed settings, privacy/security impact,","compatibility requirements or mandatory actions. A highlight with any such","impact must also carry a notice with all essential qualifications: highlight","alone is editorial placement, not an instruction to surface it across upgrades.","Required notes and notices stay visible across upgrades, never in a closed section.","Write a short benefit-led title and one useful sentence where possible; keep","opt-outs and limits. Avoid inflated adjectives, filler and generic claims.","Preserve original factual meaning. Never invent capabilities or results.","Retain setup instructions and compatibility minimums. Say only what a user","sees in the app: usage reports, telemetry and environment variables are for","README to explain, not for a note.","Verify each claim against the released diff and tests. No promotion","for invisible fixes. Do not rewrite historical releases to fit the layout.","","Keep highlight titles within 72 characters (excluding a leading emoji) and","benefit descriptions within 240 characters. These limits are validated.","Put essential compatibility, privacy or configuration details in optional","notice text, outside More improvements. Current/upgrade notices stay visible and","have no truncation limit. A notice also keeps its change visible across upgrades.","Optional noticeLabel gives it a short factual heading (1–32 characters), such","as Setup change or Compatibility. It requires notice text; default is Important.","Optional details holds secondary context, shown under the same improvements","disclosure for highlights and beside other notes. Keep the body to one useful","sentence. Never move setup, safety, privacy or compatibility conditions into","details: use notice for those, so they remain visible across upgrades.","The disclosure counts other improvements, not extra details of highlights.","Mark any other mandatory action as required. The manual digest shows only the","running release; Release history opens the full changelog. Upgrade notes keep","required/noticed changes visible and disclose the other notes in that range.","Unclassified legacy upgrade notes stay visible rather than guessing safety.","Before adding editorial metadata to a release, review every note: unmarked","changes will be treated as optional in later upgrades. Never infer safety","from a title, keyword, emoji, position or a shortened description.","","Optional icon is a semantic key: plans, accounts or skills. Use it only when","it matches the change; do not infer icons from versions, titles or emoji.","The modal shows a title's leading emoji; the glyph stands in only for a title","without one."],"//summaries":{"3.53.0":"Codex accounts, with sign-in, switching and Auto-switch","3.52.0":"ccdeck in nine more languages","3.51.0":"Jira integration updates","3.46.0":"Plans, accounts and skills at a glance"},"//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.3","3.48.1","3.49.1","3.53.1"],"3.53.2":[{title:"🔁 The deck stays up on machines without Codex",body:"Since 3.53.0 a deck with no Codex restarted itself every few seconds, and it now stays up."}],"3.53.0":[{title:"👥 Codex accounts: sign in, switch and Auto-switch",body:"Add Codex accounts from ccdeck with the official sign-in, see each one's usage, choose the default for new sessions and, if you turn it on, let Auto-switch move to the account with room.",priority:"highlight",noticeLabel:"Codex accounts",notice:"Each account keeps its own Codex folder, and ccdeck never copies, logs or refreshes its tokens. Removing an account moves its folder to codex-profiles-removed instead of deleting it. Auto-switch is off by default and acts only on a reading taken now."},{title:"🔀 One Accounts panel for Claude and Codex",body:"With both CLIs installed, a Claude | Codex switch in the panel's header changes the view, never the account in use, and ccdeck remembers it."},{title:"🕐 Reset times fit in every language",body:"The time until a reset beside each quota bar is no longer cut where a language's words run longer."},{title:"🛠️ Tool and Skill activity work when the deck's folder is gone",body:"Both open again when the folder ccdeck was started from has been deleted."}],"3.52.0":[{title:"🌍 ccdeck in your language",body:"Choose Traditional or Simplified Chinese, German, Japanese, Korean, French, Spanish, Brazilian Portuguese or Romanian in Settings › General › Language. Until you choose, ccdeck follows your browser's language.",priority:"highlight",noticeLabel:"Language",notice:"What's new and text written by Jira, GitHub or GitLab stay as they were written, and anything without a translation shows in English."},{title:"📅 Codex 30-day windows say what a day may cost",body:"A Codex window reported as 30 days is paced over its real length, and its pace note says what a day may cost to last until the reset."}],"3.51.0":[{title:"✏️ Comment and change status in Jira",body:"Add a comment or change an issue’s status from its details in ccdeck.",priority:"highlight",noticeLabel:"Jira edits",notice:"Changes are sent to your connected Jira account and follow its permissions. Jira edits require a supported native build and filesystem; if safe coordination is unavailable, ccdeck refuses the edit and you can still browse your board."},{title:"📍 Jira moves follow your selection",body:"Drag the issue you select, move completed issues between sprints, and place issues at the end by default.",priority:"highlight"},{title:"🛠️ Reduced memory use during long sessions",body:"ccdeck releases more unused memory, and Jira edits recover more reliably when a connection is interrupted."}],"3.50.0":[{title:"🤝 Paired decks no longer each read a shared account's usage",body:"No more rate limits from every machine reading it: one deck reads the account and passes the numbers to the others. Hover the reading's age to see which deck read it."}],"3.49.0":[{title:"🗞️ What's new is shorter and easier to scan",body:"Up to three main changes come first and the rest wait under Show details; Check for updates moved to the dialog's More options menu."},{title:"👥 No warning when one account is in use on several decks",body:"The account row and the desktop no longer flag it, and the Login active on another deck switch is gone from Settings › Notifications; expired logins are still shown.",priority:"required"},{title:"📍 Auto-hidden sessions come back where they were",body:"With Hide finished sessions after on, a session that works again returns to its place, with its new subagents beside it rather than further down the board."},{title:"💻 Windows: About flags an outdated terminal CLI",body:"When the npm ccdeck on PATH is older than the desktop app, Settings › About shows the command that updates it."},{title:"✏️ Texts that fell behind are up to date",body:"Explore integrations says Jira can move issues, and the Radar and Where the time went tips match what the app does."}],"3.48.0":[{title:"🗂️ Jira: move issues between sprints and the backlog",body:"On a Scrum board ordered by Rank, drag issues or use Move to reorder them or send them to another sprint or the backlog, one at a time or up to 50 together. Browsing still only reads."},{title:"🔎 The Jira list is easier to scan",body:"Titles keep more room, a row's preview no longer covers the next row, the issue key shows once in the detail, and Clear filters stays in reach on a phone."},{title:"⌨️ ccdeck tui keeps your Claude accounts on one screen over SSH",body:"Switch accounts, turn Auto-switch on or off, and sign an account in with a link you open in any browser, all from the terminal."},{title:"🎮 Machine shows NVIDIA GPU readings",body:"On Linux and Windows with nvidia-smi: each GPU's utilization, video memory, temperature and power."},{title:"👤 Claude accounts are quieter, and an expired login has a Sign in button",body:"Telemetry is a small shield explained on hover or focus, and an account whose login expired shows Sign in on its own row."},{title:"🩹 Fewer page errors from browser extensions and translation",body:"The Accounts panel recovers when an extension breaks its requests, and Local network keeps working while the browser translates the page."}],"3.47.0":[{title:"⌨️ Quick open: Cmd/Ctrl+K reaches any panel, setting, session or theme by name",body:"Type a few letters to open a panel, land on a setting inside Settings, jump to a session or switch the theme. It is also Search on the bar."},{title:"⚙️ Settings › Claude Code changes Claude Code's own settings from the deck",body:"Twelve settings in five groups, from auto memory and compaction to the Co-Authored-By credit and the update channel, written to your settings.json on this computer."},{title:"📡 Radar monitors all the time, and packet capture is one explained step",body:"There is no Start or Stop any more: Radar finds Claude Code's collector by itself. Where capture needs a permission, Allow packet capture once asks for it on your press only."},{title:"⏱️ Tool activity shows where the time went, and Skill activity who starts your skills",body:"Tool activity splits the turns' time between Claude, this machine and you. Skill activity shows how many skill uses Claude, Codex or you started, overall and per skill."},{title:"📊 Usage remembers how full each quota week ended, and names your Claude plan",body:"Under each 7-day bar a line says how full the last weeks were at their reset. The Claude quota card shows your plan beside its title, as the Codex card does."},{title:"🗂️ Stripes, dialogs and floating panels are organized more evenly",body:"The doors on both edge stripes sit in named groups, dialogs share one frame, and T switches the theme inside any dialog too."},{title:"🪟 The desktop app works on a first run without Node, and integrations got fixes",body:"Usage no longer needs npm, and Claude Code installed while the app is open is picked up. Jira and GitLab avatars load, and panels reopen where you left them."}],"3.46.0":[{title:"🔗 Jira, GitHub and GitLab panels are easier to read and navigate",body:"Jira rows show each issue's status, lists answer the arrow keys and fit a phone, and a failed refresh says “Not updated”."},{title:"📡 Radar finds more Claude Code processes on Linux",body:"It now sees Claude Code started from its versioned install folder, plus connection attempts that got no reply and the telemetry variables it was launched with."},{title:"🗺️ Follow plans at any zoom",body:"See plan progress on session notes and directly on the canvas.",priority:"highlight",icon:"plans",details:"Subagents stay in one column beside their parent."},{title:"✅ Keep your Claude account in sync",body:"After `/login`, Accounts, Switch, Auto-switch and Usage follow your active Claude Code account.",priority:"highlight",icon:"accounts",details:"Auto-switch can also be set up while it is off."},{title:"📊 Account capacity and the Reset calendar have their own buttons",body:"Both open from the left stripe, under Claude accounts, instead of from the small gauge in the accounts panel's header."},{title:"🧩 See which skills your agents use",body:"Review skill activity from the right sidebar, including typed slash commands.",priority:"highlight",notice:"Counting typed slash commands adds a `UserPromptExpansion` hook to Claude Code's `settings.json` on supported versions (2.1.116+). Set `AGENTS_DECK_SKILL_HOOK=0` to opt out.",icon:"skills",noticeLabel:"Setup change"},{title:"📈 Load history keeps the reading you click",body:"Click a minute on a chart to keep its reading. Saved limit resets now show their expiry time, and Tool activity has a clearer icon."}],"3.45.0":[{title:"🔗 Read-only Jira, GitHub and GitLab panels beside your agents",body:"Settings › Integrations connects Jira (Cloud, Server or Data Center), GitHub, and GitLab.com or your own GitLab, each with a token, and a control on the left stripe opens its panel: a Jira board's backlog in Jira's own order, or a project's branches, pull or merge requests, pipelines and issues, with the item beside the list. The panels only read: they never comment, merge, re-run a job or change an issue. The token stays on this machine, in a file only you can read, and goes only to that connection's own API. Nothing is read until you connect a tracker, and then only while its panel is open."},{title:"📤 Each account says what its organization's telemetry sends",body:"A Team or Enterprise organization can turn on Claude Code's telemetry for every member, and Claude Code applies it without asking. Each account of such an organization now carries a line under its name: “Telemetry · usage data”, or “Telemetry · prompts, tool details” in the warning colour when your prompts and tool details are sent too. Its tooltip names the organization and where the data goes. After a switch, Auto-switch's notification and the row's “Now active” note say it too. The deck changes nothing; it learns what the organization turns on from a Claude Code session run on one of its accounts, and until then that account shows no line."},{title:"⚠️ A warning when a paired deck is on the same Claude login",body:"A Claude login renews once, so when two machines use one copied login, the one that renews second is signed out. When a paired deck on Local network says it is on the login this deck is using, the live account's row now says “Also active on” and names that deck, with what to do: use a different account on one of the machines, or sign in on each one separately. A switch onto such a login says so too, and so does one desktop notification per incident, “Login active on another deck” in Settings › Notifications, which is on by default."},{title:"📱 A phone opens one panel at most when the deck loads",body:"On a window 640 px wide or less, a reload used to open Accounts, Usage and the machine panel on top of each other, with none of the board in sight. It now opens at most one of them, preferring Usage over the machine panel, and Accounts and the session list open from the dock. A wider window loads exactly as before, and nothing you chose is forgotten."}],"3.44.0":[{title:"⛔ A turn that stops on an error now shows as stopped",body:"When Claude Code ends a turn on an API error, such as an expired login or a usage limit, it sends StopFailure instead of Stop. The deck now adds StopFailure to the hooks it writes in Claude Code's settings.json, but only when every Claude Code it finds is 2.1.78 or newer; with an older one, or one whose version it cannot read, nothing changes. The card then says “Stopped · login expired”, “Stopped · usage limit” or “Stopped · API error”, and the sessions one expired login stops together arrive as one notification that names them. Each needs a “continue” once a working login is active."},{title:"🔑 Auto-switch leaves an expired login, and nothing switches onto one",body:"When Claude Code has signed a login out and claude-swap's saved copy is dead too, Auto-switch now moves to another account under your home and weekly-reset rules, and its notification says why. Neither Auto-switch nor Switch moves onto a login that is already known to be expired: that account's row says its login expired, with Sign in again, and nothing moves."},{title:"💲 Usage totals say how complete they are",body:"The usage headline is always shown now, by the rule History and the model table already used: an exact total when every cost is known, a known $0 included; the known part with “+” when some tokens could not be priced; and “not priced”, never a bare $0, when no cost is known. Sessions whose cost is a known zero show it too."},{title:"📡 Radar: a resizable inspector, prompt previews and a JSON view",body:"Radar's inspector can be resized and shows prompt previews, highlights and each record as a JSON tree, beside the File view. Settings › Radar has a new Monitor automatically switch. It is off, so Radar still watches only after you press Start, as before; turn it on to have the deck start monitoring by itself."},{title:"🧰 Tool activity opens over the deck, with the first tool's details open",body:"Tool activity now opens as a dialog over the deck instead of a page of its own, with the first tool selected and its details beside the list. Escape closes the details first, then the dialog. On a phone the details open as a sheet."},{title:"🧩 Tool activity counts skills, and the slash commands you type if you opt in",body:"Tool activity's Skills tab ranks the skills your Claude Code and Codex agents used. Counting the slash commands you type needs Claude Code's UserPromptExpansion hook, which the deck adds to settings.json only when you start it with AGENTS_DECK_SKILL_HOOK=1 and every Claude Code it finds is 2.1.116 or newer. Without that variable nothing in settings.json changes."},{title:"▶️ Continue a background session that stopped",body:"A background session that stopped on an error has a Continue button on its card and panel: the deck stops it if Claude Code still lists it, then resumes it in its own folder with “Continue from where you left off.” Continue stopped background sessions, in Settings › General, presses it for you once per stop. It is off until you turn it on."},{title:"⌨️ ccdeck commands for your terminal",body:"ccdeck accounts, ccdeck switch, ccdeck usage, ccdeck sessions and ccdeck open work from any terminal. ccdeck switch --best goes where Auto-switch would, and every switch follows the deck's own rules. Over SSH, ccdeck open prints the line that opens the deck on your own computer. Each command takes --json for scripts."}],"3.43.4":[{title:"🔐 Local network no longer sends the login a deck is signed in to",body:`Two machines on one Claude login race to renew it, and the one that renews second is signed out with “Login expired”. So paired decks no longer receive the login a deck is signed in to right now. Every other login you tick is shared as before, and this one goes out once the deck switches to another account.
156
156
 
157
157
  Update every paired deck: an older deck still sends the login it is using, and the decks paired with it still take it. To send it anyway, as before, turn on Send the login this deck is using too in the Local network dialog. Not covered yet: a paired deck that already holds a copy of that login, from before this deck switched to it, can still renew it first and sign this deck out. Auto-switch can also still move a deck onto a login another paired deck is using, if the deck already holds a copy of it.`}],"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.
158
158
 
@@ -348,11 +348,11 @@ While it is open it polls this machine once every few seconds, and it stops the
348
348
 
349
349
  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.
350
350
 
351
- 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.`}]},JT="agent-dag.releaseNotesSeen";function YI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Ro(e,t){const n=YI(e),a=YI(t);for(let i=0;i<Math.max(n.length,a.length);i++){const o=(n[i]??0)-(a[i]??0);if(o!==0)return o<0?-1:1}return 0}function Ws(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function jAe(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 AAe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,a]of Object.entries(e)){if(!Ws(n)||!Array.isArray(a))continue;const i=a.filter(jAe).map(c=>({title:c.title,body:c.body,...typeof c.details=="string"&&c.details.trim()?{details:c.details}:{},...c.priority==="highlight"||c.priority==="required"?{priority:c.priority}:{},...typeof c.notice=="string"&&c.notice.trim()?{notice:c.notice}:{},...typeof c.notice=="string"&&c.notice.trim()&&typeof c.noticeLabel=="string"&&c.noticeLabel.trim()&&c.noticeLabel.length<=32?{noticeLabel:c.noticeLabel}:{},...c.icon==="plans"||c.icon==="accounts"||c.icon==="skills"?{icon:c.icon}:{}})),o=e["//summaries"],r=o&&typeof o=="object"&&Object.hasOwn(o,n)?o[n]:void 0;i.length&&t.push({version:n,notes:i,...typeof r=="string"&&r.trim()?{summary:r}:{}})}return t.sort((n,a)=>Ro(a.version,n.version))}function TAe(e){const t=e.filter(o=>o.priority==="highlight").slice(0,3),n=t.length>0,a=e.filter(o=>!t.includes(o)&&(!n||o.priority==="required"||o.priority==="highlight"||!!o.notice)),i=e.filter(o=>!t.includes(o)&&!a.includes(o));return{highlights:t,visible:a,more:i}}function RAe(e,t,n){const[a,...i]=e;if(!t)return{latest:Ws(n)?e.find(c=>Ro(c.version,n)===0):a,visiblePrevious:[],history:[]};const o=[],r=[];for(const c of i){const d=c.notes.some(g=>g.priority==="highlight"||g.priority==="required"||!!g.notice),u=c.notes.filter(g=>!d||g.priority==="required"||!!g.notice);u.length&&o.push({version:c.version,notes:u});const p=c.notes.filter(g=>!u.includes(g));p.length&&r.push({...c,notes:p})}return{latest:a,visiblePrevious:o,history:r}}const ZI=AAe(NAe);function BW(e,t,n){return e.filter(a=>Ro(a.version,n)<=0&&(t===null||Ro(a.version,t)>0))}function EAe(e,t){return e.filter(n=>Ro(n.version,t)===0)}function _Ae(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}`}const qAe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function HW(e){const t=qAe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function zAe(e){if(!e)return null;let t=null;try{t=e.getItem(JT)}catch{return null}return Ws(t)?t:null}function LAe(e){if(!e)return!1;try{return e.getItem(JT),!0}catch{return!1}}function OAe(e,t){if(!e)return!1;try{return e.setItem(JT,t),!0}catch{return!1}}const WW="agent-dag.tourSeen";function PAe(e){if(!e)return!1;try{return e.getItem(WW)==="1"}catch{return!1}}function MAe(e){if(!e)return!1;try{return e.setItem(WW,"1"),!0}catch{return!1}}function IAe({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 DAe({stored:e,running:t,notes:n,remembers:a=!0}){if(!Ws(t))return{show:[],record:null,reason:"no-version"};if(!Ws(e)){if(!a)return{show:[],record:t,reason:"cannot-remember"};const r=EAe(n,t);return r.length?{show:r,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const i=Ro(e,t);if(i===0)return{show:[],record:null,reason:"seen"};if(i>0)return{show:[],record:null,reason:"ahead"};const o=BW(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function FAe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const a=e.indexOf("`",n+1);if(a<0)break;n=a+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function nu(e,t=!0){const n=[];let a="";const i=()=>{a&&(n.push({kind:"text",text:a}),a="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const r=e.indexOf("`",o+1);if(r>o+1){i(),n.push({kind:"code",text:e.slice(o+1,r)}),o=r+1;continue}}else if(t&&e.startsWith("**",o)){const r=FAe(e,o);if(r>0){i(),n.push({kind:"bold",kids:nu(e.slice(o+2,r),!1)}),o=r+2;continue}}a+=e[o],o+=1}return i(),n}function Eo(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const UAe=()=>C("shell.update.checkWhy"),XI=()=>C("shell.update.checking"),BAe=()=>C("shell.update.npmUnreachable"),HAe=()=>C("shell.update.deckUnreachable"),WAe=()=>C("shell.update.checksOff"),GAe=()=>C("shell.update.pendingRetry");function $Ae(e,t,n,a){const i=a?t.npx:n?un(t,n):void 0;return i?C("shell.update.outBlocked",{to:e,reason:i}):C("shell.update.outRun",{to:e})}const ua=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),dr=e=>ua(e,{tone:"note"});function QI(e,t){return rNe(t-e)}function VAe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?dr(C("shell.update.appReady",{version:n.version??""})):(n==null?void 0:n.status)==="checking"?dr(C("shell.update.appChecking")):(n==null?void 0:n.status)==="downloading"?dr(n.version?C("shell.update.appDownloadingVersion",{version:n.version}):C("shell.update.appDownloading")):(n==null?void 0:n.status)==="current"?dr(C("shell.update.appCurrent",{version:e.version??t})):(n==null?void 0:n.status)==="error"?dr(C("shell.update.appError")):dr(C("shell.update.appIdle"))}function KAe(e,t,n){var r;const a=e.version;if((a==null?void 0:a.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return ua(C("shell.update.installed",{to:t}));const c=e.upgradeState==="running",d=C("shell.update.installWhy",{command:((r=a.upgrade)==null?void 0:r.command)??a.command});return ua(c?C("shell.update.installing",{to:t}):C("shell.update.out",{to:t}),{action:{kind:"install",label:C("shell.update.now"),busy:c,why:d}})}if((a==null?void 0:a.upgradeMode)==="npx"&&a.canRestart){const c=e.upgradeState==="failed";return ua(c?C("shell.update.npxFailedBack",{to:t,running:e.running}):C("shell.update.out",{to:t}),{action:{kind:"npx",label:C(c?"shell.update.retry":"shell.update.andRestart"),busy:e.restarting,why:C("shell.update.npxWhy",{command:a.command})}})}const i=e.upgradeState==="failed"?C("shell.update.installFailed",{to:t}):$Ae(t,n,a==null?void 0:a.upgradeBlocked,(a==null?void 0:a.upgradeMode)==="npx"),o=(a==null?void 0:a.command)??null;return ua(i,{command:o,action:o?{kind:"copy",label:e.copied?C("shell.copied"):C("shell.copy"),busy:!1}:null})}function JAe(e){const t=e.version;if(e.unreachable)return ua(HAe(),{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return ua(BAe(),{tone:"warn",age:e.answered?null:C("shell.update.lastTried",{ago:QI(n,e.now)})});const a=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(a)return ua(C("shell.update.pending",{pending:a,retry:GAe()}));const i=t!=null&&t.checkedAt?QI(t.checkedAt,e.now):null;if((t==null?void 0:t.checkedAt)&&e.now>=t.checkedAt&&e.now-t.checkedAt<=60*6e4&&(t!=null&&t.latest)&&Ws(t.latest)&&Ws(e.running)){const r=Ro(t.latest,e.running),c=r===0?C("shell.update.latest",{version:e.running}):r<0?C("shell.update.ahead",{running:e.running,latest:t.latest}):C("shell.update.out",{to:t.latest});return ua(c,{age:i?C("shell.update.checkedAgo",{ago:i}):null})}return ua(C(i?"shell.update.mayHaveChanged":"shell.update.noneYet"),{age:i?C("shell.update.lastChecked",{ago:i}):null})}function YAe(e,t){var i,o;const n=e.version;if((i=e.app)!=null&&i.inApp&&(n!=null&&n.checkDisabled)){const r=VAe(e.app,e.running);return r&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?ua(C("shell.update.appRefused"),{tone:"warn"}):e.checking?ua(XI()):r}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:dr(WAe())};const a=(n==null?void 0:n.notice)??null;if((a==null?void 0:a.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:KAe(e,a.to,t)};if((a==null?void 0:a.kind)==="restart"){const r=n!=null&&n.canRestart?C("shell.update.restartDeck",{to:a.to}):C("shell.update.restartApp",{to:a.to});return{canCheck:!0,checking:e.checking,line:ua(r)}}return e.checking?{canCheck:!0,checking:!0,line:ua(XI())}:{canCheck:!0,checking:!1,line:JAe(e)}}const GW=450;async function ZAe(e,t=n=>new Promise(a=>setTimeout(a,n))){const[n]=await Promise.all([e(!0),t(GW)]);return n?"answered":"unreachable"}async function XAe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,GW))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const QAe=()=>C("shell.notes.restartWhy");function eTe(e){var q,F,z;Ea();const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Vs(3e4),[a,i]=m.useState(!1),o=m.useRef(!1),[r,c]=m.useState(!1),[d,u]=m.useState(!1),p=m.useRef(t);if(m.useEffect(()=>{p.current&&!t&&u(!0),p.current=t},[t]),!e)return null;const{versionCheck:g,upgrade:f,restart:v,desktopUpdate:k,running:y,onHandOff:N}=e,w=YAe({version:g.version,running:y,checking:a||t,answered:d,unreachable:r,now:Math.max(n,Date.now()),upgradeState:f.upgradeState,copied:f.cmdCopied,restarting:v.restarting,app:{inApp:Eo(),update:k.appUpdate,version:CW(),menu:NW()}},Cj);if(!w)return null;const S=Eo()&&((q=g.version)==null?void 0:q.checkDisabled),j=S?C("shell.update.checkWhyApp"):UAe(),A=async()=>{var I;if(!Jn(o.current||t)||S&&((I=k.appUpdate)==null?void 0:I.status)==="checking")return;o.current=!0,i(!0);const H=S?await XAe():await ZAe(g.loadVersion);o.current=!1,i(!1),c(H==="unreachable"),u(!0)},T=H=>{if(H.kind==="copy")return void f.copyCommand();N(),g.showNotice(),H.kind==="install"?f.startUpgrade():v.askRestart({upgrade:!0})},E=w.line.tone==="warn"||!!w.line.action||!!((F=g.version)!=null&&F.notice)||((z=k.appUpdate)==null?void 0:z.status)==="downloading";return{state:w,check:A,act:T,checkWhy:j,needsAttention:E}}function tTe({update:e}){const t=Nl("above","dialog"),n=m.useId();return Ea(),s.jsxs("div",{className:"rn-status-row",children:[e?s.jsx(nTe,{line:e.state.line,onAct:e.act,bindHint:t.bind,whyId:`${n}-action`,announce:!1}):s.jsx("p",{className:"rn-update-line",children:s.jsx("span",{role:"status",children:C("shell.notes.statusUnavailable")})}),t.node]})}function nTe({line:e,onAct:t,bindHint:n,whyId:a,announce:i=!0}){const{action:o}=e,r=o&&s.jsx(aTe,{action:o,onAct:t,bindHint:n,whyId:a});return s.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[s.jsx("span",{className:"rn-update-what",role:i?"status":void 0,children:e.said}),e.age&&s.jsx("span",{className:"rn-update-age",children:e.age}),e.command?s.jsxs("span",{className:"rn-update-cmd",children:[s.jsx("code",{className:"rn-code",children:e.command}),r]}):r]})}function aTe({action:e,onAct:t,bindHint:n,whyId:a}){const i=e.kind==="copy"?null:e.why;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:i?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":i&&a?a:void 0,...i&&n?n({label:i}):{},children:e.label}),i&&a&&s.jsx("span",{hidden:!0,id:a,children:i})]})}function sTe({entries:e,since:t,running:n,firstRun:a,onClose:i,onTour:o,updateVersion:r,updateBusy:c,onUpdateRestart:d,updateFailure:u,onRestart:p,updateCheck:g}){var M,U;const f=ae(),v=QAe(),k=_t(i),y=m.useRef(null),N=qt(i),w=m.useId(),[S,j]=m.useState(null),A=eTe(g),T=((M=A==null?void 0:A.state.line.action)==null?void 0:M.kind)==="install"||((U=A==null?void 0:A.state.line.action)==null?void 0:U.kind)==="npx",E=p&&!r&&!T,{latest:q,visiblePrevious:F,history:z}=RAe(e,t!==null,n),H=`${w}-history`,I=!!E||!!(A!=null&&A.state.canCheck)&&!r;m.useEffect(()=>{var G;!I&&S&&(j(null),document.activeElement===document.body&&((G=y.current)==null||G.focus()))},[I,S]);const L=Ws(n)?`v${n}`:_Ae(e.slice(0,1)),O=a&&n?f("shell.notes.contextFirst",{version:n}):t?f("shell.notes.contextSince",{since:t}):null,_=F.some(G=>G.notes.some(W=>!W.priority&&!W.notice));return s.jsx("div",{className:"modal-backdrop",...N,role:"presentation",children:s.jsxs("div",{ref:k,className:"modal release-notes",id:`${w}-dialog`,onClick:G=>G.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:f("shell.notes.title")}),L&&s.jsx("span",{className:"modal-tool-id",children:L})]}),s.jsxs("div",{className:"modal-actions",children:[I&&s.jsx("button",{id:`${w}-options`,type:"button",className:"glyph-btn","aria-label":f("shell.notes.moreOptions"),"aria-haspopup":"menu","aria-expanded":S!==null,"aria-controls":S?`${w}-menu`:void 0,onClick:()=>j(S?null:"first"),onKeyDown:G=>{(G.key==="ArrowDown"||G.key==="ArrowUp")&&(G.preventDefault(),j(G.key==="ArrowUp"?"last":"first"))},children:s.jsxs("svg",{className:"glyph",viewBox:"0 0 14 14",width:"14",height:"14",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"3",cy:"7",r:"1"}),s.jsx("circle",{cx:"7",cy:"7",r:"1"}),s.jsx("circle",{cx:"11",cy:"7",r:"1"})]})}),s.jsx("button",{ref:y,type:"button",className:"glyph-btn",onClick:i,"aria-label":f("shell.closeEsc"),title:f("shell.closeEsc"),children:"×"})]})]}),s.jsx("span",{className:"rn-live-status",role:"status",children:r?f("shell.notes.downloaded",{version:r}):A==null?void 0:A.state.line.said}),s.jsxs("section",{className:"modal-body",role:"region","aria-label":f("shell.notes.region"),tabIndex:0,children:[r?s.jsxs("div",{className:"rn-ready",children:[s.jsx("p",{children:f("shell.notes.downloaded",{version:r})}),s.jsx("p",{className:"rn-update-said",role:"status",children:u})]}):s.jsxs(s.Fragment,{children:[(A==null?void 0:A.needsAttention)&&s.jsx(tTe,{update:A}),s.jsx("p",{className:"rn-update-said",role:"status",children:u})]}),O&&s.jsx("p",{className:"rn-context",children:O}),!(q!=null&&q.notes.length)&&!F.length&&s.jsx("p",{className:"rn-empty",children:f("shell.notes.empty")}),q&&s.jsx(MS,{entry:q,showVersion:t!==null&&e.length>1},q.version),F.length>0&&s.jsxs("section",{className:"rn-upgrade-history","aria-label":f("shell.notes.earlierLabel"),children:[s.jsx("h2",{className:"rn-group-title",children:f("shell.notes.earlierTitle")}),_&&s.jsx("p",{className:"rn-context",children:f("shell.notes.legacy")}),F.map(G=>s.jsx(MS,{entry:G,showVersion:!0},G.version))]}),z.length>0&&s.jsxs("details",{className:"rn-history",children:[s.jsx("summary",{"aria-controls":H,children:f("shell.notes.otherSince",{since:t??""})}),s.jsx("div",{id:H,children:z.map(G=>s.jsx(MS,{entry:G,showVersion:!0},G.version))})]})]}),s.jsxs("footer",{className:"rn-footer",children:[s.jsxs("div",{className:"rn-footer-links",children:[s.jsxs("a",{href:"https://ccdeck.dev/changelog/",target:"_blank",rel:"noopener noreferrer","aria-label":f("shell.notes.historyLabel"),children:[f("shell.notes.history")," ",s.jsx(fl,{})]}),o&&!r&&s.jsx("button",{className:"rn-text-button",type:"button",onClick:o,children:f("shell.notes.tour")})]}),r&&d?s.jsx("button",{className:"btn primary",type:"button",onClick:d,"aria-busy":c||void 0,children:c?f("shell.notes.restarting"):Ru()}):s.jsx("button",{className:"btn primary",type:"button",onClick:i,children:f("shell.done")})]}),S&&I&&s.jsxs(Mr,{anchorId:`${w}-options`,portalRootId:`${w}-dialog`,id:`${w}-menu`,role:"menu",labelledBy:`${w}-options`,start:S,className:"ap-pop rn-options-menu",onClose:()=>j(null),children:[A&&s.jsxs("p",{className:"rn-menu-status",id:`${w}-check-status`,children:[A.state.line.said,A.state.line.age&&s.jsx("span",{children:A.state.line.age})]}),(A==null?void 0:A.state.canCheck)&&s.jsxs("button",{type:"button",className:"ap-menu-item rn-act",role:"menuitem",title:A.checkWhy,"aria-describedby":`${w}-check-status`,"aria-busy":A.state.checking||void 0,onClick:()=>void A.check(),children:[s.jsx(Qie,{}),f("shell.notes.check")]}),(A==null?void 0:A.state.canCheck)&&E&&s.jsx("div",{className:"rn-menu-separator",role:"separator"}),E&&s.jsxs("button",{type:"button",className:"ap-menu-item",role:"menuitem",title:v,"aria-describedby":`${w}-restart-why`,onClick:()=>{j(null),p==null||p()},children:[s.jsx(eoe,{}),f("shell.notes.restart")]}),s.jsx("span",{hidden:!0,id:`${w}-restart-why`,children:v})]})]})})}function MS({entry:e,showVersion:t}){const n=ae(),{highlights:a,visible:i,more:o}=TAe(e.notes),r=a.filter(d=>d.details),c=m.useId();return s.jsxs("section",{className:"rn-release",children:[t&&s.jsxs("h2",{className:"rn-version",children:["v",e.version]}),e.summary&&s.jsx("h2",{className:"rn-summary",children:e.summary}),s.jsxs("ul",{className:"rn-notes",children:[a.map((d,u)=>s.jsx(IS,{note:d,highlight:!0},`h${u}`)),i.map((d,u)=>s.jsx(IS,{note:d},`v${u}`))]}),(o.length>0||r.length>0)&&s.jsxs("details",{className:"rn-more",children:[s.jsxs("summary",{"aria-controls":c,children:[s.jsxs("span",{className:"rn-more-start",children:[s.jsx("span",{className:"rn-chevron","aria-hidden":"true",children:"›"}),s.jsx("span",{className:"rn-more-label",children:o.length?n("shell.notes.more",{count:o.length}):n("shell.notes.moreDetails")})]}),s.jsxs("span",{className:"rn-more-hint",children:[s.jsx("span",{className:"rn-show-details",children:n("shell.notes.show")}),s.jsx("span",{className:"rn-hide-details",children:n("shell.notes.hide")})]})]}),s.jsxs("div",{id:c,children:[s.jsx("ul",{className:"rn-notes",children:o.map((d,u)=>s.jsx(IS,{note:d},u))}),r.length>0&&s.jsxs("div",{className:"rn-highlight-details",role:"group","aria-labelledby":`${c}-highlights`,children:[s.jsx("h3",{id:`${c}-highlights`,className:"rn-details-title",children:n("shell.notes.aboutHighlights")}),r.map((d,u)=>s.jsxs("p",{className:"rn-note-body",children:[s.jsxs("strong",{className:"rn-strong",children:[HW(d.title).rest.trimStart(),": "]}),au(nu(d.details))]},u))]})]})]})]})}const iTe={plans:nB,accounts:aB,skills:sB};function IS({note:e,highlight:t}){const n=ae(),{icon:a,rest:i}=HW(e.title),o=!a&&e.icon?un(iTe,e.icon):void 0;return s.jsxs("li",{className:"rn-note","data-highlight":t||void 0,"data-required":e.priority==="required"||void 0,"data-has-icon":!!o||void 0,children:[o&&s.jsx("span",{className:"rn-title-icon","aria-hidden":"true",children:s.jsx(o,{})}),s.jsxs("div",{children:[s.jsxs("h3",{className:"rn-note-title",children:[a&&s.jsx("span",{className:"rn-note-icon",children:a}),a?i:i.trimStart()]}),s.jsx("p",{className:"rn-note-body",children:au(nu(e.body))}),!t&&e.details&&s.jsx("p",{className:"rn-note-body rn-extra-detail",children:au(nu(e.details))}),e.notice&&s.jsxs("p",{className:"rn-note-notice",children:[s.jsxs("strong",{children:[e.noticeLabel??n("shell.notes.important"),": "]}),au(nu(e.notice))]})]})]})}function au(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?s.jsx("code",{className:"rn-code",children:t.text},n):s.jsx("strong",{className:"rn-strong",children:au(t.kids)},n))}function oTe({state:e,sessionId:t,onClose:n}){const a=ae(),i=m.useMemo(()=>rTe(e,t),[e,e.revision,t]),o=m.useRef(null),r=_t(n,{focusRef:o}),c=qt(n);return i?s.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:s.jsxs("div",{ref:r,className:"modal session-summary",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[s.jsxs("div",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:a("insights.summary.done")}),s.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),s.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("span",{className:"modal-dur",title:a("insights.summary.wall"),children:i.durationLabel}),s.jsx("button",{type:"button",ref:o,className:"glyph-btn",onClick:n,"aria-label":a("insights.audit.closeEsc"),title:a("insights.audit.closeEsc"),children:"×"})]})]}),s.jsxs("div",{className:"modal-body",children:[s.jsxs("section",{className:"ss-hero",children:[s.jsxs("div",{className:"ss-hero-left",children:[s.jsx("div",{className:"ss-cost-label",children:ple()}),s.jsx("div",{className:"ss-cost",children:At(i.cost.total)}),i.modelChips.length>0&&s.jsx("div",{className:"ss-models",children:i.modelChips.map(d=>s.jsx("span",{className:"model-chip","data-family":_m(d),title:d,children:wo(d)},d))})]}),s.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&s.jsxs(s.Fragment,{children:[s.jsx(KA,{cost:i.cost,size:"lg"}),s.jsxs("div",{className:"ss-cost-legend",children:[s.jsxs("span",{className:"ssl ssl-in",children:[a("insights.cost.input")," ",s.jsx("b",{children:At(i.cost.input)})]}),s.jsxs("span",{className:"ssl ssl-out",children:[a("insights.cost.output")," ",s.jsx("b",{children:At(i.cost.output)})]}),s.jsxs("span",{className:"ssl ssl-cr",children:[a("insights.summary.cacheR")," ",s.jsx("b",{children:At(i.cost.cacheRead)})]}),s.jsxs("span",{className:"ssl ssl-cw",children:[a("insights.summary.cacheW")," ",s.jsx("b",{children:At(i.cost.cacheWrite)})]})]})]})})]}),s.jsxs("section",{className:"ss-stats",children:[s.jsx(Oc,{label:a("insights.summary.agents"),value:i.agentCount}),s.jsx(Oc,{label:a("insights.summary.subagents"),value:i.subagentCount}),s.jsx(Oc,{label:a("insights.summary.toolCalls"),value:i.toolCount}),s.jsx(Oc,{label:a("insights.summary.prompts"),value:i.promptCount}),s.jsx(Oc,{label:a("insights.usage.tokens"),value:i.tokensSum.toLocaleString(qe())}),i.errCount>0&&s.jsx(Oc,{label:a("insights.summary.errors"),value:i.errCount,tone:"err"})]}),i.topTools.length>0&&s.jsxs("section",{className:"modal-section",children:[s.jsx("h4",{children:a("insights.summary.topTools")}),s.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([d,u])=>s.jsxs("div",{className:"ss-tt",children:[s.jsx("span",{className:"ss-tt-name",children:d}),s.jsx("span",{className:"ss-tt-bar",children:s.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/i.topTools[0][1]*100}%`}})}),s.jsx("span",{className:"ss-tt-count",children:u})]},d))})]}),i.firstPrompt&&s.jsxs("section",{className:"modal-section",children:[s.jsx("h4",{children:a("insights.summary.opening")}),s.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function Oc({label:e,value:t,tone:n}){return s.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[s.jsx("div",{className:"ss-stat-value",children:t}),s.jsx("div",{className:"ss-stat-label",children:e})]})}function rTe(e,t){const n=e.agents.get(t);if(!n)return null;const a=[];for(const j of e.agents.values())j.sessionId===t&&a.push(j);if(a.length===0)return null;const i={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,r=new Map;let c=0,d=0,u=0,p=0,g=0,f,v=1/0,k=0;for(const j of a){const A=fa(j);i.input+=A.input,i.output+=A.output,i.cacheRead+=A.cacheRead,i.cacheWrite+=A.cacheWrite,i.total+=A.total;for(const E of D2(j))o.add(E);j.model&&o.add(j.model),j.kind==="subagent"&&g++;const T=g2(j.prompts);d+=T.length,!f&&T.length>0&&(f=T[0].text),u+=j.usage.inputTokens+j.usage.outputTokens,c+=j.toolCount,p+=j.toolErrorCount??0;for(const[E,q]of j.toolCountByName??[])r.set(E,(r.get(E)??0)+q);v=Math.min(v,j.startedAt),k=Math.max(k,j.endedAt??Date.now())}const y=Math.max(0,k-v),N=Math.floor(y/1e3),w=N<60?`${N}s`:N<3600?`${Math.floor(N/60)}m ${String(N%60).padStart(2,"0")}s`:`${Math.floor(N/3600)}h ${Math.floor(N%3600/60)}m`,S=Array.from(r.entries()).sort((j,A)=>A[1]-j[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||C("insights.summary.session"),cwd:n.cwd,durationLabel:w,cost:i,modelChips:Array.from(o),agentCount:a.length,subagentCount:g,toolCount:c,promptCount:d,tokensSum:u,errCount:p,topTools:S,firstPrompt:f}}function Yt({id:e,title:t,note:n,noteId:a,aside:i,list:o=!0,settingId:r,className:c,children:d}){const u=c?`settings-group ${c}`:"settings-group",p=o?s.jsx("div",{className:"settings-list",children:d}):d;return t===void 0?s.jsx("div",{className:u,"data-setting":r,children:p}):s.jsxs("section",{className:u,"aria-labelledby":e,"data-setting":r,children:[s.jsxs("div",{className:"settings-caption",children:[s.jsxs("div",{className:"settings-caption-text",children:[s.jsx("h3",{id:e,children:t}),n&&s.jsx("p",{className:"settings-caption-note",id:a,children:n})]}),i]}),p]})}function Ct({name:e,nameId:t,note:n,noteId:a,control:i,as:o="label",settingId:r,className:c,details:d,children:u}){const p=ae(),g=o,f=s.jsxs(g,{className:c?`settings-row ${c}`:"settings-row","data-setting":r,children:[s.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&s.jsx("span",{className:"settings-row-note",id:a,children:n}),i!==void 0&&s.jsx("span",{className:"settings-row-control",children:i}),u]});return d?s.jsxs("div",{className:"settings-row-with-details",children:[f,s.jsxs("details",{className:"settings-row-details",children:[s.jsxs("summary",{children:[p("common.details"),s.jsxs("span",{className:"vis-hidden",children:[p("common.aboutBefore"),e,p("common.aboutAfter")]})]}),s.jsx("div",{children:d})]})]}):f}function cTe(){const e=ae(),t=Ea();return s.jsx(Yt,{id:"settings-language-caption",title:e("settings.language.group"),children:s.jsx(Ct,{settingId:"language",name:e("settings.language.name"),nameId:"settings-language-label",note:e("settings.language.note"),noteId:"settings-language-note",control:s.jsx("select",{className:"sm-select",value:t,"aria-labelledby":"settings-language-label","aria-describedby":"settings-language-note",onChange:n=>MX(n.target.value),children:yl.map(n=>s.jsx("option",{value:n.code,lang:n.code,dir:n.dir,children:qX(n)},n.code))})})})}function $W(e,t,n){const[a,i]=m.useState(null),[o,r]=m.useState(!1),[c,d]=m.useState(""),u=m.useRef(!1),p=f=>typeof f=="boolean"?f:t;return m.useEffect(()=>{let f=!0;return fetch("/api/prefs").then(v=>{if(!v.ok)throw new Error;return v.json()}).then(v=>{var k;if(!v.ok)throw new Error;f&&i(p((k=v.prefs)==null?void 0:k[e]))}).catch(()=>{f&&d(n("settings.recover.readFail"))}),()=>{f=!1}},[e]),{enabled:a,busy:o,error:c,change:async()=>{if(!(a===null||!Jn(u.current))){u.current=!0,r(!0),d("");try{const f=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:!a})});if(!f.ok)throw new Error;const v=await f.json();if(!v.ok)throw new Error;i(p(v.prefs[e]))}catch{d(n("settings.recover.saveFail"))}finally{u.current=!1,r(!1)}}}}}function eD({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,a=ae(),i=$W(t,!0,a);return s.jsxs(Yt,{id:`${n}-title`,title:a("settings.recover.group",{provider:e}),children:[s.jsx(Ct,{settingId:n,name:a("settings.recover.name"),note:a(e==="Codex"?"settings.recover.codexNote":"settings.recover.claudeNote"),details:a(e==="Codex"?"settings.recover.codexDetails":"settings.recover.claudeDetails"),control:s.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":a(e==="Codex"?"settings.recover.codexAria":"settings.recover.claudeAria"),"aria-checked":i.enabled===!0,...ga(i.busy,i.enabled===null),onClick:()=>{i.change()},children:s.jsx("span",{className:"switch-knob"})})}),i.error&&s.jsx("p",{role:"alert",children:i.error}),e==="Claude"&&s.jsx(lTe,{t:a})]})}function lTe({t:e}){const t=$W("continueStopped",!1,e);return s.jsxs(s.Fragment,{children:[s.jsx(Ct,{settingId:"claude-continue-stopped",name:e("settings.recover.continueName"),note:e("settings.recover.continueNote"),details:e("settings.recover.continueDetails"),control:s.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":e("settings.recover.continueAria"),"aria-checked":t.enabled===!0,...ga(t.busy,t.enabled===null),onClick:()=>{t.change()},children:s.jsx("span",{className:"switch-knob"})})}),t.error&&s.jsx("p",{role:"alert",children:t.error})]})}function dTe(){const e=ae(),t=aW();return s.jsx(Yt,{id:"settings-board-caption",title:e("settings.board.title"),children:s.jsx(Ct,{settingId:"hide-finished",name:e("settings.board.hideLabel"),nameId:"settings-hide-finished-label",note:e("settings.board.hideNote"),details:e("settings.board.hideDetails"),noteId:"settings-hide-finished-note",control:s.jsx("select",{className:"sm-select",value:t,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:n=>Qxe(Number(n.target.value)),children:Q4.map(n=>s.jsx("option",{value:n,children:n===0?e("settings.board.never"):e("settings.board.minutes",{n})},n))})})})}const uTe="Codex accounts",hTe="Your Codex profiles and what each has left, and which one new sessions use.";function pTe({claudeHere:e,codexHere:t=!1,singleKeys:n,doors:a}){const i=ae();return s.jsxs(Yt,{id:"settings-elsewhere-caption",title:i("lan.ew.group"),children:[(e||t)&&s.jsx(DS,{settingId:"accounts",name:e?i("lan.ew.accounts"):uTe,note:e?i("lan.ew.accountsNote"):hTe,onOpen:a.accounts,cap:n?{key:"A",title:i("lan.ew.pressA")}:null}),e&&s.jsx(DS,{settingId:"local-network",name:i("lan.ew.lan"),note:i("lan.ew.lanNote"),onOpen:a.localNetwork,cap:null}),s.jsx(DS,{settingId:"browser-watch",name:i("lan.ew.watch"),note:i("lan.ew.watchNote"),onOpen:a.browserWatch,dialog:!0,cap:n?{key:"B",title:i("lan.ew.pressB")}:null})]})}function DS({settingId:e,name:t,note:n,onOpen:a,cap:i,dialog:o=!1}){const r=ae(),c=`settings-${e}`;return s.jsx(Ct,{as:"div",settingId:e,name:t,nameId:`${c}-name`,note:n,control:s.jsxs(s.Fragment,{children:[i&&s.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:i.title,children:i.key}),s.jsx("button",{type:"button",className:"btn",id:`${c}-open`,"aria-labelledby":`${c}-open ${c}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":i?i.key:void 0,onClick:a,children:r("lan.ew.open")})]})})}function gTe(e){const t=e.binds.includes("?")?C("settings.keyboard.sheetName"):e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function mTe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(a=>a.toLowerCase().includes(n)):!0}function fTe({singleKeys:e,onToggleSingleKeys:t}){const n=ae(),a=zo(Co()),[i,o]=m.useState(""),r=m.useId(),c=Xu(),d=FW(e,u=>yi(c,u)).map(u=>({...u,rows:u.rows.filter(p=>mTe(p,i))})).filter(u=>u.rows.length>0);return s.jsxs(s.Fragment,{children:[s.jsx(Yt,{children:s.jsx(Ct,{settingId:"single-keys",name:n("settings.keyboard.singleKeys"),nameId:"settings-single-keys-label",note:n("settings.keyboard.singleKeysNote"),noteId:"settings-single-keys-note",control:s.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:s.jsx("span",{className:"switch-knob"})})})}),s.jsxs("div",{className:"settings-filter",children:[s.jsx("label",{className:"vis-hidden",htmlFor:r,children:n("settings.keyboard.filter")}),s.jsx("input",{id:r,type:"search",className:"settings-filter-field",placeholder:n("settings.keyboard.filter"),autoComplete:"off",spellCheck:!1,value:i,onChange:u=>o(u.target.value),onKeyDown:u=>{Pm(u.key)&&i&&(u.stopPropagation(),o(""))}})]}),d.map(u=>{const p=`settings-keys-${u.id}`;return s.jsx(Yt,{id:p,title:u.title,className:"settings-keys",children:u.rows.map(g=>s.jsx(Ct,{as:"div",name:gTe(g),control:s.jsx("kbd",{className:"settings-key",children:a&&g.macCap?g.macCap:g.cap})},`${g.cap}:${g.action}`))},u.id)}),d.length===0&&s.jsx("p",{className:"settings-empty",role:"status",children:n("settings.keyboard.noMatch",{query:i.trim()})}),i.trim()===""&&s.jsx("p",{className:"settings-foot",children:n("settings.key.note")})]})}function bTe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:a,onAskNotify:i,accountNotify:o,onToggleAccountNotify:r}){const c=ae(),d=Qoe(a,c),u=Eo(),p=e&&!n&&!u,g=m.useRef(null),f=Ps(!d.ask,g);return s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{id:"sm-closed-caption",title:c("settings.notify.closedGroup"),children:[s.jsx(Ct,{settingId:"notify-closed",name:c("settings.notify.closedName"),nameId:"sm-notify-label",note:n?c("settings.notify.veto"):Xoe(u,c),noteId:"sm-notify-note",control:s.jsx("button",{ref:g,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":"sm-notify-note",className:"switch",onClick:t,children:s.jsx("span",{className:"switch-knob"})})}),p&&s.jsx(Ct,{as:"div",name:c("settings.notify.browserName"),nameId:"sm-channel-name",note:d.note,control:d.ask?s.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{f(),i()},children:c("settings.notify.enable")}):s.jsxs("span",{className:"sm-channel-state","data-ok":d.ok||void 0,children:[d.ok&&s.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:s.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),d.status]})})]}),s.jsx(Yt,{id:"sm-accounts-caption",title:c("settings.notify.accountsGroup"),note:c(n?"settings.notify.accountsVeto":"settings.notify.accountsNote"),children:TN.map(({kind:v,label:k,title:y})=>s.jsx(Ct,{settingId:v,name:k,nameId:`sm-${v}-label`,note:y,noteId:`sm-${v}-note`,control:s.jsx("button",{type:"button",role:"switch","aria-checked":o[v],"aria-labelledby":`sm-${v}-label`,"aria-describedby":`sm-${v}-note`,className:"switch",onClick:()=>r(v),children:s.jsx("span",{className:"switch-knob"})})},v))})]})}const vTe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function kTe(e){return vTe.find(t=>e(t))}const wTe=4400;function yTe(e){const t=e.split(";")[0],n=t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm";return{name:`${C("radio.rec.name")}.${n}`,type:t}}function xTe({full:e,setCustomError:t,runCustom:n,onImportCustom:a}){const[i,o]=m.useState(!1),r=m.useRef(null),c=m.useRef(null),d=m.useRef(!1),u=()=>{var g;c.current!==null&&clearTimeout(c.current),c.current=null,((g=r.current)==null?void 0:g.state)==="recording"&&r.current.stop()},p=async()=>{var f;if(e)return;if(t(""),!((f=navigator.mediaDevices)!=null&&f.getUserMedia)||typeof MediaRecorder>"u"){t(C("radio.rec.noMic"));return}let g;try{g=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t(C("radio.rec.denied"));return}if(d.current||r.current){g.getTracks().forEach(v=>v.stop());return}try{const v=kTe(N=>MediaRecorder.isTypeSupported(N)),k=new MediaRecorder(g,v?{mimeType:v}:void 0),y=[];r.current=k,k.ondataavailable=N=>{N.data.size&&y.push(N.data)},k.onerror=()=>t(C("radio.rec.failed")),k.onstop=()=>{g.getTracks().forEach(j=>j.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const N=r.current===k;if(N&&(r.current=null),o(!1),!N||!y.length)return;const w=yTe(k.mimeType),S=new File(y,w.name,{type:w.type});n(()=>a(S))},k.start(200),o(!0),c.current=setTimeout(u,wTe)}catch{r.current=null,g.getTracks().forEach(v=>v.stop()),t(C("radio.rec.format"))}};return m.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const g=r.current;r.current=null,(g==null?void 0:g.state)==="recording"&&g.stop()}),[]),{recording:i,startRecording:p,stopRecording:u}}function CTe({full:e,fullProps:t,runCustom:n,onCreateVoice:a}){const i=ae(),[o,r]=m.useState(()=>i("settings.sounds.voice.defaultName")),[c,d]=m.useState(()=>i("settings.sounds.voice.defaultText")),[u,p]=m.useState(""),[g,f]=m.useState("1"),[v,k]=m.useState("1"),[y,N]=m.useState([]);return m.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const w=()=>{N(window.speechSynthesis.getVoices())};return w(),window.speechSynthesis.addEventListener("voiceschanged",w),()=>window.speechSynthesis.removeEventListener("voiceschanged",w)},[]),s.jsxs("details",{className:"sm-voice",children:[s.jsxs("summary",{className:"settings-row",...t,onClick:w=>{const S=w.currentTarget.parentElement;e&&S&&!S.open&&w.preventDefault()},children:[s.jsx("span",{className:"settings-row-name",children:i("settings.sounds.voice.title")}),s.jsx("span",{className:"settings-row-note",children:i("settings.sounds.voice.note")}),s.jsx("span",{className:"settings-row-control",children:s.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:s.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),s.jsxs("div",{className:"sm-voice-fields",children:[s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.name")}),s.jsx("input",{className:"ap-manage-input",value:o,maxLength:80,onChange:w=>r(w.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.text")}),s.jsx("input",{className:"ap-manage-input",value:c,maxLength:180,onChange:w=>d(w.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.voice")}),s.jsxs("select",{className:"sm-select",value:u,onChange:w=>p(w.target.value),children:[s.jsx("option",{value:"",children:i("settings.sounds.voice.default")}),y.map(w=>s.jsx("option",{value:w.voiceURI,children:w.name},w.voiceURI))]})]}),s.jsxs("div",{className:"sm-voice-pair",children:[s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.rate")}),s.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:w=>f(w.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.pitch")}),s.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:v,onChange:w=>k(w.target.value)})]})]}),s.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await a({name:o,text:c,voiceURI:u,rate:parseFloat(g),pitch:parseFloat(v)}),d(i("settings.sounds.voice.defaultText"))})},children:i("settings.sounds.voice.add")})]})]})}function STe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:a,onPreviewCustom:i,onDeleteCustom:o}){const r=ae(),[c,d]=m.useState(""),u=e.length,p=EN(u),g=p!==null,f=g?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[v,k]=m.useState(null),y=m.useRef(0),N=m.useRef(new Map),w=m.useRef(null),S=m.useRef(null);m.useEffect(()=>{if(!v)return;const F=window.setTimeout(()=>k(null),4e3);return()=>window.clearTimeout(F)},[v]);const j=async F=>{d("");try{await F()}catch(z){d(So(z,r("settings.sounds.custom.saveFail")))}},A=(F,z)=>{const H=Date.now(),I=zr({armedFor:v,target:F,armedAt:y.current,now:H,gapMs:qr});if(I==="arm"){k(F),y.current=H;return}if(I==="ignore")return;k(null);const L=rre(e.map(O=>O.id),F);j(async()=>{var _;await o(F);const O=document.activeElement;O!==z&&!Xn((O==null?void 0:O.tagName)??null)||(_=L?N.current.get(L):w.current)==null||_.focus()})},{recording:T,startRecording:E,stopRecording:q}=xTe({full:g,setCustomError:d,runCustom:j,onImportCustom:t});return s.jsxs(Yt,{id:"sm-custom-title",title:r("settings.sounds.custom.title"),note:r("settings.sounds.custom.note"),aside:s.jsx("span",{className:"settings-caption-count",children:r("settings.sounds.custom.count",{count:u,max:RN})}),className:"sm-custom",settingId:"custom-sounds",children:[g&&s.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:p}),s.jsx(Ct,{as:"div",settingId:"custom-import",name:r("settings.sounds.custom.import"),note:r("settings.sounds.custom.importNote"),control:s.jsx("button",{ref:w,type:"button",className:"btn sm-custom-action",...f,onClick:()=>{var F;g||(F=S.current)==null||F.click()},children:r("settings.sounds.custom.chooseFile")}),children:s.jsx("input",{ref:S,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:F=>{var H;const z=(H=F.target.files)==null?void 0:H[0];F.currentTarget.value="",z&&!g&&j(()=>t(z))}})}),s.jsx(Ct,{as:"div",settingId:"custom-record",name:r("settings.sounds.custom.record"),note:r(T?"settings.sounds.custom.recording":"settings.sounds.custom.upTo5"),control:T?s.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:q,children:r("settings.sounds.custom.stopSave")}):s.jsx("button",{type:"button",className:"btn sm-custom-action",...f,onClick:()=>void E(),children:r("settings.sounds.custom.recordBtn")})}),s.jsx(CTe,{full:g,fullProps:f,runCustom:j,onCreateVoice:n}),e.map(F=>s.jsxs("div",{className:"sm-custom-item",children:[s.jsx("input",{className:"ap-manage-input","aria-label":r("settings.sounds.custom.rename",{name:F.name}),defaultValue:F.name,maxLength:80,onBlur:z=>{if(!z.target.value.trim()){z.target.value=F.name;return}j(()=>a(F.id,z.target.value))},onKeyDown:z=>{z.key==="Enter"&&z.currentTarget.blur()}}),s.jsx("span",{children:F.kind==="audio"?`${wA(F.duration,1)}s`:r("settings.sounds.custom.voice")}),s.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":r("settings.sounds.custom.playName",{name:F.name}),onClick:()=>i(F.id),children:r("settings.sounds.custom.play")}),s.jsx("button",{type:"button",ref:z=>{z?N.current.set(F.id,z):N.current.delete(F.id)},className:`btn sm-custom-icon${v===F.id?" armed":""}`,onKeyDown:z=>{z.repeat&&z.preventDefault()},onClick:z=>A(F.id,z.currentTarget),"aria-label":v===F.id?r("settings.sounds.custom.confirmName",{name:F.name}):r("settings.sounds.custom.deleteName",{name:F.name}),title:v===F.id?r("settings.sounds.custom.deleteAgain"):r("settings.sounds.custom.deleteTip"),children:v===F.id?r("settings.sounds.custom.confirm"):r("settings.sounds.custom.delete")})]},F.id)),c&&s.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:c})]})}function NTe({soundOn:e,onToggleSound:t}){const n=ae(),a=m.useId(),i=Qn(),o=m.useId();return s.jsx(Yt,{children:s.jsx(Ct,{settingId:"play-sounds",name:n("radio.sound.name"),nameId:a,note:n("radio.sound.note"),noteId:o,control:s.jsxs(s.Fragment,{children:[i&&s.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:n("radio.sound.keyTitle"),children:"M"}),s.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":a,"aria-describedby":o,"aria-keyshortcuts":i?"M":void 0,className:"switch",onClick:t,children:s.jsx("span",{className:"switch-knob"})})]})})})}const Aj="custom:";function tD(e){return`${Aj}${e}`}function jTe(e){return e.startsWith(Aj)?e.slice(Aj.length):null}function ATe({id:e,label:t,value:n,step:a=IA,onLevel:i,"aria-describedby":o}){const r=ae();return s.jsxs("div",{className:"sm-row",children:[s.jsx("label",{htmlFor:e,children:t??r("radio.volume")}),s.jsx("input",{id:e,type:"range",min:fg,max:Zg,step:a,value:n,"aria-describedby":o,onChange:c=>i(Number(c.target.value)),style:{"--sm-level":`${(n-fg)/(Zg-fg)*100}%`}}),s.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const nD={get done(){return C("settings.sounds.tone.done")},get"needs-input"(){return C("settings.sounds.tone.needsInput")}},TTe={get done(){return C("settings.sounds.tone.doneNote")},get"needs-input"(){return C("settings.sounds.tone.needsInputNote")}};function RTe({chime:e,tone:t,soundOn:n,customAssets:a,customSelections:i,onLevel:o,onFigure:r,onPreview:c,onBuiltInSelected:d,onCustomSelected:u}){const p=ae(),g=`sm-level-${e}`,f=`sm-figure-${e}`,v=i[e];return s.jsxs(Yt,{id:`sm-name-${e}`,title:nD[e],note:TTe[e],settingId:`tone-${e}`,aside:s.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":p("settings.sounds.hearAria",{tone:nD[e]}),title:p(n?"settings.sounds.hearTip":"settings.sounds.hearTipMuted"),"aria-describedby":n?void 0:"sm-preview-note",children:[s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),p("settings.sounds.hear")]}),children:[s.jsx(ATe,{id:g,value:t.level,onLevel:k=>o(e,k)}),s.jsxs("div",{className:"sm-row",children:[s.jsx("label",{htmlFor:f,children:p("settings.sounds.toneLabel")}),s.jsxs("select",{id:f,className:"sm-select",value:v?tD(v):t.figure,onChange:k=>{const y=k.target.value,N=jTe(y);N!==null?u(e,N):(d(e),r(e,y))},children:[MA[e].map(k=>s.jsx("option",{value:k.id,children:k.label},k.id)),a.length>0&&s.jsx("optgroup",{label:p("settings.sounds.customGroup"),children:a.map(k=>s.jsx("option",{value:tD(k.id),children:k.name},k.id))})]})]})]})}function ETe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:a,onLevel:i,onFigure:o,onPreview:r,customAssets:c,customSelections:d,onBuiltInSelected:u,onCustomSelected:p,onImportCustom:g,onCreateVoice:f,onRenameCustom:v,onPreviewCustom:k,onDeleteCustom:y}){var A;const N=ae(),w=ire(d),S=((A=c.find(T=>T.id===w))==null?void 0:A.name)??N("settings.sounds.sharedName"),j=w?N("settings.sounds.sharedNote",{name:S}):"";return s.jsxs("div",{className:"sm-sounds",children:[s.jsx(NTe,{soundOn:e,onToggleSound:t}),!a&&s.jsx("p",{className:"sm-note",children:N("settings.sounds.codexOnly")}),!e&&s.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:N("settings.sounds.previewNote")}),s.jsx("div",{className:"sm-tones",children:Jd.map(T=>s.jsx(RTe,{chime:T,tone:n[T],soundOn:e,customAssets:c,customSelections:d,onLevel:i,onFigure:o,onPreview:r,onBuiltInSelected:u,onCustomSelected:p},T))}),j&&s.jsx("p",{className:"sm-note","aria-hidden":!0,children:j}),s.jsx("p",{className:"vis-hidden",role:"status",children:j}),s.jsx(STe,{customAssets:c,onImportCustom:g,onCreateVoice:f,onRenameCustom:v,onPreviewCustom:k,onDeleteCustom:y})]})}function _Te({onOpen:e}){const t=ae();return s.jsx(Yt,{children:s.jsx(Ct,{as:"div",settingId:"radar-open",name:t("radar.name"),nameId:"settings-radar-open-name",note:t("radar.note"),control:s.jsx("button",{type:"button",className:"btn",id:"settings-radar-open","aria-labelledby":"settings-radar-open settings-radar-open-name","aria-haspopup":"dialog",onClick:e,children:t("radar.open")})})})}const qTe=6500,zTe=1e4;let jr={reading:null,saving:null,error:"",undone:null};const Cg=new Set;let Ed=null,_d=null,ji=null,FS=!1,Sg=0;const hr=e=>{jr={...jr,...e},Cg.forEach(t=>t(jr))};function VW(e){const t=e;return!!t&&t.ok===!0&&Array.isArray(t.settings)&&typeof t.present=="object"}async function KW(e){const t=await fetch("/api/claude-settings",{signal:e}),n=await t.json();if(!t.ok||!VW(n))throw new Error;return n}async function Tj(){if(FS||jr.saving)return;FS=!0;const e=Sg,t=new AbortController;ji=t;let n=!1;const a=setTimeout(()=>{n=!0,t.abort()},5e3);try{const i=await KW(t.signal);e===Sg&&!t.signal.aborted&&hr({reading:i,error:""})}catch{e===Sg&&(n||!t.signal.aborted)&&hr({error:C("settings.claude.readFail")})}finally{clearTimeout(a),FS=!1,ji===t&&(ji=null)}}function aD(e,t){var n;return(n=e==null?void 0:e.settings.find(a=>a.id===t))==null?void 0:n.value}async function sD(e,t){if(jr.saving)return;Sg++,ji==null||ji.abort(),_d&&(clearTimeout(_d),_d=null),hr({saving:e,error:"",undone:null});const n=new AbortController,a=setTimeout(()=>n.abort(),15e3);try{const i=await fetch("/api/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,value:t}),signal:n.signal}),o=await i.json().catch(()=>null);if(!i.ok||!VW(o))throw new Ln(typeof(o==null?void 0:o.error)=="string"&&o.error?Ng(o.error):C("settings.claude.saveFail"));hr({reading:o});const r=aD(o,e);_d=setTimeout(()=>{_d=null;const c=new AbortController,d=setTimeout(()=>c.abort(),5e3);KW(c.signal).then(u=>{hr({reading:u,undone:aD(u,e)===r?null:{id:e}})}).catch(()=>{}).finally(()=>clearTimeout(d))},qTe)}catch(i){hr({error:So(i,C("settings.claude.saveFail"))})}finally{clearTimeout(a),hr({saving:null})}}const LTe={"Your settings.json is not valid JSON, so Claude Code skips all of it, hooks included. Fix it in an editor; this section reads it again by itself.":"settings.claude.reason.invalid","Your settings.json could not be read here, so nothing is shown or changed until it can.":"settings.claude.reason.unreadable","Your organization's settings could not be read, so nothing here can be changed until they can.":"settings.claude.reason.othersUnknown","Set by your organization. Ask your administrator to change it.":"settings.claude.reason.locked","Your settings.json holds a custom value. Edit it there.":"settings.claude.reason.custom","Choose a setting this section offers and one of its values.":"settings.claude.reason.choose","Your settings.json could not be read as JSON. No changes were saved.":"settings.claude.reason.parse","Your settings.json changed while saving. Nothing was written. Try again.":"settings.claude.reason.changed","Claude Code settings can be changed on this computer only.":"settings.claude.reason.localOnly","Could not read Claude Code settings. Try again.":"settings.claude.reason.readFail","Could not save the change. Your settings.json was not modified.":"settings.claude.reason.notSaved","Your settings.json has a permissions value that is not an object. No changes were saved.":"settings.claude.reason.permissionsShape","Your settings.json has a permissions.deny value that is not a list. No changes were saved.":"settings.claude.reason.denyShape","Your settings.json holds a custom attribution. Edit it there.":"settings.claude.reason.attribution"};function Ng(e,t=C){const n=LTe[e];if(n)return t(n);const a=/^Needs Claude Code (\S+) or newer(, and the version installed here could not be read)?\.$/.exec(e);return a?t(a[2]?"settings.claude.reason.needsUnread":"settings.claude.reason.needs",{version:a[1]}):a3(e,t)}function OTe(){const[e,t]=m.useState(jr);return m.useEffect(()=>(Cg.add(t),t(jr),Ed||(Tj(),Ed=setInterval(()=>void Tj(),zTe)),()=>{Cg.delete(t),Cg.size||(Ed&&clearInterval(Ed),Ed=null,ji==null||ji.abort())}),[]),e}const US=40,PTe=(e,t)=>{const n=`settings.claudeTopic.${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`,a=t(n);return a===n?e:a},MTe={boolean:"settings.claudeIndex.kind.boolean",choice:"settings.claudeIndex.kind.choice",number:"settings.claudeIndex.kind.number",text:"settings.claudeIndex.kind.text",structured:"settings.claudeIndex.kind.structured"};function ITe(e,t=C){const n=e.scope==="Global config"?t("settings.claudeIndex.globalConfig"):e.scope==="Managed"?t("settings.claudeIndex.managedOnly"):null;return[e.topic?PTe(e.topic,t):e.topic,t(MTe[e.kind]),n,e.since?t("settings.claudeIndex.since",{since:e.since}):null].filter(Boolean).join(" · ")}function DTe(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=e.filter(o=>o.key.toLowerCase().includes(n)),i=e.filter(o=>!a.includes(o)&&(o.topic??"").toLowerCase().includes(n));return[...a,...i]}let JW=null;const FTe=()=>JW??(JW=Pr(()=>import("./claude-settings-index-1Qg1AUda.js"),[]).then(e=>e.default.keys));function UTe({present:e,noFile:t=!1}){const n=ae(),a=Ea(),[i,o]=m.useState(null),[r,c]=m.useState(""),d=m.useId();m.useEffect(()=>{let f=!0;return FTe().then(v=>{f&&o(v)},()=>{JW=null}),()=>{f=!1}},[]);const u=m.useMemo(()=>{if(!i)return[];if(r.trim())return DTe(i,r);if(!e)return[];const f=i.filter(k=>Object.hasOwn(e,k.key)),v=Object.keys(e).filter(k=>!i.some(y=>y.key===k)).sort().map(k=>({key:k,topic:C("settings.claudeIndex.notInRef"),scope:null,kind:"structured",default:null,since:null,anchor:""}));return[...f,...v]},[i,e,r,a]),p=u.slice(0,US),g=r.trim()!=="";return s.jsxs(Yt,{id:"claude-group-all",settingId:"claude-all-settings",title:n("settings.claudeIndex.title"),note:g?void 0:n(e&&!t?"settings.claudeIndex.notePresent":"settings.claudeIndex.noteAll"),aside:i?s.jsx("span",{className:"settings-caption-count",children:i.length}):void 0,list:!1,children:[s.jsxs("div",{className:"settings-filter",children:[s.jsx("label",{className:"vis-hidden",htmlFor:d,children:n("settings.claudeIndex.filterLabel")}),s.jsx("input",{id:d,type:"search",className:"settings-filter-field",placeholder:i?n("settings.claudeIndex.filterCount",{count:i.length}):n("settings.claudeIndex.filter"),autoComplete:"off",spellCheck:!1,value:r,onChange:f=>c(f.target.value),onKeyDown:f=>{Pm(f.key)&&r&&(f.stopPropagation(),c(""))}})]}),p.length>0&&s.jsx("div",{className:"settings-list settings-keys",children:p.map(f=>{const v=e&&Object.hasOwn(e,f.key)?e[f.key]:null;return s.jsx(Ct,{as:"div",name:s.jsx("code",{className:"claude-key",children:f.key}),note:ITe(f,n),control:s.jsxs(s.Fragment,{children:[v!==null&&s.jsx("span",{className:"settings-read",title:n("settings.claudeIndex.inFile"),children:v}),f.anchor&&s.jsx("a",{className:"settings-link",href:`${Voe}#${f.anchor}`,target:"_blank",rel:"noreferrer","aria-label":n("settings.claudeIndex.referenceAria",{key:f.key}),children:n("settings.claudeIndex.reference")})]})},f.key)})}),g&&u.length===0&&i&&s.jsx("p",{className:"settings-empty",role:"status",children:n("settings.claudeIndex.noMatch",{query:r.trim()})}),u.length>US&&s.jsx("p",{className:"settings-foot",role:"status",children:n("settings.claudeIndex.more",{count:u.length-US})}),!g&&e&&!t&&i&&u.length===0&&s.jsx("p",{className:"settings-empty",children:n("settings.claudeIndex.empty")})]})}function BTe(e,t=C){return t("settings.claude.foot",{file:e??t("settings.claude.footDefault")})}const iD={Off:"settings.claude.effect.off",On:"settings.claude.effect.on","Updates are off":"settings.claude.effect.updatesOff","Background updates are off":"settings.claude.effect.bgUpdatesOff"};function HTe(e,t=C){const n=`${e.env}=${e.value}`,a=iD[e.effect]?t(iD[e.effect]):e.effect;return e.where==="environment"?t("settings.claude.overrideEnv",{effect:a,set:n}):t(e.where==="user"?"settings.claude.overrideUser":"settings.claude.overrideOrg",{effect:a,set:n})}const oD="\0custom";function WTe({entry:e,row:t,saving:n,nameId:a,noteId:i}){const o=ae(),r=!!t&&t.editable&&!n,c=!t||n===e.id,d=t?!t.editable:void 0;if(e.kind==="choice"||e.kind==="days"){const p=e.kind==="days"?e.options.map(v=>({value:String(v),label:k_(v,o)})):e.options.map(v=>({...v,label:Joe(e.id,v.value,v.label,o)})),g=t?t.custom?oD:t.value===null?"":String(t.value):"",f=e.kind==="days"&&t&&!t.custom&&!p.some(v=>v.value===g)?[...p,{value:g,label:k_(Number(g),o)}].sort((v,k)=>Number(v.value)-Number(k.value)):p;return s.jsxs("select",{className:"sm-select","aria-labelledby":a,"aria-describedby":i,"aria-busy":c,disabled:d,value:g,onChange:v=>{if(!r)return;const k=v.target.value;sD(e.id,e.kind==="days"?Number(k):k===""?null:k)},children:[(t==null?void 0:t.custom)&&s.jsx("option",{value:oD,disabled:!0,children:o("settings.claude.customValue")}),f.map(v=>s.jsx("option",{value:v.value??"",children:v.label},v.value??""))]})}const u=(t==null?void 0:t.value)===!0;return s.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":u,"aria-labelledby":a,"aria-describedby":i,"aria-busy":c,disabled:d,onClick:()=>{r&&sD(e.id,!u)},children:s.jsx("span",{className:"switch-knob"})})}function GTe(e){if(!(e!=null&&e.settings.length)||e.settings.some(n=>n.editable))return null;const t=new Set(e.settings.map(n=>n.reason));return t.size===1?[...t][0]??null:null}function $Te(){return s.jsx(VTe,{state:OTe()})}function VTe({state:e}){const t=ae(),{reading:n,saving:a,error:i,undone:o}=e,r=GTe(n),c=(n==null?void 0:n.userFile)==="absent",d=n?n.userFile!=="invalid"&&n.userFile!=="unreadable":!i;return s.jsxs(s.Fragment,{children:[(n===null||i||r||c)&&s.jsxs(Yt,{children:[n===null&&!i&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.reading")}),r&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:Ng(r,t)}),c&&!r&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.noFile")}),i&&s.jsxs("div",{className:"settings-row",role:"alert",children:[s.jsx("span",{className:"settings-row-name",children:Ng(i,t)}),s.jsx("span",{className:"settings-row-control",children:s.jsx("button",{type:"button",className:"btn","aria-busy":!!a,onClick:()=>void Tj(),children:t("settings.claude.retry")})})]})]}),d&&dB.map(u=>s.jsx(Yt,{id:`claude-group-${u.id}`,title:hB(u.id,u.title,t),children:uB.filter(p=>p.group===u.id).map(p=>{const g=n==null?void 0:n.settings.find(y=>y.id===p.id),f=`claude-${p.id}-label`,v=`claude-${p.id}-note`,k=g&&!g.editable&&!r?Ng(g.reason??"",t):(o==null?void 0:o.id)===p.id?t("settings.claude.undone"):g!=null&&g.override?HTe(g.override,t):"";return s.jsx(Ct,{settingId:`claude-${p.id}`,name:pB(p,t),nameId:f,note:Koe(p,t),noteId:v,control:s.jsx(WTe,{entry:p,row:g,saving:a,nameId:f,noteId:v}),children:s.jsx("span",{className:"settings-row-said settings-row-said-quiet",role:"status",children:k})},p.id)})},u.id)),d&&s.jsx("p",{className:"settings-foot",children:BTe(n==null?void 0:n.fileShown,t)}),s.jsx(UTe,{present:(n==null?void 0:n.present)??null,noFile:c})]})}function KTe(){const e=ae(),[t,n]=m.useState(null),[a,i]=m.useState(""),[o,r]=m.useState(!1),[c,d]=m.useState(null),[u,p]=m.useState(""),g=m.useRef(!1),f=m.useRef(!0),v=async()=>{if(g.current)return;g.current=!0,r(!0),i("");const N=new AbortController,w=window.setTimeout(()=>N.abort(),12e3);try{const S=await fetch("/api/tool-audit/storage",{signal:N.signal}),j=await S.json();if(!S.ok||!j.ok)throw new Error;f.current&&n(j)}catch{f.current&&i(e("settings.tools.readFail"))}finally{window.clearTimeout(w),g.current=!1,f.current&&r(!1)}};m.useEffect(()=>(f.current=!0,v(),()=>{f.current=!1}),[]);const k=async(N,w)=>{if(g.current)return;g.current=!0,r(!0),i(""),p("");let S=!1;const j=new AbortController,A=window.setTimeout(()=>j.abort(),15e3);try{const T=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N==="clear"?{action:N,confirm:!0}:{action:N,days:w}),signal:j.signal}),E=await T.json();if(!T.ok||!E.ok)throw new Error;S=!0,f.current&&(d(null),p(N==="clear"?e("settings.tools.cleared"):e("settings.tools.retentionChanged",{days:w??0})))}catch{f.current&&i(e("settings.tools.updateFail"))}finally{window.clearTimeout(A),g.current=!1,f.current&&(r(!1),S&&v())}},y=c!==null&&s.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":e("settings.tools.confirm"),children:[s.jsx("p",{children:c==="clear"?e("settings.tools.confirmClear"):e("settings.tools.confirmKeep",{days:c})}),s.jsxs("div",{children:[s.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{k(c==="clear"?"clear":"retention",typeof c=="number"?c:void 0)},children:e(c==="clear"?"settings.tools.deleteBtn":"settings.tools.applyBtn")}),s.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{g.current||d(null)},children:e("settings.tools.cancel")})]})]});return s.jsxs(Yt,{id:"tool-history-settings-title",title:e("settings.tools.title"),note:e("settings.tools.note"),className:"ta-settings",children:[t?s.jsxs(s.Fragment,{children:[s.jsx(Ct,{settingId:"tool-history-retention",name:e("settings.tools.keep"),nameId:"ta-keep-label",note:e("settings.tools.keepNote"),control:s.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:t.retentionDays,"aria-busy":o,onChange:N=>{if(g.current)return;const w=Number(N.target.value);w<t.retentionDays?d(w):k("retention",w)},children:[30,60,90].map(N=>s.jsx("option",{value:N,children:e("settings.tools.days",{count:N})},N))})}),typeof c=="number"&&y,s.jsx(Ct,{as:"div",settingId:"tool-history-size",name:e("settings.tools.space"),note:e("settings.tools.since",{date:Xre(t.startedAt)}),control:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"settings-read",children:Zre(t.bytes)}),s.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{v()},children:e("settings.tools.refresh")})]})}),s.jsx(Ct,{as:"div",settingId:"tool-history-clear",name:e("settings.tools.clear"),note:e("settings.tools.clearNote"),control:s.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{g.current||d("clear")},children:e("settings.tools.clearBtn")})}),c==="clear"&&y,!t.storageOk&&s.jsx(Ct,{as:"div",name:e("settings.tools.unsaved"),note:e("settings.tools.unsavedNote")})]}):s.jsx(Ct,{as:"div",name:e(o?"settings.tools.reading":"settings.tools.unavailable")}),a&&s.jsxs("div",{className:"settings-row",role:"alert",children:[s.jsx("span",{className:"settings-row-name",children:a}),s.jsx("span",{className:"settings-row-control",children:s.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{v()},children:e("settings.tools.retry")})})]}),u&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:u})]})}const Rj="agent-dag.integrations.active",YT=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,JTe=32e3;function rD(e,t){const n=ht(YT(e,t));if(!n)return{};try{const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}}function a1e(e,t){return{read(n,a){const i=rD(e,t)[n];return a(i)?i:void 0},write(n,a){const i=rD(e,t);a===void 0?delete i[n]:i[n]=a;const o=JSON.stringify(i);o.length<=JTe&&pt(YT(e,t),o)}}}function YTe(e,t){Va(YT(e,t))}function s1e(e){const t=ht(Rj);if(!t)return null;try{const n=JSON.parse(t),a=n&&typeof n=="object"?n[e]:null;return typeof a=="string"&&a.length<=80?a:null}catch{return null}}function i1e(e,t){let n={};try{const a=ht(Rj),i=a?JSON.parse(a):{};i&&typeof i=="object"&&!Array.isArray(i)&&(n=Object.fromEntries(Object.entries(i).filter(([,o])=>typeof o=="string").slice(0,20)))}catch{}n[e]=t,pt(Rj,JSON.stringify(n))}function Ej(e){var a;const t=(a=e.meta)==null?void 0:a.checkedAt;if(!t)return null;const n=new Date(String(t));return Number.isNaN(n.getTime())?null:n.toLocaleString(qe(),{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...n.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}function _j(e){const t=e.meta??{};return e.kind==="gitlab"?typeof t.serverVersion=="string"&&t.serverVersion?`GitLab ${t.serverVersion}`:null:e.kind!=="jira"?null:t.deploymentType==="Cloud"?"Jira Cloud":t.deploymentType?`Jira ${t.deploymentType==="DataCenter"?"Data Center":String(t.deploymentType)}${t.serverVersion?` ${t.serverVersion}`:""}`:null}function ZTe({connection:e,provider:t,available:n,busy:a,armed:i,note:o,headingRef:r,onTest:c,onEdit:d,onDisconnect:u,onCancelDisconnect:p}){var T;const g=ae(),f=m.useRef(null),v=(t==null?void 0:t.label)??e.kind,k=e.account.name||e.account.login||g("integrations.conn.noAccount"),y=e.account.name&&e.account.login!==e.account.name?e.account.login:"",N=Ej(e),w=_j(e),S=Array.isArray((T=e.meta)==null?void 0:T.warnings)?e.meta.warnings.filter(E=>typeof E=="string"):[],j=a===`test:${e.id}`,A=a===`delete:${e.id}`;return s.jsxs("section",{className:"ig-connection-details","aria-labelledby":"ig-managed-title",children:[s.jsxs("header",{className:"ig-managed-header",children:[t&&s.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:s.jsx(t.Glyph,{})}),s.jsxs("div",{className:"ig-managed-identity",children:[s.jsx("h2",{ref:r,tabIndex:-1,id:"ig-managed-title",className:"ig-managed-title",children:e.name||e.baseUrl}),s.jsx("p",{children:g("integrations.conn.saved",{label:v})})]})]}),s.jsxs("dl",{className:"ig-detail-facts",children:[s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.host")}),s.jsx("dd",{children:e.baseUrl})]}),s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.account")}),s.jsxs("dd",{children:[k,y?` (${y})`:""]})]}),s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.lastVerified")}),s.jsx("dd",{children:N??g("integrations.conn.noVerificationTime")})]}),s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.credentials")}),s.jsx("dd",{children:e.tokenSaved?g("integrations.conn.storedLocally"):g("integrations.conn.noToken")})]}),w&&s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.server")}),s.jsx("dd",{children:w})]})]}),!n&&s.jsx("p",{className:"ig-stranded",children:g("integrations.conn.strandedDisconnect",{label:v})}),S.length>0&&s.jsx("ul",{className:"ig-warnings",children:S.map(E=>s.jsx("li",{children:E},E))}),n&&s.jsxs("div",{className:"ig-manage-actions",children:[s.jsx("button",{type:"button",className:"btn","aria-busy":j,"aria-disabled":a!==null||void 0,onClick:c,children:g(j?"integrations.conn.testing":"integrations.conn.test")}),s.jsx("button",{type:"button",className:"btn","aria-disabled":a!==null||void 0,onClick:E=>{a===null&&d(E.currentTarget)},children:g("integrations.conn.edit")})]}),o&&o.scope!=="disconnect"&&s.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text}),s.jsxs("div",{className:"ig-disconnect-section",children:[s.jsx("h3",{children:g("integrations.conn.removeTitle")}),s.jsx("p",{children:g("integrations.conn.removeBody")}),s.jsxs("div",{className:"ig-manage-actions","data-integration-disconnect-actions":!0,onBlur:E=>{i&&!E.currentTarget.contains(E.relatedTarget)&&p()},children:[s.jsx("button",{ref:f,type:"button","data-integration-disconnect":!0,className:`btn danger${i?" armed":""}`,"aria-busy":A,"aria-disabled":a!==null||void 0,onKeyDown:E=>{E.repeat&&E.preventDefault()},"aria-label":i?g("integrations.conn.confirmAria",{name:e.name}):g("integrations.conn.disconnectAria",{name:e.name}),onClick:E=>u(E.currentTarget),children:g(A?"integrations.conn.disconnecting":i?"integrations.conn.confirmDisconnect":"integrations.conn.disconnect")}),i&&s.jsx("button",{type:"button",className:"btn","data-integration-cancel-disconnect":!0,"aria-disabled":a!==null||void 0,"aria-label":g("integrations.conn.cancelDisconnect"),onClick:()=>{var E;a===null&&(p(),(E=f.current)==null||E.focus())},children:g("integrations.cancel")})]}),i&&s.jsx("p",{className:"ig-note",role:"status",children:g("integrations.conn.pressConfirm")}),(o==null?void 0:o.scope)==="disconnect"&&s.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text})]})]})}function XTe({onBeforeLeaveChange:e}={}){var ot;const t=ae(),n=Xu(),{connections:a,error:i}=n,[o,r]=m.useState(null),c=m.useRef(null),d=m.useRef(new Map),u=m.useRef(null),p=m.useRef(0),[g,f]=m.useState(null),[v,k]=m.useState(""),y=m.useRef(null),N=m.useRef(null),[w,S]=m.useState(null),[j,A]=m.useState(null),T=m.useRef(null),[E,q]=m.useState(null),[F,z]=m.useState([]),[H,I]=m.useState(null),L=m.useRef(0),[O,_]=m.useState(null),M=m.useRef(null),U=m.useRef(new Map),G=m.useRef(null),W=m.useRef(0),[$,Y]=m.useState(!1),[B,V]=m.useState(null),Z=m.useRef(null),D=m.useRef(new Map),K=m.useRef(new Map);m.useEffect(()=>{const se=$Se();se&&(G.current=D.current.get(se)??null,f(se),_(se),S({mode:"edit",id:se}));const Ne=GSe();Ne&&S({mode:"add",kind:Ne})},[]),m.useEffect(()=>{var se,Ne;!O||!a||(Ne=(se=K.current.get(O))==null?void 0:se.scrollIntoView)==null||Ne.call(se,{block:"nearest"})},[O,a]),m.useEffect(()=>{if(!H)return;const se=()=>{var Be,Se;(Be=document.activeElement)!=null&&Be.hasAttribute("data-integration-cancel-disconnect")&&((Se=document.querySelector(".ig-manage-view [data-integration-disconnect]"))==null||Se.focus()),I(null)},Ne=()=>{document.hidden&&se()},Ie=window.setTimeout(()=>{var Be;(Be=document.querySelector("[data-integration-disconnect-actions]"))!=null&&Be.contains(document.activeElement)||se()},4e3);return window.addEventListener("blur",se),document.addEventListener("visibilitychange",Ne),()=>{window.clearTimeout(Ie),window.removeEventListener("blur",se),document.removeEventListener("visibilitychange",Ne)}},[H]);const X=(se,Ne,Ie,Be)=>z(Se=>[...Se.filter(tt=>tt.id!==se),{id:se,tone:Ne,text:Ie,scope:Be}]),Q=se=>z(Ne=>Ne.filter(Ie=>Ie.id!==se)),ee=async(se,Ne)=>{if(!T.current){T.current=se,A(se);try{await Ne()}finally{T.current=null,A(null)}}},ne=se=>(Ne,Ie)=>void ee("form",async()=>{q(null);try{const Be=await FSe(se,Ne,Ie||void 0);S(null),V(null),Y(!1),f(null),r(null),k(t("integrations.settings.added")),X(Be.id,"ok",t("integrations.settings.savedTested",{name:Be.account.name||Be.account.login})),_(Be.id),M.current=()=>{var tt;const Se=d.current.get(Be.kind)??D.current.get(Be.id);return(tt=Se==null?void 0:Se.scrollIntoView)==null||tt.call(Se,{block:"nearest"}),Se}}catch(Be){q(Be instanceof $a?Be:new $a("upstream",t("integrations.settings.saveFailed")))}}),de=se=>(Ne,Ie)=>void ee("form",async()=>{q(null);try{const{connection:Be,validated:Se}=await USe(se.id,{name:Ie,input:Ne});S(null),V(null),Y(!1),M.current=()=>N.current??(g?y.current:D.current.get(Be.id)),X(Be.id,"ok",Se?t("integrations.settings.savedPassed",{name:Be.account.name||Be.account.login}):t("integrations.settings.saved"))}catch(Be){q(Be instanceof $a?Be:new $a("upstream",t("integrations.settings.changeFailed")))}}),ge=se=>void ee(`test:${se.id}`,async()=>{I(null),Q(se.id);try{const Ne=await BSe(se.id);X(se.id,"ok",t("integrations.settings.testPassed",{name:Ne.account.name||Ne.account.login}))}catch(Ne){X(se.id,"err",So(Ne,t("integrations.settings.testFailed")))}}),le=(se,Ne)=>{if(T.current)return;const Ie=Date.now(),Be=zr({armedFor:H,target:se.id,armedAt:L.current,now:Ie,gapMs:qr});if(Be==="arm"){Ne.focus({preventScroll:!0}),I(se.id),L.current=Ie;return}Be!=="ignore"&&(I(null),ee(`delete:${se.id}`,async()=>{try{await HSe(se.id),YTe(se.kind,se.id),Q(se.id),(w==null?void 0:w.mode)==="edit"&&w.id===se.id&&S(null),f(null);const Se=(a??[]).filter(fe=>fe.kind===se.kind&&fe.id!==se.id);(!o||Se.length===0)&&r(null),k(t("integrations.settings.disconnected"));const tt=document.activeElement;(tt===Ne||Xn((tt==null?void 0:tt.tagName)??null))&&(M.current=()=>{var He;const fe=(o&&Se[0]?D.current.get(Se[0].id):d.current.get(se.kind))??U.current.get(se.kind)??document.getElementById("settings-tab-integrations");return(He=fe==null?void 0:fe.scrollIntoView)==null||He.call(fe,{block:"nearest"}),fe})}catch(Se){X(se.id,"err",So(Se,t("integrations.settings.removeFailed")),"disconnect")}}))};m.useEffect(()=>{if(j!==null||B||!M.current)return;const se=M.current();M.current=null,se!=null&&se.isConnected&&(se.checkVisibility?se.checkVisibility():se.getClientRects().length>0)&&se.focus({preventScroll:!0})},[a,g,o,w,j,B]);const he=a??[],ce=Qu(n),oe=["github","gitlab","jira"],ve=$T().filter(se=>ce.has(se.kind)||he.some(Ne=>Ne.kind===se.kind)).sort((se,Ne)=>oe.indexOf(se.kind)-oe.indexOf(Ne.kind)),ke=KT(n),ye=m.useCallback(()=>{S(null),f(null),r(null),Y(!1),V(null),q(null),I(null),M.current=()=>{const se=G.current,Ne=se==null?void 0:se.closest(".settings-pane");return Ne&&(Ne.scrollTop=W.current),se!=null&&se.isConnected?se:document.getElementById("settings-tab-integrations")}},[]),Le=m.useCallback(()=>{if(!o){ye();return}f(null),S(null),Y(!1),V(null),q(null),I(null),M.current=()=>{var Ie;const se=(Ie=u.current)!=null&&Ie.isConnected?u.current:c.current,Ne=se==null?void 0:se.closest(".settings-pane");return Ne&&(Ne.scrollTop=se===c.current?0:p.current),se}},[o,ye]),Ke=m.useCallback(()=>{if(!g&&!o){ye();return}S(null),Y(!1),V(null),q(null),M.current=()=>N.current??(g?y.current:c.current)},[g,o,ye]),Qe=m.useCallback((se,Ne=!1)=>{if(T.current)return;if(B&&Ne){V(null),requestAnimationFrame(()=>{var Be;return(Be=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:Be.focus()});return}const Ie=Ne?w?Ke:g?Le:ye:()=>{S(null),f(null),r(null),se()};$?V(()=>Ie):(Y(!1),Ie())},[$,B,w,g,Ke,Le,ye]);m.useEffect(()=>(e==null||e(w||g||o?Qe:null),()=>e==null?void 0:e(null)),[w,g,o,Qe,e]),m.useEffect(()=>{var se;B&&((se=Z.current)==null||se.focus())},[B]),m.useEffect(()=>{var se;g&&((se=y.current)==null||se.focus())},[g]),m.useEffect(()=>{var se;o&&((se=c.current)==null||se.focus())},[o]);const Ae=(se,Ne)=>{var Be;if(T.current)return;M.current=null,V(null),k(""),I(null),g||o?N.current=Ne:(W.current=((Be=Ne.closest(".settings-pane"))==null?void 0:Be.scrollTop)??0,G.current=Ne,N.current=null),Y(!1),q(null),S(se);const Ie=Ne.closest(".settings-pane");Ie&&(Ie.scrollTop=0)},je=(se,Ne)=>{var Be,Se;if(T.current)return;M.current=null,o?(u.current=Ne,p.current=((Be=Ne.closest(".settings-pane"))==null?void 0:Be.scrollTop)??0):(W.current=((Se=Ne.closest(".settings-pane"))==null?void 0:Se.scrollTop)??0,G.current=Ne),N.current=null,k(""),I(null),f(se.id);const Ie=Ne.closest(".settings-pane");Ie&&(Ie.scrollTop=0)},Oe=(se,Ne)=>{var Se;const Ie=he.filter(tt=>tt.kind===se);if(Ie.length===1){je(Ie[0],Ne);return}if(T.current)return;M.current=null,W.current=((Se=Ne.closest(".settings-pane"))==null?void 0:Se.scrollTop)??0,G.current=Ne,u.current=null,p.current=0,k(""),I(null),r(se);const Be=Ne.closest(".settings-pane");Be&&(Be.scrollTop=0)},Ve=(se,Ne=!1)=>{const Ie=Wd(se.kind),Be=!yi(n,se.kind),Se=Ej(se),tt=se.account.login||se.account.name,fe=se.kind==="jira"?_j(se):null;return s.jsx("div",{className:"ig-conn",ref:He=>{He?K.current.set(se.id,He):K.current.delete(se.id)},children:s.jsxs("div",{className:"ig-summary-row",children:[s.jsxs("div",{className:"ig-summary-text",children:[s.jsx("span",{className:"ig-conn-name",children:Ne&&se.name||or(se)}),s.jsx("span",{className:"ig-conn-line",children:[Ne&&se.name!==or(se)?or(se):"",tt,fe||(Se?t("integrations.conn.lastVerifiedAt",{when:Se}):t("integrations.conn.notVerified"))].filter(Boolean).join(" · ")||t("integrations.conn.noAccount")}),!se.tokenSaved&&s.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")}),Be&&s.jsx("span",{className:"ig-stranded",children:t("integrations.conn.strandedManage",{label:(Ie==null?void 0:Ie.label)??se.kind})})]}),s.jsxs("button",{type:"button",className:"btn ig-manage",ref:He=>{He?D.current.set(se.id,He):D.current.delete(se.id)},"aria-label":t("integrations.settings.manageAria",{label:(Ie==null?void 0:Ie.label)??se.kind,name:se.name,account:tt||or(se)}),onClick:He=>je(se,He.currentTarget),children:[t("integrations.manage")," ",s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m6 4 4 4-4 4"})})]})]})},se.id)},nt=he.filter(se=>!ve.some(Ne=>Ne.kind===se.kind)),Ye=o?Wd(o):null,Ce=he.filter(se=>se.kind===o),ze=he.find(se=>se.id===g),De=(w==null?void 0:w.mode)==="edit"?he.find(se=>se.id===w.id):void 0,Fe=(w==null?void 0:w.mode)==="add"?ve.find(se=>ce.has(se.kind)&&se.kind===w.kind):De&&ve.find(se=>ce.has(se.kind)&&se.kind===De.kind);return s.jsxs("div",{className:"ig-settings","data-view":w?"form":g?"connection":o?"provider":"overview",children:[w&&s.jsxs("div",{className:"ig-config-view",children:[s.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":j!==null||void 0,onClick:()=>Qe(Ke,!0),children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),g?t("integrations.settings.backToConn"):o?t("integrations.settings.backToList",{label:(Ye==null?void 0:Ye.label)??o}):t("integrations.settings.all")]}),B&&s.jsxs("div",{className:"ig-leave-confirm",role:"group","aria-labelledby":"ig-leave-title",children:[s.jsx("strong",{id:"ig-leave-title",children:t("integrations.settings.discardTitle")}),s.jsx("p",{children:t("integrations.settings.discardBody")}),s.jsxs("div",{className:"ig-form-actions",children:[s.jsx("button",{ref:Z,type:"button",className:"btn",onClick:()=>{V(null),requestAnimationFrame(()=>{var se;return(se=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:se.focus()})},children:t("integrations.settings.keepEditing")}),s.jsx("button",{type:"button",className:"btn danger",onClick:()=>{const se=B;V(null),Y(!1),S(null),se()},children:t("integrations.settings.discard")})]})]}),s.jsx("div",{hidden:!!B,children:Fe?s.jsx(pSe,{def:Fe,existing:De,busy:j==="form",error:E,onDirtyChange:Y,onSubmit:w.mode==="add"?ne(w.kind):de(De),onCancel:()=>Qe(Ke,!0)},w.mode==="add"?w.kind:w.id):s.jsxs("div",{role:"status",children:[s.jsx("p",{children:t("integrations.settings.gone")}),s.jsx("button",{type:"button",className:"btn",onClick:Ke,children:t("integrations.settings.backToIntegrations")})]})})]}),o&&s.jsxs("div",{className:"ig-provider-view",hidden:w!==null||g!==null,children:[s.jsxs("div",{className:"ig-manage-navigation",children:[s.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":j!==null||void 0,onClick:()=>Qe(ye,!0),children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),t("integrations.settings.all")]}),yi(n,o)&&s.jsx("button",{type:"button",className:"btn","aria-disabled":j!==null||void 0,onClick:se=>Ae({mode:"add",kind:o},se.currentTarget),children:t("integrations.settings.addConn",{label:(Ye==null?void 0:Ye.label)??o})})]}),s.jsx("h2",{ref:c,tabIndex:-1,className:"ig-managed-title",children:t("integrations.settings.connsTitle",{label:(Ye==null?void 0:Ye.label)??o})}),v&&s.jsx("p",{className:"ig-note",role:"status",children:v}),Ce.length?s.jsx("div",{className:"ig-provider-connections",children:Ce.map(se=>Ve(se,!0))}):s.jsx("p",{role:"status",children:t("integrations.settings.noSaved")})]}),g&&s.jsxs("div",{className:"ig-manage-view",hidden:w!==null,children:[s.jsxs("div",{className:"ig-manage-navigation",children:[s.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":j!==null||void 0,onClick:()=>Qe(Le,!0),children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),o?t("integrations.settings.backToList",{label:(Ye==null?void 0:Ye.label)??o}):t("integrations.settings.all")]}),ze&&yi(n,ze.kind)&&s.jsx("button",{type:"button",className:"btn","aria-disabled":j!==null||void 0,onClick:se=>Ae({mode:"add",kind:ze.kind},se.currentTarget),children:t("integrations.settings.addConn",{label:((ot=Wd(ze.kind))==null?void 0:ot.label)??ze.kind})})]}),ze?s.jsx(ZTe,{connection:ze,provider:Wd(ze.kind),available:yi(n,ze.kind),busy:j,armed:H===g,note:F.find(se=>se.id===g),headingRef:y,onTest:()=>ge(ze),onEdit:se=>Ae({mode:"edit",id:ze.id},se),onDisconnect:se=>le(ze,se),onCancelDisconnect:()=>I(null)}):s.jsx("p",{role:"status",children:t("integrations.settings.noLongerSaved")})]}),s.jsxs("div",{className:"ig-overview",hidden:w!==null||g!==null||o!==null,children:[i&&s.jsxs("div",{className:"ig-list-error",role:"alert",children:[s.jsx("p",{children:i}),s.jsx("button",{type:"button",className:"btn",onClick:()=>void Of(),children:t("integrations.retry")})]}),a===null&&!i&&s.jsx("p",{role:"status",children:t("integrations.settings.reading")}),v&&s.jsx("p",{className:"ig-note",role:"status",children:v}),s.jsxs("div",{className:"ig-connection-list","data-setting":"integrations-connections",children:[a!==null&&s.jsx("div",{className:"ig-providers","data-setting":"integrations-add",id:ke==="all"?"integrations-add-title":void 0,children:ve.map(se=>{const Ne=he.filter(fe=>fe.kind===se.kind),Ie=Ne.length===1?Ne[0]:null,Be=[...new Set(Ne.map(or))],Se=Ie&&Ej(Ie),tt=(Ie==null?void 0:Ie.kind)==="jira"?_j(Ie):null;return s.jsxs("section",{className:"ig-provider",id:`ig-provider-${se.kind}`,"aria-labelledby":`ig-provider-name-${se.kind}`,"data-setting":`integration-${se.kind}`,children:[s.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:s.jsx(se.Glyph,{})}),s.jsxs("div",{className:"ig-summary-text ig-provider-content",children:[s.jsx("h3",{id:`ig-provider-name-${se.kind}`,children:se.label}),Ne.length===0?s.jsx("span",{className:"ig-conn-line",children:t("integrations.settings.notConnected")}):Ie?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ig-conn-name",children:or(Ie)}),s.jsx("span",{className:"ig-conn-line",children:[Ie.account.login||Ie.account.name,tt||(Se?t("integrations.conn.lastVerifiedAt",{when:Se}):t("integrations.conn.notVerified"))].filter(Boolean).join(" · ")}),!Ie.tokenSaved&&s.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ig-conn-name",children:t("integrations.settings.count",{count:Ne.length})}),s.jsxs("span",{className:"ig-conn-line",children:[Be.slice(0,2).join(" · "),Be.length>2?` · ${t("integrations.settings.moreInstances",{n:Be.length-2})}`:""]})]}),!ce.has(se.kind)&&s.jsx("span",{className:"ig-stranded",children:t("integrations.conn.unavailable",{label:se.label})})]}),s.jsx("button",{type:"button",className:`btn ig-manage${Ne.length?"":" primary"}`,"aria-disabled":j!==null||void 0,ref:fe=>{const He=Ne.length?d.current:U.current;fe?He.set(se.kind,fe):He.delete(se.kind)},"aria-label":Ne.length?t("integrations.manageProvider",{label:se.label}):t("integrations.form.connect",{provider:se.label}),onClick:fe=>Ne.length?Oe(se.kind,fe.currentTarget):Ae({mode:"add",kind:se.kind},fe.currentTarget),children:Ne.length?s.jsxs(s.Fragment,{children:[t("integrations.manage")," ",s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m6 4 4 4-4 4"})})]}):t("integrations.form.connectBtn")})]},se.kind)})}),(nt.length>0||ve.length===0&&ke!=="all"&&a!==null)&&s.jsxs(Yt,{id:"integrations-list-title",title:t("integrations.settings.connections"),aside:s.jsx("span",{className:"settings-caption-count",children:nt.length}),children:[nt.map(se=>Ve(se,!0)),he.length===0&&s.jsx("p",{className:"settings-row settings-row-status",children:t("integrations.settings.nothing")})]})]}),ke==="all"&&s.jsx(s.Fragment,{children:s.jsx("div",{className:"ig-overview-info",children:s.jsxs("details",{className:"ig-access",children:[s.jsx("summary",{children:t("integrations.settings.accessSummary")}),s.jsx("p",{children:t("integrations.settings.accessBody")})]})})})]})]})}function QTe({theme:e}){return s.jsx("span",{className:"appearance-preview","data-swatch":e,children:s.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[s.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),s.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),s.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),s.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),s.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),s.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),s.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),s.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),s.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),s.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function e0e({theme:e,onTheme:t,singleKeys:n}){const a=ae(),i=c=>{var g,f;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(c.key))return;c.preventDefault();const d=(g=c.target.closest("[data-theme-choice]"))==null?void 0:g.dataset.themeChoice,p=(Ms.indexOf(d??e)+(c.key==="ArrowLeft"||c.key==="ArrowUp"?-1:1)+Ms.length)%Ms.length;t(Ms[p]),(f=c.currentTarget.querySelectorAll('[role="radio"]')[p])==null||f.focus()},o=m.useRef(null),r=m.useRef(e);return m.useEffect(()=>{var u,p;const c=r.current;r.current=e;const d=document.activeElement;c===e||!d||!((u=o.current)!=null&&u.contains(d))||d.dataset.themeChoice!==c||(p=o.current.querySelector(`[data-theme-choice="${e}"]`))==null||p.focus()},[e]),s.jsx(Yt,{id:"appearance-theme-caption",title:a("settings.theme.title"),list:!1,settingId:"theme",aside:n&&s.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:a("settings.theme.keyTip"),children:"T"}),children:s.jsx("div",{ref:o,className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:i,children:Ms.map(c=>s.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":c,"data-setting":`theme-${c}`,"aria-checked":e===c,tabIndex:e===c?0:-1,onClick:()=>t(c),children:[s.jsx(QTe,{theme:c}),s.jsxs("span",{className:"appearance-theme-name",children:[SB(c,a),s.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:s.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},c))})})}const t0e=[["smallest","settings.reading.size.smallest","11 px"],["smaller","settings.reading.size.smaller","12 px"],["default","settings.reading.size.default","13 px"],["larger","settings.reading.size.larger","15 px"],["largest","settings.reading.size.largest","17 px"]],n0e=[["tightest","settings.reading.density.tightest","30%"],["tighter","settings.reading.density.tighter","50%"],["compact","settings.reading.density.compact","70%"],["default","settings.reading.density.default","100%"],["comfortable","settings.reading.density.comfortable","140%"]];function cD(){return s.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:s.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 a0e({textSize:e,density:t,onTextSize:n,onDensity:a}){const i=ae(),o=e!=="default"||t!=="default";return s.jsx("button",{type:"button",className:"btn",disabled:!o,onClick:()=>{n("default"),a("default")},children:i("settings.reading.reset")})}function s0e({textSize:e,density:t,onTextSize:n,onDensity:a}){const i=ae();return s.jsxs(s.Fragment,{children:[s.jsxs("fieldset",{className:"reading-group",children:[s.jsx("legend",{children:i("settings.reading.sizeTitle")}),s.jsx("p",{id:"reading-size-help",children:i("settings.reading.sizeHelp")}),s.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help","data-setting":"text-size",style:{"--reading-count":A_.length,"--reading-selected":A_.indexOf(e)},children:t0e.map(([o,r,c])=>{const d=i(r);return s.jsxs("label",{className:"reading-choice","data-size":o,children:[s.jsx("input",{type:"radio",name:"text-size","aria-label":`${d} ${c}`,value:o,checked:e===o,onChange:()=>n(o)}),s.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),s.jsxs("span",{className:"reading-label",children:[s.jsx("strong",{children:d}),s.jsx("small",{children:c})]}),s.jsx(cD,{})]},o)})})]}),s.jsxs("fieldset",{className:"reading-group",children:[s.jsx("legend",{children:i("settings.reading.densityTitle")}),s.jsx("p",{id:"reading-density-help",children:i("settings.reading.densityHelp")}),s.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help","data-setting":"density",style:{"--reading-count":T_.length,"--reading-selected":T_.indexOf(t)},children:n0e.map(([o,r,c])=>{const d=i(r);return s.jsxs("label",{className:"reading-choice",children:[s.jsx("input",{type:"radio",name:"density","aria-label":i("settings.reading.spacing",{label:d,note:c}),value:o,checked:t===o,onChange:()=>a(o)}),s.jsxs("span",{className:"reading-density-sample","data-density":o,"aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}),s.jsxs("span",{className:"reading-label",children:[s.jsx("strong",{children:d}),s.jsx("small",{children:c})]}),s.jsx(cD,{})]},o)})})]}),s.jsxs(Yt,{id:"reading-preview-title",title:i("settings.reading.preview"),children:[s.jsxs("div",{className:"reading-preview-row",children:[s.jsxs("div",{children:[s.jsx("strong",{children:i("settings.reading.sample1")}),s.jsx("span",{children:i("settings.reading.sample1State")})]}),s.jsx("span",{className:"reading-preview-time",children:"4m"})]}),s.jsxs("div",{className:"reading-preview-row",children:[s.jsxs("div",{children:[s.jsx("strong",{children:i("settings.reading.sample2")}),s.jsx("span",{children:i("settings.reading.sample2State")})]}),s.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),s.jsx("p",{className:"settings-foot",children:i("settings.reading.foot")})]})}function i0e({cli:e,running:t}){const n=ae(),a=n("shell.terminal.versions",{product:Pt,cli:e.version,running:t}),i=s.jsx("code",{children:e.command});return e.auto==="pending"||e.auto==="running"?s.jsx(Ct,{as:"div",name:n("shell.terminal.name"),note:a,control:s.jsx("span",{className:"settings-read",children:e.auto==="running"?n("shell.terminal.updating"):n("shell.terminal.updatingSoon")}),children:s.jsx("span",{className:"settings-row-said",children:e.auto==="running"?n("shell.terminal.updatingNow"):Sj(n("shell.terminal.soon"),"cmd",i)})}):s.jsx(Ct,{as:"div",name:n("shell.terminal.name"),note:e.auto==="failed"?a:n("shell.terminal.notUpdated",{versions:a}),control:s.jsx("span",{className:"settings-read",children:n("shell.terminal.needed")}),children:s.jsxs("span",{className:"settings-row-said",children:[e.auto==="failed"&&s.jsxs(s.Fragment,{children:[e.error?n("shell.terminal.failedWith",{error:e.error}):n("shell.terminal.failed")," "]}),Sj(n("shell.terminal.run"),"cmd",i)]})})}const o0e="AGPL-3.0-only",r0e="https://github.com/BarganConstantin/ccdeck",c0e="https://github.com/sponsors/BarganConstantin";function l0e(e,t=C){return t("settings.about.pageBehind",{bundle:e})}function d0e(e,t){return Ws(e)&&Ws(t)&&Ro(e,t)<0}function u0e(e,t,n=C){return e?{kind:"ready",to:e.version,name:n("settings.about.updateReady"),note:n("settings.about.updateReadyNote",{product:Pt,version:e.version})}:t?t.kind==="restart"?{kind:"notice",name:n("settings.about.updateInstalled"),note:n("settings.about.updateInstalledNote",{to:t.to,from:t.from})}:{kind:"notice",name:n("settings.about.updateAvailable"),note:n("settings.about.updateAvailableNote",{product:Pt,to:t.to,from:t.from})}:null}function h0e({version:e,notice:t,readyAppUpdate:n,updateRestarting:a,updateFailure:i,onUpdateRestart:o,doors:r,bundle:c="3.53.1"}){const d=ae(),u=(e==null?void 0:e.running)??c,p=u0e(n,t,d);return s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{id:"settings-about-caption",title:Pt,children:[s.jsx(Ct,{as:"div",settingId:"version",name:d("settings.about.version"),note:d0e(c,e==null?void 0:e.running)?l0e(c,d):void 0,control:s.jsx("span",{className:"settings-read",children:u})}),(e==null?void 0:e.terminalCli)&&s.jsx(i0e,{cli:e.terminalCli,running:u}),p&&s.jsx(p0e,{offer:p,restarting:a,failure:i,onRestart:o,onUpdate:r.update}),s.jsx(Ct,{as:"div",settingId:"whats-new",name:d("settings.about.whatsNew"),note:d("settings.about.whatsNewNote"),control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":d("settings.about.openWhatsNew"),onClick:r.whatsNew,children:d("settings.about.open")})}),s.jsx(Ct,{as:"div",settingId:"licence",name:d("settings.about.licence"),note:d("settings.about.licenceNote"),control:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"settings-read",children:o0e}),s.jsxs("a",{className:"settings-link",href:r0e,target:"_blank",rel:"noreferrer",children:[d("settings.about.source"),s.jsx("span",{className:"vis-hidden",children:d("settings.about.sourceHidden")})]})]})}),s.jsx(Ct,{as:"div",settingId:"sponsor",name:d("settings.about.sponsor"),note:d("settings.about.sponsorNote"),control:s.jsxs("a",{className:"settings-link",href:c0e,target:"_blank",rel:"noreferrer",children:[d("settings.about.sponsorLink"),s.jsx("span",{className:"vis-hidden",children:d("settings.about.sponsorHidden")})]})})]}),s.jsxs(Yt,{id:"settings-about-help-caption",title:d("settings.about.helpGroup"),children:[s.jsx(Ct,{as:"div",settingId:"tour",name:d("settings.about.tour"),note:d("settings.key.tourText"),control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":d("settings.about.startTour"),onClick:r.tour,children:d("settings.about.start")})}),s.jsx(Ct,{as:"div",settingId:"feedback",name:d("settings.about.feedback"),note:d("settings.about.feedbackNote"),control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":d("settings.about.openFeedback"),onClick:r.feedback,children:d("settings.about.open")})})]})]})}function p0e({offer:e,restarting:t,failure:n,onRestart:a,onUpdate:i}){const o=ae();if(e.kind==="notice")return s.jsx(Ct,{as:"div",name:e.name,note:e.note,control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:i,children:o("settings.about.updateBtn")})});const r=jW(e.to,t),c=n&&n.version===e.to?AW(n.failure,n.version):"";return s.jsx(Ct,{as:"div",name:e.name,note:e.note,control:s.jsx("button",{type:"button",className:"btn",onClick:()=>a(e.to),"aria-busy":t||void 0,"aria-label":r.label,title:r.title,children:r.text}),children:s.jsx("span",{className:"settings-row-said",role:"status",children:c})})}function g0e(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 m0e={plain:"settings.updates.plainDetails","checks-off":"settings.updates.checksOffDetails","no-restart":"settings.updates.noRestartDetails"};function f0e({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:a=Eo()}){const i=ae(),o=g0e(n,a);return s.jsx(Yt,{id:"settings-updates-caption",title:i("settings.updates.title"),children:o==="app"?s.jsx(Ct,{as:"div",settingId:"auto-update",name:i("settings.updates.title"),note:i("settings.updates.appNote")}):s.jsx(Ct,{settingId:"auto-update",name:i("settings.updates.label"),nameId:"settings-auto-update-label",note:i(o==="no-restart"?"settings.updates.noRestartNote":o==="checks-off"?"settings.updates.checksOffNote":"settings.updates.plainNote"),details:i(m0e[o]),noteId:"settings-auto-update-note",control:s.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:s.jsx("span",{className:"switch-knob"})})})})}function b0e({character:e,onCharacter:t}){const n=ae(),a=m.useRef([]);function i(o,r){var d;const c=pT(o,r,mg.length,"vertical");c.kind==="select"&&(o.preventDefault(),t(mg[c.index].id),(d=a.current[c.index])==null||d.focus())}return s.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":n("settings.character.choose"),"data-setting":"character-choice",children:mg.map((o,r)=>s.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===o.id,tabIndex:e===o.id?0:-1,ref:c=>{a.current[r]=c},onClick:()=>t(o.id),onKeyDown:c=>i(c,r),children:[s.jsx("span",{className:"character-preview",children:s.jsx(IU,{character:o.id,act:null,facing:"right"})}),s.jsx("span",{children:o.name}),s.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:s.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},o.id))})}function v0e({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:a}){const i=ae();return s.jsxs(Yt,{id:"appearance-character-caption",title:i("settings.character.title"),list:!1,children:[s.jsx("div",{className:"settings-list",children:s.jsx(Ct,{settingId:"character",name:i("settings.character.show"),nameId:"appearance-character-label",note:i("settings.character.note"),noteId:"appearance-character-note",control:s.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:s.jsx("span",{className:"switch-knob"})})})}),s.jsx(b0e,{character:n,onCharacter:a})]})}const lD="settings-search-field",YW="settings-search-results",qj=e=>`settings-result-${e}`;function k0e({inputRef:e,query:t,onQuery:n,results:a,active:i,onActive:o,onOpen:r}){const c=ae(),d=t.trim()!=="",u=d&&a.length>0,p=g=>{if(g.nativeEvent.isComposing)return;const f=Wre(g.key,t,d?a.length:0,i);f.kind!=="pass"&&(g.preventDefault(),f.kind==="move"?o(f.index):f.kind==="open"?r(a[f.index]):(g.stopPropagation(),n("")))};return s.jsxs("div",{className:"settings-search",children:[s.jsx("label",{className:"vis-hidden",htmlFor:lD,children:c("settings.search.label")}),s.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:[s.jsx("circle",{cx:"6",cy:"6",r:"4.2"}),s.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]}),s.jsx("input",{ref:e,id:lD,type:"search",className:"settings-filter-field settings-search-field",placeholder:c("settings.search.label"),autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":u,"aria-controls":u?YW:void 0,"aria-activedescendant":u?qj(Math.min(i,a.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:g=>n(g.target.value),onKeyDown:p})]})}function w0e({query:e,results:t,active:n,onOpen:a}){const i=ae(),o=TB(t.length,e);return m.useEffect(()=>{var r,c;(c=(r=document.getElementById(qj(n)))==null?void 0:r.scrollIntoView)==null||c.call(r,{block:"nearest"})},[n]),s.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[s.jsx("div",{className:"settings-pane-head",children:s.jsxs("div",{className:"settings-pane-heading",children:[s.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:i("settings.search.title")}),s.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:o})]})}),t.length>0&&s.jsx("div",{className:"settings-group",children:s.jsx("div",{className:"settings-list",id:YW,role:"listbox","aria-label":i("settings.search.results"),children:t.map((r,c)=>s.jsxs("button",{type:"button",role:"option",id:qj(c),className:"settings-result",tabIndex:-1,"aria-selected":c===n,"aria-label":Fre(r),"data-highlighted":c===n,onMouseDown:d=>d.preventDefault(),onClick:()=>a(r),children:[s.jsx(Xm,{section:r.section}),s.jsxs("span",{className:"settings-result-text",children:[s.jsx("span",{className:"settings-result-name",children:r.label}),s.jsx("span",{className:"settings-result-place",children:UA(r)})]})]},r.id))})})]})}function y0e({query:e,count:t}){return s.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?TB(t,e):""})}const x0e=1500,C0e=3e3,S0e=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function N0e(e){if(e.matches(Ig)&&!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(Ig)).filter(a=>J2({disabled:a.disabled,tabIndex:a.tabIndex,rendered:S0e(a)}));return n.find(a=>a.closest(".settings-list")!=null)??n[0]??null}function j0e(e,t,n){const[a,i]=m.useState(null),o=m.useRef(void 0),r=m.useRef(null);return m.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=r.current)==null||c.removeAttribute("data-jumped")},[]),m.useEffect(()=>{const c=e.current;if(!a||!t||!c)return;const d=()=>c.querySelector(`[data-setting="${CSS.escape(a)}"]`),u=v=>{var y,N;i(null);const k=v.offsetHeight>c.clientHeight-48;v.scrollIntoView({block:k?"start":"center"}),(y=N0e(v))==null||y.focus({preventScroll:!0}),window.clearTimeout(o.current),(N=r.current)==null||N.removeAttribute("data-jumped"),v.offsetWidth,v.setAttribute("data-jumped",""),r.current=v,o.current=window.setTimeout(()=>{v.removeAttribute("data-jumped"),r.current===v&&(r.current=null)},x0e)},p=d();if(p){u(p);return}const g=new MutationObserver(()=>{const v=d();v&&(g.disconnect(),window.clearTimeout(f),u(v))});g.observe(c,{childList:!0,subtree:!0});const f=window.setTimeout(()=>{g.disconnect(),i(null)},C0e);return()=>{g.disconnect(),window.clearTimeout(f)}},[e,a,t,n]),i}function A0e({section:e,landOn:t,onSection:n,onClose:a,providers:i,sound:o,tones:r,customTones:c,notify:d,appearance:u,versionCheck:p,desktopUpdate:g,restart:f,doors:v}){const k=ae(),y=m.useRef(null),N=m.useCallback(Se=>{y.current=Se},[]);function w(Se,tt=!1){y.current?(B(""),y.current(Se,tt),requestAnimationFrame(()=>{var fe,He;return(He=(fe=j.current)==null?void 0:fe.scrollIntoView)==null?void 0:He.call(fe,{block:"nearest",inline:"nearest"})})):Se()}const S=()=>w(a,!0),j=m.useRef(null),A=_t(S,{focusRef:j}),T=qt(()=>w(a)),E=m.useRef([]),q=Xu(),F=KT(q),z=Foe(F,e,i.claude),H=Math.max(0,z.findIndex(Se=>Se.id===e)),I=jl("(max-width: 640px)"),[L,O]=m.useState(""),[_,M]=m.useState(0),U=m.useRef(null),G=m.useRef(null),W=L.trim()!=="",$=m.useMemo(()=>Hre(L,AB(i.claude,F,Qu(q))),[L,i.claude,F,q,k]),Y=j0e(G,!W,e),B=Se=>{O(Se),M(0)};m.useEffect(()=>{t&&Y(t)},[t,Y]);const V=Se=>{w(()=>{B(""),n(Se),requestAnimationFrame(()=>{var tt;return(tt=document.getElementById(`settings-tab-${Se}`))==null?void 0:tt.focus()})})},Z=Se=>{w(()=>{B(""),n(Se.section),Zm(Se)||Y(Se.id)})};m.useEffect(()=>{const Se=tt=>{var lt,gt;if(!$oe(tt))return;const fe=A.current,He=tt.target;!fe||!(He===document.body||He===document.documentElement||He&&fe.contains(He))||(tt.preventDefault(),(lt=U.current)==null||lt.focus(),(gt=U.current)==null||gt.select())};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},[A]),m.useEffect(()=>{var Se,tt,fe,He;Uoe((Se=document.activeElement)==null?void 0:Se.id,e)&&((tt=j.current)==null||tt.focus()),(He=(fe=j.current)==null?void 0:fe.scrollIntoView)==null||He.call(fe,{block:"nearest",inline:"nearest"})},[e]);const{theme:D,setTheme:K,characterEnabled:X,setCharacterEnabled:Q,character:ee,setCharacter:ne}=u,de=Qn(),ge=Se=>{const tt=pT(Se,H,z.length,"vertical");tt.kind!=="pass"&&(Se.preventDefault(),w(()=>{var fe;B(""),n(z[tt.index].id),(fe=E.current[tt.index])==null||fe.focus()}))},le=Se=>{Se.key===" "&&Se.stopPropagation()},{soundOn:he,toggleSound:ce}=o,{tonePrefs:oe,previewTone:ve,changeTone:ke}=r,{customSelections:ye,customAssets:Le,clearCustomOnly:Ke,selectCustomTone:Qe,importNotificationAudio:Ae,createNotificationVoice:je,renameCustomAsset:Oe,deleteCustomAsset:Ve,previewCustomAsset:nt}=c,{notifyPermission:Ye,notifyOn:Ce,notifyVetoed:ze,toggleNotify:De,notifySupported:Fe,askForNotifications:ot,accountNotify:se,toggleAccountNotify:Ne}=d,Ie=(()=>{switch(e){case"radar":return s.jsx(_Te,{onOpen:v.radar});case"claude":return s.jsx($Te,{});case"appearance":return s.jsxs(s.Fragment,{children:[s.jsx(e0e,{theme:D,onTheme:K,singleKeys:de}),s.jsx(v0e,{characterEnabled:X,character:ee,onCharacter:ne,onToggleCharacter:()=>Q(Se=>!Se)})]});case"reading":return s.jsx(s0e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity});case"keyboard":return s.jsx(fTe,{singleKeys:de,onToggleSingleKeys:()=>wne(!de)});case"notifications":return s.jsx(bTe,{notifyOn:Ce,onToggleNotify:De,notifyVetoed:ze,notifyPermission:Fe?Ye:"unsupported",onAskNotify:ot,accountNotify:se,onToggleAccountNotify:Ne});case"sounds":return s.jsx(ETe,{soundOn:he===!0,onToggleSound:ce,prefs:oe,claudeHere:i.claude,onLevel:(Se,tt)=>ke(Se,{level:tt}),onFigure:(Se,tt)=>ke(Se,{figure:tt}),onPreview:Se=>ve(Se),customAssets:Le,customSelections:ye,onBuiltInSelected:Ke,onCustomSelected:Qe,onImportCustom:Ae,onCreateVoice:je,onRenameCustom:Oe,onPreviewCustom:nt,onDeleteCustom:Ve});case"integrations":return s.jsx(XTe,{onBeforeLeaveChange:N});case"data":return s.jsx(KTe,{});case"about":return s.jsx(h0e,{version:p.version,notice:p.notice,readyAppUpdate:g.readyAppUpdate,updateRestarting:g.desktopUpdateRestarting,updateFailure:g.desktopUpdateFailure,onUpdateRestart:Se=>{g.askDesktopUpdateRestart(Se)},doors:v});default:return s.jsxs(s.Fragment,{children:[s.jsx(cTe,{}),s.jsx(dTe,{}),s.jsx(eD,{provider:"Codex"}),i.claude&&s.jsx(eD,{provider:"Claude"}),s.jsx(f0e,{autoRestart:f.autoRestart,onToggleAutoRestart:f.toggleAutoRestart,version:p.version}),s.jsx(pTe,{claudeHere:i.claude,codexHere:i.codex,singleKeys:de,doors:v})]})}})(),Be=e==="reading"?s.jsx(a0e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity}):e==="integrations"&&q.connections!==null?s.jsx("span",{className:"ig-total",children:k("settings.savedConnections",{count:q.connections.length})}):null;return s.jsx("div",{className:"modal-backdrop",...T,role:"presentation",children:s.jsxs("div",{ref:A,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:Se=>Se.stopPropagation(),onKeyDown:le,children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"settings-title",className:"modal-tool-name",children:k("settings.title")})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>w(a),"aria-label":k("settings.close"),title:k("settings.closeTip"),children:"×"})})]}),s.jsxs("div",{className:"settings-body",children:[s.jsxs("div",{className:"settings-side",children:[s.jsx(k0e,{inputRef:U,query:L,onQuery:B,results:$,active:_,onActive:M,onOpen:Z}),s.jsx(y0e,{query:L,count:$.length}),s.jsx("div",{className:"settings-nav",role:"tablist","aria-label":k("settings.sections"),"aria-orientation":I?"horizontal":"vertical",onKeyDown:ge,children:z.map((Se,tt)=>s.jsxs("button",{ref:fe=>{E.current[tt]=fe,Se.id===e&&(j.current=fe)},type:"button",role:"tab",id:`settings-tab-${Se.id}`,className:"settings-tab","aria-selected":Se.id===e,"aria-controls":"settings-pane",tabIndex:Se.id===e?0:-1,onClick:()=>V(Se.id),children:[s.jsx(Xm,{section:Se.id}),s.jsx("span",{className:"settings-tab-label",children:k(`settings.section.${Se.id}.label`)})]},Se.id))})]}),s.jsxs("div",{ref:G,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:W||void 0,children:[s.jsxs("div",{className:"settings-pane-head",children:[s.jsxs("div",{className:"settings-pane-heading",children:[s.jsx("h2",{className:"settings-pane-title",children:k(`settings.section.${z[H].id}.label`)}),s.jsx("p",{className:"settings-pane-note",children:k(`settings.section.${z[H].id}.note`)})]}),Be]}),Ie]},e),W&&s.jsx(w0e,{query:L,results:$,active:_,onOpen:Z})]})]})})}function T0e({tool:e,onClose:t}){const n=ae(),a=_t(t),i=qt(t),o=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=m.useRef({of:null});r.current.of!==e&&(r.current={of:e}),e.input!==void 0&&(r.current.input=e.input),e.response!==void 0&&(r.current.response=e.response);const c=r.current.input??e.inputPreview,d=r.current.response??e.errorPreview,u=e.trimmed===!0&&r.current.input===void 0&&r.current.response===void 0,p=m.useMemo(()=>{const g=JX(e.name,c,d);return{input:g.input.map((f,v)=>s.jsx(dD,{block:f},v)),response:g.response.map((f,v)=>s.jsx(dD,{block:f},v)),copyInput:s1(e.name,"input",c),copyResponse:s1(e.name,"response",d)}},[e.name,c,d]);return s.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:s.jsxs("div",{ref:a,className:"modal tool-modal",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{className:`status-dot ${o}`,"aria-hidden":!0}),s.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),s.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("span",{className:"modal-dur",children:V2(e,n("insights.tool.inflight"))}),s.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":n("insights.audit.closeEsc"),title:n("insights.audit.closeEsc"),children:"×"})]})]}),s.jsxs("section",{className:"modal-body",children:[u&&s.jsx("div",{className:"modal-section",children:s.jsx("p",{className:"modal-note",children:n("insights.tool.released")})}),s.jsxs("div",{className:"modal-section",children:[s.jsxs("div",{className:"tm-head",children:[s.jsx("h4",{children:n("insights.cost.inputTitle")}),s.jsx(uD,{text:p.copyInput,what:"input"})]}),p.input]}),s.jsxs("div",{className:"modal-section",children:[s.jsxs("div",{className:"tm-head",children:[s.jsxs("h4",{children:[n("insights.tool.response")," ",o==="err"&&s.jsx("span",{className:"err-tag",children:n("insights.tool.error")})]}),e.endedAt!=null&&s.jsx(uD,{text:p.copyResponse,what:"response"})]}),e.endedAt==null?s.jsx("pre",{children:n("insights.tool.waiting")}):p.response]})]})]})})}const R0e={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function dD({block:e}){const[t,n]=m.useState(!1);if(e.inline)return s.jsxs("p",{className:"tm-inline",children:[e.label&&s.jsx("span",{className:"tm-label",children:e.label}),s.jsx("code",{children:e.text})]});const a=m.useMemo(()=>BX(e),[e]),{shown:i}=w2(a,t),o=HX(a,t);return s.jsxs("div",{className:"tm-block",children:[e.label&&s.jsx("span",{className:"tm-label",children:e.label}),s.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?i.map((r,c)=>s.jsxs("span",{className:r.tone?R0e[r.tone]:void 0,children:[r.text,c<i.length-1?`
351
+ 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.`}]},JT="agent-dag.releaseNotesSeen";function YI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Ro(e,t){const n=YI(e),a=YI(t);for(let i=0;i<Math.max(n.length,a.length);i++){const o=(n[i]??0)-(a[i]??0);if(o!==0)return o<0?-1:1}return 0}function Ws(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function jAe(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 AAe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,a]of Object.entries(e)){if(!Ws(n)||!Array.isArray(a))continue;const i=a.filter(jAe).map(c=>({title:c.title,body:c.body,...typeof c.details=="string"&&c.details.trim()?{details:c.details}:{},...c.priority==="highlight"||c.priority==="required"?{priority:c.priority}:{},...typeof c.notice=="string"&&c.notice.trim()?{notice:c.notice}:{},...typeof c.notice=="string"&&c.notice.trim()&&typeof c.noticeLabel=="string"&&c.noticeLabel.trim()&&c.noticeLabel.length<=32?{noticeLabel:c.noticeLabel}:{},...c.icon==="plans"||c.icon==="accounts"||c.icon==="skills"?{icon:c.icon}:{}})),o=e["//summaries"],r=o&&typeof o=="object"&&Object.hasOwn(o,n)?o[n]:void 0;i.length&&t.push({version:n,notes:i,...typeof r=="string"&&r.trim()?{summary:r}:{}})}return t.sort((n,a)=>Ro(a.version,n.version))}function TAe(e){const t=e.filter(o=>o.priority==="highlight").slice(0,3),n=t.length>0,a=e.filter(o=>!t.includes(o)&&(!n||o.priority==="required"||o.priority==="highlight"||!!o.notice)),i=e.filter(o=>!t.includes(o)&&!a.includes(o));return{highlights:t,visible:a,more:i}}function RAe(e,t,n){const[a,...i]=e;if(!t)return{latest:Ws(n)?e.find(c=>Ro(c.version,n)===0):a,visiblePrevious:[],history:[]};const o=[],r=[];for(const c of i){const d=c.notes.some(g=>g.priority==="highlight"||g.priority==="required"||!!g.notice),u=c.notes.filter(g=>!d||g.priority==="required"||!!g.notice);u.length&&o.push({version:c.version,notes:u});const p=c.notes.filter(g=>!u.includes(g));p.length&&r.push({...c,notes:p})}return{latest:a,visiblePrevious:o,history:r}}const ZI=AAe(NAe);function BW(e,t,n){return e.filter(a=>Ro(a.version,n)<=0&&(t===null||Ro(a.version,t)>0))}function EAe(e,t){return e.filter(n=>Ro(n.version,t)===0)}function _Ae(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}`}const qAe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function HW(e){const t=qAe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function zAe(e){if(!e)return null;let t=null;try{t=e.getItem(JT)}catch{return null}return Ws(t)?t:null}function LAe(e){if(!e)return!1;try{return e.getItem(JT),!0}catch{return!1}}function OAe(e,t){if(!e)return!1;try{return e.setItem(JT,t),!0}catch{return!1}}const WW="agent-dag.tourSeen";function PAe(e){if(!e)return!1;try{return e.getItem(WW)==="1"}catch{return!1}}function MAe(e){if(!e)return!1;try{return e.setItem(WW,"1"),!0}catch{return!1}}function IAe({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 DAe({stored:e,running:t,notes:n,remembers:a=!0}){if(!Ws(t))return{show:[],record:null,reason:"no-version"};if(!Ws(e)){if(!a)return{show:[],record:t,reason:"cannot-remember"};const r=EAe(n,t);return r.length?{show:r,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const i=Ro(e,t);if(i===0)return{show:[],record:null,reason:"seen"};if(i>0)return{show:[],record:null,reason:"ahead"};const o=BW(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function FAe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const a=e.indexOf("`",n+1);if(a<0)break;n=a+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function nu(e,t=!0){const n=[];let a="";const i=()=>{a&&(n.push({kind:"text",text:a}),a="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const r=e.indexOf("`",o+1);if(r>o+1){i(),n.push({kind:"code",text:e.slice(o+1,r)}),o=r+1;continue}}else if(t&&e.startsWith("**",o)){const r=FAe(e,o);if(r>0){i(),n.push({kind:"bold",kids:nu(e.slice(o+2,r),!1)}),o=r+2;continue}}a+=e[o],o+=1}return i(),n}function Eo(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const UAe=()=>C("shell.update.checkWhy"),XI=()=>C("shell.update.checking"),BAe=()=>C("shell.update.npmUnreachable"),HAe=()=>C("shell.update.deckUnreachable"),WAe=()=>C("shell.update.checksOff"),GAe=()=>C("shell.update.pendingRetry");function $Ae(e,t,n,a){const i=a?t.npx:n?un(t,n):void 0;return i?C("shell.update.outBlocked",{to:e,reason:i}):C("shell.update.outRun",{to:e})}const ua=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),dr=e=>ua(e,{tone:"note"});function QI(e,t){return rNe(t-e)}function VAe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?dr(C("shell.update.appReady",{version:n.version??""})):(n==null?void 0:n.status)==="checking"?dr(C("shell.update.appChecking")):(n==null?void 0:n.status)==="downloading"?dr(n.version?C("shell.update.appDownloadingVersion",{version:n.version}):C("shell.update.appDownloading")):(n==null?void 0:n.status)==="current"?dr(C("shell.update.appCurrent",{version:e.version??t})):(n==null?void 0:n.status)==="error"?dr(C("shell.update.appError")):dr(C("shell.update.appIdle"))}function KAe(e,t,n){var r;const a=e.version;if((a==null?void 0:a.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return ua(C("shell.update.installed",{to:t}));const c=e.upgradeState==="running",d=C("shell.update.installWhy",{command:((r=a.upgrade)==null?void 0:r.command)??a.command});return ua(c?C("shell.update.installing",{to:t}):C("shell.update.out",{to:t}),{action:{kind:"install",label:C("shell.update.now"),busy:c,why:d}})}if((a==null?void 0:a.upgradeMode)==="npx"&&a.canRestart){const c=e.upgradeState==="failed";return ua(c?C("shell.update.npxFailedBack",{to:t,running:e.running}):C("shell.update.out",{to:t}),{action:{kind:"npx",label:C(c?"shell.update.retry":"shell.update.andRestart"),busy:e.restarting,why:C("shell.update.npxWhy",{command:a.command})}})}const i=e.upgradeState==="failed"?C("shell.update.installFailed",{to:t}):$Ae(t,n,a==null?void 0:a.upgradeBlocked,(a==null?void 0:a.upgradeMode)==="npx"),o=(a==null?void 0:a.command)??null;return ua(i,{command:o,action:o?{kind:"copy",label:e.copied?C("shell.copied"):C("shell.copy"),busy:!1}:null})}function JAe(e){const t=e.version;if(e.unreachable)return ua(HAe(),{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return ua(BAe(),{tone:"warn",age:e.answered?null:C("shell.update.lastTried",{ago:QI(n,e.now)})});const a=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(a)return ua(C("shell.update.pending",{pending:a,retry:GAe()}));const i=t!=null&&t.checkedAt?QI(t.checkedAt,e.now):null;if((t==null?void 0:t.checkedAt)&&e.now>=t.checkedAt&&e.now-t.checkedAt<=60*6e4&&(t!=null&&t.latest)&&Ws(t.latest)&&Ws(e.running)){const r=Ro(t.latest,e.running),c=r===0?C("shell.update.latest",{version:e.running}):r<0?C("shell.update.ahead",{running:e.running,latest:t.latest}):C("shell.update.out",{to:t.latest});return ua(c,{age:i?C("shell.update.checkedAgo",{ago:i}):null})}return ua(C(i?"shell.update.mayHaveChanged":"shell.update.noneYet"),{age:i?C("shell.update.lastChecked",{ago:i}):null})}function YAe(e,t){var i,o;const n=e.version;if((i=e.app)!=null&&i.inApp&&(n!=null&&n.checkDisabled)){const r=VAe(e.app,e.running);return r&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?ua(C("shell.update.appRefused"),{tone:"warn"}):e.checking?ua(XI()):r}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:dr(WAe())};const a=(n==null?void 0:n.notice)??null;if((a==null?void 0:a.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:KAe(e,a.to,t)};if((a==null?void 0:a.kind)==="restart"){const r=n!=null&&n.canRestart?C("shell.update.restartDeck",{to:a.to}):C("shell.update.restartApp",{to:a.to});return{canCheck:!0,checking:e.checking,line:ua(r)}}return e.checking?{canCheck:!0,checking:!0,line:ua(XI())}:{canCheck:!0,checking:!1,line:JAe(e)}}const GW=450;async function ZAe(e,t=n=>new Promise(a=>setTimeout(a,n))){const[n]=await Promise.all([e(!0),t(GW)]);return n?"answered":"unreachable"}async function XAe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,GW))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const QAe=()=>C("shell.notes.restartWhy");function eTe(e){var q,F,z;Ea();const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Vs(3e4),[a,i]=m.useState(!1),o=m.useRef(!1),[r,c]=m.useState(!1),[d,u]=m.useState(!1),p=m.useRef(t);if(m.useEffect(()=>{p.current&&!t&&u(!0),p.current=t},[t]),!e)return null;const{versionCheck:g,upgrade:f,restart:v,desktopUpdate:k,running:y,onHandOff:N}=e,w=YAe({version:g.version,running:y,checking:a||t,answered:d,unreachable:r,now:Math.max(n,Date.now()),upgradeState:f.upgradeState,copied:f.cmdCopied,restarting:v.restarting,app:{inApp:Eo(),update:k.appUpdate,version:CW(),menu:NW()}},Cj);if(!w)return null;const S=Eo()&&((q=g.version)==null?void 0:q.checkDisabled),j=S?C("shell.update.checkWhyApp"):UAe(),A=async()=>{var I;if(!Jn(o.current||t)||S&&((I=k.appUpdate)==null?void 0:I.status)==="checking")return;o.current=!0,i(!0);const H=S?await XAe():await ZAe(g.loadVersion);o.current=!1,i(!1),c(H==="unreachable"),u(!0)},T=H=>{if(H.kind==="copy")return void f.copyCommand();N(),g.showNotice(),H.kind==="install"?f.startUpgrade():v.askRestart({upgrade:!0})},E=w.line.tone==="warn"||!!w.line.action||!!((F=g.version)!=null&&F.notice)||((z=k.appUpdate)==null?void 0:z.status)==="downloading";return{state:w,check:A,act:T,checkWhy:j,needsAttention:E}}function tTe({update:e}){const t=Nl("above","dialog"),n=m.useId();return Ea(),s.jsxs("div",{className:"rn-status-row",children:[e?s.jsx(nTe,{line:e.state.line,onAct:e.act,bindHint:t.bind,whyId:`${n}-action`,announce:!1}):s.jsx("p",{className:"rn-update-line",children:s.jsx("span",{role:"status",children:C("shell.notes.statusUnavailable")})}),t.node]})}function nTe({line:e,onAct:t,bindHint:n,whyId:a,announce:i=!0}){const{action:o}=e,r=o&&s.jsx(aTe,{action:o,onAct:t,bindHint:n,whyId:a});return s.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[s.jsx("span",{className:"rn-update-what",role:i?"status":void 0,children:e.said}),e.age&&s.jsx("span",{className:"rn-update-age",children:e.age}),e.command?s.jsxs("span",{className:"rn-update-cmd",children:[s.jsx("code",{className:"rn-code",children:e.command}),r]}):r]})}function aTe({action:e,onAct:t,bindHint:n,whyId:a}){const i=e.kind==="copy"?null:e.why;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:i?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":i&&a?a:void 0,...i&&n?n({label:i}):{},children:e.label}),i&&a&&s.jsx("span",{hidden:!0,id:a,children:i})]})}function sTe({entries:e,since:t,running:n,firstRun:a,onClose:i,onTour:o,updateVersion:r,updateBusy:c,onUpdateRestart:d,updateFailure:u,onRestart:p,updateCheck:g}){var M,U;const f=ae(),v=QAe(),k=_t(i),y=m.useRef(null),N=qt(i),w=m.useId(),[S,j]=m.useState(null),A=eTe(g),T=((M=A==null?void 0:A.state.line.action)==null?void 0:M.kind)==="install"||((U=A==null?void 0:A.state.line.action)==null?void 0:U.kind)==="npx",E=p&&!r&&!T,{latest:q,visiblePrevious:F,history:z}=RAe(e,t!==null,n),H=`${w}-history`,I=!!E||!!(A!=null&&A.state.canCheck)&&!r;m.useEffect(()=>{var G;!I&&S&&(j(null),document.activeElement===document.body&&((G=y.current)==null||G.focus()))},[I,S]);const L=Ws(n)?`v${n}`:_Ae(e.slice(0,1)),O=a&&n?f("shell.notes.contextFirst",{version:n}):t?f("shell.notes.contextSince",{since:t}):null,_=F.some(G=>G.notes.some(W=>!W.priority&&!W.notice));return s.jsx("div",{className:"modal-backdrop",...N,role:"presentation",children:s.jsxs("div",{ref:k,className:"modal release-notes",id:`${w}-dialog`,onClick:G=>G.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:f("shell.notes.title")}),L&&s.jsx("span",{className:"modal-tool-id",children:L})]}),s.jsxs("div",{className:"modal-actions",children:[I&&s.jsx("button",{id:`${w}-options`,type:"button",className:"glyph-btn","aria-label":f("shell.notes.moreOptions"),"aria-haspopup":"menu","aria-expanded":S!==null,"aria-controls":S?`${w}-menu`:void 0,onClick:()=>j(S?null:"first"),onKeyDown:G=>{(G.key==="ArrowDown"||G.key==="ArrowUp")&&(G.preventDefault(),j(G.key==="ArrowUp"?"last":"first"))},children:s.jsxs("svg",{className:"glyph",viewBox:"0 0 14 14",width:"14",height:"14",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"3",cy:"7",r:"1"}),s.jsx("circle",{cx:"7",cy:"7",r:"1"}),s.jsx("circle",{cx:"11",cy:"7",r:"1"})]})}),s.jsx("button",{ref:y,type:"button",className:"glyph-btn",onClick:i,"aria-label":f("shell.closeEsc"),title:f("shell.closeEsc"),children:"×"})]})]}),s.jsx("span",{className:"rn-live-status",role:"status",children:r?f("shell.notes.downloaded",{version:r}):A==null?void 0:A.state.line.said}),s.jsxs("section",{className:"modal-body",role:"region","aria-label":f("shell.notes.region"),tabIndex:0,children:[r?s.jsxs("div",{className:"rn-ready",children:[s.jsx("p",{children:f("shell.notes.downloaded",{version:r})}),s.jsx("p",{className:"rn-update-said",role:"status",children:u})]}):s.jsxs(s.Fragment,{children:[(A==null?void 0:A.needsAttention)&&s.jsx(tTe,{update:A}),s.jsx("p",{className:"rn-update-said",role:"status",children:u})]}),O&&s.jsx("p",{className:"rn-context",children:O}),!(q!=null&&q.notes.length)&&!F.length&&s.jsx("p",{className:"rn-empty",children:f("shell.notes.empty")}),q&&s.jsx(MS,{entry:q,showVersion:t!==null&&e.length>1},q.version),F.length>0&&s.jsxs("section",{className:"rn-upgrade-history","aria-label":f("shell.notes.earlierLabel"),children:[s.jsx("h2",{className:"rn-group-title",children:f("shell.notes.earlierTitle")}),_&&s.jsx("p",{className:"rn-context",children:f("shell.notes.legacy")}),F.map(G=>s.jsx(MS,{entry:G,showVersion:!0},G.version))]}),z.length>0&&s.jsxs("details",{className:"rn-history",children:[s.jsx("summary",{"aria-controls":H,children:f("shell.notes.otherSince",{since:t??""})}),s.jsx("div",{id:H,children:z.map(G=>s.jsx(MS,{entry:G,showVersion:!0},G.version))})]})]}),s.jsxs("footer",{className:"rn-footer",children:[s.jsxs("div",{className:"rn-footer-links",children:[s.jsxs("a",{href:"https://ccdeck.dev/changelog/",target:"_blank",rel:"noopener noreferrer","aria-label":f("shell.notes.historyLabel"),children:[f("shell.notes.history")," ",s.jsx(fl,{})]}),o&&!r&&s.jsx("button",{className:"rn-text-button",type:"button",onClick:o,children:f("shell.notes.tour")})]}),r&&d?s.jsx("button",{className:"btn primary",type:"button",onClick:d,"aria-busy":c||void 0,children:c?f("shell.notes.restarting"):Ru()}):s.jsx("button",{className:"btn primary",type:"button",onClick:i,children:f("shell.done")})]}),S&&I&&s.jsxs(Mr,{anchorId:`${w}-options`,portalRootId:`${w}-dialog`,id:`${w}-menu`,role:"menu",labelledBy:`${w}-options`,start:S,className:"ap-pop rn-options-menu",onClose:()=>j(null),children:[A&&s.jsxs("p",{className:"rn-menu-status",id:`${w}-check-status`,children:[A.state.line.said,A.state.line.age&&s.jsx("span",{children:A.state.line.age})]}),(A==null?void 0:A.state.canCheck)&&s.jsxs("button",{type:"button",className:"ap-menu-item rn-act",role:"menuitem",title:A.checkWhy,"aria-describedby":`${w}-check-status`,"aria-busy":A.state.checking||void 0,onClick:()=>void A.check(),children:[s.jsx(Qie,{}),f("shell.notes.check")]}),(A==null?void 0:A.state.canCheck)&&E&&s.jsx("div",{className:"rn-menu-separator",role:"separator"}),E&&s.jsxs("button",{type:"button",className:"ap-menu-item",role:"menuitem",title:v,"aria-describedby":`${w}-restart-why`,onClick:()=>{j(null),p==null||p()},children:[s.jsx(eoe,{}),f("shell.notes.restart")]}),s.jsx("span",{hidden:!0,id:`${w}-restart-why`,children:v})]})]})})}function MS({entry:e,showVersion:t}){const n=ae(),{highlights:a,visible:i,more:o}=TAe(e.notes),r=a.filter(d=>d.details),c=m.useId();return s.jsxs("section",{className:"rn-release",children:[t&&s.jsxs("h2",{className:"rn-version",children:["v",e.version]}),e.summary&&s.jsx("h2",{className:"rn-summary",children:e.summary}),s.jsxs("ul",{className:"rn-notes",children:[a.map((d,u)=>s.jsx(IS,{note:d,highlight:!0},`h${u}`)),i.map((d,u)=>s.jsx(IS,{note:d},`v${u}`))]}),(o.length>0||r.length>0)&&s.jsxs("details",{className:"rn-more",children:[s.jsxs("summary",{"aria-controls":c,children:[s.jsxs("span",{className:"rn-more-start",children:[s.jsx("span",{className:"rn-chevron","aria-hidden":"true",children:"›"}),s.jsx("span",{className:"rn-more-label",children:o.length?n("shell.notes.more",{count:o.length}):n("shell.notes.moreDetails")})]}),s.jsxs("span",{className:"rn-more-hint",children:[s.jsx("span",{className:"rn-show-details",children:n("shell.notes.show")}),s.jsx("span",{className:"rn-hide-details",children:n("shell.notes.hide")})]})]}),s.jsxs("div",{id:c,children:[s.jsx("ul",{className:"rn-notes",children:o.map((d,u)=>s.jsx(IS,{note:d},u))}),r.length>0&&s.jsxs("div",{className:"rn-highlight-details",role:"group","aria-labelledby":`${c}-highlights`,children:[s.jsx("h3",{id:`${c}-highlights`,className:"rn-details-title",children:n("shell.notes.aboutHighlights")}),r.map((d,u)=>s.jsxs("p",{className:"rn-note-body",children:[s.jsxs("strong",{className:"rn-strong",children:[HW(d.title).rest.trimStart(),": "]}),au(nu(d.details))]},u))]})]})]})]})}const iTe={plans:nB,accounts:aB,skills:sB};function IS({note:e,highlight:t}){const n=ae(),{icon:a,rest:i}=HW(e.title),o=!a&&e.icon?un(iTe,e.icon):void 0;return s.jsxs("li",{className:"rn-note","data-highlight":t||void 0,"data-required":e.priority==="required"||void 0,"data-has-icon":!!o||void 0,children:[o&&s.jsx("span",{className:"rn-title-icon","aria-hidden":"true",children:s.jsx(o,{})}),s.jsxs("div",{children:[s.jsxs("h3",{className:"rn-note-title",children:[a&&s.jsx("span",{className:"rn-note-icon",children:a}),a?i:i.trimStart()]}),s.jsx("p",{className:"rn-note-body",children:au(nu(e.body))}),!t&&e.details&&s.jsx("p",{className:"rn-note-body rn-extra-detail",children:au(nu(e.details))}),e.notice&&s.jsxs("p",{className:"rn-note-notice",children:[s.jsxs("strong",{children:[e.noticeLabel??n("shell.notes.important"),": "]}),au(nu(e.notice))]})]})]})}function au(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?s.jsx("code",{className:"rn-code",children:t.text},n):s.jsx("strong",{className:"rn-strong",children:au(t.kids)},n))}function oTe({state:e,sessionId:t,onClose:n}){const a=ae(),i=m.useMemo(()=>rTe(e,t),[e,e.revision,t]),o=m.useRef(null),r=_t(n,{focusRef:o}),c=qt(n);return i?s.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:s.jsxs("div",{ref:r,className:"modal session-summary",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[s.jsxs("div",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:a("insights.summary.done")}),s.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),s.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("span",{className:"modal-dur",title:a("insights.summary.wall"),children:i.durationLabel}),s.jsx("button",{type:"button",ref:o,className:"glyph-btn",onClick:n,"aria-label":a("insights.audit.closeEsc"),title:a("insights.audit.closeEsc"),children:"×"})]})]}),s.jsxs("div",{className:"modal-body",children:[s.jsxs("section",{className:"ss-hero",children:[s.jsxs("div",{className:"ss-hero-left",children:[s.jsx("div",{className:"ss-cost-label",children:ple()}),s.jsx("div",{className:"ss-cost",children:At(i.cost.total)}),i.modelChips.length>0&&s.jsx("div",{className:"ss-models",children:i.modelChips.map(d=>s.jsx("span",{className:"model-chip","data-family":_m(d),title:d,children:wo(d)},d))})]}),s.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&s.jsxs(s.Fragment,{children:[s.jsx(KA,{cost:i.cost,size:"lg"}),s.jsxs("div",{className:"ss-cost-legend",children:[s.jsxs("span",{className:"ssl ssl-in",children:[a("insights.cost.input")," ",s.jsx("b",{children:At(i.cost.input)})]}),s.jsxs("span",{className:"ssl ssl-out",children:[a("insights.cost.output")," ",s.jsx("b",{children:At(i.cost.output)})]}),s.jsxs("span",{className:"ssl ssl-cr",children:[a("insights.summary.cacheR")," ",s.jsx("b",{children:At(i.cost.cacheRead)})]}),s.jsxs("span",{className:"ssl ssl-cw",children:[a("insights.summary.cacheW")," ",s.jsx("b",{children:At(i.cost.cacheWrite)})]})]})]})})]}),s.jsxs("section",{className:"ss-stats",children:[s.jsx(Oc,{label:a("insights.summary.agents"),value:i.agentCount}),s.jsx(Oc,{label:a("insights.summary.subagents"),value:i.subagentCount}),s.jsx(Oc,{label:a("insights.summary.toolCalls"),value:i.toolCount}),s.jsx(Oc,{label:a("insights.summary.prompts"),value:i.promptCount}),s.jsx(Oc,{label:a("insights.usage.tokens"),value:i.tokensSum.toLocaleString(qe())}),i.errCount>0&&s.jsx(Oc,{label:a("insights.summary.errors"),value:i.errCount,tone:"err"})]}),i.topTools.length>0&&s.jsxs("section",{className:"modal-section",children:[s.jsx("h4",{children:a("insights.summary.topTools")}),s.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([d,u])=>s.jsxs("div",{className:"ss-tt",children:[s.jsx("span",{className:"ss-tt-name",children:d}),s.jsx("span",{className:"ss-tt-bar",children:s.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/i.topTools[0][1]*100}%`}})}),s.jsx("span",{className:"ss-tt-count",children:u})]},d))})]}),i.firstPrompt&&s.jsxs("section",{className:"modal-section",children:[s.jsx("h4",{children:a("insights.summary.opening")}),s.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function Oc({label:e,value:t,tone:n}){return s.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[s.jsx("div",{className:"ss-stat-value",children:t}),s.jsx("div",{className:"ss-stat-label",children:e})]})}function rTe(e,t){const n=e.agents.get(t);if(!n)return null;const a=[];for(const j of e.agents.values())j.sessionId===t&&a.push(j);if(a.length===0)return null;const i={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,r=new Map;let c=0,d=0,u=0,p=0,g=0,f,v=1/0,k=0;for(const j of a){const A=fa(j);i.input+=A.input,i.output+=A.output,i.cacheRead+=A.cacheRead,i.cacheWrite+=A.cacheWrite,i.total+=A.total;for(const E of D2(j))o.add(E);j.model&&o.add(j.model),j.kind==="subagent"&&g++;const T=g2(j.prompts);d+=T.length,!f&&T.length>0&&(f=T[0].text),u+=j.usage.inputTokens+j.usage.outputTokens,c+=j.toolCount,p+=j.toolErrorCount??0;for(const[E,q]of j.toolCountByName??[])r.set(E,(r.get(E)??0)+q);v=Math.min(v,j.startedAt),k=Math.max(k,j.endedAt??Date.now())}const y=Math.max(0,k-v),N=Math.floor(y/1e3),w=N<60?`${N}s`:N<3600?`${Math.floor(N/60)}m ${String(N%60).padStart(2,"0")}s`:`${Math.floor(N/3600)}h ${Math.floor(N%3600/60)}m`,S=Array.from(r.entries()).sort((j,A)=>A[1]-j[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||C("insights.summary.session"),cwd:n.cwd,durationLabel:w,cost:i,modelChips:Array.from(o),agentCount:a.length,subagentCount:g,toolCount:c,promptCount:d,tokensSum:u,errCount:p,topTools:S,firstPrompt:f}}function Yt({id:e,title:t,note:n,noteId:a,aside:i,list:o=!0,settingId:r,className:c,children:d}){const u=c?`settings-group ${c}`:"settings-group",p=o?s.jsx("div",{className:"settings-list",children:d}):d;return t===void 0?s.jsx("div",{className:u,"data-setting":r,children:p}):s.jsxs("section",{className:u,"aria-labelledby":e,"data-setting":r,children:[s.jsxs("div",{className:"settings-caption",children:[s.jsxs("div",{className:"settings-caption-text",children:[s.jsx("h3",{id:e,children:t}),n&&s.jsx("p",{className:"settings-caption-note",id:a,children:n})]}),i]}),p]})}function Ct({name:e,nameId:t,note:n,noteId:a,control:i,as:o="label",settingId:r,className:c,details:d,children:u}){const p=ae(),g=o,f=s.jsxs(g,{className:c?`settings-row ${c}`:"settings-row","data-setting":r,children:[s.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&s.jsx("span",{className:"settings-row-note",id:a,children:n}),i!==void 0&&s.jsx("span",{className:"settings-row-control",children:i}),u]});return d?s.jsxs("div",{className:"settings-row-with-details",children:[f,s.jsxs("details",{className:"settings-row-details",children:[s.jsxs("summary",{children:[p("common.details"),s.jsxs("span",{className:"vis-hidden",children:[p("common.aboutBefore"),e,p("common.aboutAfter")]})]}),s.jsx("div",{children:d})]})]}):f}function cTe(){const e=ae(),t=Ea();return s.jsx(Yt,{id:"settings-language-caption",title:e("settings.language.group"),children:s.jsx(Ct,{settingId:"language",name:e("settings.language.name"),nameId:"settings-language-label",note:e("settings.language.note"),noteId:"settings-language-note",control:s.jsx("select",{className:"sm-select",value:t,"aria-labelledby":"settings-language-label","aria-describedby":"settings-language-note",onChange:n=>MX(n.target.value),children:yl.map(n=>s.jsx("option",{value:n.code,lang:n.code,dir:n.dir,children:qX(n)},n.code))})})})}function $W(e,t,n){const[a,i]=m.useState(null),[o,r]=m.useState(!1),[c,d]=m.useState(""),u=m.useRef(!1),p=f=>typeof f=="boolean"?f:t;return m.useEffect(()=>{let f=!0;return fetch("/api/prefs").then(v=>{if(!v.ok)throw new Error;return v.json()}).then(v=>{var k;if(!v.ok)throw new Error;f&&i(p((k=v.prefs)==null?void 0:k[e]))}).catch(()=>{f&&d(n("settings.recover.readFail"))}),()=>{f=!1}},[e]),{enabled:a,busy:o,error:c,change:async()=>{if(!(a===null||!Jn(u.current))){u.current=!0,r(!0),d("");try{const f=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:!a})});if(!f.ok)throw new Error;const v=await f.json();if(!v.ok)throw new Error;i(p(v.prefs[e]))}catch{d(n("settings.recover.saveFail"))}finally{u.current=!1,r(!1)}}}}}function eD({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,a=ae(),i=$W(t,!0,a);return s.jsxs(Yt,{id:`${n}-title`,title:a("settings.recover.group",{provider:e}),children:[s.jsx(Ct,{settingId:n,name:a("settings.recover.name"),note:a(e==="Codex"?"settings.recover.codexNote":"settings.recover.claudeNote"),details:a(e==="Codex"?"settings.recover.codexDetails":"settings.recover.claudeDetails"),control:s.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":a(e==="Codex"?"settings.recover.codexAria":"settings.recover.claudeAria"),"aria-checked":i.enabled===!0,...ga(i.busy,i.enabled===null),onClick:()=>{i.change()},children:s.jsx("span",{className:"switch-knob"})})}),i.error&&s.jsx("p",{role:"alert",children:i.error}),e==="Claude"&&s.jsx(lTe,{t:a})]})}function lTe({t:e}){const t=$W("continueStopped",!1,e);return s.jsxs(s.Fragment,{children:[s.jsx(Ct,{settingId:"claude-continue-stopped",name:e("settings.recover.continueName"),note:e("settings.recover.continueNote"),details:e("settings.recover.continueDetails"),control:s.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":e("settings.recover.continueAria"),"aria-checked":t.enabled===!0,...ga(t.busy,t.enabled===null),onClick:()=>{t.change()},children:s.jsx("span",{className:"switch-knob"})})}),t.error&&s.jsx("p",{role:"alert",children:t.error})]})}function dTe(){const e=ae(),t=aW();return s.jsx(Yt,{id:"settings-board-caption",title:e("settings.board.title"),children:s.jsx(Ct,{settingId:"hide-finished",name:e("settings.board.hideLabel"),nameId:"settings-hide-finished-label",note:e("settings.board.hideNote"),details:e("settings.board.hideDetails"),noteId:"settings-hide-finished-note",control:s.jsx("select",{className:"sm-select",value:t,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:n=>Qxe(Number(n.target.value)),children:Q4.map(n=>s.jsx("option",{value:n,children:n===0?e("settings.board.never"):e("settings.board.minutes",{n})},n))})})})}const uTe="Codex accounts",hTe="Your Codex profiles and what each has left, and which one new sessions use.";function pTe({claudeHere:e,codexHere:t=!1,singleKeys:n,doors:a}){const i=ae();return s.jsxs(Yt,{id:"settings-elsewhere-caption",title:i("lan.ew.group"),children:[(e||t)&&s.jsx(DS,{settingId:"accounts",name:e?i("lan.ew.accounts"):uTe,note:e?i("lan.ew.accountsNote"):hTe,onOpen:a.accounts,cap:n?{key:"A",title:i("lan.ew.pressA")}:null}),e&&s.jsx(DS,{settingId:"local-network",name:i("lan.ew.lan"),note:i("lan.ew.lanNote"),onOpen:a.localNetwork,cap:null}),s.jsx(DS,{settingId:"browser-watch",name:i("lan.ew.watch"),note:i("lan.ew.watchNote"),onOpen:a.browserWatch,dialog:!0,cap:n?{key:"B",title:i("lan.ew.pressB")}:null})]})}function DS({settingId:e,name:t,note:n,onOpen:a,cap:i,dialog:o=!1}){const r=ae(),c=`settings-${e}`;return s.jsx(Ct,{as:"div",settingId:e,name:t,nameId:`${c}-name`,note:n,control:s.jsxs(s.Fragment,{children:[i&&s.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:i.title,children:i.key}),s.jsx("button",{type:"button",className:"btn",id:`${c}-open`,"aria-labelledby":`${c}-open ${c}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":i?i.key:void 0,onClick:a,children:r("lan.ew.open")})]})})}function gTe(e){const t=e.binds.includes("?")?C("settings.keyboard.sheetName"):e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function mTe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(a=>a.toLowerCase().includes(n)):!0}function fTe({singleKeys:e,onToggleSingleKeys:t}){const n=ae(),a=zo(Co()),[i,o]=m.useState(""),r=m.useId(),c=Xu(),d=FW(e,u=>yi(c,u)).map(u=>({...u,rows:u.rows.filter(p=>mTe(p,i))})).filter(u=>u.rows.length>0);return s.jsxs(s.Fragment,{children:[s.jsx(Yt,{children:s.jsx(Ct,{settingId:"single-keys",name:n("settings.keyboard.singleKeys"),nameId:"settings-single-keys-label",note:n("settings.keyboard.singleKeysNote"),noteId:"settings-single-keys-note",control:s.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:s.jsx("span",{className:"switch-knob"})})})}),s.jsxs("div",{className:"settings-filter",children:[s.jsx("label",{className:"vis-hidden",htmlFor:r,children:n("settings.keyboard.filter")}),s.jsx("input",{id:r,type:"search",className:"settings-filter-field",placeholder:n("settings.keyboard.filter"),autoComplete:"off",spellCheck:!1,value:i,onChange:u=>o(u.target.value),onKeyDown:u=>{Pm(u.key)&&i&&(u.stopPropagation(),o(""))}})]}),d.map(u=>{const p=`settings-keys-${u.id}`;return s.jsx(Yt,{id:p,title:u.title,className:"settings-keys",children:u.rows.map(g=>s.jsx(Ct,{as:"div",name:gTe(g),control:s.jsx("kbd",{className:"settings-key",children:a&&g.macCap?g.macCap:g.cap})},`${g.cap}:${g.action}`))},u.id)}),d.length===0&&s.jsx("p",{className:"settings-empty",role:"status",children:n("settings.keyboard.noMatch",{query:i.trim()})}),i.trim()===""&&s.jsx("p",{className:"settings-foot",children:n("settings.key.note")})]})}function bTe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:a,onAskNotify:i,accountNotify:o,onToggleAccountNotify:r}){const c=ae(),d=Qoe(a,c),u=Eo(),p=e&&!n&&!u,g=m.useRef(null),f=Ps(!d.ask,g);return s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{id:"sm-closed-caption",title:c("settings.notify.closedGroup"),children:[s.jsx(Ct,{settingId:"notify-closed",name:c("settings.notify.closedName"),nameId:"sm-notify-label",note:n?c("settings.notify.veto"):Xoe(u,c),noteId:"sm-notify-note",control:s.jsx("button",{ref:g,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":"sm-notify-note",className:"switch",onClick:t,children:s.jsx("span",{className:"switch-knob"})})}),p&&s.jsx(Ct,{as:"div",name:c("settings.notify.browserName"),nameId:"sm-channel-name",note:d.note,control:d.ask?s.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{f(),i()},children:c("settings.notify.enable")}):s.jsxs("span",{className:"sm-channel-state","data-ok":d.ok||void 0,children:[d.ok&&s.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:s.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),d.status]})})]}),s.jsx(Yt,{id:"sm-accounts-caption",title:c("settings.notify.accountsGroup"),note:c(n?"settings.notify.accountsVeto":"settings.notify.accountsNote"),children:TN.map(({kind:v,label:k,title:y})=>s.jsx(Ct,{settingId:v,name:k,nameId:`sm-${v}-label`,note:y,noteId:`sm-${v}-note`,control:s.jsx("button",{type:"button",role:"switch","aria-checked":o[v],"aria-labelledby":`sm-${v}-label`,"aria-describedby":`sm-${v}-note`,className:"switch",onClick:()=>r(v),children:s.jsx("span",{className:"switch-knob"})})},v))})]})}const vTe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function kTe(e){return vTe.find(t=>e(t))}const wTe=4400;function yTe(e){const t=e.split(";")[0],n=t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm";return{name:`${C("radio.rec.name")}.${n}`,type:t}}function xTe({full:e,setCustomError:t,runCustom:n,onImportCustom:a}){const[i,o]=m.useState(!1),r=m.useRef(null),c=m.useRef(null),d=m.useRef(!1),u=()=>{var g;c.current!==null&&clearTimeout(c.current),c.current=null,((g=r.current)==null?void 0:g.state)==="recording"&&r.current.stop()},p=async()=>{var f;if(e)return;if(t(""),!((f=navigator.mediaDevices)!=null&&f.getUserMedia)||typeof MediaRecorder>"u"){t(C("radio.rec.noMic"));return}let g;try{g=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t(C("radio.rec.denied"));return}if(d.current||r.current){g.getTracks().forEach(v=>v.stop());return}try{const v=kTe(N=>MediaRecorder.isTypeSupported(N)),k=new MediaRecorder(g,v?{mimeType:v}:void 0),y=[];r.current=k,k.ondataavailable=N=>{N.data.size&&y.push(N.data)},k.onerror=()=>t(C("radio.rec.failed")),k.onstop=()=>{g.getTracks().forEach(j=>j.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const N=r.current===k;if(N&&(r.current=null),o(!1),!N||!y.length)return;const w=yTe(k.mimeType),S=new File(y,w.name,{type:w.type});n(()=>a(S))},k.start(200),o(!0),c.current=setTimeout(u,wTe)}catch{r.current=null,g.getTracks().forEach(v=>v.stop()),t(C("radio.rec.format"))}};return m.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const g=r.current;r.current=null,(g==null?void 0:g.state)==="recording"&&g.stop()}),[]),{recording:i,startRecording:p,stopRecording:u}}function CTe({full:e,fullProps:t,runCustom:n,onCreateVoice:a}){const i=ae(),[o,r]=m.useState(()=>i("settings.sounds.voice.defaultName")),[c,d]=m.useState(()=>i("settings.sounds.voice.defaultText")),[u,p]=m.useState(""),[g,f]=m.useState("1"),[v,k]=m.useState("1"),[y,N]=m.useState([]);return m.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const w=()=>{N(window.speechSynthesis.getVoices())};return w(),window.speechSynthesis.addEventListener("voiceschanged",w),()=>window.speechSynthesis.removeEventListener("voiceschanged",w)},[]),s.jsxs("details",{className:"sm-voice",children:[s.jsxs("summary",{className:"settings-row",...t,onClick:w=>{const S=w.currentTarget.parentElement;e&&S&&!S.open&&w.preventDefault()},children:[s.jsx("span",{className:"settings-row-name",children:i("settings.sounds.voice.title")}),s.jsx("span",{className:"settings-row-note",children:i("settings.sounds.voice.note")}),s.jsx("span",{className:"settings-row-control",children:s.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:s.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),s.jsxs("div",{className:"sm-voice-fields",children:[s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.name")}),s.jsx("input",{className:"ap-manage-input",value:o,maxLength:80,onChange:w=>r(w.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.text")}),s.jsx("input",{className:"ap-manage-input",value:c,maxLength:180,onChange:w=>d(w.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.voice")}),s.jsxs("select",{className:"sm-select",value:u,onChange:w=>p(w.target.value),children:[s.jsx("option",{value:"",children:i("settings.sounds.voice.default")}),y.map(w=>s.jsx("option",{value:w.voiceURI,children:w.name},w.voiceURI))]})]}),s.jsxs("div",{className:"sm-voice-pair",children:[s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.rate")}),s.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:w=>f(w.target.value)})]}),s.jsxs("label",{children:[s.jsx("span",{children:i("settings.sounds.voice.pitch")}),s.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:v,onChange:w=>k(w.target.value)})]})]}),s.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await a({name:o,text:c,voiceURI:u,rate:parseFloat(g),pitch:parseFloat(v)}),d(i("settings.sounds.voice.defaultText"))})},children:i("settings.sounds.voice.add")})]})]})}function STe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:a,onPreviewCustom:i,onDeleteCustom:o}){const r=ae(),[c,d]=m.useState(""),u=e.length,p=EN(u),g=p!==null,f=g?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[v,k]=m.useState(null),y=m.useRef(0),N=m.useRef(new Map),w=m.useRef(null),S=m.useRef(null);m.useEffect(()=>{if(!v)return;const F=window.setTimeout(()=>k(null),4e3);return()=>window.clearTimeout(F)},[v]);const j=async F=>{d("");try{await F()}catch(z){d(So(z,r("settings.sounds.custom.saveFail")))}},A=(F,z)=>{const H=Date.now(),I=zr({armedFor:v,target:F,armedAt:y.current,now:H,gapMs:qr});if(I==="arm"){k(F),y.current=H;return}if(I==="ignore")return;k(null);const L=rre(e.map(O=>O.id),F);j(async()=>{var _;await o(F);const O=document.activeElement;O!==z&&!Xn((O==null?void 0:O.tagName)??null)||(_=L?N.current.get(L):w.current)==null||_.focus()})},{recording:T,startRecording:E,stopRecording:q}=xTe({full:g,setCustomError:d,runCustom:j,onImportCustom:t});return s.jsxs(Yt,{id:"sm-custom-title",title:r("settings.sounds.custom.title"),note:r("settings.sounds.custom.note"),aside:s.jsx("span",{className:"settings-caption-count",children:r("settings.sounds.custom.count",{count:u,max:RN})}),className:"sm-custom",settingId:"custom-sounds",children:[g&&s.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:p}),s.jsx(Ct,{as:"div",settingId:"custom-import",name:r("settings.sounds.custom.import"),note:r("settings.sounds.custom.importNote"),control:s.jsx("button",{ref:w,type:"button",className:"btn sm-custom-action",...f,onClick:()=>{var F;g||(F=S.current)==null||F.click()},children:r("settings.sounds.custom.chooseFile")}),children:s.jsx("input",{ref:S,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:F=>{var H;const z=(H=F.target.files)==null?void 0:H[0];F.currentTarget.value="",z&&!g&&j(()=>t(z))}})}),s.jsx(Ct,{as:"div",settingId:"custom-record",name:r("settings.sounds.custom.record"),note:r(T?"settings.sounds.custom.recording":"settings.sounds.custom.upTo5"),control:T?s.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:q,children:r("settings.sounds.custom.stopSave")}):s.jsx("button",{type:"button",className:"btn sm-custom-action",...f,onClick:()=>void E(),children:r("settings.sounds.custom.recordBtn")})}),s.jsx(CTe,{full:g,fullProps:f,runCustom:j,onCreateVoice:n}),e.map(F=>s.jsxs("div",{className:"sm-custom-item",children:[s.jsx("input",{className:"ap-manage-input","aria-label":r("settings.sounds.custom.rename",{name:F.name}),defaultValue:F.name,maxLength:80,onBlur:z=>{if(!z.target.value.trim()){z.target.value=F.name;return}j(()=>a(F.id,z.target.value))},onKeyDown:z=>{z.key==="Enter"&&z.currentTarget.blur()}}),s.jsx("span",{children:F.kind==="audio"?`${wA(F.duration,1)}s`:r("settings.sounds.custom.voice")}),s.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":r("settings.sounds.custom.playName",{name:F.name}),onClick:()=>i(F.id),children:r("settings.sounds.custom.play")}),s.jsx("button",{type:"button",ref:z=>{z?N.current.set(F.id,z):N.current.delete(F.id)},className:`btn sm-custom-icon${v===F.id?" armed":""}`,onKeyDown:z=>{z.repeat&&z.preventDefault()},onClick:z=>A(F.id,z.currentTarget),"aria-label":v===F.id?r("settings.sounds.custom.confirmName",{name:F.name}):r("settings.sounds.custom.deleteName",{name:F.name}),title:v===F.id?r("settings.sounds.custom.deleteAgain"):r("settings.sounds.custom.deleteTip"),children:v===F.id?r("settings.sounds.custom.confirm"):r("settings.sounds.custom.delete")})]},F.id)),c&&s.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:c})]})}function NTe({soundOn:e,onToggleSound:t}){const n=ae(),a=m.useId(),i=Qn(),o=m.useId();return s.jsx(Yt,{children:s.jsx(Ct,{settingId:"play-sounds",name:n("radio.sound.name"),nameId:a,note:n("radio.sound.note"),noteId:o,control:s.jsxs(s.Fragment,{children:[i&&s.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:n("radio.sound.keyTitle"),children:"M"}),s.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":a,"aria-describedby":o,"aria-keyshortcuts":i?"M":void 0,className:"switch",onClick:t,children:s.jsx("span",{className:"switch-knob"})})]})})})}const Aj="custom:";function tD(e){return`${Aj}${e}`}function jTe(e){return e.startsWith(Aj)?e.slice(Aj.length):null}function ATe({id:e,label:t,value:n,step:a=IA,onLevel:i,"aria-describedby":o}){const r=ae();return s.jsxs("div",{className:"sm-row",children:[s.jsx("label",{htmlFor:e,children:t??r("radio.volume")}),s.jsx("input",{id:e,type:"range",min:fg,max:Zg,step:a,value:n,"aria-describedby":o,onChange:c=>i(Number(c.target.value)),style:{"--sm-level":`${(n-fg)/(Zg-fg)*100}%`}}),s.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const nD={get done(){return C("settings.sounds.tone.done")},get"needs-input"(){return C("settings.sounds.tone.needsInput")}},TTe={get done(){return C("settings.sounds.tone.doneNote")},get"needs-input"(){return C("settings.sounds.tone.needsInputNote")}};function RTe({chime:e,tone:t,soundOn:n,customAssets:a,customSelections:i,onLevel:o,onFigure:r,onPreview:c,onBuiltInSelected:d,onCustomSelected:u}){const p=ae(),g=`sm-level-${e}`,f=`sm-figure-${e}`,v=i[e];return s.jsxs(Yt,{id:`sm-name-${e}`,title:nD[e],note:TTe[e],settingId:`tone-${e}`,aside:s.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":p("settings.sounds.hearAria",{tone:nD[e]}),title:p(n?"settings.sounds.hearTip":"settings.sounds.hearTipMuted"),"aria-describedby":n?void 0:"sm-preview-note",children:[s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),p("settings.sounds.hear")]}),children:[s.jsx(ATe,{id:g,value:t.level,onLevel:k=>o(e,k)}),s.jsxs("div",{className:"sm-row",children:[s.jsx("label",{htmlFor:f,children:p("settings.sounds.toneLabel")}),s.jsxs("select",{id:f,className:"sm-select",value:v?tD(v):t.figure,onChange:k=>{const y=k.target.value,N=jTe(y);N!==null?u(e,N):(d(e),r(e,y))},children:[MA[e].map(k=>s.jsx("option",{value:k.id,children:k.label},k.id)),a.length>0&&s.jsx("optgroup",{label:p("settings.sounds.customGroup"),children:a.map(k=>s.jsx("option",{value:tD(k.id),children:k.name},k.id))})]})]})]})}function ETe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:a,onLevel:i,onFigure:o,onPreview:r,customAssets:c,customSelections:d,onBuiltInSelected:u,onCustomSelected:p,onImportCustom:g,onCreateVoice:f,onRenameCustom:v,onPreviewCustom:k,onDeleteCustom:y}){var A;const N=ae(),w=ire(d),S=((A=c.find(T=>T.id===w))==null?void 0:A.name)??N("settings.sounds.sharedName"),j=w?N("settings.sounds.sharedNote",{name:S}):"";return s.jsxs("div",{className:"sm-sounds",children:[s.jsx(NTe,{soundOn:e,onToggleSound:t}),!a&&s.jsx("p",{className:"sm-note",children:N("settings.sounds.codexOnly")}),!e&&s.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:N("settings.sounds.previewNote")}),s.jsx("div",{className:"sm-tones",children:Jd.map(T=>s.jsx(RTe,{chime:T,tone:n[T],soundOn:e,customAssets:c,customSelections:d,onLevel:i,onFigure:o,onPreview:r,onBuiltInSelected:u,onCustomSelected:p},T))}),j&&s.jsx("p",{className:"sm-note","aria-hidden":!0,children:j}),s.jsx("p",{className:"vis-hidden",role:"status",children:j}),s.jsx(STe,{customAssets:c,onImportCustom:g,onCreateVoice:f,onRenameCustom:v,onPreviewCustom:k,onDeleteCustom:y})]})}function _Te({onOpen:e}){const t=ae();return s.jsx(Yt,{children:s.jsx(Ct,{as:"div",settingId:"radar-open",name:t("radar.name"),nameId:"settings-radar-open-name",note:t("radar.note"),control:s.jsx("button",{type:"button",className:"btn",id:"settings-radar-open","aria-labelledby":"settings-radar-open settings-radar-open-name","aria-haspopup":"dialog",onClick:e,children:t("radar.open")})})})}const qTe=6500,zTe=1e4;let jr={reading:null,saving:null,error:"",undone:null};const Cg=new Set;let Ed=null,_d=null,ji=null,FS=!1,Sg=0;const hr=e=>{jr={...jr,...e},Cg.forEach(t=>t(jr))};function VW(e){const t=e;return!!t&&t.ok===!0&&Array.isArray(t.settings)&&typeof t.present=="object"}async function KW(e){const t=await fetch("/api/claude-settings",{signal:e}),n=await t.json();if(!t.ok||!VW(n))throw new Error;return n}async function Tj(){if(FS||jr.saving)return;FS=!0;const e=Sg,t=new AbortController;ji=t;let n=!1;const a=setTimeout(()=>{n=!0,t.abort()},5e3);try{const i=await KW(t.signal);e===Sg&&!t.signal.aborted&&hr({reading:i,error:""})}catch{e===Sg&&(n||!t.signal.aborted)&&hr({error:C("settings.claude.readFail")})}finally{clearTimeout(a),FS=!1,ji===t&&(ji=null)}}function aD(e,t){var n;return(n=e==null?void 0:e.settings.find(a=>a.id===t))==null?void 0:n.value}async function sD(e,t){if(jr.saving)return;Sg++,ji==null||ji.abort(),_d&&(clearTimeout(_d),_d=null),hr({saving:e,error:"",undone:null});const n=new AbortController,a=setTimeout(()=>n.abort(),15e3);try{const i=await fetch("/api/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,value:t}),signal:n.signal}),o=await i.json().catch(()=>null);if(!i.ok||!VW(o))throw new Ln(typeof(o==null?void 0:o.error)=="string"&&o.error?Ng(o.error):C("settings.claude.saveFail"));hr({reading:o});const r=aD(o,e);_d=setTimeout(()=>{_d=null;const c=new AbortController,d=setTimeout(()=>c.abort(),5e3);KW(c.signal).then(u=>{hr({reading:u,undone:aD(u,e)===r?null:{id:e}})}).catch(()=>{}).finally(()=>clearTimeout(d))},qTe)}catch(i){hr({error:So(i,C("settings.claude.saveFail"))})}finally{clearTimeout(a),hr({saving:null})}}const LTe={"Your settings.json is not valid JSON, so Claude Code skips all of it, hooks included. Fix it in an editor; this section reads it again by itself.":"settings.claude.reason.invalid","Your settings.json could not be read here, so nothing is shown or changed until it can.":"settings.claude.reason.unreadable","Your organization's settings could not be read, so nothing here can be changed until they can.":"settings.claude.reason.othersUnknown","Set by your organization. Ask your administrator to change it.":"settings.claude.reason.locked","Your settings.json holds a custom value. Edit it there.":"settings.claude.reason.custom","Choose a setting this section offers and one of its values.":"settings.claude.reason.choose","Your settings.json could not be read as JSON. No changes were saved.":"settings.claude.reason.parse","Your settings.json changed while saving. Nothing was written. Try again.":"settings.claude.reason.changed","Claude Code settings can be changed on this computer only.":"settings.claude.reason.localOnly","Could not read Claude Code settings. Try again.":"settings.claude.reason.readFail","Could not save the change. Your settings.json was not modified.":"settings.claude.reason.notSaved","Your settings.json has a permissions value that is not an object. No changes were saved.":"settings.claude.reason.permissionsShape","Your settings.json has a permissions.deny value that is not a list. No changes were saved.":"settings.claude.reason.denyShape","Your settings.json holds a custom attribution. Edit it there.":"settings.claude.reason.attribution"};function Ng(e,t=C){const n=LTe[e];if(n)return t(n);const a=/^Needs Claude Code (\S+) or newer(, and the version installed here could not be read)?\.$/.exec(e);return a?t(a[2]?"settings.claude.reason.needsUnread":"settings.claude.reason.needs",{version:a[1]}):a3(e,t)}function OTe(){const[e,t]=m.useState(jr);return m.useEffect(()=>(Cg.add(t),t(jr),Ed||(Tj(),Ed=setInterval(()=>void Tj(),zTe)),()=>{Cg.delete(t),Cg.size||(Ed&&clearInterval(Ed),Ed=null,ji==null||ji.abort())}),[]),e}const US=40,PTe=(e,t)=>{const n=`settings.claudeTopic.${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}`,a=t(n);return a===n?e:a},MTe={boolean:"settings.claudeIndex.kind.boolean",choice:"settings.claudeIndex.kind.choice",number:"settings.claudeIndex.kind.number",text:"settings.claudeIndex.kind.text",structured:"settings.claudeIndex.kind.structured"};function ITe(e,t=C){const n=e.scope==="Global config"?t("settings.claudeIndex.globalConfig"):e.scope==="Managed"?t("settings.claudeIndex.managedOnly"):null;return[e.topic?PTe(e.topic,t):e.topic,t(MTe[e.kind]),n,e.since?t("settings.claudeIndex.since",{since:e.since}):null].filter(Boolean).join(" · ")}function DTe(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=e.filter(o=>o.key.toLowerCase().includes(n)),i=e.filter(o=>!a.includes(o)&&(o.topic??"").toLowerCase().includes(n));return[...a,...i]}let JW=null;const FTe=()=>JW??(JW=Pr(()=>import("./claude-settings-index-1Qg1AUda.js"),[]).then(e=>e.default.keys));function UTe({present:e,noFile:t=!1}){const n=ae(),a=Ea(),[i,o]=m.useState(null),[r,c]=m.useState(""),d=m.useId();m.useEffect(()=>{let f=!0;return FTe().then(v=>{f&&o(v)},()=>{JW=null}),()=>{f=!1}},[]);const u=m.useMemo(()=>{if(!i)return[];if(r.trim())return DTe(i,r);if(!e)return[];const f=i.filter(k=>Object.hasOwn(e,k.key)),v=Object.keys(e).filter(k=>!i.some(y=>y.key===k)).sort().map(k=>({key:k,topic:C("settings.claudeIndex.notInRef"),scope:null,kind:"structured",default:null,since:null,anchor:""}));return[...f,...v]},[i,e,r,a]),p=u.slice(0,US),g=r.trim()!=="";return s.jsxs(Yt,{id:"claude-group-all",settingId:"claude-all-settings",title:n("settings.claudeIndex.title"),note:g?void 0:n(e&&!t?"settings.claudeIndex.notePresent":"settings.claudeIndex.noteAll"),aside:i?s.jsx("span",{className:"settings-caption-count",children:i.length}):void 0,list:!1,children:[s.jsxs("div",{className:"settings-filter",children:[s.jsx("label",{className:"vis-hidden",htmlFor:d,children:n("settings.claudeIndex.filterLabel")}),s.jsx("input",{id:d,type:"search",className:"settings-filter-field",placeholder:i?n("settings.claudeIndex.filterCount",{count:i.length}):n("settings.claudeIndex.filter"),autoComplete:"off",spellCheck:!1,value:r,onChange:f=>c(f.target.value),onKeyDown:f=>{Pm(f.key)&&r&&(f.stopPropagation(),c(""))}})]}),p.length>0&&s.jsx("div",{className:"settings-list settings-keys",children:p.map(f=>{const v=e&&Object.hasOwn(e,f.key)?e[f.key]:null;return s.jsx(Ct,{as:"div",name:s.jsx("code",{className:"claude-key",children:f.key}),note:ITe(f,n),control:s.jsxs(s.Fragment,{children:[v!==null&&s.jsx("span",{className:"settings-read",title:n("settings.claudeIndex.inFile"),children:v}),f.anchor&&s.jsx("a",{className:"settings-link",href:`${Voe}#${f.anchor}`,target:"_blank",rel:"noreferrer","aria-label":n("settings.claudeIndex.referenceAria",{key:f.key}),children:n("settings.claudeIndex.reference")})]})},f.key)})}),g&&u.length===0&&i&&s.jsx("p",{className:"settings-empty",role:"status",children:n("settings.claudeIndex.noMatch",{query:r.trim()})}),u.length>US&&s.jsx("p",{className:"settings-foot",role:"status",children:n("settings.claudeIndex.more",{count:u.length-US})}),!g&&e&&!t&&i&&u.length===0&&s.jsx("p",{className:"settings-empty",children:n("settings.claudeIndex.empty")})]})}function BTe(e,t=C){return t("settings.claude.foot",{file:e??t("settings.claude.footDefault")})}const iD={Off:"settings.claude.effect.off",On:"settings.claude.effect.on","Updates are off":"settings.claude.effect.updatesOff","Background updates are off":"settings.claude.effect.bgUpdatesOff"};function HTe(e,t=C){const n=`${e.env}=${e.value}`,a=iD[e.effect]?t(iD[e.effect]):e.effect;return e.where==="environment"?t("settings.claude.overrideEnv",{effect:a,set:n}):t(e.where==="user"?"settings.claude.overrideUser":"settings.claude.overrideOrg",{effect:a,set:n})}const oD="\0custom";function WTe({entry:e,row:t,saving:n,nameId:a,noteId:i}){const o=ae(),r=!!t&&t.editable&&!n,c=!t||n===e.id,d=t?!t.editable:void 0;if(e.kind==="choice"||e.kind==="days"){const p=e.kind==="days"?e.options.map(v=>({value:String(v),label:k_(v,o)})):e.options.map(v=>({...v,label:Joe(e.id,v.value,v.label,o)})),g=t?t.custom?oD:t.value===null?"":String(t.value):"",f=e.kind==="days"&&t&&!t.custom&&!p.some(v=>v.value===g)?[...p,{value:g,label:k_(Number(g),o)}].sort((v,k)=>Number(v.value)-Number(k.value)):p;return s.jsxs("select",{className:"sm-select","aria-labelledby":a,"aria-describedby":i,"aria-busy":c,disabled:d,value:g,onChange:v=>{if(!r)return;const k=v.target.value;sD(e.id,e.kind==="days"?Number(k):k===""?null:k)},children:[(t==null?void 0:t.custom)&&s.jsx("option",{value:oD,disabled:!0,children:o("settings.claude.customValue")}),f.map(v=>s.jsx("option",{value:v.value??"",children:v.label},v.value??""))]})}const u=(t==null?void 0:t.value)===!0;return s.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":u,"aria-labelledby":a,"aria-describedby":i,"aria-busy":c,disabled:d,onClick:()=>{r&&sD(e.id,!u)},children:s.jsx("span",{className:"switch-knob"})})}function GTe(e){if(!(e!=null&&e.settings.length)||e.settings.some(n=>n.editable))return null;const t=new Set(e.settings.map(n=>n.reason));return t.size===1?[...t][0]??null:null}function $Te(){return s.jsx(VTe,{state:OTe()})}function VTe({state:e}){const t=ae(),{reading:n,saving:a,error:i,undone:o}=e,r=GTe(n),c=(n==null?void 0:n.userFile)==="absent",d=n?n.userFile!=="invalid"&&n.userFile!=="unreadable":!i;return s.jsxs(s.Fragment,{children:[(n===null||i||r||c)&&s.jsxs(Yt,{children:[n===null&&!i&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.reading")}),r&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:Ng(r,t)}),c&&!r&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:t("settings.claude.noFile")}),i&&s.jsxs("div",{className:"settings-row",role:"alert",children:[s.jsx("span",{className:"settings-row-name",children:Ng(i,t)}),s.jsx("span",{className:"settings-row-control",children:s.jsx("button",{type:"button",className:"btn","aria-busy":!!a,onClick:()=>void Tj(),children:t("settings.claude.retry")})})]})]}),d&&dB.map(u=>s.jsx(Yt,{id:`claude-group-${u.id}`,title:hB(u.id,u.title,t),children:uB.filter(p=>p.group===u.id).map(p=>{const g=n==null?void 0:n.settings.find(y=>y.id===p.id),f=`claude-${p.id}-label`,v=`claude-${p.id}-note`,k=g&&!g.editable&&!r?Ng(g.reason??"",t):(o==null?void 0:o.id)===p.id?t("settings.claude.undone"):g!=null&&g.override?HTe(g.override,t):"";return s.jsx(Ct,{settingId:`claude-${p.id}`,name:pB(p,t),nameId:f,note:Koe(p,t),noteId:v,control:s.jsx(WTe,{entry:p,row:g,saving:a,nameId:f,noteId:v}),children:s.jsx("span",{className:"settings-row-said settings-row-said-quiet",role:"status",children:k})},p.id)})},u.id)),d&&s.jsx("p",{className:"settings-foot",children:BTe(n==null?void 0:n.fileShown,t)}),s.jsx(UTe,{present:(n==null?void 0:n.present)??null,noFile:c})]})}function KTe(){const e=ae(),[t,n]=m.useState(null),[a,i]=m.useState(""),[o,r]=m.useState(!1),[c,d]=m.useState(null),[u,p]=m.useState(""),g=m.useRef(!1),f=m.useRef(!0),v=async()=>{if(g.current)return;g.current=!0,r(!0),i("");const N=new AbortController,w=window.setTimeout(()=>N.abort(),12e3);try{const S=await fetch("/api/tool-audit/storage",{signal:N.signal}),j=await S.json();if(!S.ok||!j.ok)throw new Error;f.current&&n(j)}catch{f.current&&i(e("settings.tools.readFail"))}finally{window.clearTimeout(w),g.current=!1,f.current&&r(!1)}};m.useEffect(()=>(f.current=!0,v(),()=>{f.current=!1}),[]);const k=async(N,w)=>{if(g.current)return;g.current=!0,r(!0),i(""),p("");let S=!1;const j=new AbortController,A=window.setTimeout(()=>j.abort(),15e3);try{const T=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N==="clear"?{action:N,confirm:!0}:{action:N,days:w}),signal:j.signal}),E=await T.json();if(!T.ok||!E.ok)throw new Error;S=!0,f.current&&(d(null),p(N==="clear"?e("settings.tools.cleared"):e("settings.tools.retentionChanged",{days:w??0})))}catch{f.current&&i(e("settings.tools.updateFail"))}finally{window.clearTimeout(A),g.current=!1,f.current&&(r(!1),S&&v())}},y=c!==null&&s.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":e("settings.tools.confirm"),children:[s.jsx("p",{children:c==="clear"?e("settings.tools.confirmClear"):e("settings.tools.confirmKeep",{days:c})}),s.jsxs("div",{children:[s.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{k(c==="clear"?"clear":"retention",typeof c=="number"?c:void 0)},children:e(c==="clear"?"settings.tools.deleteBtn":"settings.tools.applyBtn")}),s.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{g.current||d(null)},children:e("settings.tools.cancel")})]})]});return s.jsxs(Yt,{id:"tool-history-settings-title",title:e("settings.tools.title"),note:e("settings.tools.note"),className:"ta-settings",children:[t?s.jsxs(s.Fragment,{children:[s.jsx(Ct,{settingId:"tool-history-retention",name:e("settings.tools.keep"),nameId:"ta-keep-label",note:e("settings.tools.keepNote"),control:s.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:t.retentionDays,"aria-busy":o,onChange:N=>{if(g.current)return;const w=Number(N.target.value);w<t.retentionDays?d(w):k("retention",w)},children:[30,60,90].map(N=>s.jsx("option",{value:N,children:e("settings.tools.days",{count:N})},N))})}),typeof c=="number"&&y,s.jsx(Ct,{as:"div",settingId:"tool-history-size",name:e("settings.tools.space"),note:e("settings.tools.since",{date:Xre(t.startedAt)}),control:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"settings-read",children:Zre(t.bytes)}),s.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{v()},children:e("settings.tools.refresh")})]})}),s.jsx(Ct,{as:"div",settingId:"tool-history-clear",name:e("settings.tools.clear"),note:e("settings.tools.clearNote"),control:s.jsx("button",{type:"button",className:"btn danger","aria-busy":o,onClick:()=>{g.current||d("clear")},children:e("settings.tools.clearBtn")})}),c==="clear"&&y,!t.storageOk&&s.jsx(Ct,{as:"div",name:e("settings.tools.unsaved"),note:e("settings.tools.unsavedNote")})]}):s.jsx(Ct,{as:"div",name:e(o?"settings.tools.reading":"settings.tools.unavailable")}),a&&s.jsxs("div",{className:"settings-row",role:"alert",children:[s.jsx("span",{className:"settings-row-name",children:a}),s.jsx("span",{className:"settings-row-control",children:s.jsx("button",{type:"button",className:"btn","aria-busy":o,onClick:()=>{v()},children:e("settings.tools.retry")})})]}),u&&s.jsx("p",{className:"settings-row settings-row-status",role:"status",children:u})]})}const Rj="agent-dag.integrations.active",YT=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,JTe=32e3;function rD(e,t){const n=ht(YT(e,t));if(!n)return{};try{const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}}function a1e(e,t){return{read(n,a){const i=rD(e,t)[n];return a(i)?i:void 0},write(n,a){const i=rD(e,t);a===void 0?delete i[n]:i[n]=a;const o=JSON.stringify(i);o.length<=JTe&&pt(YT(e,t),o)}}}function YTe(e,t){Va(YT(e,t))}function s1e(e){const t=ht(Rj);if(!t)return null;try{const n=JSON.parse(t),a=n&&typeof n=="object"?n[e]:null;return typeof a=="string"&&a.length<=80?a:null}catch{return null}}function i1e(e,t){let n={};try{const a=ht(Rj),i=a?JSON.parse(a):{};i&&typeof i=="object"&&!Array.isArray(i)&&(n=Object.fromEntries(Object.entries(i).filter(([,o])=>typeof o=="string").slice(0,20)))}catch{}n[e]=t,pt(Rj,JSON.stringify(n))}function Ej(e){var a;const t=(a=e.meta)==null?void 0:a.checkedAt;if(!t)return null;const n=new Date(String(t));return Number.isNaN(n.getTime())?null:n.toLocaleString(qe(),{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...n.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}function _j(e){const t=e.meta??{};return e.kind==="gitlab"?typeof t.serverVersion=="string"&&t.serverVersion?`GitLab ${t.serverVersion}`:null:e.kind!=="jira"?null:t.deploymentType==="Cloud"?"Jira Cloud":t.deploymentType?`Jira ${t.deploymentType==="DataCenter"?"Data Center":String(t.deploymentType)}${t.serverVersion?` ${t.serverVersion}`:""}`:null}function ZTe({connection:e,provider:t,available:n,busy:a,armed:i,note:o,headingRef:r,onTest:c,onEdit:d,onDisconnect:u,onCancelDisconnect:p}){var T;const g=ae(),f=m.useRef(null),v=(t==null?void 0:t.label)??e.kind,k=e.account.name||e.account.login||g("integrations.conn.noAccount"),y=e.account.name&&e.account.login!==e.account.name?e.account.login:"",N=Ej(e),w=_j(e),S=Array.isArray((T=e.meta)==null?void 0:T.warnings)?e.meta.warnings.filter(E=>typeof E=="string"):[],j=a===`test:${e.id}`,A=a===`delete:${e.id}`;return s.jsxs("section",{className:"ig-connection-details","aria-labelledby":"ig-managed-title",children:[s.jsxs("header",{className:"ig-managed-header",children:[t&&s.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:s.jsx(t.Glyph,{})}),s.jsxs("div",{className:"ig-managed-identity",children:[s.jsx("h2",{ref:r,tabIndex:-1,id:"ig-managed-title",className:"ig-managed-title",children:e.name||e.baseUrl}),s.jsx("p",{children:g("integrations.conn.saved",{label:v})})]})]}),s.jsxs("dl",{className:"ig-detail-facts",children:[s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.host")}),s.jsx("dd",{children:e.baseUrl})]}),s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.account")}),s.jsxs("dd",{children:[k,y?` (${y})`:""]})]}),s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.lastVerified")}),s.jsx("dd",{children:N??g("integrations.conn.noVerificationTime")})]}),s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.credentials")}),s.jsx("dd",{children:e.tokenSaved?g("integrations.conn.storedLocally"):g("integrations.conn.noToken")})]}),w&&s.jsxs("div",{children:[s.jsx("dt",{children:g("integrations.conn.server")}),s.jsx("dd",{children:w})]})]}),!n&&s.jsx("p",{className:"ig-stranded",children:g("integrations.conn.strandedDisconnect",{label:v})}),S.length>0&&s.jsx("ul",{className:"ig-warnings",children:S.map(E=>s.jsx("li",{children:E},E))}),n&&s.jsxs("div",{className:"ig-manage-actions",children:[s.jsx("button",{type:"button",className:"btn","aria-busy":j,"aria-disabled":a!==null||void 0,onClick:c,children:g(j?"integrations.conn.testing":"integrations.conn.test")}),s.jsx("button",{type:"button",className:"btn","aria-disabled":a!==null||void 0,onClick:E=>{a===null&&d(E.currentTarget)},children:g("integrations.conn.edit")})]}),o&&o.scope!=="disconnect"&&s.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text}),s.jsxs("div",{className:"ig-disconnect-section",children:[s.jsx("h3",{children:g("integrations.conn.removeTitle")}),s.jsx("p",{children:g("integrations.conn.removeBody")}),s.jsxs("div",{className:"ig-manage-actions","data-integration-disconnect-actions":!0,onBlur:E=>{i&&!E.currentTarget.contains(E.relatedTarget)&&p()},children:[s.jsx("button",{ref:f,type:"button","data-integration-disconnect":!0,className:`btn danger${i?" armed":""}`,"aria-busy":A,"aria-disabled":a!==null||void 0,onKeyDown:E=>{E.repeat&&E.preventDefault()},"aria-label":i?g("integrations.conn.confirmAria",{name:e.name}):g("integrations.conn.disconnectAria",{name:e.name}),onClick:E=>u(E.currentTarget),children:g(A?"integrations.conn.disconnecting":i?"integrations.conn.confirmDisconnect":"integrations.conn.disconnect")}),i&&s.jsx("button",{type:"button",className:"btn","data-integration-cancel-disconnect":!0,"aria-disabled":a!==null||void 0,"aria-label":g("integrations.conn.cancelDisconnect"),onClick:()=>{var E;a===null&&(p(),(E=f.current)==null||E.focus())},children:g("integrations.cancel")})]}),i&&s.jsx("p",{className:"ig-note",role:"status",children:g("integrations.conn.pressConfirm")}),(o==null?void 0:o.scope)==="disconnect"&&s.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text})]})]})}function XTe({onBeforeLeaveChange:e}={}){var ot;const t=ae(),n=Xu(),{connections:a,error:i}=n,[o,r]=m.useState(null),c=m.useRef(null),d=m.useRef(new Map),u=m.useRef(null),p=m.useRef(0),[g,f]=m.useState(null),[v,k]=m.useState(""),y=m.useRef(null),N=m.useRef(null),[w,S]=m.useState(null),[j,A]=m.useState(null),T=m.useRef(null),[E,q]=m.useState(null),[F,z]=m.useState([]),[H,I]=m.useState(null),L=m.useRef(0),[O,_]=m.useState(null),M=m.useRef(null),U=m.useRef(new Map),G=m.useRef(null),W=m.useRef(0),[$,Y]=m.useState(!1),[B,V]=m.useState(null),Z=m.useRef(null),D=m.useRef(new Map),K=m.useRef(new Map);m.useEffect(()=>{const se=$Se();se&&(G.current=D.current.get(se)??null,f(se),_(se),S({mode:"edit",id:se}));const Ne=GSe();Ne&&S({mode:"add",kind:Ne})},[]),m.useEffect(()=>{var se,Ne;!O||!a||(Ne=(se=K.current.get(O))==null?void 0:se.scrollIntoView)==null||Ne.call(se,{block:"nearest"})},[O,a]),m.useEffect(()=>{if(!H)return;const se=()=>{var Be,Se;(Be=document.activeElement)!=null&&Be.hasAttribute("data-integration-cancel-disconnect")&&((Se=document.querySelector(".ig-manage-view [data-integration-disconnect]"))==null||Se.focus()),I(null)},Ne=()=>{document.hidden&&se()},Ie=window.setTimeout(()=>{var Be;(Be=document.querySelector("[data-integration-disconnect-actions]"))!=null&&Be.contains(document.activeElement)||se()},4e3);return window.addEventListener("blur",se),document.addEventListener("visibilitychange",Ne),()=>{window.clearTimeout(Ie),window.removeEventListener("blur",se),document.removeEventListener("visibilitychange",Ne)}},[H]);const X=(se,Ne,Ie,Be)=>z(Se=>[...Se.filter(tt=>tt.id!==se),{id:se,tone:Ne,text:Ie,scope:Be}]),Q=se=>z(Ne=>Ne.filter(Ie=>Ie.id!==se)),ee=async(se,Ne)=>{if(!T.current){T.current=se,A(se);try{await Ne()}finally{T.current=null,A(null)}}},ne=se=>(Ne,Ie)=>void ee("form",async()=>{q(null);try{const Be=await FSe(se,Ne,Ie||void 0);S(null),V(null),Y(!1),f(null),r(null),k(t("integrations.settings.added")),X(Be.id,"ok",t("integrations.settings.savedTested",{name:Be.account.name||Be.account.login})),_(Be.id),M.current=()=>{var tt;const Se=d.current.get(Be.kind)??D.current.get(Be.id);return(tt=Se==null?void 0:Se.scrollIntoView)==null||tt.call(Se,{block:"nearest"}),Se}}catch(Be){q(Be instanceof $a?Be:new $a("upstream",t("integrations.settings.saveFailed")))}}),de=se=>(Ne,Ie)=>void ee("form",async()=>{q(null);try{const{connection:Be,validated:Se}=await USe(se.id,{name:Ie,input:Ne});S(null),V(null),Y(!1),M.current=()=>N.current??(g?y.current:D.current.get(Be.id)),X(Be.id,"ok",Se?t("integrations.settings.savedPassed",{name:Be.account.name||Be.account.login}):t("integrations.settings.saved"))}catch(Be){q(Be instanceof $a?Be:new $a("upstream",t("integrations.settings.changeFailed")))}}),ge=se=>void ee(`test:${se.id}`,async()=>{I(null),Q(se.id);try{const Ne=await BSe(se.id);X(se.id,"ok",t("integrations.settings.testPassed",{name:Ne.account.name||Ne.account.login}))}catch(Ne){X(se.id,"err",So(Ne,t("integrations.settings.testFailed")))}}),le=(se,Ne)=>{if(T.current)return;const Ie=Date.now(),Be=zr({armedFor:H,target:se.id,armedAt:L.current,now:Ie,gapMs:qr});if(Be==="arm"){Ne.focus({preventScroll:!0}),I(se.id),L.current=Ie;return}Be!=="ignore"&&(I(null),ee(`delete:${se.id}`,async()=>{try{await HSe(se.id),YTe(se.kind,se.id),Q(se.id),(w==null?void 0:w.mode)==="edit"&&w.id===se.id&&S(null),f(null);const Se=(a??[]).filter(fe=>fe.kind===se.kind&&fe.id!==se.id);(!o||Se.length===0)&&r(null),k(t("integrations.settings.disconnected"));const tt=document.activeElement;(tt===Ne||Xn((tt==null?void 0:tt.tagName)??null))&&(M.current=()=>{var He;const fe=(o&&Se[0]?D.current.get(Se[0].id):d.current.get(se.kind))??U.current.get(se.kind)??document.getElementById("settings-tab-integrations");return(He=fe==null?void 0:fe.scrollIntoView)==null||He.call(fe,{block:"nearest"}),fe})}catch(Se){X(se.id,"err",So(Se,t("integrations.settings.removeFailed")),"disconnect")}}))};m.useEffect(()=>{if(j!==null||B||!M.current)return;const se=M.current();M.current=null,se!=null&&se.isConnected&&(se.checkVisibility?se.checkVisibility():se.getClientRects().length>0)&&se.focus({preventScroll:!0})},[a,g,o,w,j,B]);const he=a??[],ce=Qu(n),oe=["github","gitlab","jira"],ve=$T().filter(se=>ce.has(se.kind)||he.some(Ne=>Ne.kind===se.kind)).sort((se,Ne)=>oe.indexOf(se.kind)-oe.indexOf(Ne.kind)),ke=KT(n),ye=m.useCallback(()=>{S(null),f(null),r(null),Y(!1),V(null),q(null),I(null),M.current=()=>{const se=G.current,Ne=se==null?void 0:se.closest(".settings-pane");return Ne&&(Ne.scrollTop=W.current),se!=null&&se.isConnected?se:document.getElementById("settings-tab-integrations")}},[]),Le=m.useCallback(()=>{if(!o){ye();return}f(null),S(null),Y(!1),V(null),q(null),I(null),M.current=()=>{var Ie;const se=(Ie=u.current)!=null&&Ie.isConnected?u.current:c.current,Ne=se==null?void 0:se.closest(".settings-pane");return Ne&&(Ne.scrollTop=se===c.current?0:p.current),se}},[o,ye]),Ke=m.useCallback(()=>{if(!g&&!o){ye();return}S(null),Y(!1),V(null),q(null),M.current=()=>N.current??(g?y.current:c.current)},[g,o,ye]),Qe=m.useCallback((se,Ne=!1)=>{if(T.current)return;if(B&&Ne){V(null),requestAnimationFrame(()=>{var Be;return(Be=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:Be.focus()});return}const Ie=Ne?w?Ke:g?Le:ye:()=>{S(null),f(null),r(null),se()};$?V(()=>Ie):(Y(!1),Ie())},[$,B,w,g,Ke,Le,ye]);m.useEffect(()=>(e==null||e(w||g||o?Qe:null),()=>e==null?void 0:e(null)),[w,g,o,Qe,e]),m.useEffect(()=>{var se;B&&((se=Z.current)==null||se.focus())},[B]),m.useEffect(()=>{var se;g&&((se=y.current)==null||se.focus())},[g]),m.useEffect(()=>{var se;o&&((se=c.current)==null||se.focus())},[o]);const Ae=(se,Ne)=>{var Be;if(T.current)return;M.current=null,V(null),k(""),I(null),g||o?N.current=Ne:(W.current=((Be=Ne.closest(".settings-pane"))==null?void 0:Be.scrollTop)??0,G.current=Ne,N.current=null),Y(!1),q(null),S(se);const Ie=Ne.closest(".settings-pane");Ie&&(Ie.scrollTop=0)},je=(se,Ne)=>{var Be,Se;if(T.current)return;M.current=null,o?(u.current=Ne,p.current=((Be=Ne.closest(".settings-pane"))==null?void 0:Be.scrollTop)??0):(W.current=((Se=Ne.closest(".settings-pane"))==null?void 0:Se.scrollTop)??0,G.current=Ne),N.current=null,k(""),I(null),f(se.id);const Ie=Ne.closest(".settings-pane");Ie&&(Ie.scrollTop=0)},Oe=(se,Ne)=>{var Se;const Ie=he.filter(tt=>tt.kind===se);if(Ie.length===1){je(Ie[0],Ne);return}if(T.current)return;M.current=null,W.current=((Se=Ne.closest(".settings-pane"))==null?void 0:Se.scrollTop)??0,G.current=Ne,u.current=null,p.current=0,k(""),I(null),r(se);const Be=Ne.closest(".settings-pane");Be&&(Be.scrollTop=0)},Ve=(se,Ne=!1)=>{const Ie=Wd(se.kind),Be=!yi(n,se.kind),Se=Ej(se),tt=se.account.login||se.account.name,fe=se.kind==="jira"?_j(se):null;return s.jsx("div",{className:"ig-conn",ref:He=>{He?K.current.set(se.id,He):K.current.delete(se.id)},children:s.jsxs("div",{className:"ig-summary-row",children:[s.jsxs("div",{className:"ig-summary-text",children:[s.jsx("span",{className:"ig-conn-name",children:Ne&&se.name||or(se)}),s.jsx("span",{className:"ig-conn-line",children:[Ne&&se.name!==or(se)?or(se):"",tt,fe||(Se?t("integrations.conn.lastVerifiedAt",{when:Se}):t("integrations.conn.notVerified"))].filter(Boolean).join(" · ")||t("integrations.conn.noAccount")}),!se.tokenSaved&&s.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")}),Be&&s.jsx("span",{className:"ig-stranded",children:t("integrations.conn.strandedManage",{label:(Ie==null?void 0:Ie.label)??se.kind})})]}),s.jsxs("button",{type:"button",className:"btn ig-manage",ref:He=>{He?D.current.set(se.id,He):D.current.delete(se.id)},"aria-label":t("integrations.settings.manageAria",{label:(Ie==null?void 0:Ie.label)??se.kind,name:se.name,account:tt||or(se)}),onClick:He=>je(se,He.currentTarget),children:[t("integrations.manage")," ",s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m6 4 4 4-4 4"})})]})]})},se.id)},nt=he.filter(se=>!ve.some(Ne=>Ne.kind===se.kind)),Ye=o?Wd(o):null,Ce=he.filter(se=>se.kind===o),ze=he.find(se=>se.id===g),De=(w==null?void 0:w.mode)==="edit"?he.find(se=>se.id===w.id):void 0,Fe=(w==null?void 0:w.mode)==="add"?ve.find(se=>ce.has(se.kind)&&se.kind===w.kind):De&&ve.find(se=>ce.has(se.kind)&&se.kind===De.kind);return s.jsxs("div",{className:"ig-settings","data-view":w?"form":g?"connection":o?"provider":"overview",children:[w&&s.jsxs("div",{className:"ig-config-view",children:[s.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":j!==null||void 0,onClick:()=>Qe(Ke,!0),children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),g?t("integrations.settings.backToConn"):o?t("integrations.settings.backToList",{label:(Ye==null?void 0:Ye.label)??o}):t("integrations.settings.all")]}),B&&s.jsxs("div",{className:"ig-leave-confirm",role:"group","aria-labelledby":"ig-leave-title",children:[s.jsx("strong",{id:"ig-leave-title",children:t("integrations.settings.discardTitle")}),s.jsx("p",{children:t("integrations.settings.discardBody")}),s.jsxs("div",{className:"ig-form-actions",children:[s.jsx("button",{ref:Z,type:"button",className:"btn",onClick:()=>{V(null),requestAnimationFrame(()=>{var se;return(se=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:se.focus()})},children:t("integrations.settings.keepEditing")}),s.jsx("button",{type:"button",className:"btn danger",onClick:()=>{const se=B;V(null),Y(!1),S(null),se()},children:t("integrations.settings.discard")})]})]}),s.jsx("div",{hidden:!!B,children:Fe?s.jsx(pSe,{def:Fe,existing:De,busy:j==="form",error:E,onDirtyChange:Y,onSubmit:w.mode==="add"?ne(w.kind):de(De),onCancel:()=>Qe(Ke,!0)},w.mode==="add"?w.kind:w.id):s.jsxs("div",{role:"status",children:[s.jsx("p",{children:t("integrations.settings.gone")}),s.jsx("button",{type:"button",className:"btn",onClick:Ke,children:t("integrations.settings.backToIntegrations")})]})})]}),o&&s.jsxs("div",{className:"ig-provider-view",hidden:w!==null||g!==null,children:[s.jsxs("div",{className:"ig-manage-navigation",children:[s.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":j!==null||void 0,onClick:()=>Qe(ye,!0),children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),t("integrations.settings.all")]}),yi(n,o)&&s.jsx("button",{type:"button",className:"btn","aria-disabled":j!==null||void 0,onClick:se=>Ae({mode:"add",kind:o},se.currentTarget),children:t("integrations.settings.addConn",{label:(Ye==null?void 0:Ye.label)??o})})]}),s.jsx("h2",{ref:c,tabIndex:-1,className:"ig-managed-title",children:t("integrations.settings.connsTitle",{label:(Ye==null?void 0:Ye.label)??o})}),v&&s.jsx("p",{className:"ig-note",role:"status",children:v}),Ce.length?s.jsx("div",{className:"ig-provider-connections",children:Ce.map(se=>Ve(se,!0))}):s.jsx("p",{role:"status",children:t("integrations.settings.noSaved")})]}),g&&s.jsxs("div",{className:"ig-manage-view",hidden:w!==null,children:[s.jsxs("div",{className:"ig-manage-navigation",children:[s.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":j!==null||void 0,onClick:()=>Qe(Le,!0),children:[s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),o?t("integrations.settings.backToList",{label:(Ye==null?void 0:Ye.label)??o}):t("integrations.settings.all")]}),ze&&yi(n,ze.kind)&&s.jsx("button",{type:"button",className:"btn","aria-disabled":j!==null||void 0,onClick:se=>Ae({mode:"add",kind:ze.kind},se.currentTarget),children:t("integrations.settings.addConn",{label:((ot=Wd(ze.kind))==null?void 0:ot.label)??ze.kind})})]}),ze?s.jsx(ZTe,{connection:ze,provider:Wd(ze.kind),available:yi(n,ze.kind),busy:j,armed:H===g,note:F.find(se=>se.id===g),headingRef:y,onTest:()=>ge(ze),onEdit:se=>Ae({mode:"edit",id:ze.id},se),onDisconnect:se=>le(ze,se),onCancelDisconnect:()=>I(null)}):s.jsx("p",{role:"status",children:t("integrations.settings.noLongerSaved")})]}),s.jsxs("div",{className:"ig-overview",hidden:w!==null||g!==null||o!==null,children:[i&&s.jsxs("div",{className:"ig-list-error",role:"alert",children:[s.jsx("p",{children:i}),s.jsx("button",{type:"button",className:"btn",onClick:()=>void Of(),children:t("integrations.retry")})]}),a===null&&!i&&s.jsx("p",{role:"status",children:t("integrations.settings.reading")}),v&&s.jsx("p",{className:"ig-note",role:"status",children:v}),s.jsxs("div",{className:"ig-connection-list","data-setting":"integrations-connections",children:[a!==null&&s.jsx("div",{className:"ig-providers","data-setting":"integrations-add",id:ke==="all"?"integrations-add-title":void 0,children:ve.map(se=>{const Ne=he.filter(fe=>fe.kind===se.kind),Ie=Ne.length===1?Ne[0]:null,Be=[...new Set(Ne.map(or))],Se=Ie&&Ej(Ie),tt=(Ie==null?void 0:Ie.kind)==="jira"?_j(Ie):null;return s.jsxs("section",{className:"ig-provider",id:`ig-provider-${se.kind}`,"aria-labelledby":`ig-provider-name-${se.kind}`,"data-setting":`integration-${se.kind}`,children:[s.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:s.jsx(se.Glyph,{})}),s.jsxs("div",{className:"ig-summary-text ig-provider-content",children:[s.jsx("h3",{id:`ig-provider-name-${se.kind}`,children:se.label}),Ne.length===0?s.jsx("span",{className:"ig-conn-line",children:t("integrations.settings.notConnected")}):Ie?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ig-conn-name",children:or(Ie)}),s.jsx("span",{className:"ig-conn-line",children:[Ie.account.login||Ie.account.name,tt||(Se?t("integrations.conn.lastVerifiedAt",{when:Se}):t("integrations.conn.notVerified"))].filter(Boolean).join(" · ")}),!Ie.tokenSaved&&s.jsx("span",{className:"ig-bad",children:t("integrations.conn.noToken")})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ig-conn-name",children:t("integrations.settings.count",{count:Ne.length})}),s.jsxs("span",{className:"ig-conn-line",children:[Be.slice(0,2).join(" · "),Be.length>2?` · ${t("integrations.settings.moreInstances",{n:Be.length-2})}`:""]})]}),!ce.has(se.kind)&&s.jsx("span",{className:"ig-stranded",children:t("integrations.conn.unavailable",{label:se.label})})]}),s.jsx("button",{type:"button",className:`btn ig-manage${Ne.length?"":" primary"}`,"aria-disabled":j!==null||void 0,ref:fe=>{const He=Ne.length?d.current:U.current;fe?He.set(se.kind,fe):He.delete(se.kind)},"aria-label":Ne.length?t("integrations.manageProvider",{label:se.label}):t("integrations.form.connect",{provider:se.label}),onClick:fe=>Ne.length?Oe(se.kind,fe.currentTarget):Ae({mode:"add",kind:se.kind},fe.currentTarget),children:Ne.length?s.jsxs(s.Fragment,{children:[t("integrations.manage")," ",s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:s.jsx("path",{d:"m6 4 4 4-4 4"})})]}):t("integrations.form.connectBtn")})]},se.kind)})}),(nt.length>0||ve.length===0&&ke!=="all"&&a!==null)&&s.jsxs(Yt,{id:"integrations-list-title",title:t("integrations.settings.connections"),aside:s.jsx("span",{className:"settings-caption-count",children:nt.length}),children:[nt.map(se=>Ve(se,!0)),he.length===0&&s.jsx("p",{className:"settings-row settings-row-status",children:t("integrations.settings.nothing")})]})]}),ke==="all"&&s.jsx(s.Fragment,{children:s.jsx("div",{className:"ig-overview-info",children:s.jsxs("details",{className:"ig-access",children:[s.jsx("summary",{children:t("integrations.settings.accessSummary")}),s.jsx("p",{children:t("integrations.settings.accessBody")})]})})})]})]})}function QTe({theme:e}){return s.jsx("span",{className:"appearance-preview","data-swatch":e,children:s.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[s.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),s.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),s.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),s.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),s.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),s.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),s.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),s.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),s.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),s.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function e0e({theme:e,onTheme:t,singleKeys:n}){const a=ae(),i=c=>{var g,f;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(c.key))return;c.preventDefault();const d=(g=c.target.closest("[data-theme-choice]"))==null?void 0:g.dataset.themeChoice,p=(Ms.indexOf(d??e)+(c.key==="ArrowLeft"||c.key==="ArrowUp"?-1:1)+Ms.length)%Ms.length;t(Ms[p]),(f=c.currentTarget.querySelectorAll('[role="radio"]')[p])==null||f.focus()},o=m.useRef(null),r=m.useRef(e);return m.useEffect(()=>{var u,p;const c=r.current;r.current=e;const d=document.activeElement;c===e||!d||!((u=o.current)!=null&&u.contains(d))||d.dataset.themeChoice!==c||(p=o.current.querySelector(`[data-theme-choice="${e}"]`))==null||p.focus()},[e]),s.jsx(Yt,{id:"appearance-theme-caption",title:a("settings.theme.title"),list:!1,settingId:"theme",aside:n&&s.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:a("settings.theme.keyTip"),children:"T"}),children:s.jsx("div",{ref:o,className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:i,children:Ms.map(c=>s.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":c,"data-setting":`theme-${c}`,"aria-checked":e===c,tabIndex:e===c?0:-1,onClick:()=>t(c),children:[s.jsx(QTe,{theme:c}),s.jsxs("span",{className:"appearance-theme-name",children:[SB(c,a),s.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:s.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},c))})})}const t0e=[["smallest","settings.reading.size.smallest","11 px"],["smaller","settings.reading.size.smaller","12 px"],["default","settings.reading.size.default","13 px"],["larger","settings.reading.size.larger","15 px"],["largest","settings.reading.size.largest","17 px"]],n0e=[["tightest","settings.reading.density.tightest","30%"],["tighter","settings.reading.density.tighter","50%"],["compact","settings.reading.density.compact","70%"],["default","settings.reading.density.default","100%"],["comfortable","settings.reading.density.comfortable","140%"]];function cD(){return s.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:s.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 a0e({textSize:e,density:t,onTextSize:n,onDensity:a}){const i=ae(),o=e!=="default"||t!=="default";return s.jsx("button",{type:"button",className:"btn",disabled:!o,onClick:()=>{n("default"),a("default")},children:i("settings.reading.reset")})}function s0e({textSize:e,density:t,onTextSize:n,onDensity:a}){const i=ae();return s.jsxs(s.Fragment,{children:[s.jsxs("fieldset",{className:"reading-group",children:[s.jsx("legend",{children:i("settings.reading.sizeTitle")}),s.jsx("p",{id:"reading-size-help",children:i("settings.reading.sizeHelp")}),s.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help","data-setting":"text-size",style:{"--reading-count":A_.length,"--reading-selected":A_.indexOf(e)},children:t0e.map(([o,r,c])=>{const d=i(r);return s.jsxs("label",{className:"reading-choice","data-size":o,children:[s.jsx("input",{type:"radio",name:"text-size","aria-label":`${d} ${c}`,value:o,checked:e===o,onChange:()=>n(o)}),s.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),s.jsxs("span",{className:"reading-label",children:[s.jsx("strong",{children:d}),s.jsx("small",{children:c})]}),s.jsx(cD,{})]},o)})})]}),s.jsxs("fieldset",{className:"reading-group",children:[s.jsx("legend",{children:i("settings.reading.densityTitle")}),s.jsx("p",{id:"reading-density-help",children:i("settings.reading.densityHelp")}),s.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help","data-setting":"density",style:{"--reading-count":T_.length,"--reading-selected":T_.indexOf(t)},children:n0e.map(([o,r,c])=>{const d=i(r);return s.jsxs("label",{className:"reading-choice",children:[s.jsx("input",{type:"radio",name:"density","aria-label":i("settings.reading.spacing",{label:d,note:c}),value:o,checked:t===o,onChange:()=>a(o)}),s.jsxs("span",{className:"reading-density-sample","data-density":o,"aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}),s.jsxs("span",{className:"reading-label",children:[s.jsx("strong",{children:d}),s.jsx("small",{children:c})]}),s.jsx(cD,{})]},o)})})]}),s.jsxs(Yt,{id:"reading-preview-title",title:i("settings.reading.preview"),children:[s.jsxs("div",{className:"reading-preview-row",children:[s.jsxs("div",{children:[s.jsx("strong",{children:i("settings.reading.sample1")}),s.jsx("span",{children:i("settings.reading.sample1State")})]}),s.jsx("span",{className:"reading-preview-time",children:"4m"})]}),s.jsxs("div",{className:"reading-preview-row",children:[s.jsxs("div",{children:[s.jsx("strong",{children:i("settings.reading.sample2")}),s.jsx("span",{children:i("settings.reading.sample2State")})]}),s.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),s.jsx("p",{className:"settings-foot",children:i("settings.reading.foot")})]})}function i0e({cli:e,running:t}){const n=ae(),a=n("shell.terminal.versions",{product:Pt,cli:e.version,running:t}),i=s.jsx("code",{children:e.command});return e.auto==="pending"||e.auto==="running"?s.jsx(Ct,{as:"div",name:n("shell.terminal.name"),note:a,control:s.jsx("span",{className:"settings-read",children:e.auto==="running"?n("shell.terminal.updating"):n("shell.terminal.updatingSoon")}),children:s.jsx("span",{className:"settings-row-said",children:e.auto==="running"?n("shell.terminal.updatingNow"):Sj(n("shell.terminal.soon"),"cmd",i)})}):s.jsx(Ct,{as:"div",name:n("shell.terminal.name"),note:e.auto==="failed"?a:n("shell.terminal.notUpdated",{versions:a}),control:s.jsx("span",{className:"settings-read",children:n("shell.terminal.needed")}),children:s.jsxs("span",{className:"settings-row-said",children:[e.auto==="failed"&&s.jsxs(s.Fragment,{children:[e.error?n("shell.terminal.failedWith",{error:e.error}):n("shell.terminal.failed")," "]}),Sj(n("shell.terminal.run"),"cmd",i)]})})}const o0e="AGPL-3.0-only",r0e="https://github.com/BarganConstantin/ccdeck",c0e="https://github.com/sponsors/BarganConstantin";function l0e(e,t=C){return t("settings.about.pageBehind",{bundle:e})}function d0e(e,t){return Ws(e)&&Ws(t)&&Ro(e,t)<0}function u0e(e,t,n=C){return e?{kind:"ready",to:e.version,name:n("settings.about.updateReady"),note:n("settings.about.updateReadyNote",{product:Pt,version:e.version})}:t?t.kind==="restart"?{kind:"notice",name:n("settings.about.updateInstalled"),note:n("settings.about.updateInstalledNote",{to:t.to,from:t.from})}:{kind:"notice",name:n("settings.about.updateAvailable"),note:n("settings.about.updateAvailableNote",{product:Pt,to:t.to,from:t.from})}:null}function h0e({version:e,notice:t,readyAppUpdate:n,updateRestarting:a,updateFailure:i,onUpdateRestart:o,doors:r,bundle:c="3.53.2"}){const d=ae(),u=(e==null?void 0:e.running)??c,p=u0e(n,t,d);return s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{id:"settings-about-caption",title:Pt,children:[s.jsx(Ct,{as:"div",settingId:"version",name:d("settings.about.version"),note:d0e(c,e==null?void 0:e.running)?l0e(c,d):void 0,control:s.jsx("span",{className:"settings-read",children:u})}),(e==null?void 0:e.terminalCli)&&s.jsx(i0e,{cli:e.terminalCli,running:u}),p&&s.jsx(p0e,{offer:p,restarting:a,failure:i,onRestart:o,onUpdate:r.update}),s.jsx(Ct,{as:"div",settingId:"whats-new",name:d("settings.about.whatsNew"),note:d("settings.about.whatsNewNote"),control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":d("settings.about.openWhatsNew"),onClick:r.whatsNew,children:d("settings.about.open")})}),s.jsx(Ct,{as:"div",settingId:"licence",name:d("settings.about.licence"),note:d("settings.about.licenceNote"),control:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"settings-read",children:o0e}),s.jsxs("a",{className:"settings-link",href:r0e,target:"_blank",rel:"noreferrer",children:[d("settings.about.source"),s.jsx("span",{className:"vis-hidden",children:d("settings.about.sourceHidden")})]})]})}),s.jsx(Ct,{as:"div",settingId:"sponsor",name:d("settings.about.sponsor"),note:d("settings.about.sponsorNote"),control:s.jsxs("a",{className:"settings-link",href:c0e,target:"_blank",rel:"noreferrer",children:[d("settings.about.sponsorLink"),s.jsx("span",{className:"vis-hidden",children:d("settings.about.sponsorHidden")})]})})]}),s.jsxs(Yt,{id:"settings-about-help-caption",title:d("settings.about.helpGroup"),children:[s.jsx(Ct,{as:"div",settingId:"tour",name:d("settings.about.tour"),note:d("settings.key.tourText"),control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":d("settings.about.startTour"),onClick:r.tour,children:d("settings.about.start")})}),s.jsx(Ct,{as:"div",settingId:"feedback",name:d("settings.about.feedback"),note:d("settings.about.feedbackNote"),control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":d("settings.about.openFeedback"),onClick:r.feedback,children:d("settings.about.open")})})]})]})}function p0e({offer:e,restarting:t,failure:n,onRestart:a,onUpdate:i}){const o=ae();if(e.kind==="notice")return s.jsx(Ct,{as:"div",name:e.name,note:e.note,control:s.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:i,children:o("settings.about.updateBtn")})});const r=jW(e.to,t),c=n&&n.version===e.to?AW(n.failure,n.version):"";return s.jsx(Ct,{as:"div",name:e.name,note:e.note,control:s.jsx("button",{type:"button",className:"btn",onClick:()=>a(e.to),"aria-busy":t||void 0,"aria-label":r.label,title:r.title,children:r.text}),children:s.jsx("span",{className:"settings-row-said",role:"status",children:c})})}function g0e(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 m0e={plain:"settings.updates.plainDetails","checks-off":"settings.updates.checksOffDetails","no-restart":"settings.updates.noRestartDetails"};function f0e({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:a=Eo()}){const i=ae(),o=g0e(n,a);return s.jsx(Yt,{id:"settings-updates-caption",title:i("settings.updates.title"),children:o==="app"?s.jsx(Ct,{as:"div",settingId:"auto-update",name:i("settings.updates.title"),note:i("settings.updates.appNote")}):s.jsx(Ct,{settingId:"auto-update",name:i("settings.updates.label"),nameId:"settings-auto-update-label",note:i(o==="no-restart"?"settings.updates.noRestartNote":o==="checks-off"?"settings.updates.checksOffNote":"settings.updates.plainNote"),details:i(m0e[o]),noteId:"settings-auto-update-note",control:s.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:s.jsx("span",{className:"switch-knob"})})})})}function b0e({character:e,onCharacter:t}){const n=ae(),a=m.useRef([]);function i(o,r){var d;const c=pT(o,r,mg.length,"vertical");c.kind==="select"&&(o.preventDefault(),t(mg[c.index].id),(d=a.current[c.index])==null||d.focus())}return s.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":n("settings.character.choose"),"data-setting":"character-choice",children:mg.map((o,r)=>s.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===o.id,tabIndex:e===o.id?0:-1,ref:c=>{a.current[r]=c},onClick:()=>t(o.id),onKeyDown:c=>i(c,r),children:[s.jsx("span",{className:"character-preview",children:s.jsx(IU,{character:o.id,act:null,facing:"right"})}),s.jsx("span",{children:o.name}),s.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:s.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},o.id))})}function v0e({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:a}){const i=ae();return s.jsxs(Yt,{id:"appearance-character-caption",title:i("settings.character.title"),list:!1,children:[s.jsx("div",{className:"settings-list",children:s.jsx(Ct,{settingId:"character",name:i("settings.character.show"),nameId:"appearance-character-label",note:i("settings.character.note"),noteId:"appearance-character-note",control:s.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:s.jsx("span",{className:"switch-knob"})})})}),s.jsx(b0e,{character:n,onCharacter:a})]})}const lD="settings-search-field",YW="settings-search-results",qj=e=>`settings-result-${e}`;function k0e({inputRef:e,query:t,onQuery:n,results:a,active:i,onActive:o,onOpen:r}){const c=ae(),d=t.trim()!=="",u=d&&a.length>0,p=g=>{if(g.nativeEvent.isComposing)return;const f=Wre(g.key,t,d?a.length:0,i);f.kind!=="pass"&&(g.preventDefault(),f.kind==="move"?o(f.index):f.kind==="open"?r(a[f.index]):(g.stopPropagation(),n("")))};return s.jsxs("div",{className:"settings-search",children:[s.jsx("label",{className:"vis-hidden",htmlFor:lD,children:c("settings.search.label")}),s.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:[s.jsx("circle",{cx:"6",cy:"6",r:"4.2"}),s.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]}),s.jsx("input",{ref:e,id:lD,type:"search",className:"settings-filter-field settings-search-field",placeholder:c("settings.search.label"),autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":u,"aria-controls":u?YW:void 0,"aria-activedescendant":u?qj(Math.min(i,a.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:g=>n(g.target.value),onKeyDown:p})]})}function w0e({query:e,results:t,active:n,onOpen:a}){const i=ae(),o=TB(t.length,e);return m.useEffect(()=>{var r,c;(c=(r=document.getElementById(qj(n)))==null?void 0:r.scrollIntoView)==null||c.call(r,{block:"nearest"})},[n]),s.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[s.jsx("div",{className:"settings-pane-head",children:s.jsxs("div",{className:"settings-pane-heading",children:[s.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:i("settings.search.title")}),s.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:o})]})}),t.length>0&&s.jsx("div",{className:"settings-group",children:s.jsx("div",{className:"settings-list",id:YW,role:"listbox","aria-label":i("settings.search.results"),children:t.map((r,c)=>s.jsxs("button",{type:"button",role:"option",id:qj(c),className:"settings-result",tabIndex:-1,"aria-selected":c===n,"aria-label":Fre(r),"data-highlighted":c===n,onMouseDown:d=>d.preventDefault(),onClick:()=>a(r),children:[s.jsx(Xm,{section:r.section}),s.jsxs("span",{className:"settings-result-text",children:[s.jsx("span",{className:"settings-result-name",children:r.label}),s.jsx("span",{className:"settings-result-place",children:UA(r)})]})]},r.id))})})]})}function y0e({query:e,count:t}){return s.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?TB(t,e):""})}const x0e=1500,C0e=3e3,S0e=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function N0e(e){if(e.matches(Ig)&&!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(Ig)).filter(a=>J2({disabled:a.disabled,tabIndex:a.tabIndex,rendered:S0e(a)}));return n.find(a=>a.closest(".settings-list")!=null)??n[0]??null}function j0e(e,t,n){const[a,i]=m.useState(null),o=m.useRef(void 0),r=m.useRef(null);return m.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=r.current)==null||c.removeAttribute("data-jumped")},[]),m.useEffect(()=>{const c=e.current;if(!a||!t||!c)return;const d=()=>c.querySelector(`[data-setting="${CSS.escape(a)}"]`),u=v=>{var y,N;i(null);const k=v.offsetHeight>c.clientHeight-48;v.scrollIntoView({block:k?"start":"center"}),(y=N0e(v))==null||y.focus({preventScroll:!0}),window.clearTimeout(o.current),(N=r.current)==null||N.removeAttribute("data-jumped"),v.offsetWidth,v.setAttribute("data-jumped",""),r.current=v,o.current=window.setTimeout(()=>{v.removeAttribute("data-jumped"),r.current===v&&(r.current=null)},x0e)},p=d();if(p){u(p);return}const g=new MutationObserver(()=>{const v=d();v&&(g.disconnect(),window.clearTimeout(f),u(v))});g.observe(c,{childList:!0,subtree:!0});const f=window.setTimeout(()=>{g.disconnect(),i(null)},C0e);return()=>{g.disconnect(),window.clearTimeout(f)}},[e,a,t,n]),i}function A0e({section:e,landOn:t,onSection:n,onClose:a,providers:i,sound:o,tones:r,customTones:c,notify:d,appearance:u,versionCheck:p,desktopUpdate:g,restart:f,doors:v}){const k=ae(),y=m.useRef(null),N=m.useCallback(Se=>{y.current=Se},[]);function w(Se,tt=!1){y.current?(B(""),y.current(Se,tt),requestAnimationFrame(()=>{var fe,He;return(He=(fe=j.current)==null?void 0:fe.scrollIntoView)==null?void 0:He.call(fe,{block:"nearest",inline:"nearest"})})):Se()}const S=()=>w(a,!0),j=m.useRef(null),A=_t(S,{focusRef:j}),T=qt(()=>w(a)),E=m.useRef([]),q=Xu(),F=KT(q),z=Foe(F,e,i.claude),H=Math.max(0,z.findIndex(Se=>Se.id===e)),I=jl("(max-width: 640px)"),[L,O]=m.useState(""),[_,M]=m.useState(0),U=m.useRef(null),G=m.useRef(null),W=L.trim()!=="",$=m.useMemo(()=>Hre(L,AB(i.claude,F,Qu(q))),[L,i.claude,F,q,k]),Y=j0e(G,!W,e),B=Se=>{O(Se),M(0)};m.useEffect(()=>{t&&Y(t)},[t,Y]);const V=Se=>{w(()=>{B(""),n(Se),requestAnimationFrame(()=>{var tt;return(tt=document.getElementById(`settings-tab-${Se}`))==null?void 0:tt.focus()})})},Z=Se=>{w(()=>{B(""),n(Se.section),Zm(Se)||Y(Se.id)})};m.useEffect(()=>{const Se=tt=>{var lt,gt;if(!$oe(tt))return;const fe=A.current,He=tt.target;!fe||!(He===document.body||He===document.documentElement||He&&fe.contains(He))||(tt.preventDefault(),(lt=U.current)==null||lt.focus(),(gt=U.current)==null||gt.select())};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},[A]),m.useEffect(()=>{var Se,tt,fe,He;Uoe((Se=document.activeElement)==null?void 0:Se.id,e)&&((tt=j.current)==null||tt.focus()),(He=(fe=j.current)==null?void 0:fe.scrollIntoView)==null||He.call(fe,{block:"nearest",inline:"nearest"})},[e]);const{theme:D,setTheme:K,characterEnabled:X,setCharacterEnabled:Q,character:ee,setCharacter:ne}=u,de=Qn(),ge=Se=>{const tt=pT(Se,H,z.length,"vertical");tt.kind!=="pass"&&(Se.preventDefault(),w(()=>{var fe;B(""),n(z[tt.index].id),(fe=E.current[tt.index])==null||fe.focus()}))},le=Se=>{Se.key===" "&&Se.stopPropagation()},{soundOn:he,toggleSound:ce}=o,{tonePrefs:oe,previewTone:ve,changeTone:ke}=r,{customSelections:ye,customAssets:Le,clearCustomOnly:Ke,selectCustomTone:Qe,importNotificationAudio:Ae,createNotificationVoice:je,renameCustomAsset:Oe,deleteCustomAsset:Ve,previewCustomAsset:nt}=c,{notifyPermission:Ye,notifyOn:Ce,notifyVetoed:ze,toggleNotify:De,notifySupported:Fe,askForNotifications:ot,accountNotify:se,toggleAccountNotify:Ne}=d,Ie=(()=>{switch(e){case"radar":return s.jsx(_Te,{onOpen:v.radar});case"claude":return s.jsx($Te,{});case"appearance":return s.jsxs(s.Fragment,{children:[s.jsx(e0e,{theme:D,onTheme:K,singleKeys:de}),s.jsx(v0e,{characterEnabled:X,character:ee,onCharacter:ne,onToggleCharacter:()=>Q(Se=>!Se)})]});case"reading":return s.jsx(s0e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity});case"keyboard":return s.jsx(fTe,{singleKeys:de,onToggleSingleKeys:()=>wne(!de)});case"notifications":return s.jsx(bTe,{notifyOn:Ce,onToggleNotify:De,notifyVetoed:ze,notifyPermission:Fe?Ye:"unsupported",onAskNotify:ot,accountNotify:se,onToggleAccountNotify:Ne});case"sounds":return s.jsx(ETe,{soundOn:he===!0,onToggleSound:ce,prefs:oe,claudeHere:i.claude,onLevel:(Se,tt)=>ke(Se,{level:tt}),onFigure:(Se,tt)=>ke(Se,{figure:tt}),onPreview:Se=>ve(Se),customAssets:Le,customSelections:ye,onBuiltInSelected:Ke,onCustomSelected:Qe,onImportCustom:Ae,onCreateVoice:je,onRenameCustom:Oe,onPreviewCustom:nt,onDeleteCustom:Ve});case"integrations":return s.jsx(XTe,{onBeforeLeaveChange:N});case"data":return s.jsx(KTe,{});case"about":return s.jsx(h0e,{version:p.version,notice:p.notice,readyAppUpdate:g.readyAppUpdate,updateRestarting:g.desktopUpdateRestarting,updateFailure:g.desktopUpdateFailure,onUpdateRestart:Se=>{g.askDesktopUpdateRestart(Se)},doors:v});default:return s.jsxs(s.Fragment,{children:[s.jsx(cTe,{}),s.jsx(dTe,{}),s.jsx(eD,{provider:"Codex"}),i.claude&&s.jsx(eD,{provider:"Claude"}),s.jsx(f0e,{autoRestart:f.autoRestart,onToggleAutoRestart:f.toggleAutoRestart,version:p.version}),s.jsx(pTe,{claudeHere:i.claude,codexHere:i.codex,singleKeys:de,doors:v})]})}})(),Be=e==="reading"?s.jsx(a0e,{textSize:u.textSize,density:u.density,onTextSize:u.setTextSize,onDensity:u.setDensity}):e==="integrations"&&q.connections!==null?s.jsx("span",{className:"ig-total",children:k("settings.savedConnections",{count:q.connections.length})}):null;return s.jsx("div",{className:"modal-backdrop",...T,role:"presentation",children:s.jsxs("div",{ref:A,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:Se=>Se.stopPropagation(),onKeyDown:le,children:[s.jsxs("header",{className:"modal-head",children:[s.jsx("div",{className:"modal-title",children:s.jsx("span",{id:"settings-title",className:"modal-tool-name",children:k("settings.title")})}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>w(a),"aria-label":k("settings.close"),title:k("settings.closeTip"),children:"×"})})]}),s.jsxs("div",{className:"settings-body",children:[s.jsxs("div",{className:"settings-side",children:[s.jsx(k0e,{inputRef:U,query:L,onQuery:B,results:$,active:_,onActive:M,onOpen:Z}),s.jsx(y0e,{query:L,count:$.length}),s.jsx("div",{className:"settings-nav",role:"tablist","aria-label":k("settings.sections"),"aria-orientation":I?"horizontal":"vertical",onKeyDown:ge,children:z.map((Se,tt)=>s.jsxs("button",{ref:fe=>{E.current[tt]=fe,Se.id===e&&(j.current=fe)},type:"button",role:"tab",id:`settings-tab-${Se.id}`,className:"settings-tab","aria-selected":Se.id===e,"aria-controls":"settings-pane",tabIndex:Se.id===e?0:-1,onClick:()=>V(Se.id),children:[s.jsx(Xm,{section:Se.id}),s.jsx("span",{className:"settings-tab-label",children:k(`settings.section.${Se.id}.label`)})]},Se.id))})]}),s.jsxs("div",{ref:G,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:W||void 0,children:[s.jsxs("div",{className:"settings-pane-head",children:[s.jsxs("div",{className:"settings-pane-heading",children:[s.jsx("h2",{className:"settings-pane-title",children:k(`settings.section.${z[H].id}.label`)}),s.jsx("p",{className:"settings-pane-note",children:k(`settings.section.${z[H].id}.note`)})]}),Be]}),Ie]},e),W&&s.jsx(w0e,{query:L,results:$,active:_,onOpen:Z})]})]})})}function T0e({tool:e,onClose:t}){const n=ae(),a=_t(t),i=qt(t),o=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=m.useRef({of:null});r.current.of!==e&&(r.current={of:e}),e.input!==void 0&&(r.current.input=e.input),e.response!==void 0&&(r.current.response=e.response);const c=r.current.input??e.inputPreview,d=r.current.response??e.errorPreview,u=e.trimmed===!0&&r.current.input===void 0&&r.current.response===void 0,p=m.useMemo(()=>{const g=JX(e.name,c,d);return{input:g.input.map((f,v)=>s.jsx(dD,{block:f},v)),response:g.response.map((f,v)=>s.jsx(dD,{block:f},v)),copyInput:s1(e.name,"input",c),copyResponse:s1(e.name,"response",d)}},[e.name,c,d]);return s.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:s.jsxs("div",{ref:a,className:"modal tool-modal",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[s.jsxs("header",{className:"modal-head",children:[s.jsxs("div",{className:"modal-title",children:[s.jsx("span",{className:`status-dot ${o}`,"aria-hidden":!0}),s.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),s.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("span",{className:"modal-dur",children:V2(e,n("insights.tool.inflight"))}),s.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":n("insights.audit.closeEsc"),title:n("insights.audit.closeEsc"),children:"×"})]})]}),s.jsxs("section",{className:"modal-body",children:[u&&s.jsx("div",{className:"modal-section",children:s.jsx("p",{className:"modal-note",children:n("insights.tool.released")})}),s.jsxs("div",{className:"modal-section",children:[s.jsxs("div",{className:"tm-head",children:[s.jsx("h4",{children:n("insights.cost.inputTitle")}),s.jsx(uD,{text:p.copyInput,what:"input"})]}),p.input]}),s.jsxs("div",{className:"modal-section",children:[s.jsxs("div",{className:"tm-head",children:[s.jsxs("h4",{children:[n("insights.tool.response")," ",o==="err"&&s.jsx("span",{className:"err-tag",children:n("insights.tool.error")})]}),e.endedAt!=null&&s.jsx(uD,{text:p.copyResponse,what:"response"})]}),e.endedAt==null?s.jsx("pre",{children:n("insights.tool.waiting")}):p.response]})]})]})})}const R0e={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function dD({block:e}){const[t,n]=m.useState(!1);if(e.inline)return s.jsxs("p",{className:"tm-inline",children:[e.label&&s.jsx("span",{className:"tm-label",children:e.label}),s.jsx("code",{children:e.text})]});const a=m.useMemo(()=>BX(e),[e]),{shown:i}=w2(a,t),o=HX(a,t);return s.jsxs("div",{className:"tm-block",children:[e.label&&s.jsx("span",{className:"tm-label",children:e.label}),s.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?i.map((r,c)=>s.jsxs("span",{className:r.tone?R0e[r.tone]:void 0,children:[r.text,c<i.length-1?`
352
352
  `:""]},c)):i.map(r=>r.text).join(`
353
- `)}),o&&s.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(r=>!r),children:o.label})]})}function uD({text:e,what:t}){const n=ae(),[a,i]=m.useState(!1),o=m.useRef(!0);return m.useEffect(()=>()=>{o.current=!1},[]),s.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n(a?`insights.tool.copied.${t}`:`insights.tool.copy.${t}`),onClick:()=>void Ks(e).then(r=>{!r||!o.current||(i(!0),window.setTimeout(()=>{o.current&&i(!1)},1600))}),children:n(a?"insights.tool.copiedWord":"insights.tool.copyWord")})}const E0e=Lf(()=>Pr(()=>import("./UsageHistoryModal-Cmbih6Xe.js"),[]),()=>C("shell.lazy.usageHistory")),_0e=Lf(()=>Pr(()=>import("./BrowserWatchModal-ByNoan60.js"),[]),()=>C("shell.lazy.browserWatch")),q0e=Lf(()=>Pr(()=>import("./TrafficRadar-Dse2YLny.js"),[]),()=>C("shell.lazy.radar"));function z0e({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:a,restart:i,upgrade:o,lanPairs:r,attention:c,clearFlow:d,watchBadge:u,announcements:p,appearance:g,providers:f,stateRef:v,agentCount:k,menus:y,sound:N,tones:w,customTones:S,notify:j,panelDoors:A}){Ea();const{openedTool:T,setOpenedToolKey:E,usageHistoryOpen:q,setUsageHistoryOpen:F,browserWatchOpen:z,setBrowserWatchOpen:H,contextAgent:I,setContextFor:L,summaryFor:O,setSummaryFor:_,keyHelpOpen:M,setKeyHelpOpen:U,feedbackOpen:G,setFeedbackOpen:W,feedbackPrefill:$,setFeedbackPrefill:Y,openFeedback:B}=e,{trafficRadarOpen:V,setTrafficRadarOpen:Z}=e,{tourOpen:D,openTour:K,closeTour:X,releaseNotes:Q,closeReleaseNotes:ee,chipVersion:ne,openReleaseNotes:de}=t,{desktopUpdateRestarting:ge,desktopUpdateFailure:le,readyAppUpdate:he,askDesktopUpdateRestart:ce}=n,{version:oe,showNotice:ve}=a,{askRestart:ke}=i,{clearConfirmOpen:ye,setClearConfirmOpen:Le,requestClear:Ke}=d,{setWatchOn:Qe,markWatchSeen:Ae}=u,{setWatchSaid:je}=p,{palette:Oe}=g,{settingsOpen:Ve,settingsSection:nt,settingsLandOn:Ye,showSection:Ce,closeSettings:ze,openSettings:De}=y;return s.jsxs(s.Fragment,{children:[T&&s.jsx(T0e,{tool:T,onClose:()=>E(null)}),q&&s.jsx(m.Suspense,{fallback:null,children:s.jsx(E0e,{providers:f,onClose:()=>F(!1)})}),z&&s.jsx(m.Suspense,{fallback:null,children:s.jsx(_0e,{onClose:()=>H(!1),onSeen:Fe=>{je(""),Ae(Fe)},onWatching:Qe,palette:Oe})}),I&&s.jsx(Gee,{agent:I,onClose:()=>L(null)}),V&&s.jsx(m.Suspense,{fallback:null,children:s.jsx(q0e,{sessions:[...v.current.agents.values()].filter(Fe=>Fe.kind==="root"&&Fe.provider!=="codex").map(Fe=>({id:Fe.sessionId,label:Om(Fe.sessionName,Fe.sessionTitle).face??Fe.cwdBasename??Fe.label,project:Fe.cwdBasename??Fe.label,workspace:Fe.cwd})),onClose:()=>Z(!1)})}),G&&s.jsx(DW,{initialKind:$==null?void 0:$.initialKind,initialBody:$==null?void 0:$.initialBody,onClose:()=>{W(!1),Y(null)}}),O&&s.jsx(oTe,{state:v.current,sessionId:O,onClose:()=>_(null)}),Ve&&s.jsx(A0e,{section:nt,landOn:Ye,onSection:Ce,onClose:ze,providers:f,sound:N,tones:w,customTones:S,notify:j,appearance:g,versionCheck:a,desktopUpdate:n,restart:i,doors:{whatsNew:io(ze,de),update:io(ze,()=>{de(),ve()}),tour:io(ze,K),feedback:io(ze,()=>B()),accounts:io(ze,A.accounts),localNetwork:io(ze,A.localNetwork),browserWatch:io(ze,()=>H(!0)),radar:io(ze,()=>Z(!0))}}),Q&&s.jsx(sTe,{entries:Q.entries,since:Q.since,firstRun:Q.firstRun,running:ne,onClose:ee,onTour:()=>{ee(),K()},updateVersion:he==null?void 0:he.version,updateBusy:ge,updateFailure:le&&(!he||he.version===le.version)?AW(le.failure,le.version):void 0,onUpdateRestart:he?()=>{ce(he.version)}:void 0,onRestart:!he&&(oe!=null&&oe.canRestart)?()=>{ee(),ke()}:void 0,updateCheck:{versionCheck:a,upgrade:o,restart:i,desktopUpdate:n,running:ne,onHandOff:ee}}),s.jsx(L0e,{lanPairs:r,attention:c}),M&&s.jsx(lAe,{onClose:()=>U(!1),onTour:()=>{U(!1),K()},onSettings:()=>{U(!1),De("keyboard")}}),D&&s.jsx(Z3,{title:C("shell.guide.welcome.title"),steps:Dge,onClose:X}),ye&&s.jsx(eje,{agentCount:k,onConfirm:()=>Ke("confirmation"),onCancel:()=>Le(!1)})]})}function L0e({lanPairs:e,attention:t}){const n=wAe(e);return s.jsxs(s.Fragment,{children:[n,s.jsx(SAe,{...t,pairing:n!=null})]})}const O0e=10,ZW=500,XW=4e3,P0e=[/ResizeObserver loop/i,/^Script error\.?$/i],hD=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,M0e=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function I0e(e,t){const n=typeof e=="string"?e.split(`
353
+ `)}),o&&s.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(r=>!r),children:o.label})]})}function uD({text:e,what:t}){const n=ae(),[a,i]=m.useState(!1),o=m.useRef(!0);return m.useEffect(()=>()=>{o.current=!1},[]),s.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n(a?`insights.tool.copied.${t}`:`insights.tool.copy.${t}`),onClick:()=>void Ks(e).then(r=>{!r||!o.current||(i(!0),window.setTimeout(()=>{o.current&&i(!1)},1600))}),children:n(a?"insights.tool.copiedWord":"insights.tool.copyWord")})}const E0e=Lf(()=>Pr(()=>import("./UsageHistoryModal-2pcftBwX.js"),[]),()=>C("shell.lazy.usageHistory")),_0e=Lf(()=>Pr(()=>import("./BrowserWatchModal-DedhCY8E.js"),[]),()=>C("shell.lazy.browserWatch")),q0e=Lf(()=>Pr(()=>import("./TrafficRadar-BqjzLlO_.js"),[]),()=>C("shell.lazy.radar"));function z0e({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:a,restart:i,upgrade:o,lanPairs:r,attention:c,clearFlow:d,watchBadge:u,announcements:p,appearance:g,providers:f,stateRef:v,agentCount:k,menus:y,sound:N,tones:w,customTones:S,notify:j,panelDoors:A}){Ea();const{openedTool:T,setOpenedToolKey:E,usageHistoryOpen:q,setUsageHistoryOpen:F,browserWatchOpen:z,setBrowserWatchOpen:H,contextAgent:I,setContextFor:L,summaryFor:O,setSummaryFor:_,keyHelpOpen:M,setKeyHelpOpen:U,feedbackOpen:G,setFeedbackOpen:W,feedbackPrefill:$,setFeedbackPrefill:Y,openFeedback:B}=e,{trafficRadarOpen:V,setTrafficRadarOpen:Z}=e,{tourOpen:D,openTour:K,closeTour:X,releaseNotes:Q,closeReleaseNotes:ee,chipVersion:ne,openReleaseNotes:de}=t,{desktopUpdateRestarting:ge,desktopUpdateFailure:le,readyAppUpdate:he,askDesktopUpdateRestart:ce}=n,{version:oe,showNotice:ve}=a,{askRestart:ke}=i,{clearConfirmOpen:ye,setClearConfirmOpen:Le,requestClear:Ke}=d,{setWatchOn:Qe,markWatchSeen:Ae}=u,{setWatchSaid:je}=p,{palette:Oe}=g,{settingsOpen:Ve,settingsSection:nt,settingsLandOn:Ye,showSection:Ce,closeSettings:ze,openSettings:De}=y;return s.jsxs(s.Fragment,{children:[T&&s.jsx(T0e,{tool:T,onClose:()=>E(null)}),q&&s.jsx(m.Suspense,{fallback:null,children:s.jsx(E0e,{providers:f,onClose:()=>F(!1)})}),z&&s.jsx(m.Suspense,{fallback:null,children:s.jsx(_0e,{onClose:()=>H(!1),onSeen:Fe=>{je(""),Ae(Fe)},onWatching:Qe,palette:Oe})}),I&&s.jsx(Gee,{agent:I,onClose:()=>L(null)}),V&&s.jsx(m.Suspense,{fallback:null,children:s.jsx(q0e,{sessions:[...v.current.agents.values()].filter(Fe=>Fe.kind==="root"&&Fe.provider!=="codex").map(Fe=>({id:Fe.sessionId,label:Om(Fe.sessionName,Fe.sessionTitle).face??Fe.cwdBasename??Fe.label,project:Fe.cwdBasename??Fe.label,workspace:Fe.cwd})),onClose:()=>Z(!1)})}),G&&s.jsx(DW,{initialKind:$==null?void 0:$.initialKind,initialBody:$==null?void 0:$.initialBody,onClose:()=>{W(!1),Y(null)}}),O&&s.jsx(oTe,{state:v.current,sessionId:O,onClose:()=>_(null)}),Ve&&s.jsx(A0e,{section:nt,landOn:Ye,onSection:Ce,onClose:ze,providers:f,sound:N,tones:w,customTones:S,notify:j,appearance:g,versionCheck:a,desktopUpdate:n,restart:i,doors:{whatsNew:io(ze,de),update:io(ze,()=>{de(),ve()}),tour:io(ze,K),feedback:io(ze,()=>B()),accounts:io(ze,A.accounts),localNetwork:io(ze,A.localNetwork),browserWatch:io(ze,()=>H(!0)),radar:io(ze,()=>Z(!0))}}),Q&&s.jsx(sTe,{entries:Q.entries,since:Q.since,firstRun:Q.firstRun,running:ne,onClose:ee,onTour:()=>{ee(),K()},updateVersion:he==null?void 0:he.version,updateBusy:ge,updateFailure:le&&(!he||he.version===le.version)?AW(le.failure,le.version):void 0,onUpdateRestart:he?()=>{ce(he.version)}:void 0,onRestart:!he&&(oe!=null&&oe.canRestart)?()=>{ee(),ke()}:void 0,updateCheck:{versionCheck:a,upgrade:o,restart:i,desktopUpdate:n,running:ne,onHandOff:ee}}),s.jsx(L0e,{lanPairs:r,attention:c}),M&&s.jsx(lAe,{onClose:()=>U(!1),onTour:()=>{U(!1),K()},onSettings:()=>{U(!1),De("keyboard")}}),D&&s.jsx(Z3,{title:C("shell.guide.welcome.title"),steps:Dge,onClose:X}),ye&&s.jsx(eje,{agentCount:k,onConfirm:()=>Ke("confirmation"),onCancel:()=>Le(!1)})]})}function L0e({lanPairs:e,attention:t}){const n=wAe(e);return s.jsxs(s.Fragment,{children:[n,s.jsx(SAe,{...t,pairing:n!=null})]})}const O0e=10,ZW=500,XW=4e3,P0e=[/ResizeObserver loop/i,/^Script error\.?$/i],hD=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,M0e=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function I0e(e,t){const n=typeof e=="string"?e.split(`
354
354
  `):[],a=n.some(o=>/^\s*at\s/.test(o)),i=n.flatMap(o=>!a||/^\s*at\s/.test(o)?o.match(M0e)??[]:[]);return i.length?i.every(o=>hD.test(o)):typeof t=="string"&&hD.test(t)}const bm=String.raw`[^\s\\/:'"\`<>|?*;,]`,D0e=String.raw`${bm}(?:[^\\/\r\n:'"\`<>|?*;,]*${bm})?[\\/]`,F0e=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,qd=String.raw`(?:${D0e})*(?:${F0e})?`,U0e=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${qd}|[A-Za-z]:[\\/]${qd}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${qd}|/(?=${bm})${qd}|(?<!:)//(?=${bm})${qd})`,B0e=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,H0e=new Set([".claude",".codex"]);function W0e(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...a]=e.slice(2).split(/[\\/]/);return n?H0e.has(n)?a.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const G0e=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function $0e(e,t,n){return n?"<deck>":`${t}://<host>`}const pD=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,QW=String.raw`${pD}(?:\.${pD}){3}`,BS=String.raw`[0-9A-Fa-f]{1,4}`,gD=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${BS}:){7})(?:(?:${BS})?:)+(?:${QW}|${BS})?`,mD=String.raw`%[\w-]+(?:\.[\w-]+)*`,fD=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,V0e=String.raw`(?<![\w:.%-])(?:\[(?!${fD}\])${gD}(?:${mD})?\]|(?!${fD}(?::\d{1,5})?(?![\w:%]|\.\d))${gD}(?:${mD})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${QW}(?![\w-]|\.\d)`,HS=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,K0e=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${HS}|${HS}(?=:\d{1,5}(?![\w:-]|\.\w))|${HS}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function bD(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(U0e,"g"),W0e).replace(new RegExp(B0e,"g"),"<project>").replace(new RegExp(G0e,"g"),$0e).replace(new RegExp(V0e,"g"),"<host>").replace(new RegExp(K0e,"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,}|github_pat_[A-Za-z0-9_]{20,}|gl(?:pat|dt|rt|cbt|ptt|ft|imt|agent|oas|soat)-[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 e5=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function J0e(e,t,n=e5){const a=String(e??"").slice(0,ZW).trim();a&&n({message:a,stack:typeof t=="string"?t.slice(0,XW):void 0})}function Y0e(e,t=window,n=e5){let a=0;const i=new Set,o=(d,u,p)=>{const g=String(d??"").slice(0,ZW).trim();!e()||!g||a>=O0e||i.has(g)||P0e.some(f=>f.test(g))||I0e(u,p)||(i.add(g),a++,n({message:g,stack:typeof u=="string"?u.slice(0,XW):void 0}))},r=d=>{var u,p;return o(((u=d.error)==null?void 0:u.message)??d.message,(p=d.error)==null?void 0:p.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",r),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",r),t.removeEventListener("unhandledrejection",c)}}const Z0e=12;function X0e(e,t){const n=[bD(e).trim()||C("shell.error.noMessage")],a=t==null?void 0:t.trim();if(a){const i=a.split(`
355
355
  `).slice(0,Z0e).join(`
356
356
  `);n.push("",bD(i).trim())}return n.join(`
357
357
  `)}class Q0e extends m.Component{constructor(){super(...arguments);Ma(this,"state",{error:null,componentStack:null,reportOpen:!1});Ma(this,"onKey",n=>{Pm(n.key)&&jn.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,a){console.error("ccdeck hit a render error it could not draw past",n,a.componentStack),this.setState({componentStack:a.componentStack??null}),J0e(n.message,n.stack),oW("offline")}componentDidUpdate(n,a){this.state.reportOpen!==a.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:a,reportOpen:i}=this.state;return n?s.jsxs("div",{className:"error-fallback",children:[s.jsxs("div",{className:"error-fallback-card",role:"alert",children:[s.jsx("p",{className:"error-fallback-title",children:C("shell.error.title")}),s.jsx("p",{className:"error-fallback-note",children:C("shell.error.note")}),s.jsxs("div",{className:"error-fallback-actions",children:[s.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:C("shell.reload")}),s.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:C("shell.error.report")})]})]}),i&&s.jsx(DW,{initialKind:"bug",initialBody:X0e(n.message,a),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const eRe=1e3;function tRe(e={}){const t=Math.max(1,Math.floor(e.limit??eRe)),n=e.protect;let a=!1,i=[],o=new Set,r=0,c=0,d=null;return{get paused(){return a},get size(){return i.length},get dropped(){return r},get overflowed(){return r>0},get through(){return c},accept(u){const p=typeof(u==null?void 0:u.seq)=="number"?u.seq:null,g=(u==null?void 0:u.epoch)??null,f=g!==null&&g!==d;f&&(d=g,c=0);const v=p!==null&&!f&&p<=c;if(p!==null&&p>c&&(c=p),!a)return!0;if(v)return!1;if(i.push(u),n!=null&&n(u)&&o.add(u),i.length>t){let k=0;if(o.size<i.length)for(;o.has(i[k]);)k++;const[y]=i.splice(k,1);o.delete(y),r++}return!1},setPaused(u){if(a=u,u)return[];const p=i;return i=[],o=new Set,r=0,p}}}function nRe(e){const t=m.useState(()=>tRe({protect:o=>oQ(e.current,o)}))[0],[n,a]=m.useState(!1),i=m.useCallback(()=>{const o=t.paused&&t.dropped>0,r=t.setPaused(!t.paused);o&&GQ(e.current);for(const c of r)e.current=q2(e.current,c);a(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:i}}const vD="agent-dag.accountPanelProvider",aRe=400,sRe={claude:!1,codex:!1};function iRe(e,t){const[n,a]=m.useState(()=>ht(vD)==="codex"?"codex":"claude"),i=e.claude&&!!e.codex,o=i?n:e.codex?"codex":"claude",[r,c]=m.useState(!1);m.useEffect(()=>{if(!i||!t){c(!1);return}const y=setTimeout(()=>c(!0),aRe);return()=>clearTimeout(y)},[i,t]);const d=m.useCallback(y=>{a(y),pt(vD,y)},[]),u=m.useRef(!1),p=m.useCallback(y=>{y!==o&&(u.current=!0,c(!0),d(y))},[d,o]);m.useLayoutEffect(()=>{var y;u.current&&(u.current=!1,(y=document.querySelector(`#${t5(o)} [role="radio"][aria-checked="true"]`))==null||y.focus())},[o]);const[g,f]=m.useState(sRe),v=m.useCallback(y=>f(N=>({...N,claude:y})),[]),k=m.useCallback(y=>f(N=>({...N,codex:y})),[]);return{both:i,shown:o,bothMounted:r,remember:d,pick:p,notices:g,noteClaude:v,noteCodex:k}}function t5(e){return e==="codex"?"codex-accounts-panel":"accounts-panel"}const zj={kind:"assumed",claude:!0,codex:!0};function oRe(e){if(!e||typeof e!="object")return zj;const t=e.providers;if(!t||typeof t!="object")return zj;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function rRe(e){const[t,n]=m.useState(null),[a,i]=m.useState(zj);m.useEffect(()=>{let r=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{r||(i(oRe(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{r=!0}},[e]);const o=pa(a);return{workspace:t,providers:a,providersRef:o}}const n5=3*6e4,cRe=2e4;function lRe({fetchReport:e,visible:t,now:n,onReport:a}){let i=0,o=!0;const r=async()=>{if(!t())return;const c=await e();!o||!c||(i=n(),a(c))};return{tick:r,wake:async()=>{t()&&n()-i>=n5&&await r()},stop:()=>{o=!1}}}async function dRe(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(cRe)});return e.ok?await e.json():null}catch{return null}}function uRe(e){const[t,n]=m.useState(null);return m.useEffect(()=>{if(!e){n(null);return}const a=lRe({fetchReport:dRe,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});a.tick();const i=window.setInterval(a.tick,n5),o=()=>{a.wake()};return document.addEventListener("visibilitychange",o),()=>{a.stop(),window.clearInterval(i),document.removeEventListener("visibilitychange",o)}},[e]),t}const hRe={degraded:"shell.incident.words.degraded",partial_outage:"shell.incident.words.partial_outage",major_outage:"shell.incident.words.major_outage",maintenance:"shell.incident.words.maintenance"},pRe={degraded:"shell.incident.chip.degraded",partial_outage:"shell.incident.chip.partial_outage",major_outage:"shell.incident.chip.major_outage",maintenance:"shell.incident.chip.maintenance"},gRe={degraded:"shell.incident.short.degraded",partial_outage:"shell.incident.short.partial_outage",major_outage:"shell.incident.short.major_outage",maintenance:"shell.incident.short.maintenance"},mRe={claude:"Claude",codex:"Codex"},fRe=new Set(["status.claude.com","status.openai.com"]),bRe=30*6e4,vRe=10*6e4;function kRe(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&fRe.has(t.hostname)?t:null}catch{return null}}function kD(e){return new Date(e).toLocaleTimeString(qe(),{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function wRe(e){const t=Math.floor(e/6e4);return t<1?C("shell.ago.now"):t<60?C("shell.ago.min",{n:t}):C("shell.ago.hr",{n:Math.floor(t/60)})}function yRe(e,t){if(!e||typeof e!="object")return null;const n=un(hRe,e.state),a=n&&C(n),i=un(mRe,e.provider);if(!a||!i||typeof e.checkedAt!="number"||t-e.checkedAt>bRe)return null;const o=kRe(e.statusPageUrl);if(!o)return null;const r=Array.isArray(e.components)?e.components:[],c=e.stale===!0||t-e.checkedAt>vRe,d=[`${i}: ${a}${e.summary?` — ${e.summary}`:""}`,r.length>0?C("shell.incident.affected",{components:r.join(", ")}):null,e.scope==="page"?C("shell.incident.scopePage",{name:i}):null,c?C("shell.incident.lastRead",{host:o.hostname,time:kD(e.checkedAt)}):C("shell.incident.reported",{host:o.hostname,ago:wRe(t-e.checkedAt)}),C("shell.incident.opensPage")],u=c?kD(e.checkedAt):null,p=un(pRe,e.state),g=un(gRe,e.state);return{provider:e.provider,state:e.state,name:i,label:`${i} · ${a}${u?` · ${C("shell.incident.asOf",{time:u})}`:""}`,words:a,chipWords:p?C(p):a,shortWords:g?C(g):a,asOf:u,what:e.summary||(r.length>0?r.join(", "):null),href:o.href,host:o.hostname,stale:c,detail:d.filter(Boolean).join(`
358
- `)}}function xRe(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>yRe(n,t)).filter(n=>n!==null)}function CRe(e){return e.map(t=>C(t.state.endsWith("outage")?"shell.incident.sentenceA":"shell.incident.sentence",{name:t.name,words:t.words})).join(" ")}const SRe=()=>C("shell.incident.clear");function NRe({version:e,loadVersion:t}){var u;const[n,a]=m.useState(!1),i=((u=e==null?void 0:e.upgrade)==null?void 0:u.state)??"idle",o=BNe(e==null?void 0:e.upgrade),r=m.useRef(!1),c=m.useCallback(async()=>{if(Jn(r.current||i==="running")){r.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),r.current=!1}},[i,t]);m.useEffect(()=>{if(i!=="running")return;const p=window.setInterval(t,3e3);return()=>window.clearInterval(p)},[i,t]);const d=m.useCallback(async()=>{const p=e==null?void 0:e.command;!p||!await Ks(p)||(a(!0),window.setTimeout(()=>a(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:i,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const wD="agent-dag.browserWatch.seenMs";function jRe(e,t){return e.filter(n=>n.startMs>t)}function ARe(){const[e,t]=m.useState(()=>Number(ht(wD))||0),[n,a]=m.useState([]),[i,o]=m.useState(!1);m.useEffect(()=>{let d=!0;const u=()=>{fetch("/api/browser-watch?live=0").then(g=>g.ok?g.json():null).then(g=>{var f;!d||!(g!=null&&g.ok)||(a(g.episodes??[]),o(((f=g.settings)==null?void 0:f.enabled)===!0))}).catch(()=>{})};u();const p=setInterval(u,5*6e4);return()=>{d=!1,clearInterval(p)}},[]);const r=m.useMemo(()=>jRe(n,e).length,[n,e]),c=m.useCallback(d=>{t(d),pt(wD,String(d))},[]);return{watchOn:i,setWatchOn:o,watchUnseen:r,markWatchSeen:c}}const a5="agent-dag.character-enabled",s5="agent-dag.fm-volume",TRe=1,yD="agent-dag.fm-source",o1e=[{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 RRe(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 ERe(e){return e!=="0"}function _Re(){return ERe(ht(a5))}function qRe(e){return yB(e,TRe)}function zRe(){return qRe(ht(s5))}const i5=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function xD(e){const t={};for(const n of i5)t[n]=e(n);return t}function LRe(e){return t=>e[t]??""}function ORe(e,t){return i5.every(n=>e[n]===t[n])}function PRe(e,t){let n=null,a=0;function i(){a++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:i,run(o){i();const r=a;let c=!1;const d=()=>{r!==a||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){d();return}e.documentElement.dataset.themeTransition="true";try{const u=e.startViewTransition(d);n=u,u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{d()}),u.finished.then(()=>{n===u&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===u&&(d(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,d()}}}}function CD(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function MRe(){const[e,t]=m.useState(fce),[n,a]=m.useState(bce),[i,o]=m.useState(Ore),r=m.useRef(i),[c]=m.useState(()=>PRe(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=m.useCallback(w=>{const S=typeof w=="function"?w(r.current):w;S!==r.current&&(r.current=S,c.run(()=>Lt.flushSync(()=>o(S))))},[c]);m.useEffect(()=>()=>c.cancel(),[c]);const[u,p]=m.useState(_Re),[g,f]=m.useState(Zoe),[v,k]=m.useState(()=>xD(CD)),y=m.useMemo(()=>LRe(v),[v]),N=m.useCallback(w=>Fxe(w,y),[y]);return m.useEffect(()=>{document.documentElement.dataset.textSize=e,pt(LN,e)},[e]),m.useEffect(()=>{document.documentElement.dataset.density=n,pt(ON,n)},[n]),m.useEffect(()=>{const w=S=>{S.storageArea===Is()&&((S.key===LN||S.key===null)&&t(GA(S.newValue)),(S.key===ON||S.key===null)&&a(MB(S.newValue)))};return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[]),m.useLayoutEffect(()=>{document.documentElement.dataset.theme=i,document.documentElement.dataset.colorScheme=Iu[i].colorScheme,pt(CB,i),k(w=>{const S=xD(CD);return ORe(w,S)?w:S})},[i]),m.useEffect(()=>{pt(a5,u?"1":"0")},[u]),m.useEffect(()=>{pt(gB,g)},[g]),m.useEffect(()=>{const w=document.querySelector('meta[name="theme-color"]'),S=v["--panel"];w&&S&&w.setAttribute("content",S)},[v]),{textSize:e,setTextSize:t,density:n,setDensity:a,theme:i,setTheme:d,characterEnabled:u,setCharacterEnabled:p,character:g,setCharacter:f,palette:v,minimapNodeFill:N}}function IRe(e){const t=m.useRef(null),[n,a]=m.useState(!1),[i,o]=m.useState(()=>new Set),r=m.useMemo(()=>{const d=new Set;for(const u of e.current.agents.values())for(const p of u.tools)d.add(lW(p.name));return Object.keys(cW).filter(u=>d.has(u))},[e.current,e.current.revision]);m.useEffect(()=>{if(r.length<=1){a(!1);return}let d=0;const u=()=>{const p=t.current;if(p&&!document.hidden){const g=p.getBoundingClientRect(),f=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(k=>k.getBoundingClientRect()),v=qie(g,f,8);a(k=>k===v?k:v)}d=window.setTimeout(u,300)};return u(),()=>window.clearTimeout(d)},[r.length]);const c=m.useCallback(d=>{o(u=>{const p=new Set(u);return p.has(d)?p.delete(d):p.add(d),p})},[]);return{presentCats:r,hiddenCats:i,toggleCat:c,catBarRef:t,catBarOccluded:n}}function DRe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const a=new Set,i=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,i())};function r(){var f,v;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(f=n.addEventListener)==null||f.call(n,"statechange",o)),(v=n.resume)==null||v.call(n).then(o,()=>{}),o()}catch{}}function c(f,v,k=v.figure){if(!n||n.state!=="running")return!1;const y=_N(f,k),N=wre(v.level,y),w=n.currentTime;for(const S of y.notes){const j=n.createOscillator(),A=n.createGain();j.type=y.type??"sine",j.frequency.value=S.hz;const T=w+S.at,E=T+S.ms/1e3;A.gain.setValueAtTime(N_,T),A.gain.exponentialRampToValueAtTime(N,T+yre),A.gain.exponentialRampToValueAtTime(N_,E),j.connect(A).connect(n.destination),j.start(T),j.stop(E+.02)}return!0}async function d(f,v){var N;if(!e.loadCustom)return"unavailable";let k;try{k=await e.loadCustom(f)}catch{return"unavailable"}if(!k)return"missing";if(k.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const w=new SpeechSynthesisUtterance(k.text),S=window.speechSynthesis.getVoices();w.voice=S.find(j=>j.voiceURI===k.voiceURI)??null,w.rate=k.rate,w.pitch=k.pitch,w.volume=xre(v.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(w),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let y;try{y=await n.decodeAudioData(k.bytes.slice(0))}catch{return"broken"}try{const w=n.createBufferSource(),S=n.createGain();return w.buffer=y,S.gain.setValueAtTime(Cre(k.normalizationGain,v.level),n.currentTime),w.connect(S).connect(n.destination),a.add(w),(N=w.addEventListener)==null||N.call(w,"ended",()=>a.delete(w)),w.start(n.currentTime),"played"}catch{return"unavailable"}}function u(f,v=!1){var N,w;if(!v&&!e.enabled())return!1;const k=Ere((N=e.prefs)==null?void 0:N.call(e),f),y=((w=e.customSelection)==null?void 0:w.call(e)[f])??null;return y&&e.loadCustom?(d(y,k).then(S=>{var j;S==="played"||S==="locked"||((S==="missing"||S==="broken")&&((j=e.onCustomFailure)==null||j.call(e,f,y)),c(f,{...k,figure:Aa},Aa))}),!0):!n||n.state!=="running"?!1:c(f,k)}function p(f,v=Lr){return d(f,{level:Ym(v),figure:Aa}),!0}function g(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const f of a)try{f.stop()}catch{}a.clear()}return{unlock:r,play:u,previewCustom:p,silence:g,state:i,get context(){return n}}}function FRe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:a,fallbackCustomRef:i}){m.useEffect(()=>{const o=DRe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>a.current,loadCustom:mre,onCustomFailure:(u,p)=>i.current(u,p)});e.current=o;const r=["pointerdown","pointerup","keydown"],c=()=>{for(const u of r)window.removeEventListener(u,d,{capture:!0})},d=()=>{var u;o.unlock(),((u=o.context)==null?void 0:u.state)==="running"&&c()};for(const u of r)window.addEventListener(u,d,{capture:!0});return c},[])}function URe(){const[e,t]=m.useState(zRe),[n,a]=m.useState(()=>Dne(ht(L1))),[i,o]=m.useState(()=>Ine(ht(O1))),[r,c]=m.useState(()=>Fne(ht(yD),n,RRe)),[d,u]=m.useState(()=>new Set),[p,g]=m.useState(0);m.useEffect(()=>{pt(s5,String(e))},[e]),m.useEffect(()=>{pt(O1,i?"1":"0")},[i]),m.useEffect(()=>{pt(L1,JSON.stringify(n))},[n]),m.useEffect(()=>{pt(yD,r)},[r]);const f=m.useCallback((w,S=!1)=>{a(j=>{const A=j.find(T=>T.id===w.id);return A?!S||!w.radio||!A.radio||A.url===w.url&&JSON.stringify(A.radio)===JSON.stringify(w.radio)?j:j.map(T=>T.id===w.id?{...T,url:w.url,radio:w.radio}:T):[...j,w]}),u(j=>{if(!j.has(w.id))return j;const A=new Set(j);return A.delete(w.id),A})},[]),v=m.useCallback((w,S)=>{const j=S.trim();!j||j.length>TU||a(A=>A.map(T=>T.id===w?{...T,name:j}:T))},[]),k=m.useCallback(w=>{a(S=>S.filter(j=>j.id!==w)),c(S=>Une(S,w)),u(S=>{if(!S.has(w))return S;const j=new Set(S);return j.delete(w),j})},[]),y=m.useCallback((w,S=!1)=>{const j=P1(w),A=d.has(j);w===r&&!A&&!S||(A&&u(T=>{const E=new Set(T);return E.delete(j),E}),c(w),g(T=>T+1))},[r,d]),N=m.useCallback((w,S)=>{const j=P1(w);u(A=>{if(A.has(j)===S)return A;const E=new Set(A);return S?E.add(j):E.delete(j),E})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:i,setFmMuted:o,fmSource:r,customFmStations:n,unavailableFmStations:d,fmPlayRequest:p,addFmStation:f,renameFmStation:v,removeFmStation:k,pickFmSource:y,markFmStationAvailability:N}}function BRe(e){const[t,n]=m.useState(null),[a,i]=m.useState(!1),[o,r]=m.useState(null),c=m.useRef(0);m.useEffect(()=>{if(!e||!Eo())return;let k=!1;const y=c.current;return fetch("/api/desktop-update").then(N=>N.ok?N.json():null).then(N=>{if(k||c.current!==y)return;const w=FI(N);w&&n(w)}).catch(()=>{}),()=>{k=!0}},[e]);const d=sNe(t),u=m.useRef(!1),p=m.useRef(0),g=m.useRef(0);m.useEffect(()=>()=>window.clearTimeout(p.current),[]);const f=m.useCallback(async k=>{if(!Jn(u.current))return;const y=++g.current;window.clearTimeout(p.current),u.current=!0,i(!0),r(null);const N=w=>{y===g.current&&(window.clearTimeout(p.current),u.current=!1,i(!1),r({failure:w,version:k}))};try{const w=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!w.ok)return N(oNe(await w.json().catch(()=>null)))}catch{return N("unreachable")}y===g.current&&(p.current=window.setTimeout(()=>N("timeout"),SW))},[]),v=m.useCallback(k=>{if(Eo())try{const y=FI(JSON.parse(k));y&&(c.current++,n(y),y.status!=="ready"&&(g.current++,window.clearTimeout(p.current),u.current=!1,i(!1)))}catch{}},[]);return{desktopUpdateRestarting:a,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:f,onDesktopUpdateEvent:v}}const ig="agent-dag.autoRestart",SD="agent-dag.bundleReloadedFor";function HRe({now:e,stateRef:t,version:n,notice:a,noticeOpen:i,upgradeFailure:o,paused:r}){const[c,d]=m.useState(()=>ht(ig)!=="0"),u=m.useRef(!1),p=m.useCallback(()=>{const H=!c;u.current=!0,Va(ig),d(H),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:H})}).then(I=>I.ok?I.json():null).then(I=>{var L;I!=null&&I.ok&&d(((L=I.prefs)==null?void 0:L.autoUpdate)!==!1)}).catch(()=>{})},[c]),[g,f]=m.useState(!1),[v,k]=m.useState("restart"),[y,N]=m.useState(null),w=m.useRef(!1),S=m.useRef(null),j=m.useRef(0),A=m.useRef(null),T=m.useCallback(async H=>{if(!Jn(w.current))return;const I=(H==null?void 0:H.upgrade)===!0,L=(H==null?void 0:H.whenIdle)===!0;w.current=!0,S.current=o;const O=++j.current,_=()=>{k(I?"npx":"restart"),f(!0)};L||_();try{window.sessionStorage.setItem("agent-dag.restartPending",(a==null?void 0:a.to)??"")}catch{}let M=!1;try{const U=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L?{upgrade:I,whenIdle:L}:{upgrade:I})});M=L&&U.status===409}catch{}if(M){w.current=!1,A.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}L&&_(),window.setTimeout(()=>{if(j.current===O&&w.current){w.current=!1,f(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},I?18e4:3e4)},[a==null?void 0:a.to,o]);m.useEffect(()=>{const H=HI(t.current.agents.values())>0,I=VNe({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:i,visible:document.visibilityState==="visible",busy:H,idleSince:A.current,now:e});A.current=I.idleSince,I.restart&&T({whenIdle:!0})},[c,a==null?void 0:a.kind,n==null?void 0:n.canRestart,i,e,T]);const E=HI(t.current.agents.values()),q=$Ne(E,r),F=_W({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:i,visible:document.visibilityState==="visible",busy:E>0,idleSince:A.current,now:e});m.useEffect(()=>{const H=n==null?void 0:n.running;let I=null,L=null;try{I=window.sessionStorage.getItem("agent-dag.restartPending"),L=window.sessionStorage.getItem(SD)}catch{return}const O=UNe({bundle:"3.53.1",running:H,pending:I,lastTried:L});if(O==="reload"){try{window.sessionStorage.setItem(SD,H??"")}catch{return}window.location.reload();return}if(O!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}w.current=!1,f(!1),N(H??null);const _=window.setTimeout(()=>N(null),6e3);return()=>window.clearTimeout(_)},[n==null?void 0:n.running]),m.useEffect(()=>{if(g&&HNe({asked:S.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}w.current=!1,f(!1)}},[g,o]);const z=m.useCallback(H=>{var I,L;if(!u.current){const O=ht(ig)==="0";Va(ig),O&&((I=H.prefs)==null?void 0:I.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((L=H.prefs)==null?void 0:L.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:p,restarting:g,restartMode:v,restartedTo:y,askRestart:T,restartCopy:q,restartFuseMs:F,loadAutoRestartPrefs:z}}function WRe(){const[e,t]=m.useState([]),n=m.useRef(new Set),[a,i]=m.useState(null),[o,r]=m.useState(void 0);m.useEffect(()=>{let u=!0,p=0;const g=()=>{fetch("/api/lan").then(f=>f.ok?f.json():null).then(f=>u?(f!=null&&f.ok&&t(pq(Array.isArray(f.pending)?f.pending:[],f.aliases)),f):null).catch(()=>null).then(f=>{u&&(r(v=>f!=null&&f.ok?f:v===void 0?null:v),p=window.setTimeout(g,(f==null?void 0:f.enabled)===!0?oj:Y3))})};return g(),()=>{u=!1,window.clearTimeout(p)}},[]);const c=m.useCallback(async(u,p)=>{if(!a){i(u);try{const f=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:u,fp:p})})).json().catch(()=>null);f&&Array.isArray(f.pending)?t(pq(f.pending,f.aliases)):t(v=>v.filter(k=>k.fp!==p))}catch{}finally{i(null)}}},[a]),d=m.useCallback(u=>{a||(n.current.add(u),t(p=>[...p]))},[a]);return{lanPending:e,lanDeferred:n,lanBusy:a,answerLanPair:c,deferLanPair:d,lanStatus:o}}const GRe=6e4;function $Re({enabled:e,lanStatus:t,now:n}){const[a,i]=m.useState(null),[o,r]=m.useState(()=>new Set),[c,d]=m.useState(null),u=m.useCallback(w=>{w!=null&&w.ok&&Array.isArray(w.accounts)&&i(w.accounts)},[]),p=m.useCallback(async w=>{try{const S=await fetch(`/api/claude-accounts${w?"?refresh=1":""}`);S.ok&&u(await S.json())}catch{}},[u]);m.useEffect(()=>{e&&p(!1)},[e,p]),m.useEffect(()=>{if(!e)return;let w=Date.now();const S=()=>{document.visibilityState!=="visible"||Date.now()-w<GRe||(w=Date.now(),p(!1))};return document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[e,p]);const g=m.useMemo(()=>e?uAe(a,{lan:t,now:n,closed:o}):[],[e,a,t,n,o]),f=m.useRef(g);f.current=g;const v=m.useCallback(w=>{w.length&&r(S=>new Set([...S,...w]))},[]),k=m.useCallback(()=>{const w=f.current;w.length&&(v(w.map(S=>S.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:w.map(S=>({key:S.key,since:S.since}))})}).catch(()=>{}))},[v]),y=m.useRef(c);y.current=c;const N=m.useCallback(w=>{const S=y.current;v(hAe(S?[S,...f.current]:f.current,w))},[v]);return{rows:g,signingIn:c,observe:u,signIn:d,signedIn:N,refresh:m.useCallback(()=>{p(!0)},[p]),closeSignIn:m.useCallback(()=>d(null),[]),later:k}}const o5=288,VRe=o5;function KRe(e,t,n){return e?"session-list":t||n?"accounts":null}function ND(e){return e==="session-list"?VRe:e==="accounts"?o5:0}const JRe=240,YRe=20;function ZRe(e){const t=m.useRef(0),n=m.useRef(e);return m.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=vl()?0:performance.now()+JRe+YRe)},[e]),t}const r5="agent-dag.sessionListOpen",c5="agent-dag.accountsPanelOpen";function XRe(){return ht(r5)==="1"}function QRe(e){pt(r5,e?"1":"0")}function eEe(){const e=ht(c5);return e===null?!0:e==="1"}function tEe(){const e=m.useRef(!1),t=m.useRef(!1),[n,a]=m.useState(()=>{const k=XRe();return k&&AN()?(e.current=!0,!1):k});m.useEffect(()=>{if(n)e.current=!1;else if(e.current)return;QRe(n)},[n]);const i=m.useRef(!1),[o,r]=m.useState(()=>{const k=eEe();return k&&n?(i.current=!0,!1):k&&AN()?(t.current=!0,!1):k});m.useEffect(()=>{if(o)t.current=!1;else if(t.current)return;!o&&i.current||pt(c5,o?"1":"0")},[o]),m.useEffect(()=>{!n&&i.current&&(i.current=!1,r(!0))},[n]);const c=m.useCallback(()=>{a(k=>(k||r(y=>(y&&(i.current=!0),!1)),!k))},[]),d=m.useCallback(()=>{i.current=!1,r(k=>(k||a(!1),!k))},[]),u=m.useCallback(()=>{i.current=!1,r(k=>(k||a(!1),!0))},[]),p=m.useCallback(()=>a(!1),[]),g=m.useCallback(()=>{i.current=!1,a(!1)},[]),f=m.useCallback(()=>r(!1),[]),v=KRe(n,o,i.current);return{sessionListOpen:n,accountsPanelOpen:o,panel:v,toggleSessionList:c,toggleAccountsPanel:d,openAccountsPanel:u,closeSessionList:p,closeSessionListToCanvas:g,closeAccountsPanel:f}}const l5="agent-dag.detailOpen",d5="agent-dag.usagePanelOpen",u5="agent-dag.systemPanelOpen";function nEe(){return ht(l5)==="1"}function aEe(e){pt(l5,e?"1":"0")}function sEe(){const e=ht(d5);return e===null?!0:e==="1"}function iEe(e){pt(d5,e?"1":"0")}function oEe(){const e=ht(u5);return e===null?!0:e==="1"}function rEe(e){pt(u5,e?"1":"0")}function cEe(e=0){const[t,n]=m.useState(nEe);m.useEffect(()=>{aEe(t)},[t]);const[a,i]=m.useState(sEe);m.useEffect(()=>{iEe(a)},[a]);const o=m.useRef(!1),[r,c]=m.useState(()=>{const d=oEe();return d&&a&&(AN()||_oe(e))?(o.current=!0,!1):d});return m.useEffect(()=>{if(r)o.current=!1;else if(o.current)return;rEe(r)},[r]),An("usage-panel",a),An("machine-panel",r),{detailOpen:t,setDetailOpen:n,usagePanelOpen:a,setUsagePanelOpen:i,machinePanelOpen:r,setMachinePanelOpen:c}}const lEe={permission:"permission",asked:"answer"},dEe=()=>C("shell.announce.allClear");function uEe(e){if(e.length===0)return"";const[t,...n]=e,a=t.waiting.kind,i=n.every(o=>o.waiting.kind===a)?lEe[a]??"you":"you";return n.length===0?C(`shell.announce.block.${i}`,{label:t.label}):C(`shell.announce.blockMore.${i}`,{label:t.label,count:n.length})}function WS(e,t,n=dEe()){return t!==""?t:e===""?"":n}function hEe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[a,i]=m.useState(""),o=uEe(e);m.useEffect(()=>{i(f=>WS(f,o))},[o]);const[r,c]=m.useState(""),d=t>0?C("shell.announce.watch",{count:t}):"";m.useEffect(()=>{c(f=>WS(f,d,C("shell.announce.watchNone")))},[d]);const[u,p]=m.useState(""),g=CRe(n);return m.useEffect(()=>{p(f=>WS(f,g,SRe()))},[g]),{blockedSaid:a,watchSaid:r,setWatchSaid:c,incidentSaid:u}}const pEe="/icon-192.png",h5=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0});function jD(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:h5[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped")}}function gEe({waitingSessions:e,liveSince:t,focusSession:n}){const[a,i]=m.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,r]=m.useState(null),[c,d]=m.useState(!1),[u,p]=m.useState(!1),[g,f]=m.useState(h5),v=m.useCallback(F=>{const z=!g[F];f(H=>({...H,[F]:z})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[F]:z})}).then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&f(jD(H.prefs))}).catch(()=>{})},[g]),k=m.useRef(()=>{}),y=m.useRef(new Set),N=pa(e),w=m.useCallback(()=>{const F=!c;d(F),F&&(y.current=qp(N.current)),F&&typeof Notification<"u"&&Notification.permission==="default"&&k.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:F})}).then(z=>z.ok?z.json():null).then(z=>{var H;z!=null&&z.ok&&(d(((H=z.prefs)==null?void 0:H.notifications)===!0),p(z.notificationsVetoed===!0))}).catch(()=>{})},[c]),S=typeof Notification<"u";m.useEffect(()=>{if(!o)return;const z=setTimeout(()=>r(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(z)},[o]);const j=m.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(F=>{const z=F;i(z),z==="granted"?r("on"):z==="denied"&&r("blocked")})},[]);k.current=j;const A=m.useRef(null),T=e.map(F=>zm(F.id,F.waiting)).join("|");m.useEffect(()=>{hee(A.current,a)&&(A.current=a,y.current=qp(e))},[a]);const E=m.useRef(!1);m.useEffect(()=>{pee(E.current,t)&&(E.current=!0,y.current=qp(e))},[t]),m.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!gee(A.current,t))return;const F=typeof document>"u"||!document.hidden,z=dee(e,y.current,F,c);for(const H of z)try{const I=new Notification(H.title,{body:H.body,tag:H.key,icon:pEe});I.onclick=()=>{window.focus(),n(H.sessionId),I.close()}}catch{}y.current=F?qp(e):uee(e,z,y.current)},[T,t]);const q=m.useCallback(F=>{var z;d(((z=F.prefs)==null?void 0:z.notifications)===!0),p(F.notificationsVetoed===!0),f(jD(F.prefs))},[]);return{notifyPermission:a,notifySaid:o,notifyOn:c,notifyVetoed:u,toggleNotify:w,notifySupported:S,askForNotifications:j,loadNotifyPrefs:q,accountNotify:g,toggleAccountNotify:v}}function mEe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:a,summaryFor:i,browserWatchOpen:o,keyHelpOpen:r,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:u=!1}){const p=pa(r),g=m.useRef(!1);return g.current=e!=null||t||n!=null||a||i!=null||o||r||c!=null||d||u,{keyHelpOpenRef:p,modalOpenRef:g}}function fEe({stateRef:e,tourOpen:t,releaseNotes:n}){const[a,i]=m.useState(null),o=m.useCallback((L,O)=>i({agentId:L,toolId:O}),[]),[r,c]=m.useState(null),[d,u]=m.useState(null),p=m.useCallback(L=>u(L),[]),[g,f]=m.useState(!1),[v,k]=m.useState(!1),[y,N]=m.useState(!1),[w,S]=m.useState(!1),[j,A]=m.useState(!1),[T,E]=m.useState(null),q=m.useCallback(L=>{E(L??null),A(!0)},[]);An("tool-detail",a!==null),An("session-summary",r!==null),An("context-window",d!==null),An("keyboard-help",g),An("usage-history",v),An("browser-watch",y),An("feedback",j);const F=a?nQ(e.current.agents,a.agentId,a.toolId):null,z=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:H,modalOpenRef:I}=mEe({openedTool:F,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:r,browserWatchOpen:y,keyHelpOpen:g,releaseNotes:n,feedbackOpen:j,trafficRadarOpen:w});return{setOpenedToolKey:i,openTool:o,openedTool:F,summaryFor:r,setSummaryFor:c,contextFor:d,setContextFor:u,openContext:p,contextAgent:z,keyHelpOpen:g,setKeyHelpOpen:f,usageHistoryOpen:v,setUsageHistoryOpen:k,browserWatchOpen:y,setBrowserWatchOpen:N,trafficRadarOpen:w,setTrafficRadarOpen:S,feedbackOpen:j,setFeedbackOpen:A,feedbackPrefill:T,setFeedbackPrefill:E,openFeedback:q,keyHelpOpenRef:H,modalOpenRef:I}}function bEe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:a,lastLayoutSigRef:i,forgetRemovals:o,clearSelection:r,rerender:c,modalOpenRef:d}){const[u,p]=m.useState(!1),g=m.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Qj(),t.current.clear(),n.current.clear(),a.current.clear(),i.current="",Y4(),o(),r(),c()},[c,r,o]),f=pa(u),v=m.useCallback(k=>{const y=YNe(k,{confirmOpen:f.current,modalOpen:d.current});y==="confirm"?p(!0):y==="clear"&&(p(!1),g())},[g]);return{clearConfirmOpen:u,setClearConfirmOpen:p,requestClear:v}}const AD="agent-dag.oldNameNoticeDismissed";function vEe(e){const[t,n]=m.useState(()=>ht(AD)??""),a=e!=null&&e.invokedAs&&e.invokedAs!==Pt?e.invokedAs:null,i=a!=null&&t!==a,o=m.useCallback(()=>{a&&(n(a),pt(AD,a))},[a]);return{oldName:a,oldNameOpen:i,dismissOldName:o}}const kEe=300*1e3,wEe=1800*1e3,yEe=8e3,xEe=3e4;function TD(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function CEe({modalOpenRef:e}){const t=m.useCallback(()=>Pc({appModal:e.current,dialogDepth:jn.dialogDepth()}),[e]),[n,a]=m.useState("hidden"),[i,o]=m.useState(null),[r,c]=m.useState(!1),d=m.useRef(n);d.current=n,m.useEffect(()=>{let v=!1;const k=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const w=await fetch("/api/rating").then(S=>S.ok?S.json():null).catch(()=>null);v||!w||a(S=>S==="thanks"?S:w.ask===!0?"asking":"hidden")},y=window.setTimeout(k,kEe),N=window.setInterval(k,wEe);return()=>{v=!0,window.clearTimeout(y),window.clearInterval(N)}},[t]),m.useEffect(()=>{if(n!=="thanks"||r)return;const v=i!==null&&i<=6?xEe:yEe;let k=0;const y=()=>{t()?k=window.setTimeout(y,v):a("hidden")};return k=window.setTimeout(y,v),()=>window.clearTimeout(k)},[n,i,r,t]);const u=m.useCallback(v=>{o(v),c(!1),a("thanks"),TD({score:v})},[]),p=m.useCallback(v=>c(v),[]),g=m.useCallback(()=>{a("hidden"),TD({later:!0})},[]),f=m.useCallback(()=>a("hidden"),[]);return{ratingPhase:n,ratingScore:i,answerRating:u,rateLater:g,closeRating:f,holdThanks:p}}function SEe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:a}){const[i,o]=m.useState(()=>are(ht)),r=pa(i),[c,d]=m.useState([]),u=m.useCallback(S=>{o(j=>{const A={...j,[S]:null};return r.current=A,A}),Va(Kd[S])},[]),p=m.useCallback((S,j)=>{const A=r.current[S];j&&A!==j||(u(S),t(T=>{const E={...T,[S]:{...T[S],figure:Aa}};return n.current=E,E}),pt(Xg[S],Aa))},[u]),g=pa(p);m.useEffect(()=>{let S=!0;return gre().then(j=>{if(!S)return;d(j);const A=new Set(j.map(T=>T.id));for(const T of Jd){const E=r.current[T];E&&!A.has(E)&&g.current(T,E)}},()=>{}),()=>{S=!1}},[]);const f=m.useCallback((S,j)=>{if(!c.some(T=>T.id===j))return;const A={...r.current,[S]:j};r.current=A,o(A),pt(Kd[S],j),a(S,!0)},[c,a]),v=m.useCallback(async S=>{var E;const j=EN(c.length);if(j)throw new Ln(j);const A=window.AudioContext??window.webkitAudioContext;if(!A)throw new Ln(C("settings.sounds.custom.decodeFail"));const T=new A;try{const q=await lre(S,z=>T.decodeAudioData(z));await C_(q);const F=wu(q);d(z=>[...z.filter(H=>H.id!==F.id),F])}finally{(E=T.close)==null||E.call(T)}},[c.length]),k=m.useCallback(async S=>{const j=EN(c.length);if(j)throw new Ln(j);const A=dre(S);await C_(A);const T=wu(A);d(E=>[...E.filter(q=>q.id!==T.id),T])},[c.length]),y=m.useCallback(async(S,j)=>{const A=c.find(E=>E.id===S),T=j.trim().slice(0,80);!A||!T||T===A.name||(await fre(S,T),d(E=>E.map(q=>q.id===S?{...q,name:T}:q)))},[c]),N=m.useCallback(async S=>{await bre(S),d(E=>E.filter(q=>q.id!==S));const j=r.current,A=sre(j,S);r.current=A,o(A);const T=Jd.filter(E=>j[E]===S);for(const E of T)Va(Kd[E]),pt(Xg[E],Aa);T.length>0&&t(E=>{const q={...E};for(const F of T)q[F]={...q[F],figure:Aa};return n.current=q,q})},[]),w=m.useCallback(S=>{var T,E;const j=Jd.find(q=>r.current[q]===S),A=j?n.current[j].level:Lr;(T=e.current)==null||T.unlock(),(E=e.current)==null||E.previewCustom(S,A)},[]);return{customSelections:i,customSelectionsRef:r,customAssets:c,clearCustomOnly:u,fallbackCustomRef:g,selectCustomTone:f,importNotificationAudio:v,createNotificationVoice:k,renameCustomAsset:y,deleteCustomAsset:N,previewCustomAsset:w}}function NEe(e){const[t,n]=m.useState(()=>Rre(ht)),a=pa(t),i=m.useRef(null),o=m.useCallback((c,d=!1)=>{var u,p;if((u=e.current)==null||u.unlock(),i.current!==null&&clearTimeout(i.current),i.current=null,!d){(p=e.current)==null||p.play(c,!0);return}i.current=setTimeout(()=>{var g;i.current=null,(g=e.current)==null||g.play(c,!0)},Sre)},[]),r=m.useCallback((c,d)=>{n(u=>{const p={level:Ym(d.level??u[c].level),figure:kB(c,d.figure??u[c].figure)};return pt(xB[c],String(p.level)),pt(Xg[c],p.figure),{...u,[c]:p}}),o(c,!0)},[o]);return m.useEffect(()=>()=>{i.current!==null&&clearTimeout(i.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:a,previewTone:o,changeTone:r}}const jEe=15e3;function AEe(e){return e.visibilityState==="visible"&&e.hasFocus()}function TEe(e,t){return t||e===!0}function REe(){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 EEe(){m.useEffect(()=>{const e=REe();let t=null;const n=r=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:r}),keepalive:!0}).catch(()=>{})},a=()=>{const r=AEe(document);TEe(t,r)&&n(r),t=r},i=()=>{t&&n(!1),t=!1};a();const o=window.setInterval(a,jEe);return window.addEventListener("focus",a),window.addEventListener("blur",a),document.addEventListener("visibilitychange",a),window.addEventListener("pagehide",i),()=>{window.clearInterval(o),window.removeEventListener("focus",a),window.removeEventListener("blur",a),document.removeEventListener("visibilitychange",a),window.removeEventListener("pagehide",i),i()}},[])}function _Ee({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){m.useEffect(()=>{let a=!0;return fetch("/api/prefs").then(i=>i.ok?i.json():null).then(i=>{!a||!(i!=null&&i.ok)||(e(i),t(i),n(i))}).catch(()=>{}),()=>{a=!1}},[])}const GS="agent-dag.versionNoticeDismissed",qEe=15*6e4;function zEe(e){const[t,n]=m.useState(null),[a,i]=m.useState(()=>ht(GS)??""),o=m.useRef(0),[r,c]=m.useState(!1),d=m.useCallback((y=!1)=>(y&&(o.current=Date.now(),c(!0)),fetch(y?"/api/version?refresh=1":"/api/version").then(N=>N.ok?N.json():null).then(N=>(N&&n(N),N??null)).catch(()=>null).finally(()=>{y&&c(!1)})),[]),u=m.useCallback(()=>{d(Date.now()-o.current>=qEe)},[d]);m.useEffect(()=>{d();const y=window.setInterval(u,5*6e4),N=()=>{document.visibilityState==="visible"&&u()};return document.addEventListener("visibilitychange",N),()=>{window.clearInterval(y),document.removeEventListener("visibilitychange",N)}},[d,u]),m.useEffect(()=>{e&&d()},[e,d]);const p=(t==null?void 0:t.notice)??null,g=TW(p),f=hNe(p,a),v=m.useCallback(()=>{i(""),pt(GS,"")},[]),k=m.useCallback(()=>{p&&(i(g),pt(GS,g))},[p,g]);return{version:t,notice:p,noticeOpen:f,showNotice:v,dismissNotice:k,versionChecking:r,loadVersion:d}}function LEe({version:e,readyAppUpdate:t}){const[n,a]=m.useState(!1),i=m.useRef(null),[o,r]=m.useState(null),c=o&&t?t.version:null,d=m.useRef(null);m.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 u=m.useRef(!1);m.useEffect(()=>{if(u.current)return;const N=Is(),w=zAe(N),S=DAe({stored:w,running:(e==null?void 0:e.running)??null,notes:ZI,remembers:LAe(N)});if(S.reason==="no-version")return;u.current=!0,S.record&&OAe(N,S.record);let j=!0;return(async()=>{var F;let T=PAe(N);if(Eo())try{const z=await fetch("/api/prefs");if(!z.ok)throw new Error("desktop tour preferences unavailable");const H=await z.json();if(!(H!=null&&H.ok))throw new Error("desktop tour preferences unavailable");const I=((F=H.prefs)==null?void 0:F.tourSeen)===!0;T&&!I&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||I}catch{T=!0}if(!j)return;const E=IAe({tourSeen:T,decision:S}),q=S.show.length?{entries:S.show,since:w,firstRun:!1}:null;E.tour&&a(!0),E.notes==="now"?r(q):E.notes==="after"&&(i.current=q)})(),()=>{j=!1}},[e==null?void 0:e.running]);const p=(e==null?void 0:e.running)??"3.53.1",g=m.useMemo(()=>BW(ZI,null,p),[p]),f=m.useCallback(()=>{r({entries:g,since:null,firstRun:!1})},[g]),v=m.useCallback(()=>a(!0),[]),k=m.useCallback(()=>r(null),[]),y=m.useCallback(()=>{a(!1),MAe(Is()),Eo()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const N=i.current;i.current=null,N&&r(N)},[]);return{tourOpen:n,openTour:v,closeTour:y,releaseNotes:o,closeReleaseNotes:k,chipVersion:p,openReleaseNotes:f}}function OEe(){const[e,t]=m.useState(void 0),[n,a]=m.useState(!1),i=m.useRef(!1);return i.current=e===!0&&!n,m.useEffect(()=>Y0e(()=>i.current),[]),{loadReportsPrefs:m.useCallback(r=>{var c;t(((c=r.prefs)==null?void 0:c.reports)!==!1),a(r.reportsVetoed===!0)},[])}}function PEe(e){const[t,n]=m.useState(null);m.useEffect(()=>{const c=ht("agent-dag.sound");n(c===null?!0:c==="on")},[]);const a=m.useCallback(()=>{n(c=>{var u,p;const d=c!==!0;return pt("agent-dag.sound",d?"on":"off"),d?(u=e.current)==null||u.unlock():(p=e.current)==null||p.silence(),d})},[]),i=m.useCallback(c=>{a()},[a]),o=pa(i),r=pa(t);return{soundOn:t,toggleSound:a,activateSoundRef:o,soundOnRef:r}}function MEe(){const[e,t]=m.useState(Boe),n=m.useCallback((o,r)=>{t(c=>Hoe(c,o,r))},[]),a=m.useCallback(()=>t(o=>({...o,open:!1})),[]),i=m.useCallback(o=>t(r=>({...r,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,settingsLandOn:e.landOn,openSettings:n,closeSettings:a,showSection:i}}const IEe="agent-dag.autoFitDisabled";function DEe(e){const t=m.useRef(!1),[n,a]=m.useState(!1);m.useEffect(()=>{Va(IEe)},[]);const i=m.useCallback(()=>{t.current||(t.current=!0,a(!0))},[]),o=m.useCallback(()=>{t.current=!1,a(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:i,enableAutoFitAndRefit:o}}function FEe(){return s.jsx(Xj,{children:s.jsx(Q0e,{children:s.jsx(UEe,{})})})}function UEe(){var Hi;const e=ae(),t=bl(),n=m.useState(Qj)[0],a=m.useRef(n),[,i]=m.useState(0),o=m.useCallback(()=>i(vt=>vt+1),[]),{sessionListOpen:r,accountsPanelOpen:c,panel:d,toggleSessionList:u,toggleAccountsPanel:p,openAccountsPanel:g,closeSessionList:f,closeSessionListToCanvas:v,closeAccountsPanel:k}=tEe(),{detailOpen:y,setDetailOpen:N,usagePanelOpen:w,setUsagePanelOpen:S,machinePanelOpen:j,setMachinePanelOpen:A}=cEe(ND(d)),{selectedIds:T,primarySelectedId:E,selectAgent:q,clearSelection:F,pruneSelectionToBoard:z}=gve(a,N),H=Uc(c,200),I=Uc(r,200),L=VE(r,I),O=Uc(w,130),_=Uc(j,130),M=m.useRef(null),U=PEe(M),{activateSoundRef:G,soundOnRef:W}=U,$=NEe(M),{setTonePrefs:Y,tonePrefsRef:B,previewTone:V}=$,Z=SEe({chimesRef:M,setTonePrefs:Y,tonePrefsRef:B,previewTone:V}),{customSelectionsRef:D,fallbackCustomRef:K}=Z,X=MEe(),{openSettings:Q}=X;FRe({chimesRef:M,soundOnRef:W,tonePrefsRef:B,customSelectionsRef:D,fallbackCustomRef:K});const ee=nRe(a),{pauseGate:ne,paused:de,togglePause:ge}=ee,le=m.useRef(()=>{}),{live:he,tabCapped:ce,everConnected:oe,liveSince:ve}=sve({stateRef:a,rerender:o,pauseGate:ne,chimesRef:M,desktopUpdateRef:le}),ke=zEe(he),{version:ye,notice:Le,noticeOpen:Ke,loadVersion:Qe}=ke,Ae=BRe(he),{readyAppUpdate:je,onDesktopUpdateEvent:Oe}=Ae;le.current=Oe,EEe();const Ve=LEe({version:ye,readyAppUpdate:je}),{tourOpen:nt,openTour:Ye,releaseNotes:Ce}=Ve,{workspace:ze,providers:De,providersRef:Fe}=rRe(he),ot=iRe(De,c),se=ot.shown,Ne=vt=>{ot.remember(vt),(!c||se===vt)&&p()},Ie=ND(d==="accounts"&&!(De.claude||De.codex)?null:d),Be=ZRe(Ie),Se=VE(c,H)&&(De.claude||De.codex),[tt,fe]=m.useState(!1),He=ot.remember,lt=m.useCallback(()=>{He(De.claude?"claude":"codex"),g()},[g,De.claude,He]),gt=m.useCallback(()=>{He("claude"),g(),fe(!0)},[g,He]);m.useEffect(()=>{c||fe(!1)},[c]);const mt=m.useCallback(()=>fe(!1),[]),xt=vEe(ye),Rn=NRe({version:ye,loadVersion:Qe}),{upgradeFailure:ba}=Rn,nn=fEe({stateRef:a,tourOpen:nt,releaseNotes:Ce}),Ut=CEe({modalOpenRef:nn.modalOpenRef}),{openTool:va,setSummaryFor:yn,setContextFor:an,openContext:En,setKeyHelpOpen:Ue,setUsageHistoryOpen:Ge,setBrowserWatchOpen:st,keyHelpOpenRef:Et,modalOpenRef:Zt}=nn,Cs=OEe(),ka=ARe(),{watchOn:xn,watchUnseen:pn}=ka,_n=Xu(),[$t,Bn]=m.useState(null),[Pn,Hn]=m.useState(!1),ea=m.useCallback(()=>Hn(!1),[]),Qa=vt=>{WSe(vt),Q("integrations")},es=vt=>{vt&&DI(vt),Q("integrations")},rn=m.useCallback(()=>Bn(null),[]),St=$T().filter(vt=>xj(_n,vt.kind)),ts=pa(vt=>{const oi=St.find(Th=>Th.kind===vt);oi&&Bn(oi.kind)}),me=m.useCallback(vt=>{DI(vt),Q("integrations")},[Q]),Ee=St.length>0;m.useEffect(()=>{Ee&&RSe()},[Ee]);const Me=WRe(),[Ze,ft]=m.useState(0),{presentCats:zt,hiddenCats:Xt,toggleCat:wa,catBarRef:cn,catBarOccluded:Hr}=IRe(a),Oo=m.useRef(null),[Wr,Ys]=m.useState(0),Qt=mve({stateRef:a,rerender:o,pruneSelectionToBoard:z,setContextFor:an,setSummaryFor:yn});ine({stateRef:a,now:Qt,enabled:De.claude});const Ss=uRe(De.claude||De.codex),xe=xRe(Ss,Qt),ut=$Re({enabled:De.claude,lanStatus:Me.lanStatus,now:Qt}),Nt=HRe({now:Qt,stateRef:a,version:ye,notice:Le,noticeOpen:Ke,upgradeFailure:ba,paused:ee.paused}),{askRestart:Vt,loadAutoRestartPrefs:ta}=Nt,na=MRe(),{setTheme:Ns,palette:eh}=na,zi=URe(),yt=mxe(),{applyViewport:th,moveCamera:nh,fitLeft:Li,cameraEpochRef:ah,lastFitTimeRef:ql}=yt,Zs=Rxe(yt),{pinnedRef:Oi,positionsRef:Xs,lastLayoutSigRef:js,handleRelayout:ns,rearrangeUndo:As}=Zs,Pi=m.useRef(null),Mi=m.useRef(()=>{}),as=ve!==null,sh=m.useRef(0),zl=m.useCallback(()=>{sh.current=Date.now()},[]),{canvasRef:aa,canvasSize:Pf,paneSizeRef:ih}=fCe(Be),Po=DEe(Li),{autoFitDisabledRef:Ll,disableAutoFit:Ol}=Po,Qs=m.useRef(!1),{measuredRef:ya,measuredVersionRef:Ii,sizeVersion:Gr,domSizeVersion:Mf}=bCe(Qs,a),{removedNodes:Pl,removedAgentIds:Ts,removeNode:$r,removeSelectedNode:Vr,removalNotice:Ml,hideSessions:Rs,bringBack:Mo,bringBackAll:Kr,forgetRemovals:oh}=Jxe({stateRef:a,pinnedRef:Oi,positionsRef:Xs,returningRef:Zs.returningRef,canvasRef:aa,clearSelection:F,primarySelectedId:E});iCe({stateRef:a,removedNodes:Pl,hideSessions:Rs,ready:as,keepSessionId:E?((Hi=a.current.agents.get(E))==null?void 0:Hi.sessionId)??E:null});const Di=Wxe({stateRef:a,now:Qt,removedAgentIds:Ts,sizeVersion:Gr,domSizeVersion:Mf});Exe(Di,Zs),Kxe({layoutSig:Di,rf:t,stateRef:a,measuredRef:ya,pinnedRef:Oi,positionsRef:Xs,paneSizeRef:ih,lastInteractRef:sh,autoFitDisabledRef:Ll,lastFitTimeRef:ql,fitLeft:Li});const Io=vCe(),{bubbling:rh,endBubble:Wn,onBubble:Fi}=Hbe(),[Do,Fo]=m.useState(!1),ch=Ube(),{beginTrashDrag:Il,trackTrashDrag:Dl,endTrashDrag:Uo}=ch,Bo=Ybe({stateRef:a,measuredRef:ya,measuredVersionRef:Ii,canvasRef:aa}),{lodRef:lh,applyZoom:If}=Bo,dh=pCe({applyViewport:th,lastFitTimeRef:ql,cameraEpochRef:ah,disableAutoFit:Ol,markInteract:zl,canvasRef:aa,applyZoom:If}),Ho=E?a.current.agents.get(E):null,Wo=y&&Ho!=null,ei=xCe({sessionListShown:L,usageShown:mo(O),machineShown:mo(_),accountsShown:Se&&De.claude,codexShown:Se&&!De.claude,detailShown:Wo,primarySelectedId:E,canvasRef:aa}),{railInsetRef:Jr,availableWidth:uh,availableHeight:hh}=dxe({canvasRef:aa,canvasSize:Pf,machinePhase:_,usagePhase:O,usagePanelOpen:w,detailShown:Wo}),ph=Gxe({stateRef:a,now:Qt,availableWidth:uh,availableHeight:hh,layout:Zs,measuredRef:ya,onBubble:Fi,settled:Io,dragging:Do,layoutSig:Di,selectedIds:T,openContext:En,historyReplayed:as,removedNodes:Pl,removedAgentIds:Ts,dragTick:Ze,dragPatchRef:Oo,dragMoveTick:Wr}),{nodes:Yr,edges:Df}=ph,Fl=pa(E);_xe({nodes:Yr,edges:Df,settled:Io,dragging:Do,availableWidth:uh,availableHeight:hh,layout:Zs,camera:yt,rf:t,measuredRef:ya,stateRef:a,lastFocusRef:Pi,primarySelectedIdRef:Fl,focusAgentRef:Mi,autoFitDisabledRef:Ll});const gh=bEe({stateRef:a,pinnedRef:Oi,measuredRef:ya,positionsRef:Xs,lastLayoutSigRef:js,forgetRemovals:oh,clearSelection:F,rerender:o,modalOpenRef:Zt}),{requestClear:Ul}=gh,Bl=CCe({nodes:Yr,stateRef:a,pinnedRef:Oi,positionsRef:Xs,draggingRef:Qs,dragPatchRef:Oo,setDragging:Fo,setDragMoveTick:Ys,setDragTick:ft,endBubble:Wn,markInteract:zl,disableAutoFit:Ol,beginTrashDrag:Il,trackTrashDrag:Dl,endTrashDrag:Uo,removeNode:$r}),mh=m.useCallback(()=>Li(500),[Li]),Hl=pa(Yr),{focusAgent:Zr,stepAgent:fh,focusSession:Ui}=bxe({canvasRef:aa,stateRef:a,measuredRef:ya,nodesRef:Hl,railInsetRef:Jr,moveCamera:nh,disableAutoFit:Ol,lastFocusRef:Pi,focusAgentRef:Mi,selectAgent:q,primarySelectedIdRef:Fl}),Ff=gCe({clearSelection:F,selectAgent:q,detailOpen:y,setDetailOpen:N,detailShown:Wo,focusAgent:Zr,draggingRef:Qs,lodRef:lh}),Uf=vxe({nodesRef:Hl,stateRef:a,canvasRef:aa,railInsetRef:Jr}),Bf=pa(Vr),Wl=m.useRef(null),Xr=m.useCallback(vt=>{Ts.has(vt)&&Mo([vt]),Ui(vt)},[Ts,Mo,Ui]),Hf=kCe(),[Gl,ti]=m.useState(!1),bh=m.useCallback(()=>ti(!0),[]),vh=m.useCallback(()=>ti(!1),[]),kh=m.useCallback(vt=>{ti(!1),vt.run()},[]),wh=Qn();wCe({pointerFocusRef:Hf,nodesRef:Hl,stateRef:a,primarySelectedIdRef:Fl,providersRef:Fe,soundOnRef:W,keyHelpOpenRef:Et,modalOpenRef:Zt,waitingCursorRef:Wl,removeSelectedRef:Bf,activateSoundRef:G,clearSelection:F,selectAgent:q,focusAgent:Zr,stepAgent:fh,focusSession:Ui,requestClear:Ul,handleRelayout:ns,undoRearrange:As.undo,handleFit:mh,togglePause:ge,toggleSessionList:u,toggleAccountsPanel:p,setDetailOpen:N,setUsageHistoryOpen:Ge,setUsagePanelOpen:S,setMachinePanelOpen:A,setBrowserWatchOpen:st,setKeyHelpOpen:Ue,setTheme:Ns,openSettings:Q,openIntegrationRef:ts,openQuickOpen:bh});const Qr=a.current.agents.size,ni=m.useMemo(()=>hN(a.current.agents.values()),[a.current,a.current.revision]);Yxe({stateRef:a,waitingSessions:ni,removedAgentIds:Ts,removedNodes:Pl,bringBack:Mo}),dCe({stateRef:a,waitingSessions:ni,live:he});const ai=hEe({waitingSessions:ni,watchUnseen:pn,incidents:xe}),$l=gEe({waitingSessions:ni,liveSince:ve,focusSession:Ui}),{loadNotifyPrefs:Wf}=$l;_Ee({loadAutoRestartPrefs:ta,loadNotifyPrefs:Wf,loadReportsPrefs:Cs.loadReportsPrefs});const si=jl(Km),[yh,Vl]=m.useState(!1),[Bi,ii]=m.useState(null),Gf=m.useCallback(()=>ii(null),[]),ec=m.useCallback(vt=>{const oi=a.current.agents.get(vt);return oi?oi.label||oi.cwdBasename||"session":null},[]),$f=m.useCallback(vt=>{ii(null),Xr(vt)},[Xr]),xh=m.useCallback(()=>Vl(!1),[]),[tc,nc]=m.useState(null),Ch=m.useCallback(()=>nc(null),[]),gn=HCe({providers:De,sessionListOpen:r,toggleSessionList:u,accountsPanelOpen:c,toggleAccountsPanel:p,accountsPanelId:t5(se),codexPanelOpen:c&&se==="codex",toggleCodexPanel:()=>Ne("codex"),usagePanelOpen:w,setUsagePanelOpen:S,machinePanelOpen:j,setMachinePanelOpen:A,setUsageHistoryOpen:Ge,watchOn:xn,watchUnseen:pn,setBrowserWatchOpen:st,setTrafficRadarOpen:nn.setTrafficRadarOpen,openSettings:Q,onFeedback:nn.openFeedback,setRadioOpen:Vl,openToolActivity:ii,openCapacity:nc,toggles:ei.toggles,integrations:St.map(vt=>({provider:vt,onPress:()=>Bn(vt.kind)})),openExploreIntegrations:()=>Hn(!0),openQuickOpen:bh}),[Sh,Vf]=m.useState(0),Nh=m.useCallback(vt=>{Xr(vt),si&&v()},[Xr,si,v]),Kf=m.useCallback(()=>{r||u(),requestAnimationFrame(()=>{var vt;return(vt=document.querySelector("#session-list .sl-row"))==null?void 0:vt.focus()})},[r,u]),jh=()=>{(De.claude?ei.accounts:ei.codex)(),k()},Ah=ot.both?s.jsx(tbe,{shown:se,notices:ot.notices,onPick:ot.pick}):void 0,sa=vt=>ot.bothMounted?vt===se?"shown":"hidden":void 0;return s.jsxs("div",{className:"app",children:[s.jsx("a",{className:"skip-link",href:"#canvas",children:e("shell.skipToCanvas")}),s.jsxs("header",{className:"topbar",children:[s.jsx(Tie,{}),s.jsx(SNe,{versionCheck:ke,welcome:Ve,desktopUpdate:Ae,pause:ee,announcements:ai,notify:$l,waitingSessions:ni,waitingCursorRef:Wl,focusSession:Ui,live:he,now:Qt,incidents:xe,queueNamed:si?0:Sh}),!si&&s.jsx(wNe,{waitingSessions:ni,waitingCursorRef:Wl,focusSession:Ui,now:Qt,onFit:Vf,onMore:Kf}),Ho&&s.jsx(NNe,{selected:Ho,now:Qt,selectedIds:T,focusAgent:Zr,clearSelection:F}),!si&&s.jsx("div",{className:"actions",children:s.jsx(Ioe,{items:[gn.search,...gn.utilities]})})]}),si?s.jsx(Moe,{items:[...gn.left,...gn.right[0],gn.utilities[0]],more:[gn.search,...gn.capacity,...gn.right.slice(1).flat(),...gn.integrations,...gn.explore,gn.utilities[1]]}):s.jsx(f_,{side:"left",label:e("shell.rail.left"),groups:[...gn.leftStripe,gn.integrations,gn.explore]}),s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Ml?e("shell.board.removed",{label:Ml.label}):""}),s.jsx(JNe,{restart:Nt,versionCheck:ke,upgrade:Rn,oldNameNotice:xt,rating:Ut,onFeedback:nn.openFeedback,everConnected:oe,live:he,paused:de}),(L||Se)&&s.jsxs(Lbe,{width:Ie,children:[Se&&(se==="claude"||ot.bothMounted)&&s.jsx(Qfe,{leaving:_v(c,H),onReport:nn.openFeedback,onRoster:ut.observe,onClose:jh,lanWanted:tt,onLanShown:mt,switcher:Ah,side:sa("claude"),onNotice:ot.noteClaude}),Se&&(se==="codex"||ot.bothMounted)&&s.jsx(zbe,{leaving:_v(c,H),onClose:jh,switcher:Ah,side:sa("codex"),onNotice:ot.noteCodex}),L&&s.jsx(Lie,{leaving:_v(r,I),state:a.current,now:Qt,selectedIds:T,onSelect:Nh,onClose:()=>{ei.sessionList(),f()},removedIds:Ts,onBringBackAll:Kr})]}),s.jsxs(ENe,{canvasRef:aa,bubbling:rh,dragging:Do,trash:ch,zoom:Bo,viewport:dh,stateRef:a,peek:Uf,children:[Qr===0&&(!he&&ce?s.jsx(NCe,{reservedRight:Jr.current}):s.jsx(jCe,{live:he,everConnected:oe,providers:De,workspace:ze,onTour:Ye,reservedRight:Jr.current})),(zt.length>1||Xt.size>0)&&s.jsx(jNe,{catBarRef:cn,catBarOccluded:Hr,presentCats:zt,hiddenCats:Xt,toggleCat:wa}),s.jsx(Aie,{graph:ph,layout:Zs,viewport:dh,clicks:Ff,drag:Bl,appearance:na,fm:zi,radioOpen:yh,onRadioClose:xh,autoFit:Po,pause:ee,stateRef:a,measuredRef:ya,hiddenCats:Xt,now:Qt,openTool:va,focusAgent:Zr,requestClear:Ul,setKeyHelpOpen:Ue})]}),!si&&s.jsx(f_,{side:"right",label:e("shell.rail.right"),groups:gn.right}),Bi&&s.jsx(rle,{view:Bi,onClose:Gf,sessionLabel:ec,onOpenSession:$f}),tc&&s.jsx(fbe,{view:tc,onClose:Ch}),$t&&s.jsx(qSe,{kind:$t,connections:yi(_n,$t)?pm(_n,$t):[],onClose:rn,onReconnect:me}),Pn&&s.jsx(YSe,{integrations:_n,onClose:ea,onOpen:Bn,onConnect:Qa,onManage:es}),Gl&&s.jsx(foe,{onClose:vh,onRun:kh,items:Yre({rails:gn,sessions:YU(a.current),now:Qt,openSession:Nh,settings:AB(De.claude,KT(_n),Qu(_n)),openSettings:Q,singleKeys:wh,fit:mh,rearrange:ns,paused:de,togglePause:ge,clear:Qr>0?()=>Ul("button"):void 0,keyHelp:()=>Ue(!0),tour:Ye,theme:na.theme,setTheme:Ns})}),mo(O)&&s.jsx(Fde,{state:a.current,now:Qt,providers:De,incidents:xe,liveSince:ve,leaving:O==="leaving",onClose:()=>{ei.usage(),S(!1)}}),mo(_)&&s.jsx(Cue,{usageOpen:w,leaving:_==="leaving",onClose:()=>{ei.machine(),A(!1)}}),y&&Ho?s.jsx(FCe,{selected:Ho,now:Qt,openTool:va,setSummaryFor:yn,stateRef:a,removeSelectedNode:Vr,onClose:()=>{ei.detail(),N(!1)}}):null,s.jsx(z0e,{dialogs:nn,welcome:Ve,desktopUpdate:Ae,versionCheck:ke,restart:Nt,upgrade:Rn,lanPairs:Me,attention:ut,clearFlow:gh,watchBadge:ka,announcements:ai,appearance:na,providers:De,stateRef:a,agentCount:Qr,menus:X,sound:U,tones:$,customTones:Z,notify:$l,panelDoors:{accounts:lt,localNetwork:gt}})]})}try{U8(window.localStorage)}catch{}v2();const BEe=mG.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);BEe.render(s.jsx(FEe,{}));export{YEe as $,Mr as A,J2 as B,_t as C,qt as D,fl as E,An as F,s1e as G,nhe as H,$a as I,a1e as J,XEe as K,ZEe as L,Lt as M,Wd as N,i1e as O,t3 as P,At as Q,ZB as R,DN as S,Ig as T,P_ as U,FN as V,KEe as W,Ft as X,wo as Y,Ps as Z,JEe as _,Va as a,ju as a0,Xn as a1,rre as a2,Ha as a3,cAe as a4,Sj as a5,Ln as a6,Um as a7,a3 as a8,we as a9,zr as aa,xo as ab,fse as ac,o1e as ad,TA as ae,pl as af,Zne as ag,VEe as ah,GEe as ai,$Ee as aj,Hm as ak,zee as al,ATe as am,TRe as an,WEe as ao,bse as ap,m as b,jl as c,t1e as d,qe as e,kW as f,wA as g,OSe as h,ga as i,s as j,n1e as k,LSe as l,jn as m,or as n,So as o,vl as p,e1e as q,ht as r,Jn as s,C as t,ae as u,Ea as v,pt as w,Ks as x,QEe as y,pT as z};
358
+ `)}}function xRe(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>yRe(n,t)).filter(n=>n!==null)}function CRe(e){return e.map(t=>C(t.state.endsWith("outage")?"shell.incident.sentenceA":"shell.incident.sentence",{name:t.name,words:t.words})).join(" ")}const SRe=()=>C("shell.incident.clear");function NRe({version:e,loadVersion:t}){var u;const[n,a]=m.useState(!1),i=((u=e==null?void 0:e.upgrade)==null?void 0:u.state)??"idle",o=BNe(e==null?void 0:e.upgrade),r=m.useRef(!1),c=m.useCallback(async()=>{if(Jn(r.current||i==="running")){r.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),r.current=!1}},[i,t]);m.useEffect(()=>{if(i!=="running")return;const p=window.setInterval(t,3e3);return()=>window.clearInterval(p)},[i,t]);const d=m.useCallback(async()=>{const p=e==null?void 0:e.command;!p||!await Ks(p)||(a(!0),window.setTimeout(()=>a(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:i,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const wD="agent-dag.browserWatch.seenMs";function jRe(e,t){return e.filter(n=>n.startMs>t)}function ARe(){const[e,t]=m.useState(()=>Number(ht(wD))||0),[n,a]=m.useState([]),[i,o]=m.useState(!1);m.useEffect(()=>{let d=!0;const u=()=>{fetch("/api/browser-watch?live=0").then(g=>g.ok?g.json():null).then(g=>{var f;!d||!(g!=null&&g.ok)||(a(g.episodes??[]),o(((f=g.settings)==null?void 0:f.enabled)===!0))}).catch(()=>{})};u();const p=setInterval(u,5*6e4);return()=>{d=!1,clearInterval(p)}},[]);const r=m.useMemo(()=>jRe(n,e).length,[n,e]),c=m.useCallback(d=>{t(d),pt(wD,String(d))},[]);return{watchOn:i,setWatchOn:o,watchUnseen:r,markWatchSeen:c}}const a5="agent-dag.character-enabled",s5="agent-dag.fm-volume",TRe=1,yD="agent-dag.fm-source",o1e=[{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 RRe(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 ERe(e){return e!=="0"}function _Re(){return ERe(ht(a5))}function qRe(e){return yB(e,TRe)}function zRe(){return qRe(ht(s5))}const i5=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function xD(e){const t={};for(const n of i5)t[n]=e(n);return t}function LRe(e){return t=>e[t]??""}function ORe(e,t){return i5.every(n=>e[n]===t[n])}function PRe(e,t){let n=null,a=0;function i(){a++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:i,run(o){i();const r=a;let c=!1;const d=()=>{r!==a||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){d();return}e.documentElement.dataset.themeTransition="true";try{const u=e.startViewTransition(d);n=u,u.ready.catch(()=>{}),u.updateCallbackDone.catch(()=>{d()}),u.finished.then(()=>{n===u&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===u&&(d(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,d()}}}}function CD(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function MRe(){const[e,t]=m.useState(fce),[n,a]=m.useState(bce),[i,o]=m.useState(Ore),r=m.useRef(i),[c]=m.useState(()=>PRe(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=m.useCallback(w=>{const S=typeof w=="function"?w(r.current):w;S!==r.current&&(r.current=S,c.run(()=>Lt.flushSync(()=>o(S))))},[c]);m.useEffect(()=>()=>c.cancel(),[c]);const[u,p]=m.useState(_Re),[g,f]=m.useState(Zoe),[v,k]=m.useState(()=>xD(CD)),y=m.useMemo(()=>LRe(v),[v]),N=m.useCallback(w=>Fxe(w,y),[y]);return m.useEffect(()=>{document.documentElement.dataset.textSize=e,pt(LN,e)},[e]),m.useEffect(()=>{document.documentElement.dataset.density=n,pt(ON,n)},[n]),m.useEffect(()=>{const w=S=>{S.storageArea===Is()&&((S.key===LN||S.key===null)&&t(GA(S.newValue)),(S.key===ON||S.key===null)&&a(MB(S.newValue)))};return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[]),m.useLayoutEffect(()=>{document.documentElement.dataset.theme=i,document.documentElement.dataset.colorScheme=Iu[i].colorScheme,pt(CB,i),k(w=>{const S=xD(CD);return ORe(w,S)?w:S})},[i]),m.useEffect(()=>{pt(a5,u?"1":"0")},[u]),m.useEffect(()=>{pt(gB,g)},[g]),m.useEffect(()=>{const w=document.querySelector('meta[name="theme-color"]'),S=v["--panel"];w&&S&&w.setAttribute("content",S)},[v]),{textSize:e,setTextSize:t,density:n,setDensity:a,theme:i,setTheme:d,characterEnabled:u,setCharacterEnabled:p,character:g,setCharacter:f,palette:v,minimapNodeFill:N}}function IRe(e){const t=m.useRef(null),[n,a]=m.useState(!1),[i,o]=m.useState(()=>new Set),r=m.useMemo(()=>{const d=new Set;for(const u of e.current.agents.values())for(const p of u.tools)d.add(lW(p.name));return Object.keys(cW).filter(u=>d.has(u))},[e.current,e.current.revision]);m.useEffect(()=>{if(r.length<=1){a(!1);return}let d=0;const u=()=>{const p=t.current;if(p&&!document.hidden){const g=p.getBoundingClientRect(),f=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(k=>k.getBoundingClientRect()),v=qie(g,f,8);a(k=>k===v?k:v)}d=window.setTimeout(u,300)};return u(),()=>window.clearTimeout(d)},[r.length]);const c=m.useCallback(d=>{o(u=>{const p=new Set(u);return p.has(d)?p.delete(d):p.add(d),p})},[]);return{presentCats:r,hiddenCats:i,toggleCat:c,catBarRef:t,catBarOccluded:n}}function DRe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const a=new Set,i=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,i())};function r(){var f,v;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(f=n.addEventListener)==null||f.call(n,"statechange",o)),(v=n.resume)==null||v.call(n).then(o,()=>{}),o()}catch{}}function c(f,v,k=v.figure){if(!n||n.state!=="running")return!1;const y=_N(f,k),N=wre(v.level,y),w=n.currentTime;for(const S of y.notes){const j=n.createOscillator(),A=n.createGain();j.type=y.type??"sine",j.frequency.value=S.hz;const T=w+S.at,E=T+S.ms/1e3;A.gain.setValueAtTime(N_,T),A.gain.exponentialRampToValueAtTime(N,T+yre),A.gain.exponentialRampToValueAtTime(N_,E),j.connect(A).connect(n.destination),j.start(T),j.stop(E+.02)}return!0}async function d(f,v){var N;if(!e.loadCustom)return"unavailable";let k;try{k=await e.loadCustom(f)}catch{return"unavailable"}if(!k)return"missing";if(k.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const w=new SpeechSynthesisUtterance(k.text),S=window.speechSynthesis.getVoices();w.voice=S.find(j=>j.voiceURI===k.voiceURI)??null,w.rate=k.rate,w.pitch=k.pitch,w.volume=xre(v.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(w),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let y;try{y=await n.decodeAudioData(k.bytes.slice(0))}catch{return"broken"}try{const w=n.createBufferSource(),S=n.createGain();return w.buffer=y,S.gain.setValueAtTime(Cre(k.normalizationGain,v.level),n.currentTime),w.connect(S).connect(n.destination),a.add(w),(N=w.addEventListener)==null||N.call(w,"ended",()=>a.delete(w)),w.start(n.currentTime),"played"}catch{return"unavailable"}}function u(f,v=!1){var N,w;if(!v&&!e.enabled())return!1;const k=Ere((N=e.prefs)==null?void 0:N.call(e),f),y=((w=e.customSelection)==null?void 0:w.call(e)[f])??null;return y&&e.loadCustom?(d(y,k).then(S=>{var j;S==="played"||S==="locked"||((S==="missing"||S==="broken")&&((j=e.onCustomFailure)==null||j.call(e,f,y)),c(f,{...k,figure:Aa},Aa))}),!0):!n||n.state!=="running"?!1:c(f,k)}function p(f,v=Lr){return d(f,{level:Ym(v),figure:Aa}),!0}function g(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const f of a)try{f.stop()}catch{}a.clear()}return{unlock:r,play:u,previewCustom:p,silence:g,state:i,get context(){return n}}}function FRe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:a,fallbackCustomRef:i}){m.useEffect(()=>{const o=DRe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>a.current,loadCustom:mre,onCustomFailure:(u,p)=>i.current(u,p)});e.current=o;const r=["pointerdown","pointerup","keydown"],c=()=>{for(const u of r)window.removeEventListener(u,d,{capture:!0})},d=()=>{var u;o.unlock(),((u=o.context)==null?void 0:u.state)==="running"&&c()};for(const u of r)window.addEventListener(u,d,{capture:!0});return c},[])}function URe(){const[e,t]=m.useState(zRe),[n,a]=m.useState(()=>Dne(ht(L1))),[i,o]=m.useState(()=>Ine(ht(O1))),[r,c]=m.useState(()=>Fne(ht(yD),n,RRe)),[d,u]=m.useState(()=>new Set),[p,g]=m.useState(0);m.useEffect(()=>{pt(s5,String(e))},[e]),m.useEffect(()=>{pt(O1,i?"1":"0")},[i]),m.useEffect(()=>{pt(L1,JSON.stringify(n))},[n]),m.useEffect(()=>{pt(yD,r)},[r]);const f=m.useCallback((w,S=!1)=>{a(j=>{const A=j.find(T=>T.id===w.id);return A?!S||!w.radio||!A.radio||A.url===w.url&&JSON.stringify(A.radio)===JSON.stringify(w.radio)?j:j.map(T=>T.id===w.id?{...T,url:w.url,radio:w.radio}:T):[...j,w]}),u(j=>{if(!j.has(w.id))return j;const A=new Set(j);return A.delete(w.id),A})},[]),v=m.useCallback((w,S)=>{const j=S.trim();!j||j.length>TU||a(A=>A.map(T=>T.id===w?{...T,name:j}:T))},[]),k=m.useCallback(w=>{a(S=>S.filter(j=>j.id!==w)),c(S=>Une(S,w)),u(S=>{if(!S.has(w))return S;const j=new Set(S);return j.delete(w),j})},[]),y=m.useCallback((w,S=!1)=>{const j=P1(w),A=d.has(j);w===r&&!A&&!S||(A&&u(T=>{const E=new Set(T);return E.delete(j),E}),c(w),g(T=>T+1))},[r,d]),N=m.useCallback((w,S)=>{const j=P1(w);u(A=>{if(A.has(j)===S)return A;const E=new Set(A);return S?E.add(j):E.delete(j),E})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:i,setFmMuted:o,fmSource:r,customFmStations:n,unavailableFmStations:d,fmPlayRequest:p,addFmStation:f,renameFmStation:v,removeFmStation:k,pickFmSource:y,markFmStationAvailability:N}}function BRe(e){const[t,n]=m.useState(null),[a,i]=m.useState(!1),[o,r]=m.useState(null),c=m.useRef(0);m.useEffect(()=>{if(!e||!Eo())return;let k=!1;const y=c.current;return fetch("/api/desktop-update").then(N=>N.ok?N.json():null).then(N=>{if(k||c.current!==y)return;const w=FI(N);w&&n(w)}).catch(()=>{}),()=>{k=!0}},[e]);const d=sNe(t),u=m.useRef(!1),p=m.useRef(0),g=m.useRef(0);m.useEffect(()=>()=>window.clearTimeout(p.current),[]);const f=m.useCallback(async k=>{if(!Jn(u.current))return;const y=++g.current;window.clearTimeout(p.current),u.current=!0,i(!0),r(null);const N=w=>{y===g.current&&(window.clearTimeout(p.current),u.current=!1,i(!1),r({failure:w,version:k}))};try{const w=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!w.ok)return N(oNe(await w.json().catch(()=>null)))}catch{return N("unreachable")}y===g.current&&(p.current=window.setTimeout(()=>N("timeout"),SW))},[]),v=m.useCallback(k=>{if(Eo())try{const y=FI(JSON.parse(k));y&&(c.current++,n(y),y.status!=="ready"&&(g.current++,window.clearTimeout(p.current),u.current=!1,i(!1)))}catch{}},[]);return{desktopUpdateRestarting:a,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:f,onDesktopUpdateEvent:v}}const ig="agent-dag.autoRestart",SD="agent-dag.bundleReloadedFor";function HRe({now:e,stateRef:t,version:n,notice:a,noticeOpen:i,upgradeFailure:o,paused:r}){const[c,d]=m.useState(()=>ht(ig)!=="0"),u=m.useRef(!1),p=m.useCallback(()=>{const H=!c;u.current=!0,Va(ig),d(H),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:H})}).then(I=>I.ok?I.json():null).then(I=>{var L;I!=null&&I.ok&&d(((L=I.prefs)==null?void 0:L.autoUpdate)!==!1)}).catch(()=>{})},[c]),[g,f]=m.useState(!1),[v,k]=m.useState("restart"),[y,N]=m.useState(null),w=m.useRef(!1),S=m.useRef(null),j=m.useRef(0),A=m.useRef(null),T=m.useCallback(async H=>{if(!Jn(w.current))return;const I=(H==null?void 0:H.upgrade)===!0,L=(H==null?void 0:H.whenIdle)===!0;w.current=!0,S.current=o;const O=++j.current,_=()=>{k(I?"npx":"restart"),f(!0)};L||_();try{window.sessionStorage.setItem("agent-dag.restartPending",(a==null?void 0:a.to)??"")}catch{}let M=!1;try{const U=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L?{upgrade:I,whenIdle:L}:{upgrade:I})});M=L&&U.status===409}catch{}if(M){w.current=!1,A.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}L&&_(),window.setTimeout(()=>{if(j.current===O&&w.current){w.current=!1,f(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},I?18e4:3e4)},[a==null?void 0:a.to,o]);m.useEffect(()=>{const H=HI(t.current.agents.values())>0,I=VNe({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:i,visible:document.visibilityState==="visible",busy:H,idleSince:A.current,now:e});A.current=I.idleSince,I.restart&&T({whenIdle:!0})},[c,a==null?void 0:a.kind,n==null?void 0:n.canRestart,i,e,T]);const E=HI(t.current.agents.values()),q=$Ne(E,r),F=_W({enabled:c,kind:a==null?void 0:a.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:i,visible:document.visibilityState==="visible",busy:E>0,idleSince:A.current,now:e});m.useEffect(()=>{const H=n==null?void 0:n.running;let I=null,L=null;try{I=window.sessionStorage.getItem("agent-dag.restartPending"),L=window.sessionStorage.getItem(SD)}catch{return}const O=UNe({bundle:"3.53.2",running:H,pending:I,lastTried:L});if(O==="reload"){try{window.sessionStorage.setItem(SD,H??"")}catch{return}window.location.reload();return}if(O!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}w.current=!1,f(!1),N(H??null);const _=window.setTimeout(()=>N(null),6e3);return()=>window.clearTimeout(_)},[n==null?void 0:n.running]),m.useEffect(()=>{if(g&&HNe({asked:S.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}w.current=!1,f(!1)}},[g,o]);const z=m.useCallback(H=>{var I,L;if(!u.current){const O=ht(ig)==="0";Va(ig),O&&((I=H.prefs)==null?void 0:I.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((L=H.prefs)==null?void 0:L.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:p,restarting:g,restartMode:v,restartedTo:y,askRestart:T,restartCopy:q,restartFuseMs:F,loadAutoRestartPrefs:z}}function WRe(){const[e,t]=m.useState([]),n=m.useRef(new Set),[a,i]=m.useState(null),[o,r]=m.useState(void 0);m.useEffect(()=>{let u=!0,p=0;const g=()=>{fetch("/api/lan").then(f=>f.ok?f.json():null).then(f=>u?(f!=null&&f.ok&&t(pq(Array.isArray(f.pending)?f.pending:[],f.aliases)),f):null).catch(()=>null).then(f=>{u&&(r(v=>f!=null&&f.ok?f:v===void 0?null:v),p=window.setTimeout(g,(f==null?void 0:f.enabled)===!0?oj:Y3))})};return g(),()=>{u=!1,window.clearTimeout(p)}},[]);const c=m.useCallback(async(u,p)=>{if(!a){i(u);try{const f=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:u,fp:p})})).json().catch(()=>null);f&&Array.isArray(f.pending)?t(pq(f.pending,f.aliases)):t(v=>v.filter(k=>k.fp!==p))}catch{}finally{i(null)}}},[a]),d=m.useCallback(u=>{a||(n.current.add(u),t(p=>[...p]))},[a]);return{lanPending:e,lanDeferred:n,lanBusy:a,answerLanPair:c,deferLanPair:d,lanStatus:o}}const GRe=6e4;function $Re({enabled:e,lanStatus:t,now:n}){const[a,i]=m.useState(null),[o,r]=m.useState(()=>new Set),[c,d]=m.useState(null),u=m.useCallback(w=>{w!=null&&w.ok&&Array.isArray(w.accounts)&&i(w.accounts)},[]),p=m.useCallback(async w=>{try{const S=await fetch(`/api/claude-accounts${w?"?refresh=1":""}`);S.ok&&u(await S.json())}catch{}},[u]);m.useEffect(()=>{e&&p(!1)},[e,p]),m.useEffect(()=>{if(!e)return;let w=Date.now();const S=()=>{document.visibilityState!=="visible"||Date.now()-w<GRe||(w=Date.now(),p(!1))};return document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[e,p]);const g=m.useMemo(()=>e?uAe(a,{lan:t,now:n,closed:o}):[],[e,a,t,n,o]),f=m.useRef(g);f.current=g;const v=m.useCallback(w=>{w.length&&r(S=>new Set([...S,...w]))},[]),k=m.useCallback(()=>{const w=f.current;w.length&&(v(w.map(S=>S.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:w.map(S=>({key:S.key,since:S.since}))})}).catch(()=>{}))},[v]),y=m.useRef(c);y.current=c;const N=m.useCallback(w=>{const S=y.current;v(hAe(S?[S,...f.current]:f.current,w))},[v]);return{rows:g,signingIn:c,observe:u,signIn:d,signedIn:N,refresh:m.useCallback(()=>{p(!0)},[p]),closeSignIn:m.useCallback(()=>d(null),[]),later:k}}const o5=288,VRe=o5;function KRe(e,t,n){return e?"session-list":t||n?"accounts":null}function ND(e){return e==="session-list"?VRe:e==="accounts"?o5:0}const JRe=240,YRe=20;function ZRe(e){const t=m.useRef(0),n=m.useRef(e);return m.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=vl()?0:performance.now()+JRe+YRe)},[e]),t}const r5="agent-dag.sessionListOpen",c5="agent-dag.accountsPanelOpen";function XRe(){return ht(r5)==="1"}function QRe(e){pt(r5,e?"1":"0")}function eEe(){const e=ht(c5);return e===null?!0:e==="1"}function tEe(){const e=m.useRef(!1),t=m.useRef(!1),[n,a]=m.useState(()=>{const k=XRe();return k&&AN()?(e.current=!0,!1):k});m.useEffect(()=>{if(n)e.current=!1;else if(e.current)return;QRe(n)},[n]);const i=m.useRef(!1),[o,r]=m.useState(()=>{const k=eEe();return k&&n?(i.current=!0,!1):k&&AN()?(t.current=!0,!1):k});m.useEffect(()=>{if(o)t.current=!1;else if(t.current)return;!o&&i.current||pt(c5,o?"1":"0")},[o]),m.useEffect(()=>{!n&&i.current&&(i.current=!1,r(!0))},[n]);const c=m.useCallback(()=>{a(k=>(k||r(y=>(y&&(i.current=!0),!1)),!k))},[]),d=m.useCallback(()=>{i.current=!1,r(k=>(k||a(!1),!k))},[]),u=m.useCallback(()=>{i.current=!1,r(k=>(k||a(!1),!0))},[]),p=m.useCallback(()=>a(!1),[]),g=m.useCallback(()=>{i.current=!1,a(!1)},[]),f=m.useCallback(()=>r(!1),[]),v=KRe(n,o,i.current);return{sessionListOpen:n,accountsPanelOpen:o,panel:v,toggleSessionList:c,toggleAccountsPanel:d,openAccountsPanel:u,closeSessionList:p,closeSessionListToCanvas:g,closeAccountsPanel:f}}const l5="agent-dag.detailOpen",d5="agent-dag.usagePanelOpen",u5="agent-dag.systemPanelOpen";function nEe(){return ht(l5)==="1"}function aEe(e){pt(l5,e?"1":"0")}function sEe(){const e=ht(d5);return e===null?!0:e==="1"}function iEe(e){pt(d5,e?"1":"0")}function oEe(){const e=ht(u5);return e===null?!0:e==="1"}function rEe(e){pt(u5,e?"1":"0")}function cEe(e=0){const[t,n]=m.useState(nEe);m.useEffect(()=>{aEe(t)},[t]);const[a,i]=m.useState(sEe);m.useEffect(()=>{iEe(a)},[a]);const o=m.useRef(!1),[r,c]=m.useState(()=>{const d=oEe();return d&&a&&(AN()||_oe(e))?(o.current=!0,!1):d});return m.useEffect(()=>{if(r)o.current=!1;else if(o.current)return;rEe(r)},[r]),An("usage-panel",a),An("machine-panel",r),{detailOpen:t,setDetailOpen:n,usagePanelOpen:a,setUsagePanelOpen:i,machinePanelOpen:r,setMachinePanelOpen:c}}const lEe={permission:"permission",asked:"answer"},dEe=()=>C("shell.announce.allClear");function uEe(e){if(e.length===0)return"";const[t,...n]=e,a=t.waiting.kind,i=n.every(o=>o.waiting.kind===a)?lEe[a]??"you":"you";return n.length===0?C(`shell.announce.block.${i}`,{label:t.label}):C(`shell.announce.blockMore.${i}`,{label:t.label,count:n.length})}function WS(e,t,n=dEe()){return t!==""?t:e===""?"":n}function hEe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[a,i]=m.useState(""),o=uEe(e);m.useEffect(()=>{i(f=>WS(f,o))},[o]);const[r,c]=m.useState(""),d=t>0?C("shell.announce.watch",{count:t}):"";m.useEffect(()=>{c(f=>WS(f,d,C("shell.announce.watchNone")))},[d]);const[u,p]=m.useState(""),g=CRe(n);return m.useEffect(()=>{p(f=>WS(f,g,SRe()))},[g]),{blockedSaid:a,watchSaid:r,setWatchSaid:c,incidentSaid:u}}const pEe="/icon-192.png",h5=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0});function jD(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:h5[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped")}}function gEe({waitingSessions:e,liveSince:t,focusSession:n}){const[a,i]=m.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,r]=m.useState(null),[c,d]=m.useState(!1),[u,p]=m.useState(!1),[g,f]=m.useState(h5),v=m.useCallback(F=>{const z=!g[F];f(H=>({...H,[F]:z})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[F]:z})}).then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&f(jD(H.prefs))}).catch(()=>{})},[g]),k=m.useRef(()=>{}),y=m.useRef(new Set),N=pa(e),w=m.useCallback(()=>{const F=!c;d(F),F&&(y.current=qp(N.current)),F&&typeof Notification<"u"&&Notification.permission==="default"&&k.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:F})}).then(z=>z.ok?z.json():null).then(z=>{var H;z!=null&&z.ok&&(d(((H=z.prefs)==null?void 0:H.notifications)===!0),p(z.notificationsVetoed===!0))}).catch(()=>{})},[c]),S=typeof Notification<"u";m.useEffect(()=>{if(!o)return;const z=setTimeout(()=>r(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(z)},[o]);const j=m.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(F=>{const z=F;i(z),z==="granted"?r("on"):z==="denied"&&r("blocked")})},[]);k.current=j;const A=m.useRef(null),T=e.map(F=>zm(F.id,F.waiting)).join("|");m.useEffect(()=>{hee(A.current,a)&&(A.current=a,y.current=qp(e))},[a]);const E=m.useRef(!1);m.useEffect(()=>{pee(E.current,t)&&(E.current=!0,y.current=qp(e))},[t]),m.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!gee(A.current,t))return;const F=typeof document>"u"||!document.hidden,z=dee(e,y.current,F,c);for(const H of z)try{const I=new Notification(H.title,{body:H.body,tag:H.key,icon:pEe});I.onclick=()=>{window.focus(),n(H.sessionId),I.close()}}catch{}y.current=F?qp(e):uee(e,z,y.current)},[T,t]);const q=m.useCallback(F=>{var z;d(((z=F.prefs)==null?void 0:z.notifications)===!0),p(F.notificationsVetoed===!0),f(jD(F.prefs))},[]);return{notifyPermission:a,notifySaid:o,notifyOn:c,notifyVetoed:u,toggleNotify:w,notifySupported:S,askForNotifications:j,loadNotifyPrefs:q,accountNotify:g,toggleAccountNotify:v}}function mEe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:a,summaryFor:i,browserWatchOpen:o,keyHelpOpen:r,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:u=!1}){const p=pa(r),g=m.useRef(!1);return g.current=e!=null||t||n!=null||a||i!=null||o||r||c!=null||d||u,{keyHelpOpenRef:p,modalOpenRef:g}}function fEe({stateRef:e,tourOpen:t,releaseNotes:n}){const[a,i]=m.useState(null),o=m.useCallback((L,O)=>i({agentId:L,toolId:O}),[]),[r,c]=m.useState(null),[d,u]=m.useState(null),p=m.useCallback(L=>u(L),[]),[g,f]=m.useState(!1),[v,k]=m.useState(!1),[y,N]=m.useState(!1),[w,S]=m.useState(!1),[j,A]=m.useState(!1),[T,E]=m.useState(null),q=m.useCallback(L=>{E(L??null),A(!0)},[]);An("tool-detail",a!==null),An("session-summary",r!==null),An("context-window",d!==null),An("keyboard-help",g),An("usage-history",v),An("browser-watch",y),An("feedback",j);const F=a?nQ(e.current.agents,a.agentId,a.toolId):null,z=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:H,modalOpenRef:I}=mEe({openedTool:F,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:r,browserWatchOpen:y,keyHelpOpen:g,releaseNotes:n,feedbackOpen:j,trafficRadarOpen:w});return{setOpenedToolKey:i,openTool:o,openedTool:F,summaryFor:r,setSummaryFor:c,contextFor:d,setContextFor:u,openContext:p,contextAgent:z,keyHelpOpen:g,setKeyHelpOpen:f,usageHistoryOpen:v,setUsageHistoryOpen:k,browserWatchOpen:y,setBrowserWatchOpen:N,trafficRadarOpen:w,setTrafficRadarOpen:S,feedbackOpen:j,setFeedbackOpen:A,feedbackPrefill:T,setFeedbackPrefill:E,openFeedback:q,keyHelpOpenRef:H,modalOpenRef:I}}function bEe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:a,lastLayoutSigRef:i,forgetRemovals:o,clearSelection:r,rerender:c,modalOpenRef:d}){const[u,p]=m.useState(!1),g=m.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Qj(),t.current.clear(),n.current.clear(),a.current.clear(),i.current="",Y4(),o(),r(),c()},[c,r,o]),f=pa(u),v=m.useCallback(k=>{const y=YNe(k,{confirmOpen:f.current,modalOpen:d.current});y==="confirm"?p(!0):y==="clear"&&(p(!1),g())},[g]);return{clearConfirmOpen:u,setClearConfirmOpen:p,requestClear:v}}const AD="agent-dag.oldNameNoticeDismissed";function vEe(e){const[t,n]=m.useState(()=>ht(AD)??""),a=e!=null&&e.invokedAs&&e.invokedAs!==Pt?e.invokedAs:null,i=a!=null&&t!==a,o=m.useCallback(()=>{a&&(n(a),pt(AD,a))},[a]);return{oldName:a,oldNameOpen:i,dismissOldName:o}}const kEe=300*1e3,wEe=1800*1e3,yEe=8e3,xEe=3e4;function TD(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function CEe({modalOpenRef:e}){const t=m.useCallback(()=>Pc({appModal:e.current,dialogDepth:jn.dialogDepth()}),[e]),[n,a]=m.useState("hidden"),[i,o]=m.useState(null),[r,c]=m.useState(!1),d=m.useRef(n);d.current=n,m.useEffect(()=>{let v=!1;const k=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const w=await fetch("/api/rating").then(S=>S.ok?S.json():null).catch(()=>null);v||!w||a(S=>S==="thanks"?S:w.ask===!0?"asking":"hidden")},y=window.setTimeout(k,kEe),N=window.setInterval(k,wEe);return()=>{v=!0,window.clearTimeout(y),window.clearInterval(N)}},[t]),m.useEffect(()=>{if(n!=="thanks"||r)return;const v=i!==null&&i<=6?xEe:yEe;let k=0;const y=()=>{t()?k=window.setTimeout(y,v):a("hidden")};return k=window.setTimeout(y,v),()=>window.clearTimeout(k)},[n,i,r,t]);const u=m.useCallback(v=>{o(v),c(!1),a("thanks"),TD({score:v})},[]),p=m.useCallback(v=>c(v),[]),g=m.useCallback(()=>{a("hidden"),TD({later:!0})},[]),f=m.useCallback(()=>a("hidden"),[]);return{ratingPhase:n,ratingScore:i,answerRating:u,rateLater:g,closeRating:f,holdThanks:p}}function SEe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:a}){const[i,o]=m.useState(()=>are(ht)),r=pa(i),[c,d]=m.useState([]),u=m.useCallback(S=>{o(j=>{const A={...j,[S]:null};return r.current=A,A}),Va(Kd[S])},[]),p=m.useCallback((S,j)=>{const A=r.current[S];j&&A!==j||(u(S),t(T=>{const E={...T,[S]:{...T[S],figure:Aa}};return n.current=E,E}),pt(Xg[S],Aa))},[u]),g=pa(p);m.useEffect(()=>{let S=!0;return gre().then(j=>{if(!S)return;d(j);const A=new Set(j.map(T=>T.id));for(const T of Jd){const E=r.current[T];E&&!A.has(E)&&g.current(T,E)}},()=>{}),()=>{S=!1}},[]);const f=m.useCallback((S,j)=>{if(!c.some(T=>T.id===j))return;const A={...r.current,[S]:j};r.current=A,o(A),pt(Kd[S],j),a(S,!0)},[c,a]),v=m.useCallback(async S=>{var E;const j=EN(c.length);if(j)throw new Ln(j);const A=window.AudioContext??window.webkitAudioContext;if(!A)throw new Ln(C("settings.sounds.custom.decodeFail"));const T=new A;try{const q=await lre(S,z=>T.decodeAudioData(z));await C_(q);const F=wu(q);d(z=>[...z.filter(H=>H.id!==F.id),F])}finally{(E=T.close)==null||E.call(T)}},[c.length]),k=m.useCallback(async S=>{const j=EN(c.length);if(j)throw new Ln(j);const A=dre(S);await C_(A);const T=wu(A);d(E=>[...E.filter(q=>q.id!==T.id),T])},[c.length]),y=m.useCallback(async(S,j)=>{const A=c.find(E=>E.id===S),T=j.trim().slice(0,80);!A||!T||T===A.name||(await fre(S,T),d(E=>E.map(q=>q.id===S?{...q,name:T}:q)))},[c]),N=m.useCallback(async S=>{await bre(S),d(E=>E.filter(q=>q.id!==S));const j=r.current,A=sre(j,S);r.current=A,o(A);const T=Jd.filter(E=>j[E]===S);for(const E of T)Va(Kd[E]),pt(Xg[E],Aa);T.length>0&&t(E=>{const q={...E};for(const F of T)q[F]={...q[F],figure:Aa};return n.current=q,q})},[]),w=m.useCallback(S=>{var T,E;const j=Jd.find(q=>r.current[q]===S),A=j?n.current[j].level:Lr;(T=e.current)==null||T.unlock(),(E=e.current)==null||E.previewCustom(S,A)},[]);return{customSelections:i,customSelectionsRef:r,customAssets:c,clearCustomOnly:u,fallbackCustomRef:g,selectCustomTone:f,importNotificationAudio:v,createNotificationVoice:k,renameCustomAsset:y,deleteCustomAsset:N,previewCustomAsset:w}}function NEe(e){const[t,n]=m.useState(()=>Rre(ht)),a=pa(t),i=m.useRef(null),o=m.useCallback((c,d=!1)=>{var u,p;if((u=e.current)==null||u.unlock(),i.current!==null&&clearTimeout(i.current),i.current=null,!d){(p=e.current)==null||p.play(c,!0);return}i.current=setTimeout(()=>{var g;i.current=null,(g=e.current)==null||g.play(c,!0)},Sre)},[]),r=m.useCallback((c,d)=>{n(u=>{const p={level:Ym(d.level??u[c].level),figure:kB(c,d.figure??u[c].figure)};return pt(xB[c],String(p.level)),pt(Xg[c],p.figure),{...u,[c]:p}}),o(c,!0)},[o]);return m.useEffect(()=>()=>{i.current!==null&&clearTimeout(i.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:a,previewTone:o,changeTone:r}}const jEe=15e3;function AEe(e){return e.visibilityState==="visible"&&e.hasFocus()}function TEe(e,t){return t||e===!0}function REe(){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 EEe(){m.useEffect(()=>{const e=REe();let t=null;const n=r=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:r}),keepalive:!0}).catch(()=>{})},a=()=>{const r=AEe(document);TEe(t,r)&&n(r),t=r},i=()=>{t&&n(!1),t=!1};a();const o=window.setInterval(a,jEe);return window.addEventListener("focus",a),window.addEventListener("blur",a),document.addEventListener("visibilitychange",a),window.addEventListener("pagehide",i),()=>{window.clearInterval(o),window.removeEventListener("focus",a),window.removeEventListener("blur",a),document.removeEventListener("visibilitychange",a),window.removeEventListener("pagehide",i),i()}},[])}function _Ee({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){m.useEffect(()=>{let a=!0;return fetch("/api/prefs").then(i=>i.ok?i.json():null).then(i=>{!a||!(i!=null&&i.ok)||(e(i),t(i),n(i))}).catch(()=>{}),()=>{a=!1}},[])}const GS="agent-dag.versionNoticeDismissed",qEe=15*6e4;function zEe(e){const[t,n]=m.useState(null),[a,i]=m.useState(()=>ht(GS)??""),o=m.useRef(0),[r,c]=m.useState(!1),d=m.useCallback((y=!1)=>(y&&(o.current=Date.now(),c(!0)),fetch(y?"/api/version?refresh=1":"/api/version").then(N=>N.ok?N.json():null).then(N=>(N&&n(N),N??null)).catch(()=>null).finally(()=>{y&&c(!1)})),[]),u=m.useCallback(()=>{d(Date.now()-o.current>=qEe)},[d]);m.useEffect(()=>{d();const y=window.setInterval(u,5*6e4),N=()=>{document.visibilityState==="visible"&&u()};return document.addEventListener("visibilitychange",N),()=>{window.clearInterval(y),document.removeEventListener("visibilitychange",N)}},[d,u]),m.useEffect(()=>{e&&d()},[e,d]);const p=(t==null?void 0:t.notice)??null,g=TW(p),f=hNe(p,a),v=m.useCallback(()=>{i(""),pt(GS,"")},[]),k=m.useCallback(()=>{p&&(i(g),pt(GS,g))},[p,g]);return{version:t,notice:p,noticeOpen:f,showNotice:v,dismissNotice:k,versionChecking:r,loadVersion:d}}function LEe({version:e,readyAppUpdate:t}){const[n,a]=m.useState(!1),i=m.useRef(null),[o,r]=m.useState(null),c=o&&t?t.version:null,d=m.useRef(null);m.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 u=m.useRef(!1);m.useEffect(()=>{if(u.current)return;const N=Is(),w=zAe(N),S=DAe({stored:w,running:(e==null?void 0:e.running)??null,notes:ZI,remembers:LAe(N)});if(S.reason==="no-version")return;u.current=!0,S.record&&OAe(N,S.record);let j=!0;return(async()=>{var F;let T=PAe(N);if(Eo())try{const z=await fetch("/api/prefs");if(!z.ok)throw new Error("desktop tour preferences unavailable");const H=await z.json();if(!(H!=null&&H.ok))throw new Error("desktop tour preferences unavailable");const I=((F=H.prefs)==null?void 0:F.tourSeen)===!0;T&&!I&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||I}catch{T=!0}if(!j)return;const E=IAe({tourSeen:T,decision:S}),q=S.show.length?{entries:S.show,since:w,firstRun:!1}:null;E.tour&&a(!0),E.notes==="now"?r(q):E.notes==="after"&&(i.current=q)})(),()=>{j=!1}},[e==null?void 0:e.running]);const p=(e==null?void 0:e.running)??"3.53.2",g=m.useMemo(()=>BW(ZI,null,p),[p]),f=m.useCallback(()=>{r({entries:g,since:null,firstRun:!1})},[g]),v=m.useCallback(()=>a(!0),[]),k=m.useCallback(()=>r(null),[]),y=m.useCallback(()=>{a(!1),MAe(Is()),Eo()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const N=i.current;i.current=null,N&&r(N)},[]);return{tourOpen:n,openTour:v,closeTour:y,releaseNotes:o,closeReleaseNotes:k,chipVersion:p,openReleaseNotes:f}}function OEe(){const[e,t]=m.useState(void 0),[n,a]=m.useState(!1),i=m.useRef(!1);return i.current=e===!0&&!n,m.useEffect(()=>Y0e(()=>i.current),[]),{loadReportsPrefs:m.useCallback(r=>{var c;t(((c=r.prefs)==null?void 0:c.reports)!==!1),a(r.reportsVetoed===!0)},[])}}function PEe(e){const[t,n]=m.useState(null);m.useEffect(()=>{const c=ht("agent-dag.sound");n(c===null?!0:c==="on")},[]);const a=m.useCallback(()=>{n(c=>{var u,p;const d=c!==!0;return pt("agent-dag.sound",d?"on":"off"),d?(u=e.current)==null||u.unlock():(p=e.current)==null||p.silence(),d})},[]),i=m.useCallback(c=>{a()},[a]),o=pa(i),r=pa(t);return{soundOn:t,toggleSound:a,activateSoundRef:o,soundOnRef:r}}function MEe(){const[e,t]=m.useState(Boe),n=m.useCallback((o,r)=>{t(c=>Hoe(c,o,r))},[]),a=m.useCallback(()=>t(o=>({...o,open:!1})),[]),i=m.useCallback(o=>t(r=>({...r,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,settingsLandOn:e.landOn,openSettings:n,closeSettings:a,showSection:i}}const IEe="agent-dag.autoFitDisabled";function DEe(e){const t=m.useRef(!1),[n,a]=m.useState(!1);m.useEffect(()=>{Va(IEe)},[]);const i=m.useCallback(()=>{t.current||(t.current=!0,a(!0))},[]),o=m.useCallback(()=>{t.current=!1,a(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:i,enableAutoFitAndRefit:o}}function FEe(){return s.jsx(Xj,{children:s.jsx(Q0e,{children:s.jsx(UEe,{})})})}function UEe(){var Hi;const e=ae(),t=bl(),n=m.useState(Qj)[0],a=m.useRef(n),[,i]=m.useState(0),o=m.useCallback(()=>i(vt=>vt+1),[]),{sessionListOpen:r,accountsPanelOpen:c,panel:d,toggleSessionList:u,toggleAccountsPanel:p,openAccountsPanel:g,closeSessionList:f,closeSessionListToCanvas:v,closeAccountsPanel:k}=tEe(),{detailOpen:y,setDetailOpen:N,usagePanelOpen:w,setUsagePanelOpen:S,machinePanelOpen:j,setMachinePanelOpen:A}=cEe(ND(d)),{selectedIds:T,primarySelectedId:E,selectAgent:q,clearSelection:F,pruneSelectionToBoard:z}=gve(a,N),H=Uc(c,200),I=Uc(r,200),L=VE(r,I),O=Uc(w,130),_=Uc(j,130),M=m.useRef(null),U=PEe(M),{activateSoundRef:G,soundOnRef:W}=U,$=NEe(M),{setTonePrefs:Y,tonePrefsRef:B,previewTone:V}=$,Z=SEe({chimesRef:M,setTonePrefs:Y,tonePrefsRef:B,previewTone:V}),{customSelectionsRef:D,fallbackCustomRef:K}=Z,X=MEe(),{openSettings:Q}=X;FRe({chimesRef:M,soundOnRef:W,tonePrefsRef:B,customSelectionsRef:D,fallbackCustomRef:K});const ee=nRe(a),{pauseGate:ne,paused:de,togglePause:ge}=ee,le=m.useRef(()=>{}),{live:he,tabCapped:ce,everConnected:oe,liveSince:ve}=sve({stateRef:a,rerender:o,pauseGate:ne,chimesRef:M,desktopUpdateRef:le}),ke=zEe(he),{version:ye,notice:Le,noticeOpen:Ke,loadVersion:Qe}=ke,Ae=BRe(he),{readyAppUpdate:je,onDesktopUpdateEvent:Oe}=Ae;le.current=Oe,EEe();const Ve=LEe({version:ye,readyAppUpdate:je}),{tourOpen:nt,openTour:Ye,releaseNotes:Ce}=Ve,{workspace:ze,providers:De,providersRef:Fe}=rRe(he),ot=iRe(De,c),se=ot.shown,Ne=vt=>{ot.remember(vt),(!c||se===vt)&&p()},Ie=ND(d==="accounts"&&!(De.claude||De.codex)?null:d),Be=ZRe(Ie),Se=VE(c,H)&&(De.claude||De.codex),[tt,fe]=m.useState(!1),He=ot.remember,lt=m.useCallback(()=>{He(De.claude?"claude":"codex"),g()},[g,De.claude,He]),gt=m.useCallback(()=>{He("claude"),g(),fe(!0)},[g,He]);m.useEffect(()=>{c||fe(!1)},[c]);const mt=m.useCallback(()=>fe(!1),[]),xt=vEe(ye),Rn=NRe({version:ye,loadVersion:Qe}),{upgradeFailure:ba}=Rn,nn=fEe({stateRef:a,tourOpen:nt,releaseNotes:Ce}),Ut=CEe({modalOpenRef:nn.modalOpenRef}),{openTool:va,setSummaryFor:yn,setContextFor:an,openContext:En,setKeyHelpOpen:Ue,setUsageHistoryOpen:Ge,setBrowserWatchOpen:st,keyHelpOpenRef:Et,modalOpenRef:Zt}=nn,Cs=OEe(),ka=ARe(),{watchOn:xn,watchUnseen:pn}=ka,_n=Xu(),[$t,Bn]=m.useState(null),[Pn,Hn]=m.useState(!1),ea=m.useCallback(()=>Hn(!1),[]),Qa=vt=>{WSe(vt),Q("integrations")},es=vt=>{vt&&DI(vt),Q("integrations")},rn=m.useCallback(()=>Bn(null),[]),St=$T().filter(vt=>xj(_n,vt.kind)),ts=pa(vt=>{const oi=St.find(Th=>Th.kind===vt);oi&&Bn(oi.kind)}),me=m.useCallback(vt=>{DI(vt),Q("integrations")},[Q]),Ee=St.length>0;m.useEffect(()=>{Ee&&RSe()},[Ee]);const Me=WRe(),[Ze,ft]=m.useState(0),{presentCats:zt,hiddenCats:Xt,toggleCat:wa,catBarRef:cn,catBarOccluded:Hr}=IRe(a),Oo=m.useRef(null),[Wr,Ys]=m.useState(0),Qt=mve({stateRef:a,rerender:o,pruneSelectionToBoard:z,setContextFor:an,setSummaryFor:yn});ine({stateRef:a,now:Qt,enabled:De.claude});const Ss=uRe(De.claude||De.codex),xe=xRe(Ss,Qt),ut=$Re({enabled:De.claude,lanStatus:Me.lanStatus,now:Qt}),Nt=HRe({now:Qt,stateRef:a,version:ye,notice:Le,noticeOpen:Ke,upgradeFailure:ba,paused:ee.paused}),{askRestart:Vt,loadAutoRestartPrefs:ta}=Nt,na=MRe(),{setTheme:Ns,palette:eh}=na,zi=URe(),yt=mxe(),{applyViewport:th,moveCamera:nh,fitLeft:Li,cameraEpochRef:ah,lastFitTimeRef:ql}=yt,Zs=Rxe(yt),{pinnedRef:Oi,positionsRef:Xs,lastLayoutSigRef:js,handleRelayout:ns,rearrangeUndo:As}=Zs,Pi=m.useRef(null),Mi=m.useRef(()=>{}),as=ve!==null,sh=m.useRef(0),zl=m.useCallback(()=>{sh.current=Date.now()},[]),{canvasRef:aa,canvasSize:Pf,paneSizeRef:ih}=fCe(Be),Po=DEe(Li),{autoFitDisabledRef:Ll,disableAutoFit:Ol}=Po,Qs=m.useRef(!1),{measuredRef:ya,measuredVersionRef:Ii,sizeVersion:Gr,domSizeVersion:Mf}=bCe(Qs,a),{removedNodes:Pl,removedAgentIds:Ts,removeNode:$r,removeSelectedNode:Vr,removalNotice:Ml,hideSessions:Rs,bringBack:Mo,bringBackAll:Kr,forgetRemovals:oh}=Jxe({stateRef:a,pinnedRef:Oi,positionsRef:Xs,returningRef:Zs.returningRef,canvasRef:aa,clearSelection:F,primarySelectedId:E});iCe({stateRef:a,removedNodes:Pl,hideSessions:Rs,ready:as,keepSessionId:E?((Hi=a.current.agents.get(E))==null?void 0:Hi.sessionId)??E:null});const Di=Wxe({stateRef:a,now:Qt,removedAgentIds:Ts,sizeVersion:Gr,domSizeVersion:Mf});Exe(Di,Zs),Kxe({layoutSig:Di,rf:t,stateRef:a,measuredRef:ya,pinnedRef:Oi,positionsRef:Xs,paneSizeRef:ih,lastInteractRef:sh,autoFitDisabledRef:Ll,lastFitTimeRef:ql,fitLeft:Li});const Io=vCe(),{bubbling:rh,endBubble:Wn,onBubble:Fi}=Hbe(),[Do,Fo]=m.useState(!1),ch=Ube(),{beginTrashDrag:Il,trackTrashDrag:Dl,endTrashDrag:Uo}=ch,Bo=Ybe({stateRef:a,measuredRef:ya,measuredVersionRef:Ii,canvasRef:aa}),{lodRef:lh,applyZoom:If}=Bo,dh=pCe({applyViewport:th,lastFitTimeRef:ql,cameraEpochRef:ah,disableAutoFit:Ol,markInteract:zl,canvasRef:aa,applyZoom:If}),Ho=E?a.current.agents.get(E):null,Wo=y&&Ho!=null,ei=xCe({sessionListShown:L,usageShown:mo(O),machineShown:mo(_),accountsShown:Se&&De.claude,codexShown:Se&&!De.claude,detailShown:Wo,primarySelectedId:E,canvasRef:aa}),{railInsetRef:Jr,availableWidth:uh,availableHeight:hh}=dxe({canvasRef:aa,canvasSize:Pf,machinePhase:_,usagePhase:O,usagePanelOpen:w,detailShown:Wo}),ph=Gxe({stateRef:a,now:Qt,availableWidth:uh,availableHeight:hh,layout:Zs,measuredRef:ya,onBubble:Fi,settled:Io,dragging:Do,layoutSig:Di,selectedIds:T,openContext:En,historyReplayed:as,removedNodes:Pl,removedAgentIds:Ts,dragTick:Ze,dragPatchRef:Oo,dragMoveTick:Wr}),{nodes:Yr,edges:Df}=ph,Fl=pa(E);_xe({nodes:Yr,edges:Df,settled:Io,dragging:Do,availableWidth:uh,availableHeight:hh,layout:Zs,camera:yt,rf:t,measuredRef:ya,stateRef:a,lastFocusRef:Pi,primarySelectedIdRef:Fl,focusAgentRef:Mi,autoFitDisabledRef:Ll});const gh=bEe({stateRef:a,pinnedRef:Oi,measuredRef:ya,positionsRef:Xs,lastLayoutSigRef:js,forgetRemovals:oh,clearSelection:F,rerender:o,modalOpenRef:Zt}),{requestClear:Ul}=gh,Bl=CCe({nodes:Yr,stateRef:a,pinnedRef:Oi,positionsRef:Xs,draggingRef:Qs,dragPatchRef:Oo,setDragging:Fo,setDragMoveTick:Ys,setDragTick:ft,endBubble:Wn,markInteract:zl,disableAutoFit:Ol,beginTrashDrag:Il,trackTrashDrag:Dl,endTrashDrag:Uo,removeNode:$r}),mh=m.useCallback(()=>Li(500),[Li]),Hl=pa(Yr),{focusAgent:Zr,stepAgent:fh,focusSession:Ui}=bxe({canvasRef:aa,stateRef:a,measuredRef:ya,nodesRef:Hl,railInsetRef:Jr,moveCamera:nh,disableAutoFit:Ol,lastFocusRef:Pi,focusAgentRef:Mi,selectAgent:q,primarySelectedIdRef:Fl}),Ff=gCe({clearSelection:F,selectAgent:q,detailOpen:y,setDetailOpen:N,detailShown:Wo,focusAgent:Zr,draggingRef:Qs,lodRef:lh}),Uf=vxe({nodesRef:Hl,stateRef:a,canvasRef:aa,railInsetRef:Jr}),Bf=pa(Vr),Wl=m.useRef(null),Xr=m.useCallback(vt=>{Ts.has(vt)&&Mo([vt]),Ui(vt)},[Ts,Mo,Ui]),Hf=kCe(),[Gl,ti]=m.useState(!1),bh=m.useCallback(()=>ti(!0),[]),vh=m.useCallback(()=>ti(!1),[]),kh=m.useCallback(vt=>{ti(!1),vt.run()},[]),wh=Qn();wCe({pointerFocusRef:Hf,nodesRef:Hl,stateRef:a,primarySelectedIdRef:Fl,providersRef:Fe,soundOnRef:W,keyHelpOpenRef:Et,modalOpenRef:Zt,waitingCursorRef:Wl,removeSelectedRef:Bf,activateSoundRef:G,clearSelection:F,selectAgent:q,focusAgent:Zr,stepAgent:fh,focusSession:Ui,requestClear:Ul,handleRelayout:ns,undoRearrange:As.undo,handleFit:mh,togglePause:ge,toggleSessionList:u,toggleAccountsPanel:p,setDetailOpen:N,setUsageHistoryOpen:Ge,setUsagePanelOpen:S,setMachinePanelOpen:A,setBrowserWatchOpen:st,setKeyHelpOpen:Ue,setTheme:Ns,openSettings:Q,openIntegrationRef:ts,openQuickOpen:bh});const Qr=a.current.agents.size,ni=m.useMemo(()=>hN(a.current.agents.values()),[a.current,a.current.revision]);Yxe({stateRef:a,waitingSessions:ni,removedAgentIds:Ts,removedNodes:Pl,bringBack:Mo}),dCe({stateRef:a,waitingSessions:ni,live:he});const ai=hEe({waitingSessions:ni,watchUnseen:pn,incidents:xe}),$l=gEe({waitingSessions:ni,liveSince:ve,focusSession:Ui}),{loadNotifyPrefs:Wf}=$l;_Ee({loadAutoRestartPrefs:ta,loadNotifyPrefs:Wf,loadReportsPrefs:Cs.loadReportsPrefs});const si=jl(Km),[yh,Vl]=m.useState(!1),[Bi,ii]=m.useState(null),Gf=m.useCallback(()=>ii(null),[]),ec=m.useCallback(vt=>{const oi=a.current.agents.get(vt);return oi?oi.label||oi.cwdBasename||"session":null},[]),$f=m.useCallback(vt=>{ii(null),Xr(vt)},[Xr]),xh=m.useCallback(()=>Vl(!1),[]),[tc,nc]=m.useState(null),Ch=m.useCallback(()=>nc(null),[]),gn=HCe({providers:De,sessionListOpen:r,toggleSessionList:u,accountsPanelOpen:c,toggleAccountsPanel:p,accountsPanelId:t5(se),codexPanelOpen:c&&se==="codex",toggleCodexPanel:()=>Ne("codex"),usagePanelOpen:w,setUsagePanelOpen:S,machinePanelOpen:j,setMachinePanelOpen:A,setUsageHistoryOpen:Ge,watchOn:xn,watchUnseen:pn,setBrowserWatchOpen:st,setTrafficRadarOpen:nn.setTrafficRadarOpen,openSettings:Q,onFeedback:nn.openFeedback,setRadioOpen:Vl,openToolActivity:ii,openCapacity:nc,toggles:ei.toggles,integrations:St.map(vt=>({provider:vt,onPress:()=>Bn(vt.kind)})),openExploreIntegrations:()=>Hn(!0),openQuickOpen:bh}),[Sh,Vf]=m.useState(0),Nh=m.useCallback(vt=>{Xr(vt),si&&v()},[Xr,si,v]),Kf=m.useCallback(()=>{r||u(),requestAnimationFrame(()=>{var vt;return(vt=document.querySelector("#session-list .sl-row"))==null?void 0:vt.focus()})},[r,u]),jh=()=>{(De.claude?ei.accounts:ei.codex)(),k()},Ah=ot.both?s.jsx(tbe,{shown:se,notices:ot.notices,onPick:ot.pick}):void 0,sa=vt=>ot.bothMounted?vt===se?"shown":"hidden":void 0;return s.jsxs("div",{className:"app",children:[s.jsx("a",{className:"skip-link",href:"#canvas",children:e("shell.skipToCanvas")}),s.jsxs("header",{className:"topbar",children:[s.jsx(Tie,{}),s.jsx(SNe,{versionCheck:ke,welcome:Ve,desktopUpdate:Ae,pause:ee,announcements:ai,notify:$l,waitingSessions:ni,waitingCursorRef:Wl,focusSession:Ui,live:he,now:Qt,incidents:xe,queueNamed:si?0:Sh}),!si&&s.jsx(wNe,{waitingSessions:ni,waitingCursorRef:Wl,focusSession:Ui,now:Qt,onFit:Vf,onMore:Kf}),Ho&&s.jsx(NNe,{selected:Ho,now:Qt,selectedIds:T,focusAgent:Zr,clearSelection:F}),!si&&s.jsx("div",{className:"actions",children:s.jsx(Ioe,{items:[gn.search,...gn.utilities]})})]}),si?s.jsx(Moe,{items:[...gn.left,...gn.right[0],gn.utilities[0]],more:[gn.search,...gn.capacity,...gn.right.slice(1).flat(),...gn.integrations,...gn.explore,gn.utilities[1]]}):s.jsx(f_,{side:"left",label:e("shell.rail.left"),groups:[...gn.leftStripe,gn.integrations,gn.explore]}),s.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Ml?e("shell.board.removed",{label:Ml.label}):""}),s.jsx(JNe,{restart:Nt,versionCheck:ke,upgrade:Rn,oldNameNotice:xt,rating:Ut,onFeedback:nn.openFeedback,everConnected:oe,live:he,paused:de}),(L||Se)&&s.jsxs(Lbe,{width:Ie,children:[Se&&(se==="claude"||ot.bothMounted)&&s.jsx(Qfe,{leaving:_v(c,H),onReport:nn.openFeedback,onRoster:ut.observe,onClose:jh,lanWanted:tt,onLanShown:mt,switcher:Ah,side:sa("claude"),onNotice:ot.noteClaude}),Se&&(se==="codex"||ot.bothMounted)&&s.jsx(zbe,{leaving:_v(c,H),onClose:jh,switcher:Ah,side:sa("codex"),onNotice:ot.noteCodex}),L&&s.jsx(Lie,{leaving:_v(r,I),state:a.current,now:Qt,selectedIds:T,onSelect:Nh,onClose:()=>{ei.sessionList(),f()},removedIds:Ts,onBringBackAll:Kr})]}),s.jsxs(ENe,{canvasRef:aa,bubbling:rh,dragging:Do,trash:ch,zoom:Bo,viewport:dh,stateRef:a,peek:Uf,children:[Qr===0&&(!he&&ce?s.jsx(NCe,{reservedRight:Jr.current}):s.jsx(jCe,{live:he,everConnected:oe,providers:De,workspace:ze,onTour:Ye,reservedRight:Jr.current})),(zt.length>1||Xt.size>0)&&s.jsx(jNe,{catBarRef:cn,catBarOccluded:Hr,presentCats:zt,hiddenCats:Xt,toggleCat:wa}),s.jsx(Aie,{graph:ph,layout:Zs,viewport:dh,clicks:Ff,drag:Bl,appearance:na,fm:zi,radioOpen:yh,onRadioClose:xh,autoFit:Po,pause:ee,stateRef:a,measuredRef:ya,hiddenCats:Xt,now:Qt,openTool:va,focusAgent:Zr,requestClear:Ul,setKeyHelpOpen:Ue})]}),!si&&s.jsx(f_,{side:"right",label:e("shell.rail.right"),groups:gn.right}),Bi&&s.jsx(rle,{view:Bi,onClose:Gf,sessionLabel:ec,onOpenSession:$f}),tc&&s.jsx(fbe,{view:tc,onClose:Ch}),$t&&s.jsx(qSe,{kind:$t,connections:yi(_n,$t)?pm(_n,$t):[],onClose:rn,onReconnect:me}),Pn&&s.jsx(YSe,{integrations:_n,onClose:ea,onOpen:Bn,onConnect:Qa,onManage:es}),Gl&&s.jsx(foe,{onClose:vh,onRun:kh,items:Yre({rails:gn,sessions:YU(a.current),now:Qt,openSession:Nh,settings:AB(De.claude,KT(_n),Qu(_n)),openSettings:Q,singleKeys:wh,fit:mh,rearrange:ns,paused:de,togglePause:ge,clear:Qr>0?()=>Ul("button"):void 0,keyHelp:()=>Ue(!0),tour:Ye,theme:na.theme,setTheme:Ns})}),mo(O)&&s.jsx(Fde,{state:a.current,now:Qt,providers:De,incidents:xe,liveSince:ve,leaving:O==="leaving",onClose:()=>{ei.usage(),S(!1)}}),mo(_)&&s.jsx(Cue,{usageOpen:w,leaving:_==="leaving",onClose:()=>{ei.machine(),A(!1)}}),y&&Ho?s.jsx(FCe,{selected:Ho,now:Qt,openTool:va,setSummaryFor:yn,stateRef:a,removeSelectedNode:Vr,onClose:()=>{ei.detail(),N(!1)}}):null,s.jsx(z0e,{dialogs:nn,welcome:Ve,desktopUpdate:Ae,versionCheck:ke,restart:Nt,upgrade:Rn,lanPairs:Me,attention:ut,clearFlow:gh,watchBadge:ka,announcements:ai,appearance:na,providers:De,stateRef:a,agentCount:Qr,menus:X,sound:U,tones:$,customTones:Z,notify:$l,panelDoors:{accounts:lt,localNetwork:gt}})]})}try{U8(window.localStorage)}catch{}v2();const BEe=mG.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);BEe.render(s.jsx(FEe,{}));export{YEe as $,Mr as A,J2 as B,_t as C,qt as D,fl as E,An as F,s1e as G,nhe as H,$a as I,a1e as J,XEe as K,ZEe as L,Lt as M,Wd as N,i1e as O,t3 as P,At as Q,ZB as R,DN as S,Ig as T,P_ as U,FN as V,KEe as W,Ft as X,wo as Y,Ps as Z,JEe as _,Va as a,ju as a0,Xn as a1,rre as a2,Ha as a3,cAe as a4,Sj as a5,Ln as a6,Um as a7,a3 as a8,we as a9,zr as aa,xo as ab,fse as ac,o1e as ad,TA as ae,pl as af,Zne as ag,VEe as ah,GEe as ai,$Ee as aj,Hm as ak,zee as al,ATe as am,TRe as an,WEe as ao,bse as ap,m as b,jl as c,t1e as d,qe as e,kW as f,wA as g,OSe as h,ga as i,s as j,n1e as k,LSe as l,jn as m,or as n,So as o,vl as p,e1e as q,ht as r,Jn as s,C as t,ae as u,Ea as v,pt as w,Ks as x,QEe as y,pT as z};