kaizen-agent 1.61.1 → 1.61.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/board.test.ts +17 -2
- package/cli/pty.ts +1 -1
- package/cli/state-snap.ts +75 -0
- package/cli/web-decide.test.ts +13 -1
- package/cli/web.ts +46 -24
- package/package.json +1 -1
- package/web/board/icebox.ts +2 -2
- package/web/board/ideas.ts +29 -7
- package/web/board/settings.ts +20 -4
- package/web/board/update.ts +55 -14
- package/web/board.html +22 -12
- package/web/board.js +54 -54
- package/web/notebook.js +1 -1
- package/web/notes.html +2 -0
- package/web/term.js +3 -3
- package/web/term.ts +5 -3
- package/web/video.html +2 -0
- package/web/video.js +1 -1
package/web/notebook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen notebook
|
|
1
|
+
/* kaizen notebook bf8430f9ab3270fb -- generated by bun run build:web from web/notebook.ts; do not edit */
|
|
2
2
|
var Ka=null,Ja=(e)=>{Ka=e};function Am(e,t,i){Vr++,Ka?.(e,t,i)}var Vr=0,Fa="",Ur=!1,As=!1;async function Nr(){if(Ur){As=!0;return}Ur=!0;do{As=!1;let e=Vr;try{let t=await fetch("/state?all=1");if(!t.ok)continue;let i=await t.text(),n=i.replace(/"now":\d+\}$/,"");if(n===Fa)continue;let{cards:s,projects:r,rail:o,agents:l}=JSON.parse(i);if(!As&&e===Vr)Fa=n,Am(s,[...r,...o??[]],l)}catch{}}while(As);Ur=!1}var Xm={S:{project:null,projects:[],cards:[],now:Date.now(),all:!1,dir:null},all:new URLSearchParams(location.search).get("all")!=="0",dir:null,openKey:null,mode:null,modeKey:null,menuKey:null,flash:new Set,tab:"request",lastTab:"request",runDoc:null,clearMenu:!1,sevMenu:!1,wantTerm:null,wantPty:null,shells:[],setQ:"",setScope:"all",setPage:null,setBack:!1,pageGen:0,PL:[],shown:new Set((()=>{try{return JSON.parse(localStorage.getItem("kz-show"))||[]}catch(e){return[]}})())};var G=(e)=>document.getElementById(e),Zm=(e)=>String(e).replace(/[&<>"]/g,(t)=>({"&":"&","<":"<",">":">",'"':"""})[t]);class Gr{s;constructor(e){this.s=e}toString(){return this.s}}var bt=(e)=>new Gr(String(e)),eh=(e)=>e instanceof Gr?e.s:Array.isArray(e)?e.map(eh).join(""):e==null||e===!1?"":Zm(e),R=(e,...t)=>bt(e.reduce((i,n,s)=>i+eh(t[s-1])+n));var vw=bt('<div aria-busy="true" aria-label="Loading"><span class="skel" style="height:16px;width:35%;margin:20px 0 14px"></span>'+'<span class="skel" style="height:44px;margin-bottom:10px"></span>'.repeat(4)+"</div>");function Xs(e){let t=document.createElement("dialog");return t.className="kz",t.innerHTML=`<form class="inl" method="dialog">${e}</form>`,t.onclose=()=>t.remove(),t.onclick=(i)=>{if(i.target===t)t.close()},document.body.appendChild(t),t.showModal(),t}var mi=(e,t)=>{let i=t-e;return i<3600000?Math.round(i/60000)+"m":i<86400000?Math.round(i/3600000)+"h":Math.round(i/86400000)+"d"};var Kr=(e)=>typeof e==="string"?[e]:e.kids.flatMap(Kr);var Jr=(e,t)=>`ws:${e}:${t}`,sh=(e)=>e.kind==="run"&&e.status==="done"&&e.accept!=="needs"&&!e.archived&&e.git==="pending";var rh=3000,Ms=new Map,vn=(e)=>e.key+"@"+(e.born??0),th={asking:0,working:1,done:2},Zs={asking:"Asking",working:"Working",done:"Done"},Mm={asking:"wait",working:"build",done:"done"};function Rm(e,t,i=Ms){if(e.asking)return"asking";if(e.busy)return i.set(vn(e),t),"working";return t-(i.get(vn(e))??-1/0)<rh?"working":"done"}var oh=(e,t,i=Ms)=>Math.min(1/0,...e.filter((n)=>!n.asking&&!n.busy&&i.has(vn(n))).map((n)=>rh-(t-i.get(vn(n)))).filter((n)=>n>0)),lh=(e,t=Ms)=>{let i=new Set(e.map(vn));for(let n of t.keys())if(!i.has(n))t.delete(n)},ah=(e,t,i,n,s,r=Ms)=>e.filter((o)=>o.dir===t&&n({state:o.dir,ws:o.ws})===i).map((o)=>({a:o,st:Rm(o,s,r)})).sort((o,l)=>th[o.st]-th[l.st]),ih=({a:e,st:t})=>e.last||`${Zs[t]} - ${e.name}`,nh=(e,t)=>!e?"":t-e<60000?"now":mi(e,t),jm=(e,t)=>e+"\x00"+t;function hh(e,t,i){let n=jm(t,i);if(e[n])delete e[n];else e[n]=!0;return e}var Lm=["claude","codex","gemini"],Hr=(e)=>R`<svg aria-hidden="true"><use href="#i-${Lm.includes(e.agent??"")?e.agent:"ai"}"/></svg>`,Fr=(e)=>R`<i class="si ${Mm[e]}"></i>`,Em=R`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;function ch(e,t,i,n,s){if(!e.length)return"";let r=R`data-dir="${n}" data-ws="${s}"`;if(e.length===1){let a=e[0];return R`<div class="wag"><button type="button" class="aone" data-term="${a.a.key}" ${r} title="${a.a.name}: open its terminal">${Fr(a.st)}${Hr(a.a)}<span class="atx">${Zs[a.st]} - ${a.a.name}</span><small>${nh(a.a.at,t)}</small></button></div>`}let o=R`<button type="button" class="wchev${i?" on":""}" data-wopen ${r} aria-expanded="${String(i)}" aria-label="${String(e.length)} agents: ${i?"hide":"show"} the list">${Em}</button>`;if(i)return R`<div class="wag"><span class="aht">${String(e.length)} agents</span>${o}</div><div class="alist">${e.map((a)=>R`<button type="button" class="arow" data-term="${a.a.key}" ${r} title="${ih(a)}">${Fr(a.st)}${Hr(a.a)}<span class="atx">${ih(a)}</span><small>${nh(a.a.at,t)}</small></button>`)}</div>`;let l=["asking","working","done"].map((a)=>({st:a,rs:e.filter((h)=>h.st===a)})).filter((a)=>a.rs.length);return R`<div class="wag"><span class="chips">${l.map((a)=>R`<span class="chip">${Fr(a.st)}${a.rs.map((h)=>R`<button type="button" class="amark" data-term="${h.a.key}" ${r} title="${h.a.name} - ${Zs[a.st]}: open its terminal" aria-label="${h.a.name} - ${Zs[a.st]}: open its terminal">${Hr(h.a)}</button>`)}</span>`)}</span>${o}</div>`}function eo(e){return e.toLowerCase().trim().replace(/[^a-z0-9/._-]+/g,"-").replace(/\.{2,}/g,".").replace(/\/{2,}/g,"/").replace(/(^|\/)[-.]+/g,"$1").slice(0,60).replace(/[-./]+(\/|$)/g,"$1").replace(/\/$/,"").replace(/\.lock(\/|$)/g,"-lock$1")}var _m=(e)=>e.includes("\\")?"\\":"/";async function Ut(e,t){try{let i=await fetch(e,t?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}:void 0),n=await i.json().catch(()=>({}));return{ok:i.ok,d:i.ok?n:{error:n.error||n.why||"that did not work"}}}catch{return{ok:!1,d:{error:"the board is offline"}}}}function Pn(e={}){let t=Xs(""),i=t.querySelector("form");t.setAttribute("aria-label","Add a project");let n=e.start==="ws",s=(u)=>i.elements.namedItem(u),r=(u,d,p,O)=>(u.disabled=d,u.textContent=d?p:O),o=n?"":R`<button type="button" class="btn ghost" data-a="back">Back to add options</button>`,l=(u)=>R`<small class="att err" role="alert"></small><div class="row">${o}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">${u}</button></div>`,a=(u)=>i.querySelector(".err").textContent=u,h=(u,d)=>{a(d);try{localStorage.setItem("kz-proj",u)}catch{}setTimeout(()=>location.href="/?view=board",900)},c=async(u,d)=>{let p=await Ut("/pick-folder",{});if(p.d.path)u.value=d?p.d.path.replace(/[\\/]+$/,"")+_m(p.d.path)+d():p.d.path},f=(u)=>{let d=fh();if(t.classList.toggle("wsnew",u==="ws"),u==="menu")i.innerHTML=R`<b>Add a project</b><small class="att">Add a project to get started with kaizen.</small><button type="button" class="btn opt" data-go="folder"><b>Existing folder</b><small>A project, a Git repo, or any folder</small></button><small class="att">Other ways to add</small><button type="button" class="btn opt" data-go="clone"><b>Clone from URL</b><small>Clone a remote Git repository</small></button><button type="button" class="btn opt" data-go="create"><b>Create new project</b><small>Start from an empty folder</small></button>${d.length?R`<button type="button" class="btn opt" data-go="ws"><b>New workspace</b><small>A branch in its own folder, in a project you have</small></button>`:""}<div class="row"><button type="button" class="btn ghost" data-a="x">Cancel</button></div>`.toString(),i.querySelectorAll("[data-go]").forEach((O)=>O.onclick=()=>f(O.dataset.go)),i.onsubmit=(O)=>O.preventDefault();else if(u==="folder")i.innerHTML=R`<b>Existing folder</b><small class="att">Pick a folder, or type its path. A .kaizen folder is added to it.</small><div class="row"><input name="path" placeholder="/path/to/folder" aria-label="Folder" autocomplete="off" spellcheck="false" required><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${l("Add project")}`.toString(),s("path").focus(),i.onsubmit=async(O)=>{O.preventDefault();let g=i.querySelector("[data-a=go]");r(g,!0,"Adding...","Add project");let b=await Ut("/add-project",{path:s("path").value.trim()});r(g,!1,"","Add project"),b.ok?h(b.d.dir,b.d.already?"Project already added":"Project added"):a(b.d.error)},i.querySelector("[data-a=pick]").onclick=()=>c(s("path"));else if(u==="clone"){i.innerHTML=R`<b>Clone from URL</b><small class="att">Enter the Git URL (https or ssh) and choose where to clone it.</small><input name="url" placeholder="https://github.com/user/repo.git" aria-label="Git URL" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to clone into" aria-label="Clone into" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${l("Clone")}`.toString(),s("url").focus();let O="",g="",b=async()=>{let y=s("url").value.trim();if(!y)return!1;let S=await Ut("/clone",{url:y,check:!0});if(!S.ok)return a(S.d.error),!1;if(a(""),O=S.d.name,!s("to").value.trim()||s("to").value===g)s("to").value=g=S.d.to;return!0};s("url").onchange=b,i.querySelector("[data-a=pick]").onclick=async()=>await b()?c(s("to"),()=>O):s("url").focus(),i.onsubmit=async(y)=>{if(y.preventDefault(),!await b())return;let S=i.querySelector("[data-a=go]");r(S,!0,"Cloning...","Clone");let x=await Ut("/clone",{url:s("url").value.trim(),to:s("to").value.trim()||void 0});r(S,!1,"","Clone"),x.ok?h(x.d.dir,"Cloned"):a(x.d.error)}}else if(u==="create"){i.innerHTML=R`<b>Create a new project</b><small class="att">Name it and kaizen will create the folder with a .kaizen inside.</small><input name="name" placeholder="my-project" aria-label="Name" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to create" aria-label="Create in" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div><label class="att"><input type="checkbox" name="git" checked> Git repository</label>${l("Create project")}`.toString(),s("name").focus();let O="";s("name").oninput=async()=>{let g=s("name").value.trim();if(!g||/[\\/:*?"<>|]/.test(g)||s("to").value.trim()&&s("to").value!==O)return;let b=await Ut("/new-project",{name:g,check:!0});if(b.ok&&s("name").value.trim()===g)s("to").value=O=b.d.to},i.querySelector("[data-a=pick]").onclick=()=>c(s("to"),()=>s("name").value.trim()),i.onsubmit=async(g)=>{g.preventDefault();let b=i.querySelector("[data-a=go]");r(b,!0,"Creating...","Create project");let y=await Ut("/new-project",{name:s("name").value.trim(),to:s("to").value.trim()||void 0,git:s("git").checked});if(r(b,!1,"","Create project"),!y.ok)return a(y.d.error);h(y.d.dir,y.d.git===!1?"Project created, but git init failed":"Project created")}}else{let O=d.some((S)=>S.dir===e.dir)?e.dir:d[0]?.dir,g=/Mac/.test(navigator.platform)?"⌘":"Ctrl";i.innerHTML=R`<b>New workspace</b><label class="att">Project<select name="project" aria-label="Project">${d.map((S)=>R`<option value="${S.dir}"${S.dir===O?" selected":""}>${S.name}</option>`)}</select></label><div class="wsfrom"><span class="att" id="wsfl">Create from <i>[Optional]</i></span><label class="wsbase">from <select name="base" aria-label="Start from branch"></select></label></div><input name="name" placeholder="What is this workspace for?" aria-labelledby="wsfl" autocomplete="off" spellcheck="false"><details class="wsadv"><summary>Advanced</summary><label class="att">Branch name<input name="branch" placeholder="feature/my-branch" aria-label="Branch name" autocomplete="off" spellcheck="false"></label></details><small class="att err" role="alert"></small><div class="row">${o}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">Create workspace</button><kbd class="wskey" aria-hidden="true">${g} ↵</kbd></div>`.toString(),s("name").focus();let b=i.elements.namedItem("base");s("name").oninput=()=>s("branch").placeholder=eo(s("name").value)||"feature/my-branch";let y=async()=>{let S=await Ut("/branches?dir="+encodeURIComponent(s("project").value)),{def:x="",branches:v=[]}=S.ok?S.d:{};b.innerHTML=v.map((X)=>R`<option${X===x?" selected":""}>${X}</option>`.toString()).join("")||'<option value="">current branch</option>'};i.elements.namedItem("project").onchange=y,y(),i.onkeydown=(S)=>{if(S.key==="Enter"&&(S.ctrlKey||S.metaKey))S.preventDefault(),i.requestSubmit()},i.onsubmit=async(S)=>{S.preventDefault();let x=s("project").value,v=i.querySelector("[data-a=go]");if(v.disabled)return;a("");let X=s("branch").value.trim()||eo(s("name").value)||"workspace-"+Math.random().toString(36).slice(2,6);r(v,!0,"Creating...","Create workspace");let T=await Ut("/worktree",{dir:x,branch:X,base:b.value||void 0});r(v,!1,"","Create workspace"),T.ok?(t.close(),location.href=Vt(x,T.d.path)):a(T.d.error)}}i.querySelector("[data-a=x]").onclick=()=>t.close();let p=i.querySelector("[data-a=back]");if(p)p.onclick=()=>f("menu")};f(e.start??"menu")}function uh(e,t){let i=t.toLowerCase().split(/\s+/).filter(Boolean);if(!i.length)return e;let n=t.trim().toLowerCase(),s=(r)=>{let o=r.title.toLowerCase();return o.startsWith(n)?0:o.includes(n)?1:2};return e.filter((r)=>{let o=(r.title+" "+(r.sub??"")+" "+r.hay).toLowerCase();return i.every((l)=>o.includes(l))}).sort((r,o)=>s(r)-s(o)||(o.at??0)-(r.at??0))}var js=(e,t)=>!dispatchEvent(new CustomEvent(e,{cancelable:!0,detail:t})),gi=(e,t)=>()=>{let i=document.querySelector(`.rail a.it[data-view="${e}"]`);i?i.click():location.href=t},dh=(e,t)=>{if(!js("kz-open-ws",{dir:e,ws:t}))location.href=Vt(e,t)},mh=()=>{try{return JSON.parse(localStorage.getItem("kz-runtabs")||"{}")}catch{return{}}},zm=(e,t,i)=>{if(js("kz-open-tab",{dir:e,ws:t,id:i}))return;let n=mh(),s=n[Jr(e,t)],r=s?.screens?.find((o)=>Kr(o.tree).includes(i));if(r)try{s.on=r.id,localStorage.setItem("kz-runtabs",JSON.stringify(n))}catch{}location.href=Vt(e,t)},Ym=["local","preview","note","history","shell"],qm=(e)=>{try{return localStorage.getItem("kz-browse:"+e)?.replace(/^https?:\/\//,"").replace(/\/$/,"")}catch{}},Dm={ws:'<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/>',run:'<path d="M5 4l14 8-14 8z"/>',idea:'<path d="M9 18h6M10 21h4M12 3a6 6 0 0 0-4 10.5c.7.7 1 1.5 1 2.5h6c0-1 .3-1.8 1-2.5A6 6 0 0 0 12 3z"/>',chat:'<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/>',term:'<path d="M4 17l6-5-6-5M12 19h8"/>',proj:'<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',page:'<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 9h16"/>',act:'<path d="M13 3L5 14h6l-1 7 8-11h-6z"/>',tab:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 9h8V5"/>',plus:'<path d="M12 5v14M5 12h14"/>',search:'<circle cx="11" cy="11" r="7"/><path d="M20 20l-4-4"/>'},gh=(e)=>bt(`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${Dm[e]}</g></svg>`),bh=[];function Wm(){let{cards:e,projects:t=[],agents:i=[]}=kh(),n=Date.now(),s=new URLSearchParams(location.search),r=s.get("id")&&e.find((u)=>u.kind==="run"&&u.state===s.get("dir")&&u.id===s.get("id")),o=s.get("ws")??(r?Yi(r,t):null),l=[],a=mh(),h=new Map;for(let u of e){let d=u.state+"\x00"+Yi(u,t);h.set(d,Math.max(h.get(d)??0,u.moved??0))}for(let u of t){let d=Ve(u.dir,t);for(let p of u.workspaces??[]){let O=s.get("dir")===u.dir&&o===p.path,g=h.get(u.dir+"\x00"+p.path);l.push({group:O?"Current":"Workspaces",title:bi(p),sub:d,when:g?mi(g,n):void 0,hay:`${bi(p)} ${d} ${p.path} workspace`,at:O?1/0:g??0,ico:"ws",act:()=>dh(u.dir,p.path)});let b=Jr(u.dir,p.path),y=a[b];for(let S of y?.tabs??[]){if(!Ym.includes(S.kind)||y.hidden?.includes(S.id))continue;let x=S.kind==="local"&&qm(b)||S.title;l.push({group:"Tabs",title:x,sub:`${bi(p)} · ${d}`,hay:`${x} ${S.title} ${S.kind} ${S.note??""} ${bi(p)} ${d} tab`,ico:"tab",act:()=>zm(u.dir,p.path,S.id)})}}l.push({group:"Projects",title:d,hay:`${d} ${u.dir} project`,ico:"proj",act:()=>{let p=u.workspaces?.find((O)=>O.main)??u.workspaces?.[0];p?dh(u.dir,p.path):gi("board","/?view=board")()}})}for(let u of e.filter((d)=>!d.archived)){let d=yi(u);l.push({group:u.kind==="run"?"Runs":"Ideas",title:io(u)||u.id,sub:Ve(u.state,t),when:u.moved?mi(u.moved,n):void 0,hay:`${io(u)} ${u.id??""} ${u.text??""} ${Ve(u.state,t)} ${d}`,at:u.moved??0,dot:d,ico:u.kind==="run"?"run":"idea",act:()=>{if(!js("kz-open-card",{dir:u.state,id:u.kind==="run"?u.id:void 0,text:u.text}))location.href=Sh(u)}})}for(let u of bh){let d=Date.parse(u.updated)||0;l.push({group:"Chats & terminals",title:u.title||"Chat",sub:u.project?Ve(u.project,t):void 0,when:d?mi(d,n):void 0,hay:`${u.title} chat ${u.project??""}`,at:d,dot:u.busy?"build":void 0,ico:"chat",act:()=>{try{sessionStorage.setItem("kz-chat",u.id)}catch{}gi("home","/")()}})}for(let u of i)l.push({group:"Chats & terminals",title:u.name||u.agent||"Terminal",sub:Ve(u.dir,t),hay:`${u.name} ${u.agent??""} ${u.run??""} ${u.last??""} ${Ve(u.dir,t)} terminal agent`,at:u.at??u.born??0,dot:u.asking?"wait":u.busy?"build":"done",ico:"term",act:()=>{if(!js("kz-open-term",{dir:u.dir,ws:u.ws,key:u.key}))location.href=Vt(u.dir,u.ws??"")}});let c=(u)=>()=>G(u)?.click(),f=[["Home","page",gi("home","/"),"chat"],["Icebox","page",gi("sources","/?view=icebox"),"requests sources gathered"],["Ideas","page",gi("ideas","/?view=ideas"),"backlog"],["Board","page",gi("board","/?view=board"),"kanban runs"],["Notes","page",()=>location.href="/notebook","notebook docs"],["Settings","page",gi("settings","/?view=settings"),"preferences config"],["New idea","act",()=>G("newtop")?G("newtop").click():location.href="/?view=board","create add run"],["Add a project","act",()=>Pn({dir:null}),"clone folder create workspace"],["Toggle theme","act",c("themet"),"dark light"],["Collapse or expand menu","act",c("fold"),"sidebar rail"],["Keyboard shortcuts","act",c("kbd"),"keys help"],["Report an issue","act",()=>open("/issue","_blank","noopener"),"bug feedback"]];for(let[u,d,p,O]of f)l.push({group:"Actions",title:u,hay:`${u} ${O??""}`,ico:d,act:p});return l}var Bm=["Current","Workspaces","Tabs","Chats & terminals","Runs","Ideas","Projects","Actions"],Im={Workspaces:5,Tabs:4,"Chats & terminals":5,Runs:5,Ideas:3,Projects:5},H=null,nt=[],st=0;function Rs(){let e=H.querySelector("input").value,t=Wm(),i=e.trim()?uh(t,e):t.slice().sort((o,l)=>(l.at??0)-(o.at??0));nt=[];let n=e.trim()?[...new Set(i.map((o)=>o.group))]:Bm;for(let o of n){let l=i.filter((a)=>a.group===o);nt.push(...l.slice(0,e.trim()?8:Im[o]??l.length))}if(e.trim())nt.push({group:"Create",title:`New idea "${e.trim()}"`,hay:"",ico:"plus",act:()=>Um(e.trim())});st=Math.min(st,nt.length-1);let s=H.querySelector(".gs-list"),r="";s.innerHTML=String(R`${nt.map((o,l)=>{let a=o.group!==r?(r=o.group,R`<div class="gs-h" role="presentation">${o.group}</div>`):"";return R`${a}<div class="gs-i" role="option" id="gs-${l}" data-n="${l}" aria-selected="${String(l===st)}">${gh(o.ico)}${o.dot?R`<span class="si ${o.dot}"></span>`:""}<span class="gs-t">${o.title}</span>${o.sub?R`<span class="gs-s">${o.sub}</span>`:""}${o.when?R`<span class="gs-w">${o.when}</span>`:""}</div>`})}${nt.length===1&&e.trim()?R`<div class="gs-none">No results</div>`:""}`),to(st),H.querySelector(".gs-live").textContent=`${nt.length} result${nt.length===1?"":"s"} found`}function to(e){H.querySelector(`#gs-${st}`)?.setAttribute("aria-selected","false"),st=e;let t=H.querySelector(`#gs-${e}`);t?.setAttribute("aria-selected","true"),H.querySelector("input").setAttribute("aria-activedescendant","gs-"+e),t?.scrollIntoView({block:"nearest"})}function Um(e){if(!G("newtop"))return void(location.href="/?view=board");G("newtop").click();let t=document.querySelector("dialog[open] textarea");if(t)t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0}))}function ph(e){let t=nt[e];if(!t)return;H.close(),t.act()}function Oh(){if(H)return H.querySelector("input").focus();H=document.createElement("dialog"),H.className="gs",H.setAttribute("aria-label","Search"),H.innerHTML=String(R`<div class="gs-box"><div class="gs-q">${gh("search")}<input type="text" placeholder="Search" aria-label="Search" role="combobox" aria-expanded="true" aria-controls="gs-list" autocomplete="off" spellcheck="false"></div><div class="gs-list" id="gs-list" role="listbox"></div><span class="gs-live" role="status" aria-live="polite"></span></div>`),document.body.append(H);let e=H.querySelector("input");st=0,e.oninput=()=>(st=0,Rs()),e.onkeydown=(i)=>{let n={ArrowDown:1,ArrowUp:-1}[i.key]??(i.ctrlKey&&i.key==="n"?1:i.ctrlKey&&i.key==="p"?-1:0);if(n)i.preventDefault(),to((st+n+nt.length)%nt.length);else if(i.key==="Enter")i.preventDefault(),ph(st)};let t=H.querySelector(".gs-list");t.onclick=(i)=>{let n=i.target.closest(".gs-i");if(n)ph(+n.dataset.n)},t.onpointermove=(i)=>{let n=i.target.closest(".gs-i");if(n&&+n.dataset.n!==st)to(+n.dataset.n)},H.onclick=(i)=>i.target===H&&H.close(),H.onclose=()=>(H.remove(),H=null),H.showModal(),Rs(),fetch("/chats").then((i)=>i.json()).then((i)=>{if(bh=i.chats??[],H)Rs()}).catch(()=>{})}var Vm=`dialog.gs{border:0;padding:0;margin:14vh auto auto;background:none;width:min(560px,calc(100vw - 32px));color:var(--ink);overflow:visible}
|
|
3
3
|
dialog.gs::backdrop{background:rgb(0 0 0/.35)}
|
|
4
4
|
.gs-box{display:flex;flex-direction:column;max-height:min(480px,72vh);background:var(--bg);border:1px solid var(--line);border-radius:10px;box-shadow:0 16px 40px rgb(0 0 0/.25);overflow:hidden}
|
package/web/notes.html
CHANGED
|
@@ -368,6 +368,8 @@ select.sel{cursor:pointer;appearance:none;padding-right:30px;max-width:min(320px
|
|
|
368
368
|
// Motion: full, reduce, or unset to follow the system's reduced-motion, in kz-motion.
|
|
369
369
|
window.setMotion=m=>{if(m==="system")delete r.dataset.motion;else r.dataset.motion=m;try{m==="system"?localStorage.removeItem("kz-motion"):localStorage.setItem("kz-motion",m)}catch(e){}};
|
|
370
370
|
try{const m=localStorage.getItem("kz-motion");if(m)r.dataset.motion=m}catch(e){}
|
|
371
|
+
// Settings changed in another window or tab apply here at once, not on the next reload.
|
|
372
|
+
addEventListener("storage",e=>{const m={"kz-theme":"theme","kz-color":"color","kz-motion":"motion"}[e.key];if(!m)return;if(e.newValue)r.dataset[m]=e.newValue;else delete r.dataset[m];dispatchEvent(new Event("kz-theme"))});
|
|
371
373
|
os.addEventListener("change",paint);paint();
|
|
372
374
|
document.getElementById("themet").onclick=e=>setTheme(e.currentTarget.dataset.dark==="true"?"light":"dark");
|
|
373
375
|
// Setup: while first-run onboarding is skipped or unfinished, a row that continues it; the board redraws it as it saves.
|
package/web/term.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen terminal
|
|
1
|
+
/* kaizen terminal bf8430f9ab3270fb -- generated by bun run build:web from web/term.ts; do not edit */
|
|
2
2
|
(()=>{var{defineProperty:Oo,getOwnPropertyDescriptor:Jh}=Object,Qh=(e,t)=>{for(var i in t)Oo(e,i,{get:t[i],enumerable:!0})},he=(e,t,i,s)=>{for(var r=s>1?void 0:s?Jh(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Oo(t,i,r),r},P=(e,t)=>(i,s)=>t(i,s,e),Tn="Terminal input",or={get:()=>Tn,set:(e)=>Tn=e},Bn="Too much output to announce, navigate to rows manually to read",ar={get:()=>Bn,set:(e)=>Bn=e};function el(e){return e.replace(/\r?\n/g,"\r")}function tl(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function il(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function sl(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Io(r,t,i,s)}}function Io(e,t,i,s){e=el(e),e=tl(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function No(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function An(e,t,i,s,r){No(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function At(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _s(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var rl=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},nl=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,l=0,h=0;if(this.interim[0]){let u=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let p=0,b;for(;(b=this.interim[++p]&63)&&p<4;)g<<=6,g|=b;let E=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,B=E-p;for(;h<B;){if(h>=i)return 0;if(b=e[h++],(b&192)!==128){h--,u=!0;break}else this.interim[p++]=b,g<<=6,g|=b&63}u||(E===2?g<128?h--:t[s++]=g:E===3?g<2048||g>=55296&&g<=57343||g===65279||(t[s++]=g):g<65536||g>1114111||(t[s++]=g)),this.interim.fill(0)}let d=i-4,c=h;for(;c<i;){for(;c<d&&!((r=e[c])&128)&&!((n=e[c+1])&128)&&!((o=e[c+2])&128)&&!((a=e[c+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,c+=4;if(r=e[c++],r<128)t[s++]=r;else if((r&224)===192){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(l=(r&31)<<6|n&63,l<128){c--;continue}t[s++]=l}else if((r&240)===224){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(l=(r&15)<<12|(n&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;t[s++]=l}else if((r&248)===240){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[c++],(a&192)!==128){c--;continue}if(l=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;t[s++]=l}}return s}},Fo="",Pt=" ",Di=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rs}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rs=class e{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xe=class e extends Di{constructor(){super(...arguments);this.content=0,this.fg=0,this.bg=0,this.extended=new rs,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?At(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Pn="di$target",hr="di$dependencies",Ks=new Map;function ol(e){return e[hr]||[]}function ye(e){if(Ks.has(e))return Ks.get(e);let t=function(i,s,r){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");al(t,i,r)};return t._id=e,Ks.set(e,t),t}function al(e,t,i){t[Pn]===t?t[hr].push({id:e,index:i}):(t[hr]=[{id:e,index:i}],t[Pn]=t)}var Oe=ye("BufferService"),Wo=ye("CoreMouseService"),jt=ye("CoreService"),hl=ye("CharsetService"),Ir=ye("InstantiationService"),zo=ye("LogService"),Ie=ye("OptionsService"),Ho=ye("OscLinkService"),ll=ye("UnicodeService"),Ti=ye("DecorationService"),lr=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Xe,o=i.getTrimmedLength(),a=-1,l=-1,h=!1;for(let d=0;d<o;d++)if(!(l===-1&&!i.hasContent(d))){if(i.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(l===-1){l=d,a=n.extended.urlId;continue}else h=n.extended.urlId!==a;else l!==-1&&(h=!0);if(h||l!==-1&&d===o-1){let c=this._oscLinkService.getLinkData(a)?.uri;if(c){let u={start:{x:l+1,y:e},end:{x:d+(!h&&d===o-1?1:0),y:e}},g=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(c);["http:","https:"].includes(p.protocol)||(g=!0)}catch{g=!0}g||s.push({text:c,range:u,activate:(p,b)=>r?r.activate(p,b,u):cl(p,b),hover:(p,b)=>r?.hover?.(p,b,u),leave:(p,b)=>r?.leave?.(p,b,u)})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(l=d,a=n.extended.urlId):(l=-1,a=-1)}}t(s)}};lr=he([P(0,Oe),P(1,Ie),P(2,Ho)],lr);function cl(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
3
3
|
|
|
4
4
|
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var fs=ye("CharSizeService"),vt=ye("CoreBrowserService"),Nr=ye("MouseService"),mt=ye("RenderService"),dl=ye("SelectionService"),$o=ye("CharacterJoinerService"),ei=ye("ThemeService"),Uo=ye("LinkProviderService"),ul=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?On.isErrorNoTelemetry(e)?new On(e.message+`
|
|
@@ -143,8 +143,8 @@ ${d.join(`
|
|
|
143
143
|
`))}},wg=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},bg=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Cg=0,Os=class{constructor(e){this.value=e,this.id=Cg++}},yg=2,xg=(e,t)=>{if(e instanceof Os)t(e);else for(let i=0;i<e.length;i++){let s=e[i];s&&t(s)}},Is;if(pg){let e=[];setInterval(()=>{e.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(e.join(`
|
|
144
144
|
`)),e.length=0)},3000),Is=new FinalizationRegistry((t)=>{typeof t=="string"&&e.push(t)})}var ct=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Fh>0||this._options?.leakWarningThreshold?new Sg(e?.onListenerError??Sn,this._options?.leakWarningThreshold??Fh):void 0,this._perfMon=this._options?._profName?new mg(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Nh){let e=this._listeners;queueMicrotask(()=>{xg(e,(t)=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new bg(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Sn)(h),dt.None}if(this._disposed)return dt.None;t&&(e=e.bind(t));let s=new Os(e),r,n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*0.2)&&(s.stack=xn.create(),r=this._leakageMon.check(s.stack,this._size+1)),Nh&&(s.stack=n??xn.create()),this._listeners?this._listeners instanceof Os?(this._deliveryQueue??=new kg,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=ci(()=>{Is?.unregister(o),r?.(),this._removeListener(s)});if(i instanceof En?i.add(o):Array.isArray(i)&&i.push(o),Is){let a=Error().stack.split(`
|
|
145
145
|
`).slice(2,3).join(`
|
|
146
|
-
`).trim(),l=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);Is.register(o,l?.[2]??a,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*yg<=t.length){let r=0;for(let n=0;n<t.length;n++)t[n]?t[r++]=t[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let i=this._options?.onListenerError||Sn;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Os)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},kg=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vh=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Lg;((e)=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Eg?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vh})})(Lg||={});var Eg=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vh:(this._emitter||(this._emitter=new ct),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},hi="en",kn=!1,Ln=!1,Ns=!1,Mg=!1,Rg=!1,Gh=!1,Dg=!1,Tg=!1,Bg=!1,Ag=!1,Ps,Fs=hi,Wh=hi,Pg,Et,Mt=globalThis,Ge;typeof Mt.vscode<"u"&&typeof Mt.vscode.process<"u"?Ge=Mt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ge=process);var jh=typeof Ge?.versions?.electron=="string",Og=jh&&Ge?.type==="renderer";if(typeof Ge=="object"){kn=Ge.platform==="win32",Ln=Ge.platform==="darwin",Ns=Ge.platform==="linux",Mg=Ns&&!!Ge.env.SNAP&&!!Ge.env.SNAP_REVISION,Dg=jh,Bg=!!Ge.env.CI||!!Ge.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ps=hi,Fs=hi;let e=Ge.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ps=t.userLocale,Wh=t.osLocale,Fs=t.resolvedLanguage||hi,Pg=t.languagePack?.translationsConfigFile}catch{}Rg=!0}else typeof navigator=="object"&&!Og?(Et=navigator.userAgent,kn=Et.indexOf("Windows")>=0,Ln=Et.indexOf("Macintosh")>=0,Tg=(Et.indexOf("Macintosh")>=0||Et.indexOf("iPad")>=0||Et.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ns=Et.indexOf("Linux")>=0,Ag=Et?.indexOf("Mobi")>=0,Gh=!0,Fs=globalThis._VSCODE_NLS_LANGUAGE||hi,Ps=navigator.language.toLowerCase(),Wh=Ps):console.error("Unable to resolve platform.");var wn=0;Ln?wn=1:kn?wn=3:Ns&&(wn=2);var Ig=Gh&&typeof Mt.importScripts=="function",V0=Ig?Mt.origin:void 0,ut=Et,zt=Fs,Ng;((e)=>{function t(){return zt}e.value=t;function i(){return zt.length===2?zt==="en":zt.length>=3?zt[0]==="e"&&zt[1]==="n"&&zt[2]==="-":!1}e.isDefaultVariant=i;function s(){return zt==="en"}e.isDefault=s})(Ng||={});var Fg=typeof Mt.postMessage=="function"&&!Mt.importScripts,Wg=(()=>{if(Fg){let e=[];Mt.addEventListener("message",(i)=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return(i)=>{let s=++t;e.push({id:s,callback:i}),Mt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return(e)=>setTimeout(e)})(),zg=!!(ut&&ut.indexOf("Chrome")>=0),G0=!!(ut&&ut.indexOf("Firefox")>=0),j0=!!(!zg&&ut&&ut.indexOf("Safari")>=0),Y0=!!(ut&&ut.indexOf("Edg/")>=0),X0=!!(ut&&ut.indexOf("Android")>=0),Z0=Symbol("MicrotaskDelay");function Yh(e,t=0,i){let s=setTimeout(()=>{e(),i&&r.dispose()},t),r=ci(()=>{clearTimeout(s),i?.deleteAndLeak(r)});return i?.add(r),r}var Hg,bn;(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?bn=(e,t)=>{Wg(()=>{if(i)return;let s=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,s-Date.now())}}))});let i=!1;return{dispose(){i||(i=!0)}}}:bn=(e,t,i)=>{let s=e.requestIdleCallback(t,typeof i=="number"?{timeout:i}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(s))}}},Hg=(e)=>bn(globalThis,e)})();var $g;((e)=>{async function t(s){let r,n=await Promise.all(s.map((o)=>o.then((a)=>a,(a)=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})($g||={});var zh=class e{static fromArray(t){return new e((i)=>{i.emitMany(t)})}static fromPromise(t){return new e(async(i)=>{i.emitMany(await t)})}static fromPromises(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>i.emitOne(await s)))})}static merge(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ct,queueMicrotask(async()=>{let s={emitOne:(r)=>this.emitOne(r),emitMany:(r)=>this.emitMany(r),reject:(r)=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new e(async(s)=>{for await(let r of t)s.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async(s)=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,(i)=>!!i)}coalesce(){return e.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return e.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};zh.EMPTY=zh.fromArray([]);var Ug=class extends dt{constructor(e){super();this._terminal=e,this._linesCacheTimeout=this._register(new Ws),this._linesCacheDisposables=this._register(new Ws),this._register(ci(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Uh(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Yh(()=>this._destroyLinesCache(),15000)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let i=[],s=[0],r=this._terminal.buffer.active.getLine(e);for(;r;){let n=this._terminal.buffer.active.getLine(e+1),o=n?n.isWrapped:!1,a=r.translateToString(!o&&t);if(o&&n){let l=r.getCell(r.length-1);l&&l.getCode()===0&&l.getWidth()===1&&n.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(i.push(a),o)s.push(s[s.length-1]+a.length);else break;e++,r=n}return[i.join(""),s]}},Kg=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},qg=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,s){if(!e||e.length===0){this._terminal.clearSelection();return}if(i>this._terminal.cols)throw Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:i},n=this._findInLine(e,r,s);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=o,r.startCol=0,n=this._findInLine(e,r,s),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,n=0;s&&(i===e?(r=s.end.x,n=s.end.y):(r=s.start.x,n=s.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:r},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&n!==0)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&s&&(o.startRow=s.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:n},l;if(s&&(a.startRow=r=s.start.y,a.startCol=n=s.start.x,i!==e&&(l=this._findInLine(e,a,t,!1),l||(a.startRow=r=s.end.y,a.startCol=n=s.end.x))),l||(l=this._findInLine(e,a,t,o)),!l){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let h=r-1;h>=0&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);}if(!l&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=r&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);return l}_isWholeWord(e,t,i){return(e===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},s=!1){let{startRow:r,startCol:n}=t;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(s){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i)}let o=this._lineCache.getLineFromCache(r);o||(o=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,o));let[a,l]=o,h=this._bufferColsToStringOffset(r,n),d=e,c=a;i.regex||(d=i.caseSensitive?e:e.toLowerCase(),c=i.caseSensitive?a:a.toLowerCase());let u=-1;if(i.regex){let g=RegExp(d,i.caseSensitive?"g":"gi"),p;if(s)for(;p=g.exec(c.slice(0,h));)u=g.lastIndex-p[0].length,e=p[0],g.lastIndex-=e.length-1;else p=g.exec(c.slice(h)),p&&p[0].length>0&&(u=h+(g.lastIndex-p[0].length),e=p[0])}else s?h-d.length>=0&&(u=c.lastIndexOf(d,h-d.length)):u=c.indexOf(d,h);if(u>=0){if(i.wholeWord&&!this._isWholeWord(u,c,e))return;let g=0;for(;g<l.length-1&&u>=l[g+1];)g++;let p=g;for(;p<l.length-1&&u+e.length>=l[p+1];)p++;let b=u-l[g],E=u+e.length-l[p],B=this._stringLengthToBufferSize(r+g,b),A=this._stringLengthToBufferSize(r+p,E)-B+this._terminal.cols*(p-g);return{term:e,col:B,row:r+g,size:A}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let s=0;s<t;s++){let r=i.getCell(s);if(!r)break;let n=r.getChars();n.length>1&&(t-=n.length-1);let o=i.getCell(s+1);o&&o.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,s=0,r=this._terminal.buffer.active.getLine(i);for(;t>0&&r;){for(let n=0;n<t&&n<this._terminal.cols;n++){let o=r.getCell(n);if(!o)break;o.getWidth()&&(s+=o.getCode()===0?1:o.getChars().length)}if(i++,r=this._terminal.buffer.active.getLine(i),r&&!r.isWrapped)break;t-=this._terminal.cols}return s}},Vg=class extends dt{constructor(e){super();this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ci(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let s=this._createResultDecorations(i,t,!1);if(s)for(let r of s)this._storeDecoration(r,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){Ui(i)}}}clearHighlightDecorations(){Ui(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let s=[],{col:r,size:n}=e,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let l=Math.min(this._terminal.cols-r,n);s.push([o,r,l]),r=0,n-=l,o++}let a=[];for(let l of s){let h=this._terminal.registerMarker(l[0]),d=this._terminal.registerDecoration({marker:h,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(h.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(d){let c=[];c.push(h),c.push(d.onRender((u)=>this._applyStyles(u,i?t.activeMatchBorder:t.matchBorder,!1))),c.push(d.onDispose(()=>Ui(c))),a.push(d)}}return a.length===0?void 0:a}},Gg=class extends dt{constructor(){super(...arguments);this._searchResults=[],this._onDidChangeResults=this._register(new ct)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Xh=class extends dt{constructor(e){super();this._highlightTimeout=this._register(new Ws),this._lineCache=this._register(new Ws),this._state=new Kg,this._resultTracker=this._register(new Gg),this._highlightLimit=e?.highlightLimit??1000}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Ug(e),this._engine=new qg(e,this._lineCache.value),this._decorationManager=new Vg(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ci(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Yh(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let i=[],s,r=this._engine.find(e,0,0,t);for(;r&&(s?.row!==r.row||s?.col!==r.col)&&!(i.length>=this._highlightLimit);)s=r,i.push(s),r=this._engine.find(e,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,t);this._resultTracker.updateResults(i,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(i,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let s=this._decorationManager.createActiveDecoration(e,t);s&&(this._resultTracker.selectedDecoration=s)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let s=e.row-this._terminal.buffer.active.viewportY;s-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(s)}return!0}};function jg(e,t,i){let s=getComputedStyle(e),r=(x)=>s.getPropertyValue(x).trim()||void 0,n=()=>({background:r("--bg"),foreground:r("--ink-hi"),cursor:r("--accent"),selectionBackground:r("--line")}),o=new wa({cursorBlink:!0,fontFamily:r("--mono"),fontSize:12,scrollback:5000,allowProposedApi:!0,theme:n()}),a=()=>requestAnimationFrame(()=>o.options.theme=n()),l=matchMedia("(prefers-color-scheme: dark)");addEventListener("kz-theme",a),l.addEventListener("change",a);let h=new ba;o.loadAddon(h),o.loadAddon(new Th((x,F)=>window.open(F,"_blank","noopener")));let d=new Xh;o.loadAddon(d),o.open(e);try{let x=new Dh;x.onContextLoss(()=>x.dispose()),o.loadAddon(x)}catch{}let c=[1,2,4,8,15],u,g=0,p,b=!1,E=(x)=>{if(u?.readyState===WebSocket.OPEN)u.send(JSON.stringify(x))},B=(x=!1)=>{if(!e.offsetWidth)return;if(h.fit(),x&&o.rows>5)E({t:"r",c:o.cols,r:o.rows-1}),setTimeout(()=>E({t:"r",c:o.cols,r:o.rows}),80);else E({t:"r",c:o.cols,r:o.rows})},A=()=>{if(clearTimeout(p),u)u.onopen=u.onmessage=u.onclose=null,u.close();u=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/pty?key=${encodeURIComponent(t)}`),u.onopen=()=>{if(b)o.reset();b=!1,g=0,m.hidden=!0,B(!0)},u.onmessage=(x)=>o.write(String(x.data)),u.onclose=(x)=>{if(x.reason==="ended")o.write(`\r
|
|
146
|
+
`).trim(),l=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);Is.register(o,l?.[2]??a,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*yg<=t.length){let r=0;for(let n=0;n<t.length;n++)t[n]?t[r++]=t[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let i=this._options?.onListenerError||Sn;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Os)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},kg=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vh=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Lg;((e)=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Eg?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vh})})(Lg||={});var Eg=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vh:(this._emitter||(this._emitter=new ct),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},hi="en",kn=!1,Ln=!1,Ns=!1,Mg=!1,Rg=!1,Gh=!1,Dg=!1,Tg=!1,Bg=!1,Ag=!1,Ps,Fs=hi,Wh=hi,Pg,Et,Mt=globalThis,Ge;typeof Mt.vscode<"u"&&typeof Mt.vscode.process<"u"?Ge=Mt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ge=process);var jh=typeof Ge?.versions?.electron=="string",Og=jh&&Ge?.type==="renderer";if(typeof Ge=="object"){kn=Ge.platform==="win32",Ln=Ge.platform==="darwin",Ns=Ge.platform==="linux",Mg=Ns&&!!Ge.env.SNAP&&!!Ge.env.SNAP_REVISION,Dg=jh,Bg=!!Ge.env.CI||!!Ge.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ps=hi,Fs=hi;let e=Ge.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ps=t.userLocale,Wh=t.osLocale,Fs=t.resolvedLanguage||hi,Pg=t.languagePack?.translationsConfigFile}catch{}Rg=!0}else typeof navigator=="object"&&!Og?(Et=navigator.userAgent,kn=Et.indexOf("Windows")>=0,Ln=Et.indexOf("Macintosh")>=0,Tg=(Et.indexOf("Macintosh")>=0||Et.indexOf("iPad")>=0||Et.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ns=Et.indexOf("Linux")>=0,Ag=Et?.indexOf("Mobi")>=0,Gh=!0,Fs=globalThis._VSCODE_NLS_LANGUAGE||hi,Ps=navigator.language.toLowerCase(),Wh=Ps):console.error("Unable to resolve platform.");var wn=0;Ln?wn=1:kn?wn=3:Ns&&(wn=2);var Ig=Gh&&typeof Mt.importScripts=="function",V0=Ig?Mt.origin:void 0,ut=Et,zt=Fs,Ng;((e)=>{function t(){return zt}e.value=t;function i(){return zt.length===2?zt==="en":zt.length>=3?zt[0]==="e"&&zt[1]==="n"&&zt[2]==="-":!1}e.isDefaultVariant=i;function s(){return zt==="en"}e.isDefault=s})(Ng||={});var Fg=typeof Mt.postMessage=="function"&&!Mt.importScripts,Wg=(()=>{if(Fg){let e=[];Mt.addEventListener("message",(i)=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return(i)=>{let s=++t;e.push({id:s,callback:i}),Mt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return(e)=>setTimeout(e)})(),zg=!!(ut&&ut.indexOf("Chrome")>=0),G0=!!(ut&&ut.indexOf("Firefox")>=0),j0=!!(!zg&&ut&&ut.indexOf("Safari")>=0),Y0=!!(ut&&ut.indexOf("Edg/")>=0),X0=!!(ut&&ut.indexOf("Android")>=0),Z0=Symbol("MicrotaskDelay");function Yh(e,t=0,i){let s=setTimeout(()=>{e(),i&&r.dispose()},t),r=ci(()=>{clearTimeout(s),i?.deleteAndLeak(r)});return i?.add(r),r}var Hg,bn;(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?bn=(e,t)=>{Wg(()=>{if(i)return;let s=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,s-Date.now())}}))});let i=!1;return{dispose(){i||(i=!0)}}}:bn=(e,t,i)=>{let s=e.requestIdleCallback(t,typeof i=="number"?{timeout:i}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(s))}}},Hg=(e)=>bn(globalThis,e)})();var $g;((e)=>{async function t(s){let r,n=await Promise.all(s.map((o)=>o.then((a)=>a,(a)=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})($g||={});var zh=class e{static fromArray(t){return new e((i)=>{i.emitMany(t)})}static fromPromise(t){return new e(async(i)=>{i.emitMany(await t)})}static fromPromises(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>i.emitOne(await s)))})}static merge(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ct,queueMicrotask(async()=>{let s={emitOne:(r)=>this.emitOne(r),emitMany:(r)=>this.emitMany(r),reject:(r)=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new e(async(s)=>{for await(let r of t)s.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async(s)=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,(i)=>!!i)}coalesce(){return e.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return e.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};zh.EMPTY=zh.fromArray([]);var Ug=class extends dt{constructor(e){super();this._terminal=e,this._linesCacheTimeout=this._register(new Ws),this._linesCacheDisposables=this._register(new Ws),this._register(ci(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Uh(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Yh(()=>this._destroyLinesCache(),15000)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let i=[],s=[0],r=this._terminal.buffer.active.getLine(e);for(;r;){let n=this._terminal.buffer.active.getLine(e+1),o=n?n.isWrapped:!1,a=r.translateToString(!o&&t);if(o&&n){let l=r.getCell(r.length-1);l&&l.getCode()===0&&l.getWidth()===1&&n.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(i.push(a),o)s.push(s[s.length-1]+a.length);else break;e++,r=n}return[i.join(""),s]}},Kg=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},qg=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,s){if(!e||e.length===0){this._terminal.clearSelection();return}if(i>this._terminal.cols)throw Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:i},n=this._findInLine(e,r,s);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=o,r.startCol=0,n=this._findInLine(e,r,s),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,n=0;s&&(i===e?(r=s.end.x,n=s.end.y):(r=s.start.x,n=s.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:r},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&n!==0)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&s&&(o.startRow=s.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:n},l;if(s&&(a.startRow=r=s.start.y,a.startCol=n=s.start.x,i!==e&&(l=this._findInLine(e,a,t,!1),l||(a.startRow=r=s.end.y,a.startCol=n=s.end.x))),l||(l=this._findInLine(e,a,t,o)),!l){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let h=r-1;h>=0&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);}if(!l&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=r&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);return l}_isWholeWord(e,t,i){return(e===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},s=!1){let{startRow:r,startCol:n}=t;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(s){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i)}let o=this._lineCache.getLineFromCache(r);o||(o=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,o));let[a,l]=o,h=this._bufferColsToStringOffset(r,n),d=e,c=a;i.regex||(d=i.caseSensitive?e:e.toLowerCase(),c=i.caseSensitive?a:a.toLowerCase());let u=-1;if(i.regex){let g=RegExp(d,i.caseSensitive?"g":"gi"),p;if(s)for(;p=g.exec(c.slice(0,h));)u=g.lastIndex-p[0].length,e=p[0],g.lastIndex-=e.length-1;else p=g.exec(c.slice(h)),p&&p[0].length>0&&(u=h+(g.lastIndex-p[0].length),e=p[0])}else s?h-d.length>=0&&(u=c.lastIndexOf(d,h-d.length)):u=c.indexOf(d,h);if(u>=0){if(i.wholeWord&&!this._isWholeWord(u,c,e))return;let g=0;for(;g<l.length-1&&u>=l[g+1];)g++;let p=g;for(;p<l.length-1&&u+e.length>=l[p+1];)p++;let b=u-l[g],E=u+e.length-l[p],B=this._stringLengthToBufferSize(r+g,b),A=this._stringLengthToBufferSize(r+p,E)-B+this._terminal.cols*(p-g);return{term:e,col:B,row:r+g,size:A}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let s=0;s<t;s++){let r=i.getCell(s);if(!r)break;let n=r.getChars();n.length>1&&(t-=n.length-1);let o=i.getCell(s+1);o&&o.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,s=0,r=this._terminal.buffer.active.getLine(i);for(;t>0&&r;){for(let n=0;n<t&&n<this._terminal.cols;n++){let o=r.getCell(n);if(!o)break;o.getWidth()&&(s+=o.getCode()===0?1:o.getChars().length)}if(i++,r=this._terminal.buffer.active.getLine(i),r&&!r.isWrapped)break;t-=this._terminal.cols}return s}},Vg=class extends dt{constructor(e){super();this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ci(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let s=this._createResultDecorations(i,t,!1);if(s)for(let r of s)this._storeDecoration(r,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){Ui(i)}}}clearHighlightDecorations(){Ui(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let s=[],{col:r,size:n}=e,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let l=Math.min(this._terminal.cols-r,n);s.push([o,r,l]),r=0,n-=l,o++}let a=[];for(let l of s){let h=this._terminal.registerMarker(l[0]),d=this._terminal.registerDecoration({marker:h,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(h.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(d){let c=[];c.push(h),c.push(d.onRender((u)=>this._applyStyles(u,i?t.activeMatchBorder:t.matchBorder,!1))),c.push(d.onDispose(()=>Ui(c))),a.push(d)}}return a.length===0?void 0:a}},Gg=class extends dt{constructor(){super(...arguments);this._searchResults=[],this._onDidChangeResults=this._register(new ct)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Xh=class extends dt{constructor(e){super();this._highlightTimeout=this._register(new Ws),this._lineCache=this._register(new Ws),this._state=new Kg,this._resultTracker=this._register(new Gg),this._highlightLimit=e?.highlightLimit??1000}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Ug(e),this._engine=new qg(e,this._lineCache.value),this._decorationManager=new Vg(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ci(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Yh(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let i=[],s,r=this._engine.find(e,0,0,t);for(;r&&(s?.row!==r.row||s?.col!==r.col)&&!(i.length>=this._highlightLimit);)s=r,i.push(s),r=this._engine.find(e,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,t);this._resultTracker.updateResults(i,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(i,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let s=this._decorationManager.createActiveDecoration(e,t);s&&(this._resultTracker.selectedDecoration=s)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let s=e.row-this._terminal.buffer.active.viewportY;s-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(s)}return!0}};function jg(e,t,i){let s=getComputedStyle(e),r=(x)=>s.getPropertyValue(x).trim()||void 0,n=()=>({background:r("--bg"),foreground:r("--ink-hi"),cursor:r("--accent"),selectionBackground:r("--line")}),o=new wa({cursorBlink:!0,fontFamily:r("--mono"),fontSize:12,scrollback:5000,allowProposedApi:!0,theme:n()}),a=()=>requestAnimationFrame(()=>o.options.theme=n()),l=matchMedia("(prefers-color-scheme: dark)");addEventListener("kz-theme",a),l.addEventListener("change",a);let h=new ba;o.loadAddon(h),o.loadAddon(new Th((x,F)=>window.open(F,"_blank","noopener")));let d=new Xh;o.loadAddon(d),o.open(e);try{let x=new Dh;x.onContextLoss(()=>x.dispose()),o.loadAddon(x)}catch{}let c=[1,2,4,8,15],u,g=0,p,b=!1,E=(x)=>{if(u?.readyState===WebSocket.OPEN)u.send(JSON.stringify(x))},B=(x=!1)=>{if(!e.offsetWidth)return;if(!u)return A();if(h.fit(),x&&o.rows>5)E({t:"r",c:o.cols,r:o.rows-1}),setTimeout(()=>E({t:"r",c:o.cols,r:o.rows}),80);else E({t:"r",c:o.cols,r:o.rows})},A=()=>{if(clearTimeout(p),u)u.onopen=u.onmessage=u.onclose=null,u.close();u=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/pty?key=${encodeURIComponent(t)}`),u.onopen=()=>{if(b)o.reset();b=!1,g=0,m.hidden=!0,B(!0)},u.onmessage=(x)=>o.write(String(x.data)),u.onclose=(x)=>{if(x.reason==="ended")o.write(`\r
|
|
147
147
|
\x1B[2m[agent ended]\x1B[0m\r
|
|
148
148
|
`),m.hidden=!0;else{if(!b)o.write(`\r
|
|
149
149
|
\x1B[2m[connection to the board lost]\x1B[0m\r
|
|
150
|
-
`);if(b=!0,m.hidden=!1,g<c.length)p=setTimeout(A,c[g++]*1000)}i?.()}},D={alt:!1},C=o.onData((x)=>{if(D.alt)x="\x1B"+x;D.alt=!1,k?.querySelector(".alt")?.classList.remove("on"),E({t:"i",d:x})}),k=null;if(matchMedia("(pointer: coarse)").matches){let x=(W)=>()=>`\x1B${o.modes.applicationCursorKeysMode?"O":"["}${W}`,F=()=>navigator.clipboard?.readText().then((W)=>W&&o.paste(W),()=>{}),z=[["1","1"],["2","2"],["3","3"],["Esc","\x1B"],["^C","\x03"],["↑",x("A")],["↓",x("B")],["←",x("D")],["→",x("C")],["↵","\r"],["⇧⇥","\x1B[Z"],["Ctrl","ctrl"],["Alt","alt"],["⋯","more"]];k=document.createElement("div"),k.className="termkeys";let I=document.createElement("input"),j=(W,oe)=>{let Ae=document.createElement("button");return Ae.type="button",Ae.textContent=W,Ae.addEventListener("pointerdown",($s)=>$s.preventDefault()),Ae.addEventListener("click",()=>{if(oe(),document.activeElement!==I)o.focus()}),Ae},U=document.createElement("div");U.className="chips";let Y=document.createElement("div");Y.className="ctrlpad",Y.hidden=!0;for(let W of["qwertyuiop","asdfghjkl","zxcvbnm✕"]){let oe=document.createElement("div");for(let Ae of W)oe.append(j(Ae,()=>{if(Ae!=="✕")E({t:"i",d:String.fromCharCode(Ae.charCodeAt(0)&31)});Y.hidden=!0}));Y.append(oe)}let V=o.textarea;if(V)V.inputMode="none";let Z=document.createElement("div");Z.className="tmore",Z.hidden=!0;let Qe=j("Raw keyboard",()=>{if(Z.hidden=!0,!V)return;let W=Qe.classList.toggle("on");V.inputMode=W?"text":"none",V.blur()});Z.append(j("Search",()=>{Z.hidden=!0,v()}),j("Paste",()=>{Z.hidden=!0,F()}),Qe);for(let[W,oe]of z){let Ae=j(W,()=>{if(oe==="alt")Ae.classList.toggle("on",D.alt=!D.alt);else if(oe==="ctrl")Y.hidden=!Y.hidden,Z.hidden=!0;else if(oe==="more")Z.hidden=!Z.hidden,Y.hidden=!0;else E({t:"i",d:typeof oe==="function"?oe():oe})});if(oe==="alt")Ae.classList.add(oe);U.append(Ae)}let Be=document.createElement("form");Be.className="compose",I.placeholder="Message the agent…",I.enterKeyHint="send",I.autocomplete="off",I.setAttribute("aria-label","Message the agent");let me=document.createElement("button");me.textContent="➤",me.setAttribute("aria-label","Send"),me.addEventListener("pointerdown",(W)=>W.preventDefault()),Be.append(I,me),Be.addEventListener("submit",(W)=>{if(W.preventDefault(),I.value)E({t:"i",d:I.value});I.value="",setTimeout(()=>E({t:"i",d:"\r"}),60)}),k.append(Y,Z,U,Be),e.after(k)}let R=null,N=(x)=>{R=x.touches.length===1?x.touches[0].clientY:null},G=(x)=>{if(R===null||x.touches.length!==1)return;let F=e.querySelector(".xterm-screen"),z=(F?.clientHeight||e.clientHeight)/o.rows,I=x.touches[0],j=Math.trunc((R-I.clientY)/z);if(x.preventDefault(),!j)return;if(R-=j*z,o.modes.mouseTrackingMode==="none")return o.scrollLines(j);let U=(F??e).getBoundingClientRect(),Y=Math.min(o.cols,Math.max(1,Math.ceil((I.clientX-U.left)/(U.width/o.cols)))),V=Math.min(o.rows,Math.max(1,Math.ceil((I.clientY-U.top)/z)));E({t:"i",d:`\x1B[<${j>0?65:64};${Y};${V}M`.repeat(Math.abs(j))})};e.addEventListener("touchstart",N,{passive:!0}),e.addEventListener("touchmove",G,{passive:!1});let X=document.createElement("div");X.className="termtools";let ee=(x,F,z)=>{let I=document.createElement("button");return I.type="button",I.textContent=x,I.title=F,I.addEventListener("mousedown",(j)=>j.preventDefault()),I.addEventListener("click",z),I},O=document.createElement("input");O.type="search",O.placeholder="Search";let Te={matchBackground:"#7a5c00",activeMatchBackground:"#d08000",matchOverviewRuler:"#d08000",activeMatchColorOverviewRuler:"#ff9900"},_=(x=!1)=>{if(!O.value)return d.clearDecorations();let F={decorations:Te};x?d.findPrevious(O.value,F):d.findNext(O.value,F)},f=document.createElement("span");f.className="tsearch",f.hidden=!0;let w=()=>{f.hidden=!0,d.clearDecorations(),o.focus()},v=()=>{f.hidden=!1,O.select(),O.focus()};O.addEventListener("input",()=>_()),O.addEventListener("keydown",(x)=>{if(x.key==="Enter")x.preventDefault(),_(x.shiftKey);else if(x.key==="Escape")x.preventDefault(),w()}),f.append(O,ee("↑","Previous (Shift+Enter)",()=>_(!0)),ee("↓","Next (Enter)",()=>_()),ee("✕","Close (Esc)",w)),X.append(f,ee("⌕","Search (Ctrl+Shift+F)",()=>f.hidden?v():w()));let S=ee("Paste","Paste from clipboard",()=>{let x=()=>{S.textContent="Blocked",setTimeout(()=>S.textContent="Paste",1500)};if(!navigator.clipboard?.readText)x();else navigator.clipboard.readText().then((F)=>F&&o.paste(F),x);o.focus()});if(!k)X.append(S);let m=ee("Reconnect","Reconnect to the board",()=>{g=0,A(),o.focus()});m.className="recon",m.hidden=!0,X.prepend(m),e.append(X),
|
|
150
|
+
`);if(b=!0,m.hidden=!1,g<c.length)p=setTimeout(A,c[g++]*1000)}i?.()}},D={alt:!1},C=o.onData((x)=>{if(D.alt)x="\x1B"+x;D.alt=!1,k?.querySelector(".alt")?.classList.remove("on"),E({t:"i",d:x})}),k=null;if(matchMedia("(pointer: coarse)").matches){let x=(W)=>()=>`\x1B${o.modes.applicationCursorKeysMode?"O":"["}${W}`,F=()=>navigator.clipboard?.readText().then((W)=>W&&o.paste(W),()=>{}),z=[["1","1"],["2","2"],["3","3"],["Esc","\x1B"],["^C","\x03"],["↑",x("A")],["↓",x("B")],["←",x("D")],["→",x("C")],["↵","\r"],["⇧⇥","\x1B[Z"],["Ctrl","ctrl"],["Alt","alt"],["⋯","more"]];k=document.createElement("div"),k.className="termkeys";let I=document.createElement("input"),j=(W,oe)=>{let Ae=document.createElement("button");return Ae.type="button",Ae.textContent=W,Ae.addEventListener("pointerdown",($s)=>$s.preventDefault()),Ae.addEventListener("click",()=>{if(oe(),document.activeElement!==I)o.focus()}),Ae},U=document.createElement("div");U.className="chips";let Y=document.createElement("div");Y.className="ctrlpad",Y.hidden=!0;for(let W of["qwertyuiop","asdfghjkl","zxcvbnm✕"]){let oe=document.createElement("div");for(let Ae of W)oe.append(j(Ae,()=>{if(Ae!=="✕")E({t:"i",d:String.fromCharCode(Ae.charCodeAt(0)&31)});Y.hidden=!0}));Y.append(oe)}let V=o.textarea;if(V)V.inputMode="none";let Z=document.createElement("div");Z.className="tmore",Z.hidden=!0;let Qe=j("Raw keyboard",()=>{if(Z.hidden=!0,!V)return;let W=Qe.classList.toggle("on");V.inputMode=W?"text":"none",V.blur()});Z.append(j("Search",()=>{Z.hidden=!0,v()}),j("Paste",()=>{Z.hidden=!0,F()}),Qe);for(let[W,oe]of z){let Ae=j(W,()=>{if(oe==="alt")Ae.classList.toggle("on",D.alt=!D.alt);else if(oe==="ctrl")Y.hidden=!Y.hidden,Z.hidden=!0;else if(oe==="more")Z.hidden=!Z.hidden,Y.hidden=!0;else E({t:"i",d:typeof oe==="function"?oe():oe})});if(oe==="alt")Ae.classList.add(oe);U.append(Ae)}let Be=document.createElement("form");Be.className="compose",I.placeholder="Message the agent…",I.enterKeyHint="send",I.autocomplete="off",I.setAttribute("aria-label","Message the agent");let me=document.createElement("button");me.textContent="➤",me.setAttribute("aria-label","Send"),me.addEventListener("pointerdown",(W)=>W.preventDefault()),Be.append(I,me),Be.addEventListener("submit",(W)=>{if(W.preventDefault(),I.value)E({t:"i",d:I.value});I.value="",setTimeout(()=>E({t:"i",d:"\r"}),60)}),k.append(Y,Z,U,Be),e.after(k)}let R=null,N=(x)=>{R=x.touches.length===1?x.touches[0].clientY:null},G=(x)=>{if(R===null||x.touches.length!==1)return;let F=e.querySelector(".xterm-screen"),z=(F?.clientHeight||e.clientHeight)/o.rows,I=x.touches[0],j=Math.trunc((R-I.clientY)/z);if(x.preventDefault(),!j)return;if(R-=j*z,o.modes.mouseTrackingMode==="none")return o.scrollLines(j);let U=(F??e).getBoundingClientRect(),Y=Math.min(o.cols,Math.max(1,Math.ceil((I.clientX-U.left)/(U.width/o.cols)))),V=Math.min(o.rows,Math.max(1,Math.ceil((I.clientY-U.top)/z)));E({t:"i",d:`\x1B[<${j>0?65:64};${Y};${V}M`.repeat(Math.abs(j))})};e.addEventListener("touchstart",N,{passive:!0}),e.addEventListener("touchmove",G,{passive:!1});let X=document.createElement("div");X.className="termtools";let ee=(x,F,z)=>{let I=document.createElement("button");return I.type="button",I.textContent=x,I.title=F,I.addEventListener("mousedown",(j)=>j.preventDefault()),I.addEventListener("click",z),I},O=document.createElement("input");O.type="search",O.placeholder="Search";let Te={matchBackground:"#7a5c00",activeMatchBackground:"#d08000",matchOverviewRuler:"#d08000",activeMatchColorOverviewRuler:"#ff9900"},_=(x=!1)=>{if(!O.value)return d.clearDecorations();let F={decorations:Te};x?d.findPrevious(O.value,F):d.findNext(O.value,F)},f=document.createElement("span");f.className="tsearch",f.hidden=!0;let w=()=>{f.hidden=!0,d.clearDecorations(),o.focus()},v=()=>{f.hidden=!1,O.select(),O.focus()};O.addEventListener("input",()=>_()),O.addEventListener("keydown",(x)=>{if(x.key==="Enter")x.preventDefault(),_(x.shiftKey);else if(x.key==="Escape")x.preventDefault(),w()}),f.append(O,ee("↑","Previous (Shift+Enter)",()=>_(!0)),ee("↓","Next (Enter)",()=>_()),ee("✕","Close (Esc)",w)),X.append(f,ee("⌕","Search (Ctrl+Shift+F)",()=>f.hidden?v():w()));let S=ee("Paste","Paste from clipboard",()=>{let x=()=>{S.textContent="Blocked",setTimeout(()=>S.textContent="Paste",1500)};if(!navigator.clipboard?.readText)x();else navigator.clipboard.readText().then((F)=>F&&o.paste(F),x);o.focus()});if(!k)X.append(S);let m=ee("Reconnect","Reconnect to the board",()=>{g=0,A(),o.focus()});m.className="recon",m.hidden=!0,X.prepend(m),e.append(X),B(),o.attachCustomKeyEventHandler((x)=>{if(x.type==="keydown"&&(x.ctrlKey||x.metaKey)&&x.shiftKey&&x.code==="KeyF")return x.preventDefault(),v(),!1;return!0});let y,L=new ResizeObserver(()=>{clearTimeout(y),y=setTimeout(B,100)});return L.observe(e),o.focus(),()=>{if(L.disconnect(),clearTimeout(y),e.removeEventListener("touchstart",N),e.removeEventListener("touchmove",G),C.dispose(),k?.remove(),X.remove(),clearTimeout(p),u)u.onclose=null,u.close();removeEventListener("kz-theme",a),l.removeEventListener("change",a),o.dispose()}}window.kzTerm=jg;})();
|
package/web/term.ts
CHANGED
|
@@ -52,6 +52,7 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
52
52
|
};
|
|
53
53
|
const size = (nudge = false) => {
|
|
54
54
|
if (!el.offsetWidth) return;
|
|
55
|
+
if (!ws) return connect(); // its onopen comes back here to fit and nudge
|
|
55
56
|
fit.fit();
|
|
56
57
|
// The replay was drawn at whatever size the agent had before; a resize to the same size
|
|
57
58
|
// sends it no signal, so a full-screen agent never repaints it. One row short, then back, does.
|
|
@@ -254,7 +255,9 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
254
255
|
reBtn.hidden = true;
|
|
255
256
|
tools.prepend(reBtn);
|
|
256
257
|
el.append(tools);
|
|
257
|
-
|
|
258
|
+
// A pane in a background tab has no size yet. The replay is cursor moves for the agent's real
|
|
259
|
+
// width, and xterm's default 80 columns would clamp them for good, so attach once it is shown.
|
|
260
|
+
size();
|
|
258
261
|
// xterm keeps one custom key handler: add further shortcuts here, not in a second call.
|
|
259
262
|
term.attachCustomKeyEventHandler((e) => {
|
|
260
263
|
if (e.type === "keydown" && (e.ctrlKey || e.metaKey) && e.shiftKey && e.code === "KeyF") {
|
|
@@ -280,8 +283,7 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
280
283
|
bar?.remove();
|
|
281
284
|
tools.remove();
|
|
282
285
|
clearTimeout(retry);
|
|
283
|
-
ws.onclose = null;
|
|
284
|
-
ws.close();
|
|
286
|
+
if (ws) { ws.onclose = null; ws.close(); }
|
|
285
287
|
removeEventListener("kz-theme", retheme);
|
|
286
288
|
os.removeEventListener("change", retheme);
|
|
287
289
|
term.dispose();
|
package/web/video.html
CHANGED
|
@@ -406,6 +406,8 @@ pre.mark span:nth-child(1){color:var(--ink-hi)}pre.mark span:nth-child(2){color:
|
|
|
406
406
|
// Motion: full, reduce, or unset to follow the system's reduced-motion, in kz-motion.
|
|
407
407
|
window.setMotion=m=>{if(m==="system")delete r.dataset.motion;else r.dataset.motion=m;try{m==="system"?localStorage.removeItem("kz-motion"):localStorage.setItem("kz-motion",m)}catch(e){}};
|
|
408
408
|
try{const m=localStorage.getItem("kz-motion");if(m)r.dataset.motion=m}catch(e){}
|
|
409
|
+
// Settings changed in another window or tab apply here at once, not on the next reload.
|
|
410
|
+
addEventListener("storage",e=>{const m={"kz-theme":"theme","kz-color":"color","kz-motion":"motion"}[e.key];if(!m)return;if(e.newValue)r.dataset[m]=e.newValue;else delete r.dataset[m];dispatchEvent(new Event("kz-theme"))});
|
|
409
411
|
os.addEventListener("change",paint);paint();
|
|
410
412
|
document.getElementById("themet").onclick=e=>setTheme(e.currentTarget.dataset.dark==="true"?"light":"dark");
|
|
411
413
|
// Setup: while first-run onboarding is skipped or unfinished, a row that continues it; the board redraws it as it saves.
|
package/web/video.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen video page
|
|
1
|
+
/* kaizen video page bf8430f9ab3270fb -- generated by bun run build:web from web/video.ts; do not edit */
|
|
2
2
|
(()=>{var gt=null,ht=(e)=>{gt=e};function cn(e,t,n){Oe++,gt?.(e,t,n)}var Oe=0,ft="",Pe=!1,we=!1;async function qe(){if(Pe){we=!0;return}Pe=!0;do{we=!1;let e=Oe;try{let t=await fetch("/state?all=1");if(!t.ok)continue;let n=await t.text(),a=n.replace(/"now":\d+\}$/,"");if(a===ft)continue;let{cards:s,projects:i,rail:l,agents:r}=JSON.parse(n);if(!we&&e===Oe)ft=a,cn(s,[...i,...l??[]],r)}catch{}}while(we);Pe=!1}var pn={S:{project:null,projects:[],cards:[],now:Date.now(),all:!1,dir:null},all:new URLSearchParams(location.search).get("all")!=="0",dir:null,openKey:null,mode:null,modeKey:null,menuKey:null,flash:new Set,tab:"request",lastTab:"request",runDoc:null,clearMenu:!1,sevMenu:!1,wantTerm:null,wantPty:null,shells:[],setQ:"",setScope:"all",setPage:null,setBack:!1,pageGen:0,PL:[],shown:new Set((()=>{try{return JSON.parse(localStorage.getItem("kz-show"))||[]}catch(e){return[]}})())};var L=(e)=>document.getElementById(e),un=(e)=>String(e).replace(/[&<>"]/g,(t)=>({"&":"&","<":"<",">":">",'"':"""})[t]);class Fe{s;constructor(e){this.s=e}toString(){return this.s}}var U=(e)=>new Fe(String(e)),bt=(e)=>e instanceof Fe?e.s:Array.isArray(e)?e.map(bt).join(""):e==null||e===!1?"":un(e),w=(e,...t)=>U(e.reduce((n,a,s)=>n+bt(t[s-1])+a));var as=U('<div aria-busy="true" aria-label="Loading"><span class="skel" style="height:16px;width:35%;margin:20px 0 14px"></span>'+'<span class="skel" style="height:44px;margin-bottom:10px"></span>'.repeat(4)+"</div>");function $e(e){let t=document.createElement("dialog");return t.className="kz",t.innerHTML=`<form class="inl" method="dialog">${e}</form>`,t.onclose=()=>t.remove(),t.onclick=(n)=>{if(n.target===t)t.close()},document.body.appendChild(t),t.showModal(),t}var te=(e,t)=>{let n=t-e;return n<3600000?Math.round(n/60000)+"m":n<86400000?Math.round(n/3600000)+"h":Math.round(n/86400000)+"d"};var Ke=(e)=>typeof e==="string"?[e]:e.kids.flatMap(Ke);var Ve=(e,t)=>`ws:${e}:${t}`,$t=(e)=>e.kind==="run"&&e.status==="done"&&e.accept!=="needs"&&!e.archived&&e.git==="pending";var kt=3000,xe=new Map,me=(e)=>e.key+"@"+(e.born??0),vt={asking:0,working:1,done:2},ke={asking:"Asking",working:"Working",done:"Done"},mn={asking:"wait",working:"build",done:"done"};function fn(e,t,n=xe){if(e.asking)return"asking";if(e.busy)return n.set(me(e),t),"working";return t-(n.get(me(e))??-1/0)<kt?"working":"done"}var xt=(e,t,n=xe)=>Math.min(1/0,...e.filter((a)=>!a.asking&&!a.busy&&n.has(me(a))).map((a)=>kt-(t-n.get(me(a)))).filter((a)=>a>0)),Et=(e,t=xe)=>{let n=new Set(e.map(me));for(let a of t.keys())if(!n.has(a))t.delete(a)},Lt=(e,t,n,a,s,i=xe)=>e.filter((l)=>l.dir===t&&a({state:l.dir,ws:l.ws})===n).map((l)=>({a:l,st:fn(l,s,i)})).sort((l,r)=>vt[l.st]-vt[r.st]),yt=({a:e,st:t})=>e.last||`${ke[t]} - ${e.name}`,wt=(e,t)=>!e?"":t-e<60000?"now":te(e,t),gn=(e,t)=>e+"\x00"+t;function Mt(e,t,n){let a=gn(t,n);if(e[a])delete e[a];else e[a]=!0;return e}var hn=["claude","codex","gemini"],Ue=(e)=>w`<svg aria-hidden="true"><use href="#i-${hn.includes(e.agent??"")?e.agent:"ai"}"/></svg>`,We=(e)=>w`<i class="si ${mn[e]}"></i>`,bn=w`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;function St(e,t,n,a,s){if(!e.length)return"";let i=w`data-dir="${a}" data-ws="${s}"`;if(e.length===1){let p=e[0];return w`<div class="wag"><button type="button" class="aone" data-term="${p.a.key}" ${i} title="${p.a.name}: open its terminal">${We(p.st)}${Ue(p.a)}<span class="atx">${ke[p.st]} - ${p.a.name}</span><small>${wt(p.a.at,t)}</small></button></div>`}let l=w`<button type="button" class="wchev${n?" on":""}" data-wopen ${i} aria-expanded="${String(n)}" aria-label="${String(e.length)} agents: ${n?"hide":"show"} the list">${bn}</button>`;if(n)return w`<div class="wag"><span class="aht">${String(e.length)} agents</span>${l}</div><div class="alist">${e.map((p)=>w`<button type="button" class="arow" data-term="${p.a.key}" ${i} title="${yt(p)}">${We(p.st)}${Ue(p.a)}<span class="atx">${yt(p)}</span><small>${wt(p.a.at,t)}</small></button>`)}</div>`;let r=["asking","working","done"].map((p)=>({st:p,rs:e.filter((k)=>k.st===p)})).filter((p)=>p.rs.length);return w`<div class="wag"><span class="chips">${r.map((p)=>w`<span class="chip">${We(p.st)}${p.rs.map((k)=>w`<button type="button" class="amark" data-term="${k.a.key}" ${i} title="${k.a.name} - ${ke[p.st]}: open its terminal" aria-label="${k.a.name} - ${ke[p.st]}: open its terminal">${Ue(k.a)}</button>`)}</span>`)}</span>${l}</div>`}function Je(e){return e.toLowerCase().trim().replace(/[^a-z0-9/._-]+/g,"-").replace(/\.{2,}/g,".").replace(/\/{2,}/g,"/").replace(/(^|\/)[-.]+/g,"$1").slice(0,60).replace(/[-./]+(\/|$)/g,"$1").replace(/\/$/,"").replace(/\.lock(\/|$)/g,"-lock$1")}var vn=(e)=>e.includes("\\")?"\\":"/";async function Y(e,t){try{let n=await fetch(e,t?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}:void 0),a=await n.json().catch(()=>({}));return{ok:n.ok,d:n.ok?a:{error:a.error||a.why||"that did not work"}}}catch{return{ok:!1,d:{error:"the board is offline"}}}}function fe(e={}){let t=$e(""),n=t.querySelector("form");t.setAttribute("aria-label","Add a project");let a=e.start==="ws",s=(o)=>n.elements.namedItem(o),i=(o,d,u,b)=>(o.disabled=d,o.textContent=d?u:b),l=a?"":w`<button type="button" class="btn ghost" data-a="back">Back to add options</button>`,r=(o)=>w`<small class="att err" role="alert"></small><div class="row">${l}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">${o}</button></div>`,p=(o)=>n.querySelector(".err").textContent=o,k=(o,d)=>{p(d);try{localStorage.setItem("kz-proj",o)}catch{}setTimeout(()=>location.href="/?view=board",900)},M=async(o,d)=>{let u=await Y("/pick-folder",{});if(u.d.path)o.value=d?u.d.path.replace(/[\\/]+$/,"")+vn(u.d.path)+d():u.d.path},f=(o)=>{let d=Tt();if(t.classList.toggle("wsnew",o==="ws"),o==="menu")n.innerHTML=w`<b>Add a project</b><small class="att">Add a project to get started with kaizen.</small><button type="button" class="btn opt" data-go="folder"><b>Existing folder</b><small>A project, a Git repo, or any folder</small></button><small class="att">Other ways to add</small><button type="button" class="btn opt" data-go="clone"><b>Clone from URL</b><small>Clone a remote Git repository</small></button><button type="button" class="btn opt" data-go="create"><b>Create new project</b><small>Start from an empty folder</small></button>${d.length?w`<button type="button" class="btn opt" data-go="ws"><b>New workspace</b><small>A branch in its own folder, in a project you have</small></button>`:""}<div class="row"><button type="button" class="btn ghost" data-a="x">Cancel</button></div>`.toString(),n.querySelectorAll("[data-go]").forEach((b)=>b.onclick=()=>f(b.dataset.go)),n.onsubmit=(b)=>b.preventDefault();else if(o==="folder")n.innerHTML=w`<b>Existing folder</b><small class="att">Pick a folder, or type its path. A .kaizen folder is added to it.</small><div class="row"><input name="path" placeholder="/path/to/folder" aria-label="Folder" autocomplete="off" spellcheck="false" required><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${r("Add project")}`.toString(),s("path").focus(),n.onsubmit=async(b)=>{b.preventDefault();let v=n.querySelector("[data-a=go]");i(v,!0,"Adding...","Add project");let y=await Y("/add-project",{path:s("path").value.trim()});i(v,!1,"","Add project"),y.ok?k(y.d.dir,y.d.already?"Project already added":"Project added"):p(y.d.error)},n.querySelector("[data-a=pick]").onclick=()=>M(s("path"));else if(o==="clone"){n.innerHTML=w`<b>Clone from URL</b><small class="att">Enter the Git URL (https or ssh) and choose where to clone it.</small><input name="url" placeholder="https://github.com/user/repo.git" aria-label="Git URL" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to clone into" aria-label="Clone into" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${r("Clone")}`.toString(),s("url").focus();let b="",v="",y=async()=>{let C=s("url").value.trim();if(!C)return!1;let x=await Y("/clone",{url:C,check:!0});if(!x.ok)return p(x.d.error),!1;if(p(""),b=x.d.name,!s("to").value.trim()||s("to").value===v)s("to").value=v=x.d.to;return!0};s("url").onchange=y,n.querySelector("[data-a=pick]").onclick=async()=>await y()?M(s("to"),()=>b):s("url").focus(),n.onsubmit=async(C)=>{if(C.preventDefault(),!await y())return;let x=n.querySelector("[data-a=go]");i(x,!0,"Cloning...","Clone");let E=await Y("/clone",{url:s("url").value.trim(),to:s("to").value.trim()||void 0});i(x,!1,"","Clone"),E.ok?k(E.d.dir,"Cloned"):p(E.d.error)}}else if(o==="create"){n.innerHTML=w`<b>Create a new project</b><small class="att">Name it and kaizen will create the folder with a .kaizen inside.</small><input name="name" placeholder="my-project" aria-label="Name" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to create" aria-label="Create in" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div><label class="att"><input type="checkbox" name="git" checked> Git repository</label>${r("Create project")}`.toString(),s("name").focus();let b="";s("name").oninput=async()=>{let v=s("name").value.trim();if(!v||/[\\/:*?"<>|]/.test(v)||s("to").value.trim()&&s("to").value!==b)return;let y=await Y("/new-project",{name:v,check:!0});if(y.ok&&s("name").value.trim()===v)s("to").value=b=y.d.to},n.querySelector("[data-a=pick]").onclick=()=>M(s("to"),()=>s("name").value.trim()),n.onsubmit=async(v)=>{v.preventDefault();let y=n.querySelector("[data-a=go]");i(y,!0,"Creating...","Create project");let C=await Y("/new-project",{name:s("name").value.trim(),to:s("to").value.trim()||void 0,git:s("git").checked});if(i(y,!1,"","Create project"),!C.ok)return p(C.d.error);k(C.d.dir,C.d.git===!1?"Project created, but git init failed":"Project created")}}else{let b=d.some((x)=>x.dir===e.dir)?e.dir:d[0]?.dir,v=/Mac/.test(navigator.platform)?"⌘":"Ctrl";n.innerHTML=w`<b>New workspace</b><label class="att">Project<select name="project" aria-label="Project">${d.map((x)=>w`<option value="${x.dir}"${x.dir===b?" selected":""}>${x.name}</option>`)}</select></label><div class="wsfrom"><span class="att" id="wsfl">Create from <i>[Optional]</i></span><label class="wsbase">from <select name="base" aria-label="Start from branch"></select></label></div><input name="name" placeholder="What is this workspace for?" aria-labelledby="wsfl" autocomplete="off" spellcheck="false"><details class="wsadv"><summary>Advanced</summary><label class="att">Branch name<input name="branch" placeholder="feature/my-branch" aria-label="Branch name" autocomplete="off" spellcheck="false"></label></details><small class="att err" role="alert"></small><div class="row">${l}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">Create workspace</button><kbd class="wskey" aria-hidden="true">${v} ↵</kbd></div>`.toString(),s("name").focus();let y=n.elements.namedItem("base");s("name").oninput=()=>s("branch").placeholder=Je(s("name").value)||"feature/my-branch";let C=async()=>{let x=await Y("/branches?dir="+encodeURIComponent(s("project").value)),{def:E="",branches:W=[]}=x.ok?x.d:{};y.innerHTML=W.map((G)=>w`<option${G===E?" selected":""}>${G}</option>`.toString()).join("")||'<option value="">current branch</option>'};n.elements.namedItem("project").onchange=C,C(),n.onkeydown=(x)=>{if(x.key==="Enter"&&(x.ctrlKey||x.metaKey))x.preventDefault(),n.requestSubmit()},n.onsubmit=async(x)=>{x.preventDefault();let E=s("project").value,W=n.querySelector("[data-a=go]");if(W.disabled)return;p("");let G=s("branch").value.trim()||Je(s("name").value)||"workspace-"+Math.random().toString(36).slice(2,6);i(W,!0,"Creating...","Create workspace");let ue=await Y("/worktree",{dir:E,branch:G,base:y.value||void 0});i(W,!1,"","Create workspace"),ue.ok?(t.close(),location.href=X(E,ue.d.path)):p(ue.d.error)}}n.querySelector("[data-a=x]").onclick=()=>t.close();let u=n.querySelector("[data-a=back]");if(u)u.onclick=()=>f("menu")};f(e.start??"menu")}function jt(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return e;let a=t.trim().toLowerCase(),s=(i)=>{let l=i.title.toLowerCase();return l.startsWith(a)?0:l.includes(a)?1:2};return e.filter((i)=>{let l=(i.title+" "+(i.sub??"")+" "+i.hay).toLowerCase();return n.every((r)=>l.includes(r))}).sort((i,l)=>s(i)-s(l)||(l.at??0)-(i.at??0))}var Le=(e,t)=>!dispatchEvent(new CustomEvent(e,{cancelable:!0,detail:t})),ne=(e,t)=>()=>{let n=document.querySelector(`.rail a.it[data-view="${e}"]`);n?n.click():location.href=t},Ct=(e,t)=>{if(!Le("kz-open-ws",{dir:e,ws:t}))location.href=X(e,t)},At=()=>{try{return JSON.parse(localStorage.getItem("kz-runtabs")||"{}")}catch{return{}}},yn=(e,t,n)=>{if(Le("kz-open-tab",{dir:e,ws:t,id:n}))return;let a=At(),s=a[Ve(e,t)],i=s?.screens?.find((l)=>Ke(l.tree).includes(n));if(i)try{s.on=i.id,localStorage.setItem("kz-runtabs",JSON.stringify(a))}catch{}location.href=X(e,t)},wn=["local","preview","note","history","shell"],$n=(e)=>{try{return localStorage.getItem("kz-browse:"+e)?.replace(/^https?:\/\//,"").replace(/\/$/,"")}catch{}},kn={ws:'<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/>',run:'<path d="M5 4l14 8-14 8z"/>',idea:'<path d="M9 18h6M10 21h4M12 3a6 6 0 0 0-4 10.5c.7.7 1 1.5 1 2.5h6c0-1 .3-1.8 1-2.5A6 6 0 0 0 12 3z"/>',chat:'<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/>',term:'<path d="M4 17l6-5-6-5M12 19h8"/>',proj:'<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',page:'<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 9h16"/>',act:'<path d="M13 3L5 14h6l-1 7 8-11h-6z"/>',tab:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 9h8V5"/>',plus:'<path d="M12 5v14M5 12h14"/>',search:'<circle cx="11" cy="11" r="7"/><path d="M20 20l-4-4"/>'},Rt=(e)=>U(`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${kn[e]}</g></svg>`),Bt=[];function xn(){let{cards:e,projects:t=[],agents:n=[]}=Dt(),a=Date.now(),s=new URLSearchParams(location.search),i=s.get("id")&&e.find((o)=>o.kind==="run"&&o.state===s.get("dir")&&o.id===s.get("id")),l=s.get("ws")??(i?ce(i,t):null),r=[],p=At(),k=new Map;for(let o of e){let d=o.state+"\x00"+ce(o,t);k.set(d,Math.max(k.get(d)??0,o.moved??0))}for(let o of t){let d=N(o.dir,t);for(let u of o.workspaces??[]){let b=s.get("dir")===o.dir&&l===u.path,v=k.get(o.dir+"\x00"+u.path);r.push({group:b?"Current":"Workspaces",title:se(u),sub:d,when:v?te(v,a):void 0,hay:`${se(u)} ${d} ${u.path} workspace`,at:b?1/0:v??0,ico:"ws",act:()=>Ct(o.dir,u.path)});let y=Ve(o.dir,u.path),C=p[y];for(let x of C?.tabs??[]){if(!wn.includes(x.kind)||C.hidden?.includes(x.id))continue;let E=x.kind==="local"&&$n(y)||x.title;r.push({group:"Tabs",title:E,sub:`${se(u)} · ${d}`,hay:`${E} ${x.title} ${x.kind} ${x.note??""} ${se(u)} ${d} tab`,ico:"tab",act:()=>yn(o.dir,u.path,x.id)})}}r.push({group:"Projects",title:d,hay:`${d} ${o.dir} project`,ico:"proj",act:()=>{let u=o.workspaces?.find((b)=>b.main)??o.workspaces?.[0];u?Ct(o.dir,u.path):ne("board","/?view=board")()}})}for(let o of e.filter((d)=>!d.archived)){let d=ae(o);r.push({group:o.kind==="run"?"Runs":"Ideas",title:Ge(o)||o.id,sub:N(o.state,t),when:o.moved?te(o.moved,a):void 0,hay:`${Ge(o)} ${o.id??""} ${o.text??""} ${N(o.state,t)} ${d}`,at:o.moved??0,dot:d,ico:o.kind==="run"?"run":"idea",act:()=>{if(!Le("kz-open-card",{dir:o.state,id:o.kind==="run"?o.id:void 0,text:o.text}))location.href=zt(o)}})}for(let o of Bt){let d=Date.parse(o.updated)||0;r.push({group:"Chats & terminals",title:o.title||"Chat",sub:o.project?N(o.project,t):void 0,when:d?te(d,a):void 0,hay:`${o.title} chat ${o.project??""}`,at:d,dot:o.busy?"build":void 0,ico:"chat",act:()=>{try{sessionStorage.setItem("kz-chat",o.id)}catch{}ne("home","/")()}})}for(let o of n)r.push({group:"Chats & terminals",title:o.name||o.agent||"Terminal",sub:N(o.dir,t),hay:`${o.name} ${o.agent??""} ${o.run??""} ${o.last??""} ${N(o.dir,t)} terminal agent`,at:o.at??o.born??0,dot:o.asking?"wait":o.busy?"build":"done",ico:"term",act:()=>{if(!Le("kz-open-term",{dir:o.dir,ws:o.ws,key:o.key}))location.href=X(o.dir,o.ws??"")}});let M=(o)=>()=>L(o)?.click(),f=[["Home","page",ne("home","/"),"chat"],["Icebox","page",ne("sources","/?view=icebox"),"requests sources gathered"],["Ideas","page",ne("ideas","/?view=ideas"),"backlog"],["Board","page",ne("board","/?view=board"),"kanban runs"],["Notes","page",()=>location.href="/notebook","notebook docs"],["Settings","page",ne("settings","/?view=settings"),"preferences config"],["New idea","act",()=>L("newtop")?L("newtop").click():location.href="/?view=board","create add run"],["Add a project","act",()=>fe({dir:null}),"clone folder create workspace"],["Toggle theme","act",M("themet"),"dark light"],["Collapse or expand menu","act",M("fold"),"sidebar rail"],["Keyboard shortcuts","act",M("kbd"),"keys help"],["Report an issue","act",()=>open("/issue","_blank","noopener"),"bug feedback"]];for(let[o,d,u,b]of f)r.push({group:"Actions",title:o,hay:`${o} ${b??""}`,ico:d,act:u});return r}var En=["Current","Workspaces","Tabs","Chats & terminals","Runs","Ideas","Projects","Actions"],Ln={Workspaces:5,Tabs:4,"Chats & terminals":5,Runs:5,Ideas:3,Projects:5},S=null,P=[],O=0;function Ee(){let e=S.querySelector("input").value,t=xn(),n=e.trim()?jt(t,e):t.slice().sort((l,r)=>(r.at??0)-(l.at??0));P=[];let a=e.trim()?[...new Set(n.map((l)=>l.group))]:En;for(let l of a){let r=n.filter((p)=>p.group===l);P.push(...r.slice(0,e.trim()?8:Ln[l]??r.length))}if(e.trim())P.push({group:"Create",title:`New idea "${e.trim()}"`,hay:"",ico:"plus",act:()=>Mn(e.trim())});O=Math.min(O,P.length-1);let s=S.querySelector(".gs-list"),i="";s.innerHTML=String(w`${P.map((l,r)=>{let p=l.group!==i?(i=l.group,w`<div class="gs-h" role="presentation">${l.group}</div>`):"";return w`${p}<div class="gs-i" role="option" id="gs-${r}" data-n="${r}" aria-selected="${String(r===O)}">${Rt(l.ico)}${l.dot?w`<span class="si ${l.dot}"></span>`:""}<span class="gs-t">${l.title}</span>${l.sub?w`<span class="gs-s">${l.sub}</span>`:""}${l.when?w`<span class="gs-w">${l.when}</span>`:""}</div>`})}${P.length===1&&e.trim()?w`<div class="gs-none">No results</div>`:""}`),_e(O),S.querySelector(".gs-live").textContent=`${P.length} result${P.length===1?"":"s"} found`}function _e(e){S.querySelector(`#gs-${O}`)?.setAttribute("aria-selected","false"),O=e;let t=S.querySelector(`#gs-${e}`);t?.setAttribute("aria-selected","true"),S.querySelector("input").setAttribute("aria-activedescendant","gs-"+e),t?.scrollIntoView({block:"nearest"})}function Mn(e){if(!L("newtop"))return void(location.href="/?view=board");L("newtop").click();let t=document.querySelector("dialog[open] textarea");if(t)t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0}))}function Ht(e){let t=P[e];if(!t)return;S.close(),t.act()}function It(){if(S)return S.querySelector("input").focus();S=document.createElement("dialog"),S.className="gs",S.setAttribute("aria-label","Search"),S.innerHTML=String(w`<div class="gs-box"><div class="gs-q">${Rt("search")}<input type="text" placeholder="Search" aria-label="Search" role="combobox" aria-expanded="true" aria-controls="gs-list" autocomplete="off" spellcheck="false"></div><div class="gs-list" id="gs-list" role="listbox"></div><span class="gs-live" role="status" aria-live="polite"></span></div>`),document.body.append(S);let e=S.querySelector("input");O=0,e.oninput=()=>(O=0,Ee()),e.onkeydown=(n)=>{let a={ArrowDown:1,ArrowUp:-1}[n.key]??(n.ctrlKey&&n.key==="n"?1:n.ctrlKey&&n.key==="p"?-1:0);if(a)n.preventDefault(),_e((O+a+P.length)%P.length);else if(n.key==="Enter")n.preventDefault(),Ht(O)};let t=S.querySelector(".gs-list");t.onclick=(n)=>{let a=n.target.closest(".gs-i");if(a)Ht(+a.dataset.n)},t.onpointermove=(n)=>{let a=n.target.closest(".gs-i");if(a&&+a.dataset.n!==O)_e(+a.dataset.n)},S.onclick=(n)=>n.target===S&&S.close(),S.onclose=()=>(S.remove(),S=null),S.showModal(),Ee(),fetch("/chats").then((n)=>n.json()).then((n)=>{if(Bt=n.chats??[],S)Ee()}).catch(()=>{})}var Sn=`dialog.gs{border:0;padding:0;margin:14vh auto auto;background:none;width:min(560px,calc(100vw - 32px));color:var(--ink);overflow:visible}
|
|
3
3
|
dialog.gs::backdrop{background:rgb(0 0 0/.35)}
|
|
4
4
|
.gs-box{display:flex;flex-direction:column;max-height:min(480px,72vh);background:var(--bg);border:1px solid var(--line);border-radius:10px;box-shadow:0 16px 40px rgb(0 0 0/.25);overflow:hidden}
|