glimmervoid 0.52.3-next.855 → 0.52.3-next.857
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/glimmervoid.js +9 -9
- package/dist/chunks/agent-api-cli-BhkFT3bA.js +1 -0
- package/dist/chunks/{agent-api-cli-B_jkEGg1.js → agent-api-cli-ChgZJ5wE.js} +1 -1
- package/dist/chunks/{agent-api-core-DAgiGgT8.js → agent-api-core-CHoEoSF4.js} +3 -3
- package/dist/chunks/{host-cli-D239oCSA.js → host-cli-BYE6Tp0E.js} +1 -1
- package/dist/chunks/{main-BuurWS79.js → main-BGIzJLpr.js} +3 -3
- package/dist/chunks/{packs-cli-DNl-vg8k.js → packs-cli-IR347Coe.js} +1 -1
- package/dist/chunks/{pr-flows-cli-BJ14BYKy.js → pr-flows-cli-IAAAru2F.js} +2 -2
- package/dist/chunks/settings-cli-B47zWe9s.js +1 -0
- package/dist/chunks/{settings-cli-CzBhdojc.js → settings-cli-P6tAQf0d.js} +1 -1
- package/dist/chunks/{ssh-sign-cli-D1BbnyNS.js → ssh-sign-cli-D2zn_WTM.js} +1 -1
- package/dist/client/assets/{agent-core-BadgKzKF.js → agent-core-QaO-cL5S.js} +2 -2
- package/dist/client/assets/agent-core-QaO-cL5S.js.br +0 -0
- package/dist/client/assets/{agent-mark--zgMeJWs.js → agent-mark-DLq6N-1P.js} +1 -1
- package/dist/client/assets/agent-mark-DLq6N-1P.js.br +0 -0
- package/dist/client/assets/{arena-panel-DexXM5ZI.js → arena-panel-MckT97sK.js} +2 -2
- package/dist/client/assets/arena-panel-MckT97sK.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-DIzWyMlj.js → benchmark-panel-D1oKyaaU.js} +1 -1
- package/dist/client/assets/benchmark-panel-D1oKyaaU.js.br +0 -0
- package/dist/client/assets/{boards-view-CF7LMyq8.js → boards-view-DEfz3LXf.js} +1 -1
- package/dist/client/assets/boards-view-DEfz3LXf.js.br +0 -0
- package/dist/client/assets/{community-panel-Be5ua1sN.js → community-panel-DeXYMcVM.js} +1 -1
- package/dist/client/assets/community-panel-DeXYMcVM.js.br +0 -0
- package/dist/client/assets/{dialogs-g0wjP_DO.js → dialogs-DeNhWrq0.js} +1 -1
- package/dist/client/assets/dialogs-DeNhWrq0.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-CzKZhCxJ.js → doc-editor-ui-qiUAkgrk.js} +1 -1
- package/dist/client/assets/doc-editor-ui-qiUAkgrk.js.br +0 -0
- package/dist/client/assets/{feature-hint-gteOHjfY.js → feature-hint-BLcSuUI-.js} +1 -1
- package/dist/client/assets/feature-hint-BLcSuUI-.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-B3TjARXd.js → first-run-checklist-Cg545_cC.js} +1 -1
- package/dist/client/assets/first-run-checklist-Cg545_cC.js.br +0 -0
- package/dist/client/assets/{hooks-panel-WsaB8bPr.js → hooks-panel-DFeA4Whi.js} +1 -1
- package/dist/client/assets/hooks-panel-DFeA4Whi.js.br +0 -0
- package/dist/client/assets/{index-TGlDg84u.js → index-CS1WCbXX.js} +6 -6
- package/dist/client/assets/index-CS1WCbXX.js.br +0 -0
- package/dist/client/assets/{issues-panel-DKJzoqmB.js → issues-panel-ogwSMK2J.js} +1 -1
- package/dist/client/assets/issues-panel-ogwSMK2J.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-DHtlaeJz.js → lane-read-token-step-CcLCpi7I.js} +1 -1
- package/dist/client/assets/lane-read-token-step-CcLCpi7I.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-7NDgEZV9.js → my-prs-panel-DkOkbLqg.js} +1 -1
- package/dist/client/assets/my-prs-panel-DkOkbLqg.js.br +0 -0
- package/dist/client/assets/{nyan-cat-CpxK5zne.js → nyan-cat-C-VIOfWJ.js} +1 -1
- package/dist/client/assets/nyan-cat-C-VIOfWJ.js.br +0 -0
- package/dist/client/assets/{phone-shell-CwV9Bbu6.js → phone-shell-BDaNq42f.js} +1 -1
- package/dist/client/assets/phone-shell-BDaNq42f.js.br +0 -0
- package/dist/client/assets/{plan-face-CgXtpYfu.js → plan-face-BWOXiL-I.js} +1 -1
- package/dist/client/assets/plan-face-BWOXiL-I.js.br +0 -0
- package/dist/client/assets/{plan-render-1Lc3vxd4.js → plan-render-BRK9_3s8.js} +1 -1
- package/dist/client/assets/plan-render-BRK9_3s8.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-pl8VzlPc.js → pr-queue-columns-B-x0t1Iv.js} +1 -1
- package/dist/client/assets/pr-queue-columns-B-x0t1Iv.js.br +0 -0
- package/dist/client/assets/{radar-panel-BmuLWhvV.js → radar-panel-J1gE_fbu.js} +1 -1
- package/dist/client/assets/radar-panel-J1gE_fbu.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-DrnTExnG.js → repo-roots-adder-DtEMQL0F.js} +1 -1
- package/dist/client/assets/repo-roots-adder-DtEMQL0F.js.br +0 -0
- package/dist/client/assets/{resume-dialog-DNRnVCO1.js → resume-dialog-Bzol4epg.js} +1 -1
- package/dist/client/assets/resume-dialog-Bzol4epg.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-DBN3OAG3.js → review-queue-panel-CuytUn5I.js} +1 -1
- package/dist/client/assets/review-queue-panel-CuytUn5I.js.br +0 -0
- package/dist/client/assets/{session-row-BmQlDxys.js → session-row-DwDl-WaK.js} +1 -1
- package/dist/client/assets/session-row-DwDl-WaK.js.br +0 -0
- package/dist/client/assets/{settings-panel-DaQA4Q8p.js → settings-panel-CkynqqHG.js} +2 -2
- package/dist/client/assets/settings-panel-CkynqqHG.js.br +0 -0
- package/dist/client/assets/{trace-panel-a7rGK9nU.js → trace-panel-1FsfFmLQ.js} +1 -1
- package/dist/client/assets/trace-panel-1FsfFmLQ.js.br +0 -0
- package/dist/client/assets/{usage-panel-Dw34fIgP.js → usage-panel-B8Iuuba1.js} +1 -1
- package/dist/client/assets/usage-panel-B8Iuuba1.js.br +0 -0
- package/dist/client/assets/{your-day-tip-CMbaByo0.js → your-day-tip-ObU2fTgK.js} +1 -1
- package/dist/client/assets/your-day-tip-ObU2fTgK.js.br +0 -0
- package/dist/client/index.html +4 -4
- package/dist/client/index.html.br +0 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/agent-api-cli-DZd9VPgs.js +0 -1
- package/dist/chunks/settings-cli-CYAadJNV.js +0 -1
- package/dist/client/assets/agent-core-BadgKzKF.js.br +0 -0
- package/dist/client/assets/agent-mark--zgMeJWs.js.br +0 -0
- package/dist/client/assets/arena-panel-DexXM5ZI.js.br +0 -0
- package/dist/client/assets/benchmark-panel-DIzWyMlj.js.br +0 -0
- package/dist/client/assets/boards-view-CF7LMyq8.js.br +0 -0
- package/dist/client/assets/community-panel-Be5ua1sN.js.br +0 -0
- package/dist/client/assets/dialogs-g0wjP_DO.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-CzKZhCxJ.js.br +0 -0
- package/dist/client/assets/feature-hint-gteOHjfY.js.br +0 -0
- package/dist/client/assets/first-run-checklist-B3TjARXd.js.br +0 -0
- package/dist/client/assets/hooks-panel-WsaB8bPr.js.br +0 -0
- package/dist/client/assets/index-TGlDg84u.js.br +0 -0
- package/dist/client/assets/issues-panel-DKJzoqmB.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-DHtlaeJz.js.br +0 -0
- package/dist/client/assets/my-prs-panel-7NDgEZV9.js.br +0 -0
- package/dist/client/assets/nyan-cat-CpxK5zne.js.br +0 -0
- package/dist/client/assets/phone-shell-CwV9Bbu6.js.br +0 -0
- package/dist/client/assets/plan-face-CgXtpYfu.js.br +0 -0
- package/dist/client/assets/plan-render-1Lc3vxd4.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-pl8VzlPc.js.br +0 -0
- package/dist/client/assets/radar-panel-BmuLWhvV.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-DrnTExnG.js.br +0 -0
- package/dist/client/assets/resume-dialog-DNRnVCO1.js.br +0 -0
- package/dist/client/assets/review-queue-panel-DBN3OAG3.js.br +0 -0
- package/dist/client/assets/session-row-BmQlDxys.js.br +0 -0
- package/dist/client/assets/settings-panel-DaQA4Q8p.js.br +0 -0
- package/dist/client/assets/trace-panel-a7rGK9nU.js.br +0 -0
- package/dist/client/assets/usage-panel-Dw34fIgP.js.br +0 -0
- package/dist/client/assets/your-day-tip-CMbaByo0.js.br +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{An as e,Cn as t,Dn as n,En as r,Fn as i,In as a,Ln as o,Mn as s,Nn as c,On as l,Pn as u,Rn as d,Sn as f,Tn as p,_n as m,an as h,f as g,jn as _,kn as v,on as y,pn as b,rn as x,s as S,sn as C,wn as w,xn as T,yn as E}from"./dom-helpers-C7CaSePf.js";import{$t as D,D as O,Qt as ee,Si as te,Xt as k,Zt as A,a as ne,an as re,c as ie,d as j,en as ae,f as oe,gi as se,i as M,in as ce,l as le,m as ue,n as N,nn as de,o as fe,p as pe,r as me,rn as he,s as ge,t as _e,tn as ve,u as ye,vi as be}from"./index-TGlDg84u.js";import{i as xe}from"./action-status-B5J9yJlM.js";import{O as Se,a as Ce,k as we,r as Te,t as P}from"./button-C8v9_rcy.js";import{n as Ee,t as De}from"./menu-nocBEdDd.js";import{a as Oe,r as ke}from"./card-registry-Ct6a2qHl.js";import{a as Ae,i as je,n as F}from"./modal-DAfPARiv.js";import{i as Me,t as Ne}from"./plan-render-1Lc3vxd4.js";var Pe=new WeakMap,Fe=/^(?:0|[1-9]\d{0,9})$/,Ie=4294967294;function Le(e){return Fe.test(e)&&Number(e)<=Ie}function Re(e,t){return Le(t)?e.indexKeyIdsByKind:e.idsByKind}function ze(e){return e?.kind===`box`?v(e)?.asset??null:null}function Be(e,t,n){if(t===null)return;let r=(e.assetRefCount.get(t)??0)+n;r>0?e.assetRefCount.set(t,r):e.assetRefCount.delete(t)}function Ve(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`wire`?[e.from,e.to]:e.kind===`note`?[e.on]:e.kind===`frame`?e.contains:[]}function He(e,t,n){t.kind===`box`&&t.step!==null&&(n?e.stepBoxIds.add(t.id):e.stepBoxIds.delete(t.id))}function Ue(e){return e.kind===`note`?e.ref!==null:e.kind===`box`&&(e.refs.length>0||l(e).some(e=>e.ref!==null))}function We(e,t){Ue(t)?e.anchoredIds.add(t.id):e.anchoredIds.delete(t.id)}function Ge(e,t){for(let n of Ve(t)){let r=e.dependentIdsByBoxId.get(n)??new Set;r.add(t.id),e.dependentIdsByBoxId.set(n,r)}}function Ke(e,t){let n=Re(e,t.id),r=n.get(t.kind)??new Set;r.add(t.id),n.set(t.kind,r),e.elementCount+=1,Be(e,ze(t),1),Ge(e,t),He(e,t,!0),We(e,t)}function qe(e){let t=Pe.get(e);if(t)return t;let n={elementCount:0,idsByKind:new Map,indexKeyIdsByKind:new Map,assetRefCount:new Map,dependentIdsByBoxId:new Map,stepBoxIds:new Set,anchoredIds:new Set};for(let t of Object.values(e))Ke(n,t);return Pe.set(e,n),n}var Je=26,Ye=97;function Xe(e){return e.step!==null}function Ze(e){return[...qe(e.elements).stepBoxIds].flatMap(t=>{let n=e.elements[t];return n?.kind===`box`&&Xe(n)?[n]:[]})}function Qe(e,t,n){return[...qe(e.elements).dependentIdsByBoxId.get(t)??[]].flatMap(r=>{let i=e.elements[r];return i?.kind===`wire`&&i.to===t&&i.from!==t&&n.has(i.from)?[i]:[]})}function $e(e,t){let n=new Map;for(let r of t){let i=Qe(e,r,t).map(e=>e.from);i.length>0&&n.set(r,i)}return n}function et(e){let t=String.fromCharCode(Ye+e%Je),n=Math.floor(e/Je);return n===0?t:`${t}${n+1}`}function tt(e,t){let n=new Map,r=new Set;function i(e){let a=n.get(e);if(a!==void 0)return a;if(r.has(e))return 0;r.add(e);let o=1+Math.max(0,...(t.get(e)??[]).map(i));return r.delete(e),n.set(e,o),o}for(let t of e)i(t);return n}function nt(e){let t=Ze(e),n=$e(e,new Set(t.map(e=>e.id))),r=tt(t.map(e=>e.id),n),i=new Map;for(let e of t){let t=r.get(e.id)??1;i.set(t,[...i.get(t)??[],e])}let a=new Map,o=[];for(let e of[...i.keys()].sort((e,t)=>e-t)){let t=(i.get(e)??[]).sort((e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id));for(let[n,r]of t.entries())a.set(r.id,t.length===1?String(e):`${e}${et(n)}`),o.push(r)}return o.map(e=>({boxId:e.id,title:e.title,status:e.step.status,level:r.get(e.id)??1,label:a.get(e.id)??``,afterLabels:(n.get(e.id)??[]).flatMap(e=>a.get(e)??[]),linkedBoardId:e.step.linkedBoardId}))}Object.freeze({stepWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedStepIds:[],notChecked:null});var rt=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function it(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function at(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function I(e){let t=rt.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(it(n))return{error:`an absolute path is never read; name the file relative to the code session worktree`};if(n.split(/[\\/]/).includes(`..`))return{error:`a path with .. is never read; name the file relative to the code session worktree`};let r=t[2]?Number(t[2]):null,i=t[3]?Number(t[3]):r;return r!==null&&i!==null&&i<r?{error:`the line range ends before it starts`}:{path:at(n),startLine:r,endLine:i}}function ot(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function st(e){let t=`${e.kind} ${e.id}`;switch(e.kind){case`box`:return[...e.refs.map(n=>({elementId:e.id,ref:n,where:t})),...ot(t,e.id,l(e))];case`note`:return e.ref?[{elementId:e.id,ref:e.ref,where:t}]:[];case`frame`:case`wire`:return[]}}function ct(e){return[...new Set(st(e).map(e=>e.ref))]}function lt(e){let t=I(e);return`path`in t?t.path:null}var L=40,ut=220,dt=90,ft=30,pt=18,mt=12,ht=20,gt=18,_t=28,vt=12,yt=2,bt=20,xt=26,St=18,Ct=26,wt=170,Tt=21,Et=17,Dt=10,Ot=22,kt=24,At=8,jt=40,Mt=18,Nt=8,Pt=320,Ft=256,It=160;function Lt(e,t){let n=e.split(/\s+/).filter(Boolean),r=[],i=``;for(let e of n){let n=e.match(RegExp(`.{1,${t}}`,`g`))??[e];for(let e of n){let n=i?`${i} ${e}`:e;n.length<=t?i=n:(r.push(i),i=e)}}return i&&r.push(i),r.length>0?r:[``]}function Rt(e,t,n){let r=e.icon?n-3:n,i=e.muted?2:0,a=e.style===`numbered`?`${t}.`:e.style===`kv`?e.key:null,o=(t,n,r,i)=>({text:t,muted:e.muted,style:e.style,marker:n===0?i:null,indentChars:r,isFirstRow:n===0,icon:e.icon});if(a&&a.length+1>vt){let t=Lt(e.text,r-i-yt).map(e=>o(e,1,yt,null));return[o(``,0,0,a),...t]}let s=e.style===`item`?yt:a?a.length+1:0;return Lt(e.text,r-i-s-+(e.style===`code`)).map((e,t)=>o(e,t,s,a))}function zt(e,t=xt){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,Rt(e,n,t)))}function Bt(e){return e.shape===`icon`?It:e.shape===`device`?u[e.device].defaultBoxWidth:ut}function Vt(e){return e.width??Bt(e)}function Ht(e,t){return Math.floor(e*(t-24)/196)}function Ut(e){let t=e.icon?2:0;return e.shape===`icon`?{lines:[],media:null,device:null,fit:`fit`,glyphRoom:56,titleIconChars:0}:e.shape===`device`?{lines:[],media:e.media,device:e.device,fit:e.fit,glyphRoom:0,titleIconChars:t}:{lines:e.lines,media:e.media,device:null,fit:`fit`,glyphRoom:0,titleIconChars:t}}function Wt(e,t){let{screen:n,bezel:r,toolbarHeight:i,base:a}=u[e],o=d(e),s=t/o.width;return{width:t,height:Math.round(o.height*s),scale:s,screen:{x:Math.round(((a?.overhang??0)+r.side)*s),y:Math.round((r.top+i)*s),width:Math.round(n.width*s),height:Math.round(n.height*s)}}}function Gt(e,t){let n=t-24,r=Math.round(Pt*t/ut),i=Math.min(r,Math.max(1,Math.round(n*e.height/e.width)));return{width:n,height:i,scale:1,screen:{x:0,y:0,width:n,height:i}}}function Kt(e,t){return e.device?Wt(e.device,t-24):e.media?Gt(e.media,t):null}function qt(e,t,n,r){let{media:i}=e;return!i||!r?null:{kind:i.kind,asset:i.asset,mime:i.mime,hasPreview:i.hasPreview,alt:i.alt,fit:e.fit,x:t.x+mt+r.screen.x,y:t.y+n+r.screen.y,width:r.screen.width,height:r.screen.height}}function Jt(e,t,n,r){if(!e.device||!r)return null;let i=t.x+mt,a=t.y+n,o={x:i+r.screen.x,y:a+r.screen.y,width:r.screen.width,height:r.screen.height};return{name:e.device,scale:r.scale,x:i,y:a,width:r.width,height:r.height,screen:o}}var Yt=new WeakMap,Xt=new WeakMap;function Zt(e){let t=Yt.get(e);if(t)return t;let n=Qt(e);return Yt.set(e,n),n}function Qt(e){let t=Ut(e),n=e.step?Mt:0,r=+!!e.step?.linkedBoardId,i=Vt(e),a=Ht(bt,i),o=Lt(e.title,a-t.titleIconChars),s=e.change===`relabeled`&&e.was?Lt(e.was,a):[],c=zt(t.lines,Ht(xt,i)),l=mt+n+t.glyphRoom+(s.length+o.length)*ht+(c.length+r)*gt,u=Kt(t,i),d=u?u.height+Nt:0,f=l+mt+d,p=e.shape===`decision`?e.outputs:[];return{titleLines:o,wasLines:s,bodyLines:c,headerHeight:f,outputs:p,content:t,artTop:l+Nt,art:u,height:f+p.length*_t}}function $t(e,t){switch(t.kind){case`box`:e.box.push(t);return;case`frame`:e.frame.push(t);return;case`wire`:e.wire.push(t);return;case`note`:e.note.push(t);return}}function en(e){let t={box:[],frame:[],wire:[],note:[]};for(let n of Object.values(e.elements))$t(t,n);return{...e,elementsByKind:t,planStepById:new Map(nt(e).map(e=>[e.boxId,e]))}}function R(e,t){return e.elementsByKind[t]}function tn(e){let t=Xt.get(e);if(t)return t;let n=Lt(e.text,Tt),r={lines:n,height:24+(n.length+1)*Et};return Xt.set(e,r),r}function nn(e){let t=new Map;for(let n of R(e,`note`)){let e=t.get(n.on),r=tn(n).height;t.set(n.on,e===void 0?r:e+Dt+r)}return t}function rn(e,t){return t.step?{label:e.get(t.id)?.label??``,status:t.step.status,linkedBoardId:t.step.linkedBoardId}:null}function an(e,t,n){let r=Zt(t),i=Vt(t);return{kind:`box`,id:t.id,x:n.x,y:n.y,width:i,height:r.height,titleLines:r.titleLines,icon:t.icon,bodyLines:r.bodyLines,change:t.change,wasLines:r.wasLines,shape:t.shape,headerHeight:r.headerHeight,media:qt(r.content,n,r.artTop,r.art),device:Jt(r.content,n,r.artTop,r.art),step:rn(e,t),outputs:r.outputs.map((e,t)=>({id:e.id,label:e.label,port:{x:n.x+i,y:n.y+r.headerHeight+t*_t+_t/2}}))}}function on(e,t,n){let r=e.y+e.height/2-n.height/2,i=e.x+e.width/2-n.width/2;switch(t.side){case`right`:return{x:e.x+e.width+t.gap,y:r};case`left`:return{x:e.x-n.width-t.gap,y:r};case`bottom`:return{x:i,y:e.y+e.height+t.gap};case`top`:return{x:i,y:e.y-n.height-t.gap}}}function sn(e,t,n,r){let i=on(r,n,{width:Vt(t),height:Zt(t).height});return an(e,t,{x:Math.round(i.x),y:Math.round(i.y)})}function cn(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+dt:L,y:t}}function ln(e,t,n,r){let i=R(e,`box`).filter(e=>e.at===null&&e.near!==null),a=new Set(i.map(e=>e.id)),o=(i,s)=>{let c=n.get(i.id);if(c||!i.near)return c;let l=e.elements[i.near.of],u=l?.kind===`box`&&!s.has(l.id)&&(n.has(l.id)||a.has(l.id))?o(l,new Set([...s,i.id])):void 0;u||r.push(`box ${i.id} sits near ${i.near.of}, which is not placed on the board`);let d=u?sn(e.planStepById,i,i.near,u):an(e.planStepById,i,cn(n,t));return n.set(i.id,d),d};for(let e of i)o(e,new Set)}function un(e){return e.shape===`panel`&&e.step===null&&e.near===null&&e.at===null}function dn(e,t,n,r){let i=R(e,`box`).filter(un).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id));if(i.length===0)return;let a=[...r.values()].reduce((e,t)=>Math.max(e,t.x+t.width+(n.has(t.id)?146:0)),-1/0),o=r.size>0?Math.round(a+dt):L,s=t;for(let t of i){let i=an(e.planStepById,t,{x:o,y:s});r.set(t.id,i),s+=Math.max(i.height,(n.get(t.id)??0)-At)+ft}}function fn(e,t,n,r){let i=new Map,a=[];for(let t of R(e,`box`)){let n=r.get(t.id);n&&i.set(t.id,an(e.planStepById,t,n))}for(let t of R(e,`box`))t.at&&i.set(t.id,an(e.planStepById,t,t.at));ln(e,t,i,a),dn(e,t,n,i);for(let n of R(e,`box`))i.has(n.id)||i.set(n.id,an(e.planStepById,n,cn(i,t)));return{boxesById:i,warnings:a}}function pn(e,t){let n=ye(e.contains.flatMap(e=>t.get(e)??[]));return n?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-St,y:n.y-St-Ct,width:n.width+36,height:n.height+36+Ct}:null}function mn(e,t){return R(e,`frame`).flatMap(e=>pn(e,t)??[])}function hn(e){return{x:e.x,y:e.y,width:e.width,height:Ct}}function gn(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function _n(e,t,n){let{lines:r,height:i}=tn(e);return{kind:`note`,id:e.id,x:t.x+t.width-kt,y:n,width:wt,height:i,lines:r,byline:gn(e),isResolved:e.resolvedBy!==null}}function vn(e,t){let n=new Map;return R(e,`note`).flatMap(e=>{let r=t.get(e.on);if(!r)return[];let i=_n(e,r,n.get(e.on)??r.y-At);return n.set(e.on,i.y+i.height+Dt),[i]})}function yn(e){return{x:0,y:0,width:L,height:e}}function bn(e){return e?{x:Math.min(0,e.x-L),y:Math.min(0,e.y-L),width:e.width+80,height:e.height+80}:{x:0,y:0,width:80,height:80}}function xn(e,t,n){let r=e.flatMap(e=>e.kind===`wire`?[]:[e]);return bn(ye([...r,...t?[t]:[],yn(n)]))}function Sn(e,t){return`box ${e} overlaps box ${t}`}function Cn(e,t){return`box ${e} covers the title of frame ${t}`}function wn(e,t,n){let r=[...e.values()],i=oe(r).flatMap(([e,t])=>{let n=r[e],i=r[t];return n&&i&&ie(n,i)?[Sn(n.id,i.id)]:[]}),a=new Map(R(n,`frame`).map(e=>[e.id,new Set(e.contains)])),o=ue(r,Ft),s=t.flatMap(e=>{let t=hn(e),n=[];return pe(o,t,i=>{let o=r[i];o&&!a.get(e.id)?.has(o.id)&&ie(o,t)&&n.push(i)}),n.sort((e,t)=>e-t).map(t=>Cn(r[t]?.id??``,e.id))});return[...i,...s]}function Tn(e,t,n){let{boxesById:r,warnings:i}=fn(e,t.boxesTop,t.stackHeightByBoxId,t.stepBandPositions),a=mn(e,r),o=vn(e,r);return{boxesById:r,frames:a,notes:o,routing:le({wires:R(e,`wire`),boxesById:r,softObstacles:[...o,...a.map(hn)],loopFrames:a.filter(e=>e.isLoop),contentTop:t.contentTop},n),collectPlacementWarnings:()=>[...i,...wn(r,a,e)]}}function En(e){return e.step!==null&&e.near===null&&e.at===null}function Dn(e){let t=new Map;for(let n of Object.values(e.elements))n.kind===`box`&&En(n)&&t.set(n.id,n);let n=new Map;if(t.size===0)return{positionById:n,bottom:L,columns:[]};let r=new Map;for(let n of nt(e)){let e=t.get(n.boxId);e&&r.set(n.level,[...r.get(n.level)??[],e])}let i=L,a=L,o=[];for(let e of[...r.keys()].sort((e,t)=>e-t)){let t=r.get(e)??[],s=70,c=s;for(let e of t)n.set(e.id,{x:i,y:s}),s+=Zt(e).height,c=s,a=Math.max(a,s),s+=ft;t.length>0&&o.push({x:i,bottom:c,boxCount:t.length}),i+=Math.max(...t.map(Vt))+dt}return{positionById:n,bottom:a+jt,columns:o}}function On(e){return e-pt}function kn(e,t){let n=(e?.columns??[]).flatMap(e=>{let n=t.filter(t=>t.x===e.x);return n.length>=e.boxCount?[]:[e.bottom-n.reduce((e,t)=>e+t.height+ft,0)]});return n.length===0?0:Math.max(L,...n)+jt-L}function An(e,t){if(t===0)return e;let n=Object.fromEntries(Object.entries(e.elements).map(([e,n])=>n.kind!==`box`||!n.at?[e,n]:[e,{...n,at:{x:n.at.x,y:n.at.y+t}}]));return{...e,elements:n}}var jn={plain:null,fail:`failure path`,join:`joins`};function Mn(e,t,n){return`${e}|${t}|${n}`}function Nn(e,t,n){let r=[jn[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var Pn={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function Fn(e){return y.flatMap(t=>t===`none`||!e.has(t)?[]:[{label:Pn[t],swatch:{kind:`change`,change:t}}])}function In(e){return e?T.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}})):[]}function Ln(e){return Rn(e.legend,R(e,`wire`),new Set(R(e,`box`).map(e=>e.change)),e.planStepById.size>0)}function Rn(e,t,n,r){let i=new Map(e.map(e=>[Mn(e.tone,e.dashed||e.back,e.back),e.label])),a=new Set,o=[...t].flatMap(e=>{let t=e.dashed||e.back,n=Mn(e.tone,t,e.back),r=i.get(n)??Nn(e.tone,t,e.back);return a.has(n)||r===null?[]:(a.add(n),[{key:n,label:r,swatch:{kind:`wire`,tone:e.tone,isDashed:t,isBack:e.back}}])}).sort((e,t)=>e.key.localeCompare(t.key)),s=e.filter(e=>!a.has(Mn(e.tone,e.dashed||e.back,e.back))).map(e=>({label:e.label,swatch:{kind:`wire`,tone:e.tone,isDashed:e.dashed||e.back,isBack:e.back}}));return[...o.map(({label:e,swatch:t})=>({label:e,swatch:t})),...s,...Fn(n),...In(r)]}function zn(e){return Bn(e,null).layout}function Bn(e,t){let{positionById:n,bottom:r,columns:i}=Dn(e),a=r-L,o=en(An(e,a)),s=nn(o),c=r,l=Tn(o,{boxesTop:c,contentTop:On(r),stackHeightByBoxId:s,stepBandPositions:n},t?.route??null),u={route:l.routing.memory},d=[...l.frames,...l.routing.wires,...l.boxesById.values(),...l.notes],f=Vn(o.caption,xn(d,l.routing.extent,c),Ln(o),n.size>0?i:[],a),p=[...l.routing.collectWarnings(),j(l.collectPlacementWarnings())];return{layout:{elements:d,...f,warnings:ne(p)},memory:u,warningLists:p}}function Vn(e,t,n,r,i){let a=t.y+t.height,o=n.map((e,t)=>({...e,x:L,y:a+t*Ot})),s=a+o.length*Ot+(o.length>0?12:0),c=e?{text:e,x:L,y:s}:null,l=o.length*Ot+(c?30:0)+(o.length>0?12:0);return{legend:o,caption:c,pinnedOffsetY:i,plan:r.length>0?{titleAt:{x:L,y:56},columns:[...r]}:null,bounds:{...t,height:t.height+l}}}function Hn(e){return JSON.stringify(e)}function Un(e,t,n){let r=e.outputs.map(e=>({...e,port:{x:e.port.x+t,y:e.port.y+n}})),i=e.media?{...e.media,x:e.media.x+t,y:e.media.y+n}:null,a=e.device?{...e.device,x:e.device.x+t,y:e.device.y+n,screen:{...e.device.screen,x:e.device.screen.x+t,y:e.device.screen.y+n}}:null;return{...e,x:e.x+t,y:e.y+n,outputs:r,media:i,device:a}}function Wn(e,t){let n=new Set(t),r=!0;for(;r;){r=!1;for(let t of Object.values(e.elements)){let e=t.kind===`box`?t.near?.of:t.kind===`note`?t.on:void 0;!n.has(t.id)&&e&&n.has(e)&&(n.add(t.id),r=!0)}}return n}function Gn(e,t,n){let r=Wn(e,n),i=new Map,a=[],o=[],s=[];for(let e of t.elements)e.kind===`box`&&i.set(e.id,e),e.kind===`note`&&r.has(e.id)&&o.push(e),e.kind===`note`&&!r.has(e.id)&&a.push(e),e.kind===`frame`&&a.push(hn(e)),e.kind===`frame`&&e.isLoop&&s.push(e);let c=[...r].flatMap(e=>i.get(e)??[]),l=Object.values(e.elements).flatMap(e=>e.kind===`wire`&&(r.has(e.from)||r.has(e.to))?[e]:[]),u=On(t.pinnedOffsetY+L);return(e,t)=>{let n=c.map(n=>Un(n,e,t));for(let e of n)i.set(e.id,e);let r=o.map(n=>({...n,x:n.x+e,y:n.y+t}));return[...n,...r,...ge({wires:l,boxesById:i,softObstacles:[...a,...r],loopFrames:s,contentTop:u})]}}var Kn=4,qn=200,Jn=2e4,Yn=1.1,Xn=[`wire`,`note`,`frame`,`box`],Zn={v:`select`,r:`box`,d:`decision`,p:`panel`,i:`icon`,m:`device`,a:`wire`},Qn=new Set([1,2]);function $n(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}function er(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function tr(){return document.documentElement.dataset.layout===`phone`}function nr(e){return e===`box`||e===`decision`||e===`panel`||e===`icon`||e===`device`}var rr={box:`Box`,decision:`Decision`,panel:`Panel`,icon:`Icon`,device:`Device`};function ir(e,t,n,r){let i={kind:`box`,id:er(`box`),title:t,icon:null,refs:[],change:`none`,was:null,near:null,order:0,at:e,width:null,step:null};switch(r){case`icon`:return{...i,shape:r,icon:c};case`device`:return{...i,shape:r,device:o,fit:`fill`,media:n};case`decision`:return{...i,shape:r,lines:[],media:n,outputs:[{id:`yes`,label:`yes`},{id:`no`,label:`no`}]};case`box`:case`panel`:return{...i,shape:r,lines:[],media:n}}}function ar(e){return e?.part!==`media`||!e.media?null:{boxId:e.id,href:e.media.href,alt:e.media.alt}}var or={body:`pointer`,port:`crosshair`,resize:`ew-resize`,link:`pointer`,media:`zoom-in`};function sr(e){return e?e.part===`body`&&e.kind===`box`?`move`:or[e.part]:``}var cr=2,lr=12/10;function ur(e){let{viewport:n,world:r,svg:i,canvas:a,renderer:o}=e,s=new Map,c=new Set,l={x:0,y:0,scale:1},u=null,d=null,f=null,p=`select`,m=null,h=!1;function g(t){p=t,n.dataset.tool=t,e.onToolChange(t)}function _(){r.style.transform=`translate(${-l.x*l.scale}px, ${-l.y*l.scale}px) scale(${l.scale})`,o.setCamera(l)}function v(){return(n.clientWidth||1)/l.scale}function y(){let e=n.getBoundingClientRect(),t=[...a.querySelectorAll(`.wb-island`)].filter(e=>e.checkVisibility()).map(e=>e.getBoundingClientRect()),r=e.top+e.height/2,i=t.filter(e=>e.top+e.height/2<r).map(t=>t.bottom-e.top),o=t.filter(e=>e.top+e.height/2>=r).map(t=>t.top-e.top),s=Math.max(0,...i),c=Math.min(e.height,...o)-s;return c<e.height/2?{topPx:0,heightPx:e.height}:{topPx:s,heightPx:c}}function b(){let e=o.layout();if(!e)return;let{bounds:t}=e,r=n.clientWidth,i=n.clientHeight;if(r===0||i===0){l={x:t.x,y:t.y,scale:1},_(),h=!0;return}h=!1;let a=y(),s=e.elements.length===0?1:cr,c=Math.max(1/s,t.width/r,t.height/a.heightPx),u=c>lr,d=u?lr:c,f=r*d,p=t.y+t.height/2,m=a.topPx+a.heightPx/2;l={x:t.x-Math.max(0,f-t.width)/2,y:u?t.y-a.topPx*d:p-m*d,scale:1/d},_()}function x(e,t){let r=n.getBoundingClientRect();return{x:l.x+(e-r.left-n.clientLeft)/l.scale,y:l.y+(t-r.top-n.clientTop)/l.scale}}function C(){return 1/l.scale}function w(e,t){let n=v(),r=Math.min(Jn,Math.max(qn,n*t))/n;l={x:e.x-(e.x-l.x)*r,y:e.y-(e.y-l.y)*r,scale:l.scale/r},_()}function T(e,t){l={...l,x:l.x-e/l.scale,y:l.y-t/l.scale},_()}function E(t){c=t,o.setSelection(c),e.onSelectionChange(c)}function D(e,t){if(!t){E(c.has(e)&&c.size===1?new Set:new Set([e]));return}let n=new Set(c);n.delete(e)||n.add(e),E(n)}function O(e,t){return{x:Math.round(t.x+e.latest.x-e.origin.x),y:Math.round(t.y+e.latest.y-e.origin.y-e.pinnedOffsetY)}}function ee(e,n){let r=Math.round(n.width+e.latest.x-e.origin.x);return Math.min(t.boxWidthMax,Math.max(t.boxWidthMin,r))}function te(t){if(t.mode===`resize`)return t.movingBoxes.map(e=>({boxId:e.boxId,fields:{width:ee(t,e.start)}}));let n=t.movingBoxes.map(e=>({boxId:e.boxId,at:O(t,e.start)})),r=e.currentBoard(),i=t.movingBoxes.filter(e=>{let t=r?.elements[e.boxId];return t?.kind===`box`&&En(t)}),a=t.pinnedOffsetY-kn(o.layout()?.plan??null,i.map(e=>e.start));return n.map(({boxId:e,at:t})=>({boxId:e,fields:{at:{x:t.x,y:t.y+a}}}))}function k(){f!==null&&cancelAnimationFrame(f),f=null}function A(e){return{x:Math.round(e.latest.x-e.origin.x),y:Math.round(e.latest.y-e.origin.y)}}function ne(e,t){let n=o.layout();if(e.mode!==`move`||!e.hasMoved||!n)return!1;let r=A(e);if(!e.preview||e.previewLayout!==n){let r=n.elements.find(t=>t.kind===`box`&&t.id===e.boxId),i=r?.kind===`box`?r:null;e.laidOutOffset=i?{x:i.x-e.start.x,y:i.y-e.start.y}:{x:0,y:0},e.preview=Gn(t,n,new Set(e.movingBoxes.map(e=>e.boxId))),e.previewLayout=n}return o.paintElements(e.preview(r.x-e.laidOutOffset.x,r.y-e.laidOutOffset.y)),!0}function re(e,t,n){let r=new Set(e.movingBoxes.map(e=>e.boxId)),i=new Map(n.elements.flatMap(e=>e.kind===`box`&&r.has(e.id)?[[e.id,e]]:[])),a={};for(let{boxId:n,fields:r}of te(e)){let e=t.elements[n],o=i.get(n);e?.kind===`box`&&o&&(a[n]={...e,...r,near:null,step:null,at:{x:o.x,y:o.y}})}let o=new Map;for(let e of zn({...t,elements:a}).elements){let t=i.get(e.id);e.kind===`box`&&t&&o.set(e.id,Un(e,t.x-e.x,t.y-e.y))}return Gn(t,{...n,elements:n.elements.map(e=>o.get(e.id)??e)},new Set(o.keys()))(0,0)}function ie(e,t){let n=o.layout();return e.mode!==`resize`||!e.hasMoved||!n?!1:(o.paintElements(re(e,t,n)),!0)}function j(){k();let t=e.currentBoard();u?.kind!==`drag`||!t?e.repaint():ne(u,t)||ie(u,t)||e.repaint()}function ae(){let t=e.currentBoard();u?.kind===`drag`&&t&&(ne(u,t)||ie(u,t))}function oe(){f===null&&(f=requestAnimationFrame(j))}function se(e){u?.kind===`drag`&&e?.elements[u.boxId]?.kind!==`box`&&(u=null),u?.kind===`drag`&&u.hasMoved&&(u.movingBoxes=u.movingBoxes.filter(t=>e?.elements[t.boxId]?.kind===`box`));let t=new Set([...c].filter(t=>e?.elements[t]));t.size!==c.size&&E(t)}function M(e,t){return o.hitTest(x(e,t))}function ce(){let[e,t]=[...s.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function le(){u?.kind===`wire`&&ye(u,!1),u={kind:`pinch`,distance:ce(),viewWidth:v()}}function ue(e){e.preventDefault(),s.set(e.pointerId,{x:e.clientX,y:e.clientY}),n.setPointerCapture(e.pointerId),u={kind:`pan`,pointerId:e.pointerId,lastClient:{x:e.clientX,y:e.clientY},hasMoved:!1,isAuxiliaryButton:!0,tappedBoxId:null,pressedImage:null}}function N(e){let t=x(e.clientX,e.clientY),n=document.createElementNS(`http://www.w3.org/2000/svg`,`rect`);n.setAttribute(`class`,`wb-wire-line wb-dashed wb-wire-draft`),u={kind:`marquee`,pointerId:e.pointerId,origin:t,latest:t,hasMoved:!1,isAdditive:e.shiftKey,baseSelection:e.shiftKey?new Set(c):new Set,outline:n}}function de(t,n,r){if(r||!c.has(t))return[{boxId:t,start:n}];let i=e.currentBoard();return[...c].flatMap(e=>{let t=i?.elements[e]?.kind===`box`?o.boundsOf(e):null;return t?[{boxId:e,start:t}]:[]})}function fe(t){if(d)return;if(t.pointerType===`mouse`&&Qn.has(t.button)&&!u){ue(t);return}if(t.button!==0)return;let r=M(t.clientX,t.clientY);if(r?.part===`link`&&r.linkedBoardId){e.onOpenLinkedBoard(r.linkedBoardId);return}if(s.set(t.pointerId,{x:t.clientX,y:t.clientY}),n.setPointerCapture(t.pointerId),s.size===2){le();return}if(nr(p)){pe(p,x(t.clientX,t.clientY));return}let i=r?.kind===`box`?o.boundsOf(r.id):null,a=r?.part===`resize`&&!tr()?i:null;if(r&&a){let e=x(t.clientX,t.clientY);u={kind:`drag`,mode:`resize`,pointerId:t.pointerId,boxId:r.id,origin:e,start:a,movingBoxes:de(r.id,a,!1),pinnedOffsetY:0,latest:e,hasMoved:!1,isAdditive:!1,pressedImage:null,preview:null,previewLayout:null,laidOutOffset:{x:0,y:0}};return}if(r?.kind===`box`&&r.port&&!tr()){ge(t.pointerId,r.id,r.port);return}let c=p===`wire`?i:null;if(r&&c){ge(t.pointerId,r.id,{x:c.x+c.width/2,y:c.y+c.height/2});return}let l=tr()?null:i;if(r&&l){let e=x(t.clientX,t.clientY),n=o.layout()?.pinnedOffsetY??0;u={kind:`drag`,mode:`move`,pointerId:t.pointerId,boxId:r.id,origin:e,start:l,movingBoxes:de(r.id,l,t.shiftKey),pinnedOffsetY:n,latest:e,hasMoved:!1,isAdditive:t.shiftKey,pressedImage:ar(r),preview:null,previewLayout:null,laidOutOffset:{x:0,y:0}};return}if(r&&!tr()){D(r.id,t.shiftKey);return}if(!r&&t.pointerType===`mouse`&&!tr()){N(t);return}let f=r?.kind===`box`?r.id:null;u={kind:`pan`,pointerId:t.pointerId,lastClient:{x:t.clientX,y:t.clientY},hasMoved:!1,isAuxiliaryButton:!1,tappedBoxId:f,pressedImage:ar(r)}}async function pe(t,n){if(g(`select`),!e.currentBoard())return;let r=o.layout()?.pinnedOffsetY??0,i=ir({x:Math.round(n.x),y:Math.round(n.y-r)},rr[t],null,t);m=i.id;let a=await e.sendOps([{op:`add`,element:i}]);a||(m=null),a&&E(new Set([i.id])),he()}async function me(t,r,i){if(!e.currentBoard())return!1;let a=i?x(i.x,i.y):{x:l.x+v()/2,y:l.y+(n.clientHeight||1)/l.scale/2},s=o.layout()?.pinnedOffsetY??0,c=ir({x:Math.round(a.x),y:Math.round(a.y-s)},t,r,`box`),u=await e.sendOps([{op:`add`,element:c}]);return u&&E(new Set([c.id])),u}function he(){if(!m||!o.boundsOf(m)||!e.currentBoard()?.elements[m])return;let t=m;m=null,je(t)}function ge(e,t,n){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);r.setAttribute(`class`,`wb-wire-line wb-dashed wb-wire-draft`),r.setAttribute(`d`,`M ${n.x} ${n.y} L ${n.x} ${n.y}`),i.append(r),u={kind:`wire`,pointerId:e,fromBoxId:t,start:n,draftLine:r,targetBoxId:null}}function _e(e,t){e.targetBoxId=t,o.setWireTarget(t)}function ve(e,t){let n=x(t.clientX,t.clientY);e.draftLine.setAttribute(`d`,`M ${e.start.x} ${e.start.y} L ${n.x} ${n.y}`);let r=o.hitTest(n);_e(e,r?.kind===`box`&&r.id!==e.fromBoxId?r.id:null)}function ye(t,n){let r=t.targetBoxId;_e(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function be(e,t){let n=x(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<Kn*C()||(e.hasMoved=!0,e.latest=n,oe())}function xe(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<Kn||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},T(n,r))}function Se(e,t){let n=x(t.clientX,t.clientY);if(!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<Kn*C())return;e.hasMoved||i.append(e.outline),e.hasMoved=!0,e.latest=n;let r=$n(e.origin,n);e.outline.setAttribute(`x`,String(r.x)),e.outline.setAttribute(`y`,String(r.y)),e.outline.setAttribute(`width`,String(r.width)),e.outline.setAttribute(`height`,String(r.height));let a=new Set([...e.baseSelection,...o.elementsInRect(r)]);a.size===c.size&&[...a].every(e=>c.has(e))||E(a)}function Ce(e){e.outline.remove(),e.hasMoved||e.isAdditive||E(new Set)}function we(e){let t=ce();if(t<=0||e.distance<=0)return;let n=[...s.values()];w(x(n.reduce((e,t)=>e+t.x,0)/n.length,n.reduce((e,t)=>e+t.y,0)/n.length),e.viewWidth*(e.distance/t)/v())}function Te(e){if(e.pointerType!==`mouse`||tr())return;let t=M(e.clientX,e.clientY);o.setHover(t?.kind===`box`?t.id:null),n.dataset.hoverKind=t?.kind??``,n.style.cursor=p===`select`?sr(t):``}function P(e){u||Te(e),s.has(e.pointerId)&&(s.set(e.pointerId,{x:e.clientX,y:e.clientY}),u?.kind===`pinch`?we(u):u?.kind===`drag`&&u.pointerId===e.pointerId?be(u,e):u?.kind===`wire`&&u.pointerId===e.pointerId?ve(u,e):u?.kind===`marquee`&&u.pointerId===e.pointerId?Se(u,e):u?.kind===`pan`&&u.pointerId===e.pointerId&&xe(u,e))}async function Ee(t,n){if(!t.hasMoved&&t.mode===`resize`)return;if(!t.hasMoved){D(t.boxId,t.isAdditive),t.pressedImage&&!t.isAdditive&&e.onOpenImage(t.pressedImage);return}k(),t.latest=x(n.clientX,n.clientY);let r=te(t),i=e.currentBoard();i&&!ne(t,i)&&ie(t,i),await e.sendOps(r.map(({boxId:e,fields:t})=>({op:`set`,id:e,fields:t})))||j()}function De(t){if(!s.delete(t.pointerId))return;let n=u;n?.kind===`pinch`?u=null:(u=null,n?.kind===`drag`&&n.pointerId===t.pointerId?Ee(n,t):n?.kind===`wire`?(ye(n,n.pointerId===t.pointerId),p===`wire`&&g(`select`)):n?.kind===`marquee`?Ce(n):n?.kind!==`pan`||n.hasMoved||n.isAuxiliaryButton||(n.pressedImage&&tr()?e.onOpenImage(n.pressedImage):n.tappedBoxId&&tr()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||E(new Set)))}function Oe(e){s.delete(e.pointerId);let t=u?.kind===`drag`;u?.kind===`wire`&&ye(u,!1),u?.kind===`marquee`&&u.outline.remove(),u=null,t&&j()}function ke(e){e.preventDefault(),e.ctrlKey||e.metaKey?w(x(e.clientX,e.clientY),e.deltaY>0?Yn:1/Yn):T(-e.deltaX,-e.deltaY)}function Ae(){let e=d;d=null,e?.remove()}function je(t){let r=e.currentBoard()?.elements[t],i=o.boundsOf(t);if(r?.kind!==`box`||!i)return;Ae();let s=a.getBoundingClientRect(),c=n.getBoundingClientRect(),u={left:c.left+n.clientLeft+(i.x-l.x)*l.scale,top:c.top+n.clientTop+(i.y-l.y)*l.scale,width:i.width*l.scale},f=S(`input`,`wb-title-input`);f.type=`text`,f.value=r.title,f.maxLength=80,f.setAttribute(`aria-label`,r.shape===`panel`?`Panel title`:`Box title`),f.style.left=`${u.left-s.left}px`,f.style.top=`${u.top-s.top}px`,f.style.width=`${Math.max(160,u.width)}px`,d=f,a.append(f),f.addEventListener(`keydown`,i=>{if(i.key===`Escape`){i.preventDefault(),Ae(),n.focus();return}if(i.key!==`Enter`)return;i.preventDefault();let a=f.value.trim();Ae(),n.focus(),a&&a!==r.title&&e.sendOps([{op:`set`,id:t,fields:{title:a}}])}),f.addEventListener(`blur`,Ae),f.focus(),f.select()}function F(e){if(tr())return;let t=M(e.clientX,e.clientY);t?.kind===`box`&&je(t.id)}function Me(){let t=e.currentBoard();if(!t||c.size===0)return;let n=[...c].flatMap(e=>t.elements[e]??[]),r=Xn.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));E(new Set),e.sendOps(r)}function Ne(e){if(e.target!==n||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),Me();return}let t=Zn[e.key.toLowerCase()];t&&!e.shiftKey?(e.preventDefault(),g(t)):e.key===`Escape`&&(E(new Set),g(`select`))}return r.style.transition=`none`,n.tabIndex=0,n.addEventListener(`pointerdown`,fe),n.addEventListener(`pointermove`,P),n.addEventListener(`pointerup`,De),n.addEventListener(`pointercancel`,Oe),n.addEventListener(`wheel`,ke,{passive:!1}),n.addEventListener(`dblclick`,F),n.addEventListener(`contextmenu`,e=>e.preventDefault()),n.addEventListener(`keydown`,Ne),n.addEventListener(`pointerleave`,()=>{u||(o.setHover(null),n.dataset.hoverKind=``)}),new ResizeObserver(()=>{h&&n.clientWidth>0&&n.clientHeight>0&&b()}).observe(n),{fit:b,selectedIds:()=>c,clearSelection:()=>E(new Set),pruneSelection:se,repaintPreview:ae,closeTitleInput:Ae,setTool:g,placeMediaBox:me,openPendingTitleEdit:he,focusCanvas:()=>n.focus()}}var dr=Object.freeze({box:b,frame:m,wire:w,note:E});Object.freeze({id:`operator`,name:`operator`});function fr(e){return C.some(t=>t===e)}function pr(e,t){if(e.kind!==`box`||t.shape===void 0||t.shape===e.shape||!fr(t.shape))return e;let r=n(t.shape);return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}Object.freeze({x:0,y:0});function mr(e,t,n){if(n[0]===`put`)return n[1].id===t?n[1]:null;if(n[0]===`remove`||!e)return null;let r=dr[e.kind].safeParse({...pr(e,n[1]),...n[1]});return r.success&&r.data.id===t?r.data:null}function hr(e,n,r,i){let a={...e.elements};for(let[e,t]of Object.entries(n.elements)){let n=a[e];if(t[0]===`remove`){if(!n)return null;delete a[e];continue}let r=mr(n,e,t);if(!r)return null;t[0]===`put`&&delete a[e],a[e]=r}return Object.keys(a).length>t.elements?null:{...e,...n.fields,elements:a,version:r,updatedAt:i}}var gr=Object.freeze({undo:[],redo:[]}),_r=new Set([`box`]),vr=[`wire`,`note`,`frame`,`box`],yr=new Set([`kind`,`id`]);function br(e,t){return JSON.stringify(e)===JSON.stringify(t)}function xr(e){return e.kind===`box`&&e.near?[e.near.of]:[]}function Sr(e){let t=new Set(e.map(e=>e.id)),n=[];for(;t.size>0;){let r=e.filter(e=>t.has(e.id)&&xr(e).every(e=>!t.has(e))),i=r.length>0?r:e.filter(e=>t.has(e.id));for(let e of i)t.delete(e.id);n.push(...i)}return n}function Cr(e,t){let n={...e},r=Object.fromEntries(Object.entries(t).filter(([e,t])=>!yr.has(e)&&!br(n[e],t)));return t.kind!==`note`||Object.keys(r).length===0?r:{...r,author:t.author,resolvedBy:t.resolvedBy}}function wr(e,t){let n={...e.title===t.title?{}:{title:t.title},...e.caption===t.caption?{}:{caption:t.caption},...br(e.legend,t.legend)?{}:{legend:t.legend},...e.codeSessionId===t.codeSessionId?{}:{codeSessionId:t.codeSessionId}};return Object.keys(n).length===0?[]:[{op:`board`,...n}]}function Tr(e,t){let n=Object.values(e.elements),r=Object.values(t.elements),i=vr.flatMap(e=>n.filter(n=>n.kind===e&&!t.elements[n.id])),a=Sr(r.filter(t=>!e.elements[t.id])),o=r.flatMap(t=>{let n=e.elements[t.id];if(!n||n===t)return[];let r=Cr(n,t);return Object.keys(r).length===0?[]:[{op:`set`,id:t.id,fields:r}]});return[...i.map(e=>({op:`remove`,id:e.id})),...a.filter(e=>_r.has(e.kind)).map(e=>({op:`add`,element:e})),...o,...a.filter(e=>!_r.has(e.kind)).map(e=>({op:`add`,element:e})),...wr(e,t)]}var Er=Object.freeze({id:`touched`,title:`touched`,version:0,caption:null,legend:[],codeSessionId:null,project:null,createdAt:0,updatedAt:0});function Dr(e,t){let n=Object.fromEntries(Object.entries(e.elements).flatMap(([e,t])=>t?[[e,t]]:[])),r={...Er,...e.fields,elements:n},i=hr(r,t,0,0);return i?Tr(i,r):[]}function Or(e,t){return t.length===0?[...e]:[...e,t].slice(-100)}function kr(e,t){return t.length===0?e:{undo:Or(e.undo,t),redo:[]}}function Ar(e,t){let n=e[t].at(-1);return n?{entry:n,history:{...e,[t]:e[t].slice(0,-1)}}:null}function jr(e,t,n){let r=t===`undo`?`redo`:`undo`;return{...e,[r]:Or(e[r],n)}}var Mr=16;function Nr(t){let n=we(24,24);return n.setAttribute(`width`,String(Mr)),n.setAttribute(`height`,String(Mr)),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.innerHTML=e[t].elements.join(``),n}function Pr(t){let n=S(`span`,`wb-icon-current`);return t?(n.append(Nr(t),S(`span`,`wb-icon-current-label`,e[t].label)),n):(n.append(S(`span`,`wb-icon-current-label`,`none`)),n)}function Fr(t,n){return t.includes(n)||e[t].label.toLowerCase().includes(n)}function Ir({field:t,icon:n,isRequired:r,accessibleName:i,commit:a}){let o=S(`div`,`wb-icon-picker`);o.dataset.field=t;let c=S(`div`,`wb-icon-popover`);c.hidden=!0,c.tabIndex=-1;let l=S(`input`,`wb-inspect-input wb-icon-search`);l.type=`search`,l.placeholder=`search icons`,l.setAttribute(`aria-label`,`Search icons for ${i}`);let u=new Map,d=()=>{c.hidden=!0,p.setAttribute(`aria-expanded`,`false`)},f=e=>{d(),p.focus(),e!==n&&a(e)},p=P({variant:`quiet`,size:`small`,label:`icon`,action:`icon-pick`,onClick:()=>{let e=c.hidden;c.hidden=!e,p.setAttribute(`aria-expanded`,String(e)),e&&l.focus()}});p.setAttribute(`aria-label`,i),p.setAttribute(`aria-expanded`,`false`),p.setAttribute(`aria-haspopup`,`true`);let m=_.map(t=>{let r=S(`div`,`wb-icon-group`),i=S(`div`,`wb-icon-grid`);for(let r of s.filter(n=>e[n].category===t)){let t=P({variant:`icon`,size:`small`,label:e[r].label,icon:Nr(r),action:`icon-choice`,onClick:()=>f(r)});t.dataset.icon=r,t.classList.add(`wb-icon-choice`),t.setAttribute(`aria-pressed`,String(r===n)),u.set(r,t),i.append(t)}return r.append(S(`span`,`wb-icon-group-label`,t),i),{group:r,grid:i}});l.addEventListener(`input`,()=>{let e=l.value.trim().toLowerCase();for(let[t,n]of u)n.hidden=!Fr(t,e);for(let{group:e,grid:t}of m)e.hidden=[...t.children].every(e=>e instanceof HTMLElement&&e.hidden)}),l.addEventListener(`keydown`,e=>{if(e.key!==`Enter`)return;e.preventDefault();let t=[...u].find(([,e])=>!e.hidden);t&&f(t[0])}),c.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),d(),p.focus())});let h=P({variant:`quiet`,size:`small`,label:`no icon`,action:`icon-clear`,onClick:()=>f(null),disabled:r||n===null});return c.append(l,...m.map(({group:e})=>e),h),o.append(Pr(n),p,c),o}var Lr=8,Rr=12,zr=30,Br=40,Vr=40,Hr=400,Ur=200,Wr=8,Gr=`README.md`,Kr=[`text`,`code`,`item`,`numbered`,`kv`],qr=[`plain`,`fail`,`join`],Jr=ii(Kr),Yr=ii(qr),Xr=ii(C),Zr={box:`Box`,decision:`Decision`,panel:`Panel`,icon:`Icon`,device:`Device`},Qr=ii(a),$r=ii(i),ei=ii(y),ti=ii(T),ni=[{value:``,text:`auto`},...ii([`left`,`right`,`top`,`bottom`])],ri=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function ii(e){return e.map(e=>({value:e,text:e}))}function ai(e){return S(`h3`,`wb-inspect-heading`,e)}function z(e,t){let n=S(`label`,`wb-inspect-field`);return n.append(S(`span`,`wb-inspect-label`,e),t),n}function oi(e,t){let n=S(`div`,`wb-inspect-field`);return n.append(S(`span`,`wb-inspect-label`,e),t),n}function B(e,t,n,r,i){let a=S(`input`,`wb-inspect-input`);return a.type=`text`,a.value=t,a.maxLength=n,a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.addEventListener(`change`,()=>r(a.value)),a}function V(e,t,n,r,i){let a=S(`select`,`wb-inspect-select`);return a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.append(...t.map(e=>{let t=S(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),a.addEventListener(`change`,()=>r(a.value)),a}function si(e,t,n,r){let i=S(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let a=S(`label`,`wb-inspect-toggle`);return a.append(i,S(`span`,null,t)),a}function H(e,t,n,r){let i=P({variant:`quiet`,size:`small`,label:t,action:t.replaceAll(` `,`-`),onClick:n});return i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i}function ci(e,t,n){let r=S(`div`,`wb-inspect-list`);return r.append(S(`span`,`wb-inspect-label`,e),...t,n),r}function li(e,t){return{edit(n,r){let i=e(),a=i?.[n];i&&a!==void 0&&t(i.map((e,t)=>t===n?r(a):e))},remove(n){let r=e();r&&t(r.filter((e,t)=>t!==n))},append(n){let r=e();r&&t([...r,n(r)])}}}function ui(e){let t=e.trim();return x.safeParse(t).success?t:null}function di(e,t,n,r){let i=B(e,t??``,Ur,e=>{if(!e.trim()){n(null);return}let t=ui(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function fi(e,t,n,r){let i=li(n,r),a=t.map((e,t)=>{let n=S(`div`,`wb-inspect-row`);return n.append(B(`ref-${t}`,e,Ur,e=>{let n=ui(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),H(`ref-${t}-remove`,`remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),o=H(`ref-add`,`add ref`,()=>i.append(()=>Gr),`Add a ref to ${e}`);return o.disabled=t.length>=Wr,ci(`Refs`,a,o)}function pi(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function mi(e,n,r,i){let a=li(r,i),o=n.map((e,n)=>{let r=S(`div`,`wb-inspect-row`),i=n+1;return r.append(V(`line-${n}-style`,Jr,e.style,e=>{let t=Kr.find(t=>t===e);t&&a.edit(n,e=>pi(e,t))},`Line ${i} style`)),e.style===`kv`&&r.append(B(`line-${n}-key`,e.key??``,Vr,e=>{e.trim()&&a.edit(n,t=>({...t,key:e.trim()}))},`Line ${i} key`)),r.append(Ir({field:`line-${n}-icon`,icon:e.icon,isRequired:!1,accessibleName:`Line ${i} icon`,commit:e=>a.edit(n,t=>({...t,icon:e}))}),B(`line-${n}-text`,e.text,t.line,e=>a.edit(n,t=>({...t,text:e})),`Line ${i} text`),di(`line-${n}-ref`,e.ref,e=>a.edit(n,t=>({...t,ref:e})),`Line ${i} ref`),H(`line-${n}-remove`,`remove`,()=>a.remove(n),`Remove line ${i}`)),r}),s=H(`line-add`,`add line`,()=>a.append(()=>({text:`new line`,muted:!1,style:`text`,key:null,ref:null,icon:null})),`Add a line to ${e}`);return s.disabled=n.length>=t.linesPerBox,ci(`Lines`,o,s)}function hi(e){let t=new Set(e.map(e=>e.id)),n=e.length+1;for(;t.has(`exit-${n}`);)n+=1;return`exit-${n}`}function gi(e,t,n){let r=li(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=S(`div`,`wb-inspect-row`);return n.append(B(`output-${e.id}-label`,e.label,zr,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),H(`output-${e.id}-remove`,`remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),a=H(`output-add`,`add output`,()=>r.append(e=>({id:hi(e),label:`exit`})));return a.disabled=e.outputs.length>=Lr,ci(`Outputs`,i,a)}function _i(e,n,r,i){let a=()=>{let e=n();return e?.kind===`box`?e:null},s=()=>{let e=a();return e&&`lines`in e?e.lines??null:null},c=()=>{let e=a();return e?.shape===`decision`?e.outputs:null},l=()=>{let t=r?.elements.find(t=>t.id===e.id);return!r||t?.kind!==`box`?null:{x:t.x,y:t.y-r.pinnedOffsetY}},u=()=>{let e=a(),t=e&&un(e)?l():null;return t?{at:t}:{}};return[ai(Zr[e.shape]),z(`Title`,B(`title`,e.title,t.title,e=>{e.trim()&&i({title:e.trim()})})),oi(`Icon`,Ir({field:`icon`,icon:e.icon,isRequired:e.shape===`icon`,accessibleName:`Box icon`,commit:e=>i({icon:e})})),z(`Shape`,V(`shape`,Xr,e.shape,e=>{e===`decision`&&i({shape:e,outputs:c()??ri,...u()}),e===`box`&&i({shape:e,...u()}),e===`panel`&&i({shape:e}),e===`icon`&&i({shape:e,icon:a()?.icon??`component`,...u()}),e===`device`&&i({shape:e,device:o,...u()})})),z(`Change`,V(`change`,ei,e.change,t=>{i(t===`relabeled`?{change:t,was:a()?.was??e.title}:{change:t,was:null})})),...e.change===`relabeled`?[z(`Was`,B(`was`,e.was??``,t.title,e=>{e.trim()&&i({was:e.trim()})}))]:[],...e.shape===`decision`?[gi(e,c,i)]:[],...e.shape===`device`?vi(e,i):[],fi(`this box`,e.refs,()=>a()?.refs??null,e=>i({refs:e})),...e.shape===`icon`||e.shape===`device`?[]:[mi(`this box`,e.lines,s,e=>i({lines:e}))],...e.step?Ci(e.step,i):[]]}function vi(e,t){return[z(`Device`,V(`device`,Qr,e.device,e=>t({device:e}))),z(`Fit`,V(`fit`,$r,e.fit,e=>t({fit:e})))]}function yi(e,t,n){let r=e.elements[t.from],i=r?.kind===`box`&&r.shape===`decision`?r.outputs:null,a=!r&&t.fromOutput?[{id:t.fromOutput,label:t.fromOutput}]:[],o=i??a,s=o.length>0?[{value:``,text:`none`},...o.map(e=>({value:e.id,text:e.label}))]:[];return[ai(`Wire`),z(`Label`,B(`label`,t.label??``,Br,e=>n({label:e.trim()||null}))),z(`Tone`,V(`tone`,Yr,t.tone,e=>n({tone:e}))),si(`dashed`,`dashed`,t.dashed,e=>n({dashed:e})),si(`back`,`returns to an earlier step`,t.back,e=>n({back:e})),z(`Leaves from`,V(`fromSide`,ni,t.fromSide??``,e=>n({fromSide:e||null}))),z(`Arrives at`,V(`toSide`,ni,t.toSide??``,e=>n({toSide:e||null}))),...s.length>0?[z(`From output`,V(`fromOutput`,s,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function bi(e,n){return[ai(`Frame`),z(`Title`,B(`title`,e.title,t.title,e=>n({title:e.trim()}))),si(`loop`,`repeats as a loop`,e.loop,e=>n({loop:e}))]}function xi(e,t,n){let r=li(t,n),i=e.map((e,t)=>{let n=S(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(V(`legend-${t}-tone`,Yr,e.tone,e=>{let n=qr.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),B(`legend-${t}-label`,e.label,Br,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),si(`legend-${t}-dashed`,`dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),si(`legend-${t}-back`,`returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),H(`legend-${t}-remove`,`remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),a=H(`legend-add`,`add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return a.disabled=e.length>=Rr,ci(`Legend`,i,a)}function Si(e,t){return[ai(`Note`),z(`Ref`,di(`ref`,e.ref,e=>t({ref:e}),`Ref`)),S(`p`,`wb-inspect-hint`,`Edit a note from its box.`)]}function Ci(e,t){return[ai(`Step`),z(`Status`,V(`step-status`,ti,e.status,e=>{let n=T.find(t=>t===e);n&&t({step:{status:n}})})),S(`p`,`wb-inspect-hint`,`A wire from one step to another means the second is built after the first.`)]}function wi(e,n,r,i,a){let o=[{value:``,text:`none`},...i];return[ai(`Board`),H(`board-settings-close`,`close`,a,`Close board settings`),z(`Title`,B(`board-title`,e.title,t.title,e=>{e.trim()&&r([{op:`board`,title:e.trim()}])})),z(`Caption`,B(`board-caption`,e.caption??``,Hr,e=>r([{op:`board`,caption:e.trim()||null}]))),z(`Code session`,V(`board-code-session`,o,e.codeSessionId??``,e=>r([{op:`board`,codeSessionId:e||null}]))),xi(e.legend,()=>n()?.legend??null,e=>r([{op:`board`,legend:e}]))]}function Ti(e,t,n,r,i){let a=e=>i([{op:`set`,id:t.id,fields:e}]),o=()=>n()?.elements[t.id];switch(t.kind){case`box`:return _i(t,o,r,a);case`wire`:return yi(e,t,a);case`frame`:return bi(t,a);case`note`:return Si(t,a)}}function Ei(e,t,n){let r=ct(t);if(r.length===0)return[];let i=e.codeSessionId!==null,a=r.map((e,t)=>{let r=S(`div`,`wb-inspect-row wb-inspect-review-row`),a=H(`review-${t}`,`open in review`,()=>n(e),`Open ${e} in review`);return a.disabled=!i,r.append(S(`code`,`wb-inspect-ref`,e),a),r}),o=i?[]:[S(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[ai(`In review`),...a,...o]}function Di(e,t,n){let r=S(`div`,`wb-inspect-review`);return r.append(...Ei(e,t,n)),r}function Oi(e){let t=document.activeElement;return!t||!e.contains(t)?!1:t instanceof HTMLInputElement&&t.type===`text`||t.closest(`.wb-icon-popover`)!==null}function ki(e){let{container:t}=e;t.setAttribute(`aria-label`,`Properties`);let n=t=>void e.sendOps(t),r=new Set,i=!1,a=!1;function o(e,t){if(t.size!==1)return;let[n]=t;return n===void 0?void 0:e.elements[n]}function s(n,r){let i=o(n,r),a=t.querySelector(`.wb-inspect-review`);i&&a&&a.replaceChildren(...Ei(n,i,e.openRef))}function c(t,r){if(r.size>1)return[ai(`${r.size} selected`)];let i=o(t,r);return i?[...Ti(t,i,e.currentBoard,e.layout(),n),Di(t,i,e.openRef)]:wi(t,e.currentBoard,n,e.codeSessionChoices(),d)}function l(n){r=n,n.size>0&&(a=!1);let o=e.currentBoard();if(t.hidden=!o||n.size===0&&!a,!o||t.hidden)return;if(Oi(t)){s(o,n);return}let l=document.activeElement,u=l instanceof HTMLElement&&t.contains(l)?l.dataset.field:void 0;i=!0,t.replaceChildren(...c(o,n)),u&&t.querySelector(`[data-field="${CSS.escape(u)}"]`)?.focus(),i=!1}function u(){a=!0,l(r),t.querySelector(`[data-field="board-caption"]`)?.focus()}function d(){a&&(a=!1,l(r))}return t.addEventListener(`keydown`,e=>{e.key===`Escape`&&a&&(e.preventDefault(),d())}),t.addEventListener(`focusout`,e=>{i||t.hidden||e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||queueMicrotask(()=>l(r))}),{paint:l,openBoardSettings:u,closeBoardSettings:d}}var Ai=`http://www.w3.org/2000/svg`,ji=`Plan`,Mi=`open linked board`,Ni=8,Pi=12,Fi=7.2,Ii=2.2,Li=9.6;Object.freeze({fill:`xMidYMid slice`,fit:`xMidYMid meet`});function Ri(e){return Object.entries(e).flatMap(([e,t])=>t===null?[]:[` ${e}="${te(t)}"`]).join(``)}function zi(e,t,n=``){return`<${e}${Ri(t)}>${n}</${e}>`}function Bi(e){let t=e.x+e.width,n=e.y+e.height,r=e.y+e.headerHeight/2,i=[{x:e.x+Pi,y:e.y},{x:t-Pi,y:e.y},{x:t,y:r}];return e.outputs.length===0?[...i,{x:t-Pi,y:n},{x:e.x+Pi,y:n},{x:e.x,y:r}]:[...i,{x:t,y:n},{x:e.x,y:n},{x:e.x,y:r}]}function Vi(e){return`${Bi(e).map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `)} Z`}function Hi(e){let t={fill:`black`,stroke:`black`,"stroke-width":12,"stroke-linejoin":`round`};return e.kind===`box`&&e.shape===`decision`?zi(`path`,{d:Vi(e),...t}):zi(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:Ni,...t})}function Ui(e,t){if(t.length===0)return null;let n={x:e.x,y:e.y,width:e.width,height:e.height},r=zi(`mask`,{id:`page-mask`,maskUnits:`userSpaceOnUse`,...n},[zi(`rect`,{...n,fill:`white`}),...t.map(Hi)].join(``)),i=zi(`svg`,{xmlns:Ai,viewBox:`${e.x} ${e.y} ${e.width} ${e.height}`,width:e.width,height:e.height,preserveAspectRatio:`none`},zi(`defs`,{},r)+zi(`rect`,{...n,mask:`url(#page-mask)`}));return`url("data:image/svg+xml,${encodeURIComponent(i)}")`}var Wi=2048,Gi=4,Ki=37,qi=73,Ji=Gi+49,Yi=Math.floor(Wi/Ki),Xi=1540,Zi=Math.log2(Wi)+1,Qi=33,$i=126,ea=8,ta=ea*Xi,na=`?`;function ra(){let e=(typeof OffscreenCanvas==`function`?new OffscreenCanvas(Ki,qi):Object.assign(document.createElement(`canvas`),{width:Ki,height:qi})).getContext(`2d`,{willReadFrequently:!0});if(!e)throw Error(`this browser cannot draw text for the whiteboard`);return e}function ia(e){let t=ra(),n=new Map,r=[],i=[],a=null,o=0;function s(n,r){t.clearRect(0,0,Ki,qi),t.font=`${r?700:400} 48px ${e}`,t.textBaseline=`alphabetic`,t.fillStyle=`#fff`,t.fillText(n,Gi,Ji);let i=t.getImageData(0,0,Ki,qi).data,a=new Uint8Array(2701);for(let e=0;e<a.length;e+=1)a[e]=i[e*4+3]??0;return a}function c(e,t){let a=r.length,o=Math.floor(a/Xi),c=a%Xi,l=c%Yi*Ki,u=Math.floor(c/Yi)*qi,d={cell:{u0:l/Wi,v0:u/Wi,u1:(l+Ki)/Wi,v1:(u+qi)/Wi,page:o},index:a,character:e,isBold:t,coverage:s(e,t)};return n.set(`${t?`b`:`r`}${e}`,d),r.push(d),i.push(d),d}function l(e,t){let i=n.get(`${t?`b`:`r`}${e}`);return i?i.cell:r.length>=ta?l(na,t):c(e,t).cell}function u(){for(let e=Qi;e<=$i;e+=1)l(String.fromCharCode(e),!1),l(String.fromCharCode(e),!0)}function d(){n.clear(),r.length=0,i=[],u()}function f(e,t){a&&e.deleteTexture(a),a=e.createTexture(),o=Math.max(1,t),e.bindTexture(e.TEXTURE_2D_ARRAY,a),e.texStorage3D(e.TEXTURE_2D_ARRAY,Zi,e.R8,Wi,Wi,o),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i=[...r]}function p(e,t){let n=Math.ceil(r.length/Xi);if((!a||n>o)&&f(e,Math.min(n*2,ea)),e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D_ARRAY,a),i.length!==0){e.pixelStorei(e.UNPACK_ALIGNMENT,1);for(let t of i){let n=t.index%Xi,r=n%Yi*Ki,i=Math.floor(n/Yi)*qi;e.texSubImage3D(e.TEXTURE_2D_ARRAY,0,r,i,t.cell.page,Ki,qi,1,e.RED,e.UNSIGNED_BYTE,t.coverage)}e.generateMipmap(e.TEXTURE_2D_ARRAY),i=[]}}function m(){for(let e of r)e.coverage=s(e.character,e.isBold);i=[...r]}return u(),{cellOf:l,cellWidthEm:Ki/48,cellHeightEm:qi/48,padLeftEm:Gi/48,ascentEm:Ji/48,bind:p,forgetTexture:()=>{a=null,o=0},release:e=>{a&&e.deleteTexture(a),a=null,o=0},rasterizeAgain:m,isFull:()=>r.length>=ta,forgetUnusedGlyphs:d}}var aa=8,oa=4,sa=4,ca=/<(\w+)([^>]*)\/?>/g,la=/([\w-]+)="([^"]*)"/g,ua=/[a-zA-Z]|-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?/g,da=new Map;function fa(e){return new Map([...e.matchAll(la)].map(e=>[e[1]??``,e[2]??``]))}function U(e,t){return Number(e.get(t)??0)}function pa(e){let t=e.trim().split(/[\s,]+/).map(Number),n=[];for(let e=0;e+1<t.length;e+=2)n.push({x:t[e]??0,y:t[e+1]??0});return n}function ma(e,t,n){return Array.from({length:17},(r,i)=>{let a=i/16*Math.PI*2;return{x:e.x+Math.cos(a)*t,y:e.y+Math.sin(a)*n}})}function ha(e,t,n,r,i){let a=Math.min(i,n/2,r/2);if(a<=0)return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r},{x:e,y:t}];let o=[{x:e+n-a,y:t+a,startAngle:-Math.PI/2},{x:e+n-a,y:t+r-a,startAngle:0},{x:e+a,y:t+r-a,startAngle:Math.PI/2},{x:e+a,y:t+a,startAngle:Math.PI}].flatMap(e=>Array.from({length:5},(t,n)=>{let r=e.startAngle+n/sa*(Math.PI/2);return{x:e.x+Math.cos(r)*a,y:e.y+Math.sin(r)*a}})),[s]=o;return s?[...o,s]:o}function ga(e,t,n,r){return Array.from({length:aa},(i,a)=>{let o=(a+1)/aa,s=1-o,c=s*s*s,l=3*s*s*o,u=3*s*o*o,d=o*o*o;return{x:c*e.x+l*t.x+u*n.x+d*r.x,y:c*e.y+l*t.y+u*n.y+d*r.y}})}function _a(e,t,n,r){return Math.atan2(e*r-t*n,e*n+t*r)}function va(e,t,n,r,i,a,o){if(t===0||n===0)return[o];let s=r*Math.PI/180,c=Math.cos(s),l=Math.sin(s),u=(e.x-o.x)/2,d=(e.y-o.y)/2,f=c*u+l*d,p=-l*u+c*d,m=f*f/(t*t)+p*p/(n*n),h=m>1?Math.sqrt(m):1,g=Math.abs(t)*h,_=Math.abs(n)*h,v=g*g*_*_-g*g*p*p-_*_*f*f,y=g*g*p*p+_*_*f*f,b=y===0?0:(i===a?-1:1)*Math.sqrt(Math.max(0,v/y)),x=b*(g*p/_),S=b*(-(_*f)/g),C=c*x-l*S+(e.x+o.x)/2,w=l*x+c*S+(e.y+o.y)/2,T=_a(1,0,(f-x)/g,(p-S)/_),E=_a((f-x)/g,(p-S)/_,(-f-x)/g,(-p-S)/_);!a&&E>0&&(E-=Math.PI*2),a&&E<0&&(E+=Math.PI*2);let D=Math.max(2,Math.ceil(Math.abs(E)/(Math.PI/2)*oa));return Array.from({length:D},(e,t)=>{let n=T+E*(t+1)/D,r=Math.cos(n)*g,i=Math.sin(n)*_;return{x:c*r-l*i+C,y:l*r+c*i+w}})}function ya(e){let t=e.match(ua)??[],n=[],r=[],i={x:0,y:0},a={x:0,y:0},o=null,s=``,c=0,l=()=>Number(t[c++]??0),u=()=>c<t.length&&!/^[a-zA-Z]$/.test(t[c]??``),d=e=>{r.length===0&&r.push(i),r.push(e),i=e},f=()=>{r.length>1&&n.push(r),r=[]};for(;c<t.length;){u()||(s=t[c++]??``);let e=s===s.toLowerCase(),n=e?i.x:0,r=e?i.y:0,p=s.toUpperCase();switch(p!==`C`&&p!==`S`&&(o=null),p){case`M`:f(),i={x:n+l(),y:r+l()},a=i,s=e?`l`:`L`;break;case`L`:d({x:n+l(),y:r+l()});break;case`H`:d({x:n+l(),y:i.y});break;case`V`:d({x:i.x,y:r+l()});break;case`C`:{let e={x:n+l(),y:r+l()},t={x:n+l(),y:r+l()},a={x:n+l(),y:r+l()},s=i;for(let n of ga(s,e,t,a))d(n);o=t;break}case`S`:{let e=o?{x:i.x*2-o.x,y:i.y*2-o.y}:i,t={x:n+l(),y:r+l()},a={x:n+l(),y:r+l()},s=i;for(let n of ga(s,e,t,a))d(n);o=t;break}case`A`:{let e=l(),t=l(),a=l(),o=l()!==0,s=l()!==0,c={x:n+l(),y:r+l()},u=i;for(let n of va(u,e,t,a,o,s,c))d(n);break}case`Z`:d(a),f();break;default:c+=1}}return f(),n}function ba(e,t){switch(e){case`path`:return{polylines:ya(t.get(`d`)??``),circles:[]};case`line`:return{polylines:[[{x:U(t,`x1`),y:U(t,`y1`)},{x:U(t,`x2`),y:U(t,`y2`)}]],circles:[]};case`polyline`:return{polylines:[pa(t.get(`points`)??``)],circles:[]};case`polygon`:{let e=pa(t.get(`points`)??``),[n]=e;return{polylines:[n?[...e,n]:e],circles:[]}}case`rect`:{let e=U(t,t.has(`rx`)?`rx`:`ry`);return{polylines:[ha(U(t,`x`),U(t,`y`),U(t,`width`),U(t,`height`),e)],circles:[]}}case`circle`:return{polylines:[],circles:[{center:{x:U(t,`cx`),y:U(t,`cy`)},radius:U(t,`r`),isFilled:t.get(`fill`)===`currentColor`}]};case`ellipse`:return{polylines:[ma({x:U(t,`cx`),y:U(t,`cy`)},U(t,`rx`),U(t,`ry`))],circles:[]};default:return{polylines:[],circles:[]}}}function xa(t){let n=da.get(t);if(n)return n;let r={polylines:[],circles:[]};for(let n of e[t].elements)for(let e of n.matchAll(ca)){let t=ba(e[1]??``,fa(e[2]??``));r.polylines.push(...t.polylines),r.circles.push(...t.circles)}return da.set(t,r),r}var Sa=0,Ca=0,wa=3,Ta={frame:1,wire:2,box:4,note:5},Ea=4,Da=12,Oa=8,ka=4,Aa=12.8,ja=5.12,Ma=1.28,Na=1.6,Pa=1.6,Fa=.08,Ia=Fi/12,La=3,Ra=12,za=4,W=0,Ba=24,Va=2,Ha=[0,0,0,0];function Ua(e,t,n){let r=1-n;return[e[0]*n+t[0]*r,e[1]*n+t[1]*r,e[2]*n+t[2]*r,e[3]*n+t[3]*r]}function G(e,t){return t===1?e:[e[0],e[1],e[2],e[3]*t]}function Wa(){return{rects:[],segments:[],triangles:[],glyphs:[]}}function Ga(e){return{rects:Float32Array.from(e.rects),segments:Float32Array.from(e.segments),triangles:Float32Array.from(e.triangles),glyphs:Float32Array.from(e.glyphs)}}var K={on:0,off:0};function q(e,t,n,r,i,a,o){e.rects.push(t.x,t.y,t.width,t.height,n,a,r[0],r[1],r[2],r[3],i[0],i[1],i[2],i[3],o,Sa)}function Ka(e,t,n,r,i,a,o){q(e,{x:t.x-n,y:t.y-n,width:n*2,height:n*2},n,r,i,a,o)}function J(e,t,n,r,i,a){let o=0;for(let s=1;s<t.length;s+=1){let c=t[s-1],l=t[s];c&&l&&(e.segments.push(c.x,c.y,l.x,l.y,n,i.on,i.off,o,r[0],r[1],r[2],r[3],a,Sa),o+=Math.hypot(l.x-c.x,l.y-c.y))}}function qa(e,t,n,r){for(let i of t)e.triangles.push(i.x,i.y,n[0],n[1],n[2],n[3],r,Sa)}function Ja(e,t,n,r){let[i]=t;if(i)for(let a=2;a<t.length;a+=1){let o=t[a-1],s=t[a];o&&s&&qa(e,[i,o,s],n,r)}}function Ya(e,t,n,r,i){let a=Math.hypot(n.x-t.x,n.y-t.y);if(a===0)return;let o=(n.x-t.x)/a,s=(n.y-t.y)/a,c={x:n.x+o*Ma,y:n.y+s*Ma},l=c.x-o*Aa,u=c.y-s*Aa;qa(e,[c,{x:l-s*ja,y:u+o*ja},{x:l+s*ja,y:u-o*ja}],r,i)}function Xa(e,t){let n=[{x:e.x+e.width-t,y:e.y+t,startAngle:-Math.PI/2},{x:e.x+e.width-t,y:e.y+e.height-t,startAngle:0},{x:e.x+t,y:e.y+e.height-t,startAngle:Math.PI/2},{x:e.x+t,y:e.y+t,startAngle:Math.PI}],r=[{x:e.x+t,y:e.y}];for(let e of n)for(let n=0;n<=za;n+=1){let i=e.startAngle+n/za*(Math.PI/2);r.push({x:e.x+Math.cos(i)*t,y:e.y+Math.sin(i)*t})}return r.push({x:e.x+t,y:e.y}),r}function Za(e,t,n,r,i,a,o,s){o.on===0?q(e,t,n,r,i,a,s):(q(e,t,n,r,r,0,s),J(e,Xa(t,n),a,i,o,s))}function Qa(e){return e.size*(Ia+(e.isUppercase?Fa:0))}function $a(e,t){return[...e].length*Qa(t)}function eo(e){return(e.minPixels??Ea)/e.size}function Y(e,t,n,r,i,a){let o=a.isUppercase?n.toUpperCase():n,s=Qa(a),c=$a(o,a),l=r-(a.anchor===`middle`?c/2:a.anchor===`end`?c:0),u=eo(a),d=t.cellWidthEm*a.size,f=t.cellHeightEm*a.size,p=i-t.ascentEm*a.size,{color:m}=a,h=0;for(let n of o){if(n!==` `){let r=t.cellOf(n,a.isBold===!0);e.glyphs.push(l+h*s-t.padLeftEm*a.size,p,d,f,r.u0,r.v0,r.u1,r.v1,r.page,m[0],m[1],m[2],m[3],u,Sa)}h+=1}a.isStruckThrough&&J(e,[{x:l,y:i-a.size*.3},{x:l+c,y:i-a.size*.3}],1,m,K,u),a.isUnderlined&&J(e,[{x:l,y:i+2},{x:l+c,y:i+2}],1,m,K,u)}function to(e,t,n,r,i,a,o){let s=i/Ba,c=Va*s,l=xa(t);for(let t of l.polylines)J(e,t.map(e=>({x:n+e.x*s,y:r+e.y*s})),c,a,K,o);for(let t of l.circles)Ka(e,{x:n+t.center.x*s,y:r+t.center.y*s},t.radius*s,t.isFilled?a:Ha,a,c,o)}function no(e,t){let n=e.map(e=>e.x),r=e.map(e=>e.y),i=Math.min(...n)-t,a=Math.min(...r)-t;return{x:i,y:a,width:Math.max(...n)+t-i,height:Math.max(...r)+t-a}}function ro(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function io(e,t){return e.style===`code`?t.accent:e.muted?t.inkDim:t.ink}function ao(e,t,n,r,i,a,o,s){let{palette:c,glyphs:l}=t,u=c.metaSize;n.forEach((t,n)=>{let d=a+n*18,f=r+12+(t.muted?14:0),p=t.icon?f+3*Fi:f;t.icon&&t.isFirstRow&&to(e,t.icon,f,d-10,13,G(c.inkDim,o),s),t.style===`code`&&q(e,{x:p-4,y:d-13,width:r+i-12+8-p,height:17},3,G(c.codeBand,o),G(c.codeBand,o),0,s),t.style===`item`&&t.isFirstRow&&Ka(e,{x:p+4,y:d-4},Ii,G(c.inkDim,o),G(c.inkDim,o),0,s),t.marker!==null&&Y(e,l,t.marker,p,d,{size:u,color:G(c.inkDim,o),isBold:t.style===`kv`}),t.text&&Y(e,l,t.text,p+t.indentChars*Fi,d,{size:u,color:G(io(t,c),o)})})}function oo(e,t){let n=e.shape===`panel`,r=n&&!e.step?1.4:Pa,i=e.step?t.accent:null,a=n?t.panelFill:t.board;return e.change===`added`?{fill:a,stroke:i??t.running,dash:{on:7,off:5},width:r}:e.change===`removed`?{fill:[0,0,0,0],stroke:i??t.failed,dash:{on:7,off:5},width:r}:e.change===`relabeled`?{fill:a,stroke:i??t.noteStroke,dash:K,width:r}:{fill:a,stroke:i??(n?t.line:t.inkDim),dash:K,width:r}}function so(e,t){return e===`building`?t.waiting:e===`landed`?t.running:t.muted}function co(e,t,n,r,i,a){let{base:o}=u[t.name];if(!o)return;let s=o.height*t.scale,c=t.x+t.width/2;if(o.overhang>0){q(e,{x:t.x,y:n,width:t.width,height:s},s/3,r,i,1,a);return}let l=24*t.scale,d=180*t.scale,f=520*t.scale;q(e,{x:c-d/2,y:n,width:d,height:s-l},0,r,i,1,a),q(e,{x:c-f/2,y:n+s-l,width:f,height:l},l/3,r,i,1,a)}function lo(e,t,n,r,i,a){let{palette:o,glyphs:s}=t,c=u[r.name],l=G(Ua(o.ink,o.board,.12),i),d=G(o.inkDim,i),f=G(o.board,i),p=(c.base?.overhang??0)*r.scale,m=r.x+p,h=r.width-p*2,g=(c.bezel.top+c.toolbarHeight+c.screen.height+c.bezel.bottom)*r.scale;if(q(e,{x:m,y:r.y,width:h,height:g},c.bezel.radius*r.scale,l,d,1,a),co(e,r,r.y+g,l,d,a),c.toolbarHeight>0){let t=r.y+c.bezel.top*r.scale,n=c.toolbarHeight*r.scale,s=t+n/2,l=22*r.scale,u=96*r.scale,p=G(Ua(o.ink,o.board,.06),i);q(e,{x:m,y:t,width:h,height:n},0,p,p,0,a);for(let t of[1,2,3])Ka(e,{x:m+t*22*r.scale,y:s},6*r.scale,d,d,0,a);q(e,{x:m+u,y:s-l/2,width:h-u*2,height:l},l/2,f,f,0,a)}q(e,r.screen,c.bezel.screenRadius*r.scale,f,f,0,a),n.media||Y(e,s,n.titleLines.join(` `),r.screen.x+r.screen.width/2,r.screen.y+r.screen.height/2+4,{size:o.metaSize,color:G(o.inkDim,i),anchor:`middle`})}function uo(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=e.change===`removed`?.6:1,o=Da/Math.max(1,e.height),s=oo(e,n),c=G(s.fill,a),l=G(s.stroke,a);if(e.shape===`decision`){let t=Bi(e);Ja(i,t,c,W);let[n]=t;n&&J(i,[...t,n],s.width,l,s.dash,W)}e.shape!==`decision`&&Za(i,e,8,c,l,s.width,s.dash,W);for(let t of e.outputs){let s=(e.height-e.headerHeight)/e.outputs.length/2,c=t.port.y-s;J(i,[{x:e.x,y:c},{x:e.x+e.width,y:c}],1,G(n.line,a),K,o),Y(i,r,t.label,e.x+12,t.port.y+4,{size:n.metaSize,color:G(n.ink,a),isBold:!0,isUppercase:!0}),Ka(i,t.port,3,G(n.inkDim,a),G(n.inkDim,a),0,o)}let u=e.step?18:0;e.step&&(Y(i,r,e.step.label,e.x+12,e.y+22,{size:n.metaSize,color:G(n.accent,a),isBold:!0}),Y(i,r,e.step.status,e.x+e.width-12,e.y+22,{size:n.metaSize,color:G(so(e.step.status,n),a),anchor:`end`}));let d=e.shape===`icon`,f=d?56:0,p=e.x+e.width/2;d&&e.icon&&to(i,e.icon,p-24,e.y+12+u,48,G(n.accent,a),o);let m=d?p:e.x+12,h=d?`middle`:`start`;e.wasLines.forEach((t,o)=>{Y(i,r,t,m,e.y+26+u+f+o*20,{size:n.titleSize,color:G(n.inkDim,a),isStruckThrough:!0,anchor:h})});let g=e.y+26+u+f+e.wasLines.length*20,_=d?null:e.icon;_&&to(i,_,m,g-12,14,G(n.ink,a),o);let v=_?m+2*Li:m;e.titleLines.forEach((t,o)=>{Y(i,r,t,v,g+o*20,{size:n.titleSize,color:G(n.ink,a),isBold:!0,isStruckThrough:e.change===`removed`,anchor:h})}),e.device&&lo(i,t,e,e.device,a,o);let y=g+e.titleLines.length*20;e.shape===`panel`&&e.bodyLines.length>0&&J(i,[{x:e.x+12,y:y-12},{x:e.x+e.width-12,y:y-12}],1,G(n.line,a),K,o),ao(i,t,e.bodyLines,e.x,e.width,y,a,o);let b=e.media!==null&&t.hasDrawnMedia(e);if(e.media&&!b){let t=e.media.alt||e.media.kind;Za(i,e.media,6,G(n.placeholderFill,a),G(n.inkDim,a),1,{on:4,off:4},o),Y(i,r,t,e.media.x+e.media.width/2,e.media.y+e.media.height/2+4,{size:n.metaSize,color:G(n.inkDim,a),anchor:`middle`})}let x=e.step?.linkedBoardId??null;if(!x)return{part:i,hitShape:{kind:`rect`,rect:e,linkRect:null,mediaRect:e.media,hasDrawnMedia:b}};let S={size:n.metaSize,color:G(n.accent,a),isUnderlined:!0},C=y+e.bodyLines.length*18;return Y(i,r,Mi,e.x+12,C,S),{part:i,hitShape:{kind:`rect`,rect:e,linkRect:{x:e.x+12,y:C-n.metaSize,width:$a(Mi,S),height:n.metaSize+4,linkedBoardId:x},mediaRect:e.media,hasDrawnMedia:b}}}function fo(e,t,n,r){return Array.from({length:13},(i,a)=>{let o=n+a/Ra*r;return{x:e.x+Math.cos(o)*t,y:e.y+Math.sin(o)*t}})}function po(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=e.isLoop?n.accent:n.line;Za(i,e,12,n.frameFill,a,1.4,{on:10,off:6},W);let o={size:n.metaSize,color:n.inkDim,isBold:!0};if(Y(i,r,e.title,e.x+14,e.y+18,o),e.isLoop){let t=fo({x:e.x+e.width-20,y:e.y+6+6},6,0,-Math.PI*1.5);J(i,t,Pa,n.accent,K,Da/e.height);let r=t[t.length-2],a=t[t.length-1];r&&a&&Ya(i,r,a,n.accent,ka/Aa)}return{part:i,hitShape:{kind:`outline`,rect:e,titleRect:{x:e.x,y:e.y,width:28+$a(e.title,o),height:26}}}}function mo(e,t){return e.tone===`fail`?t.failed:e.tone===`join`||e.isBack?t.accent:t.inkDim}function ho(e,t,n){let r=t[t.length-2],i=t[t.length-1];r&&i&&Ya(e,r,i,n,ka/Aa)}function go(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=Wa(),o=fe(e.path),s=mo(e,n);J(i,o,Na,s,e.isDashed?{on:7,off:6}:K,W),e.hasArrowhead&&ho(i,o,s);let c=ka/6;Ka(i,e.start,3,n.inkDim,n.inkDim,0,c),e.joinAt&&Ka(i,e.joinAt,3,n.inkDim,n.inkDim,0,c);let l=no(o.length>0?o:[e.start,e.end],8);if(e.label){let t={size:n.metaSize,color:n.ink,anchor:`middle`,minPixels:Oa},i=$a(e.label,t),o={x:e.labelAt.x-i/2-La,y:e.labelAt.y-n.metaSize,width:i+6,height:n.metaSize+La+2};q(a,o,3,n.board,n.board,0,eo(t)),Y(a,r,e.label,e.labelAt.x,e.labelAt.y,t),l=ro(l,o)}return{parts:[{layer:Ta.wire,part:Ga(i)},{layer:wa,part:Ga(a)}],hitShape:{kind:`path`,points:o},bounds:l}}function _o(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=e.isResolved?.5:1;return q(i,e,4,G(n.noteCard,a),G(n.noteStroke,a),1.2,W),e.lines.forEach((t,o)=>{Y(i,r,t,e.x+10,e.y+22+o*17,{size:n.metaSize,color:G(n.noteText,a)})}),e.byline&&Y(i,r,e.byline,e.x+10,e.y+22+e.lines.length*17,{size:n.metaSize,color:G(n.noteByline,a)}),{part:i,hitShape:{kind:`rect`,rect:e,linkRect:null,mediaRect:null,hasDrawnMedia:!1}}}function vo(e,t){return{parts:[{layer:Ta[e.kind],part:Ga(t.part)}],hitShape:t.hitShape,bounds:yo(e,t.hitShape)}}function yo(e,t){if(t.kind!==`outline`)return e;let n=Math.max(e.x+e.width,t.titleRect.x+t.titleRect.width);return{x:e.x,y:e.y,width:n-e.x,height:e.height}}function bo(e,t){switch(e.kind){case`box`:return vo(e,uo(e,t));case`frame`:return vo(e,po(e,t));case`wire`:return go(e,t);case`note`:return vo(e,_o(e,t))}}function xo(e,t,n){let{parts:r,hitShape:i,bounds:a}=bo(e,n);return{id:e.id,kind:e.kind,paintRank:t,bounds:a,parts:r,hitShape:i}}function So(e,t,n){let{swatch:r}=t;if(r.kind===`status`){q(e,{x:t.x,y:t.y,width:14,height:14},3,so(r.status,n),n.accent,Pa,W);return}if(r.kind===`change`){let i={x:t.x,y:t.y,width:28,height:14},a=oo({change:r.change,shape:`box`,step:null},n),o=r.change===`removed`?.6:1;Za(e,i,3,G(a.fill,o),G(a.stroke,o),a.width,a.dash,W);return}let i=mo(r,n),a=[{x:t.x,y:t.y+7},{x:t.x+28,y:t.y+7}];J(e,a,Na,i,r.isDashed?{on:7,off:6}:K,W),ho(e,a,i)}function Co(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a={size:n.metaSize,color:n.inkDim,isBold:!0,isUppercase:!0};e.plan&&Y(i,r,ji,e.plan.titleAt.x,e.plan.titleAt.y,a);for(let t of e.legend){So(i,t,n);let e=t.x+(t.swatch.kind===`status`?22:40);Y(i,r,t.label,e,t.y+12,{size:n.metaSize,color:n.inkDim})}return e.caption&&Y(i,r,e.caption.text,e.caption.x,e.caption.y+16,{size:n.bodySize,color:n.inkDim}),{id:``,kind:`frame`,paintRank:-1,bounds:e.bounds,parts:[{layer:Ca,part:Ga(i)}],hitShape:{kind:`path`,points:[]}}}function wo(e,t,n,r){if(t.kind===`wire`)J(e,fe(t.path),2.6,n,K,W);else if(t.kind===`box`&&t.shape===`decision`){let i=Bi(t),[a]=i;a&&J(e,[...i,a],r,n,K,W)}else q(e,t,{box:8,note:4,frame:12}[t.kind],[0,0,0,0],n,r,W)}function To(e){let t=e.x+e.width/2,n=e.y+e.height/2;return[{x:t,y:e.y},{x:e.x+e.width,y:n},{x:t,y:e.y+e.height},{x:e.x,y:n}]}function Eo(e){return{x:e.x+e.width-10,y:e.y+e.height-10,width:10,height:10}}function Do(e,t){let{palette:n,glyphs:r}=t,i=Wa();for(let t of e){if(t.kind===`selected`||t.kind===`wire-target`){wo(i,t.element,n.accent,2.4);continue}if(t.kind===`flagged`){wo(i,t.element,n.waiting,2.4);continue}if(t.kind===`hover-handles`){for(let e of To(t.box))Ka(i,e,5,n.board,n.accent,Pa,W);q(i,Eo(t.box),2,n.board,n.accent,Pa,W);continue}let e={x:t.element.x+t.element.width,y:t.element.y};Ka(i,e,9,n.waiting,n.cardBackground,2,W),Y(i,r,`!`,e.x,e.y+4,{size:n.metaSize,color:n.cardBackground,isBold:!0,anchor:`middle`,minPixels:0})}return Ga(i)}function Oo(e,t,n){let r=e.elements.map((e,t)=>({element:e,index:t})).sort((e,t)=>Ta[e.element.kind]-Ta[t.element.kind]||e.index-t.index).map(({element:e},r)=>{let i=n(e);return i?{...i,paintRank:r}:xo(e,r,t)});return{chrome:Co(e,t),elements:r}}var ko={worthALookIds:new Set,flaggedStepIds:new Set},Ao=512,jo=.75,Mo=4,No=7,Po=6,Fo=3,Io=6,Lo=4096,Ro=`#version 300 es
|
|
1
|
+
import{An as e,Cn as t,Dn as n,En as r,Fn as i,In as a,Ln as o,Mn as s,Nn as c,On as l,Pn as u,Rn as d,Sn as f,Tn as p,_n as m,an as h,f as g,jn as _,kn as v,on as y,pn as b,rn as x,s as S,sn as C,wn as w,xn as T,yn as E}from"./dom-helpers-C7CaSePf.js";import{$t as D,D as O,Qt as ee,Si as te,Xt as k,Zt as A,a as ne,an as re,c as ie,d as j,en as ae,f as oe,gi as se,i as M,in as ce,l as le,m as ue,n as N,nn as de,o as fe,p as pe,r as me,rn as he,s as ge,t as _e,tn as ve,u as ye,vi as be}from"./index-CS1WCbXX.js";import{i as xe}from"./action-status-B5J9yJlM.js";import{O as Se,a as Ce,k as we,r as Te,t as P}from"./button-C8v9_rcy.js";import{n as Ee,t as De}from"./menu-nocBEdDd.js";import{a as Oe,r as ke}from"./card-registry-Ct6a2qHl.js";import{a as Ae,i as je,n as F}from"./modal-DAfPARiv.js";import{i as Me,t as Ne}from"./plan-render-BRK9_3s8.js";var Pe=new WeakMap,Fe=/^(?:0|[1-9]\d{0,9})$/,Ie=4294967294;function Le(e){return Fe.test(e)&&Number(e)<=Ie}function Re(e,t){return Le(t)?e.indexKeyIdsByKind:e.idsByKind}function ze(e){return e?.kind===`box`?v(e)?.asset??null:null}function Be(e,t,n){if(t===null)return;let r=(e.assetRefCount.get(t)??0)+n;r>0?e.assetRefCount.set(t,r):e.assetRefCount.delete(t)}function Ve(e){return e.kind===`box`?e.near?[e.near.of]:[]:e.kind===`wire`?[e.from,e.to]:e.kind===`note`?[e.on]:e.kind===`frame`?e.contains:[]}function He(e,t,n){t.kind===`box`&&t.step!==null&&(n?e.stepBoxIds.add(t.id):e.stepBoxIds.delete(t.id))}function Ue(e){return e.kind===`note`?e.ref!==null:e.kind===`box`&&(e.refs.length>0||l(e).some(e=>e.ref!==null))}function We(e,t){Ue(t)?e.anchoredIds.add(t.id):e.anchoredIds.delete(t.id)}function Ge(e,t){for(let n of Ve(t)){let r=e.dependentIdsByBoxId.get(n)??new Set;r.add(t.id),e.dependentIdsByBoxId.set(n,r)}}function Ke(e,t){let n=Re(e,t.id),r=n.get(t.kind)??new Set;r.add(t.id),n.set(t.kind,r),e.elementCount+=1,Be(e,ze(t),1),Ge(e,t),He(e,t,!0),We(e,t)}function qe(e){let t=Pe.get(e);if(t)return t;let n={elementCount:0,idsByKind:new Map,indexKeyIdsByKind:new Map,assetRefCount:new Map,dependentIdsByBoxId:new Map,stepBoxIds:new Set,anchoredIds:new Set};for(let t of Object.values(e))Ke(n,t);return Pe.set(e,n),n}var Je=26,Ye=97;function Xe(e){return e.step!==null}function Ze(e){return[...qe(e.elements).stepBoxIds].flatMap(t=>{let n=e.elements[t];return n?.kind===`box`&&Xe(n)?[n]:[]})}function Qe(e,t,n){return[...qe(e.elements).dependentIdsByBoxId.get(t)??[]].flatMap(r=>{let i=e.elements[r];return i?.kind===`wire`&&i.to===t&&i.from!==t&&n.has(i.from)?[i]:[]})}function $e(e,t){let n=new Map;for(let r of t){let i=Qe(e,r,t).map(e=>e.from);i.length>0&&n.set(r,i)}return n}function et(e){let t=String.fromCharCode(Ye+e%Je),n=Math.floor(e/Je);return n===0?t:`${t}${n+1}`}function tt(e,t){let n=new Map,r=new Set;function i(e){let a=n.get(e);if(a!==void 0)return a;if(r.has(e))return 0;r.add(e);let o=1+Math.max(0,...(t.get(e)??[]).map(i));return r.delete(e),n.set(e,o),o}for(let t of e)i(t);return n}function nt(e){let t=Ze(e),n=$e(e,new Set(t.map(e=>e.id))),r=tt(t.map(e=>e.id),n),i=new Map;for(let e of t){let t=r.get(e.id)??1;i.set(t,[...i.get(t)??[],e])}let a=new Map,o=[];for(let e of[...i.keys()].sort((e,t)=>e-t)){let t=(i.get(e)??[]).sort((e,t)=>e.title.localeCompare(t.title)||e.id.localeCompare(t.id));for(let[n,r]of t.entries())a.set(r.id,t.length===1?String(e):`${e}${et(n)}`),o.push(r)}return o.map(e=>({boxId:e.id,title:e.title,status:e.step.status,level:r.get(e.id)??1,label:a.get(e.id)??``,afterLabels:(n.get(e.id)??[]).flatMap(e=>a.get(e)??[]),linkedBoardId:e.step.linkedBoardId}))}Object.freeze({stepWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedStepIds:[],notChecked:null});var rt=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function it(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function at(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function I(e){let t=rt.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(it(n))return{error:`an absolute path is never read; name the file relative to the code session worktree`};if(n.split(/[\\/]/).includes(`..`))return{error:`a path with .. is never read; name the file relative to the code session worktree`};let r=t[2]?Number(t[2]):null,i=t[3]?Number(t[3]):r;return r!==null&&i!==null&&i<r?{error:`the line range ends before it starts`}:{path:at(n),startLine:r,endLine:i}}function ot(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function st(e){let t=`${e.kind} ${e.id}`;switch(e.kind){case`box`:return[...e.refs.map(n=>({elementId:e.id,ref:n,where:t})),...ot(t,e.id,l(e))];case`note`:return e.ref?[{elementId:e.id,ref:e.ref,where:t}]:[];case`frame`:case`wire`:return[]}}function ct(e){return[...new Set(st(e).map(e=>e.ref))]}function lt(e){let t=I(e);return`path`in t?t.path:null}var L=40,ut=220,dt=90,ft=30,pt=18,mt=12,ht=20,gt=18,_t=28,vt=12,yt=2,bt=20,xt=26,St=18,Ct=26,wt=170,Tt=21,Et=17,Dt=10,Ot=22,kt=24,At=8,jt=40,Mt=18,Nt=8,Pt=320,Ft=256,It=160;function Lt(e,t){let n=e.split(/\s+/).filter(Boolean),r=[],i=``;for(let e of n){let n=e.match(RegExp(`.{1,${t}}`,`g`))??[e];for(let e of n){let n=i?`${i} ${e}`:e;n.length<=t?i=n:(r.push(i),i=e)}}return i&&r.push(i),r.length>0?r:[``]}function Rt(e,t,n){let r=e.icon?n-3:n,i=e.muted?2:0,a=e.style===`numbered`?`${t}.`:e.style===`kv`?e.key:null,o=(t,n,r,i)=>({text:t,muted:e.muted,style:e.style,marker:n===0?i:null,indentChars:r,isFirstRow:n===0,icon:e.icon});if(a&&a.length+1>vt){let t=Lt(e.text,r-i-yt).map(e=>o(e,1,yt,null));return[o(``,0,0,a),...t]}let s=e.style===`item`?yt:a?a.length+1:0;return Lt(e.text,r-i-s-+(e.style===`code`)).map((e,t)=>o(e,t,s,a))}function zt(e,t=xt){let n=0;return e.flatMap(e=>(n=e.style===`numbered`?n+1:0,Rt(e,n,t)))}function Bt(e){return e.shape===`icon`?It:e.shape===`device`?u[e.device].defaultBoxWidth:ut}function Vt(e){return e.width??Bt(e)}function Ht(e,t){return Math.floor(e*(t-24)/196)}function Ut(e){let t=e.icon?2:0;return e.shape===`icon`?{lines:[],media:null,device:null,fit:`fit`,glyphRoom:56,titleIconChars:0}:e.shape===`device`?{lines:[],media:e.media,device:e.device,fit:e.fit,glyphRoom:0,titleIconChars:t}:{lines:e.lines,media:e.media,device:null,fit:`fit`,glyphRoom:0,titleIconChars:t}}function Wt(e,t){let{screen:n,bezel:r,toolbarHeight:i,base:a}=u[e],o=d(e),s=t/o.width;return{width:t,height:Math.round(o.height*s),scale:s,screen:{x:Math.round(((a?.overhang??0)+r.side)*s),y:Math.round((r.top+i)*s),width:Math.round(n.width*s),height:Math.round(n.height*s)}}}function Gt(e,t){let n=t-24,r=Math.round(Pt*t/ut),i=Math.min(r,Math.max(1,Math.round(n*e.height/e.width)));return{width:n,height:i,scale:1,screen:{x:0,y:0,width:n,height:i}}}function Kt(e,t){return e.device?Wt(e.device,t-24):e.media?Gt(e.media,t):null}function qt(e,t,n,r){let{media:i}=e;return!i||!r?null:{kind:i.kind,asset:i.asset,mime:i.mime,hasPreview:i.hasPreview,alt:i.alt,fit:e.fit,x:t.x+mt+r.screen.x,y:t.y+n+r.screen.y,width:r.screen.width,height:r.screen.height}}function Jt(e,t,n,r){if(!e.device||!r)return null;let i=t.x+mt,a=t.y+n,o={x:i+r.screen.x,y:a+r.screen.y,width:r.screen.width,height:r.screen.height};return{name:e.device,scale:r.scale,x:i,y:a,width:r.width,height:r.height,screen:o}}var Yt=new WeakMap,Xt=new WeakMap;function Zt(e){let t=Yt.get(e);if(t)return t;let n=Qt(e);return Yt.set(e,n),n}function Qt(e){let t=Ut(e),n=e.step?Mt:0,r=+!!e.step?.linkedBoardId,i=Vt(e),a=Ht(bt,i),o=Lt(e.title,a-t.titleIconChars),s=e.change===`relabeled`&&e.was?Lt(e.was,a):[],c=zt(t.lines,Ht(xt,i)),l=mt+n+t.glyphRoom+(s.length+o.length)*ht+(c.length+r)*gt,u=Kt(t,i),d=u?u.height+Nt:0,f=l+mt+d,p=e.shape===`decision`?e.outputs:[];return{titleLines:o,wasLines:s,bodyLines:c,headerHeight:f,outputs:p,content:t,artTop:l+Nt,art:u,height:f+p.length*_t}}function $t(e,t){switch(t.kind){case`box`:e.box.push(t);return;case`frame`:e.frame.push(t);return;case`wire`:e.wire.push(t);return;case`note`:e.note.push(t);return}}function en(e){let t={box:[],frame:[],wire:[],note:[]};for(let n of Object.values(e.elements))$t(t,n);return{...e,elementsByKind:t,planStepById:new Map(nt(e).map(e=>[e.boxId,e]))}}function R(e,t){return e.elementsByKind[t]}function tn(e){let t=Xt.get(e);if(t)return t;let n=Lt(e.text,Tt),r={lines:n,height:24+(n.length+1)*Et};return Xt.set(e,r),r}function nn(e){let t=new Map;for(let n of R(e,`note`)){let e=t.get(n.on),r=tn(n).height;t.set(n.on,e===void 0?r:e+Dt+r)}return t}function rn(e,t){return t.step?{label:e.get(t.id)?.label??``,status:t.step.status,linkedBoardId:t.step.linkedBoardId}:null}function an(e,t,n){let r=Zt(t),i=Vt(t);return{kind:`box`,id:t.id,x:n.x,y:n.y,width:i,height:r.height,titleLines:r.titleLines,icon:t.icon,bodyLines:r.bodyLines,change:t.change,wasLines:r.wasLines,shape:t.shape,headerHeight:r.headerHeight,media:qt(r.content,n,r.artTop,r.art),device:Jt(r.content,n,r.artTop,r.art),step:rn(e,t),outputs:r.outputs.map((e,t)=>({id:e.id,label:e.label,port:{x:n.x+i,y:n.y+r.headerHeight+t*_t+_t/2}}))}}function on(e,t,n){let r=e.y+e.height/2-n.height/2,i=e.x+e.width/2-n.width/2;switch(t.side){case`right`:return{x:e.x+e.width+t.gap,y:r};case`left`:return{x:e.x-n.width-t.gap,y:r};case`bottom`:return{x:i,y:e.y+e.height+t.gap};case`top`:return{x:i,y:e.y-n.height-t.gap}}}function sn(e,t,n,r){let i=on(r,n,{width:Vt(t),height:Zt(t).height});return an(e,t,{x:Math.round(i.x),y:Math.round(i.y)})}function cn(e,t){let n=[...e.values()].reduce((e,t)=>Math.max(e,t.x+t.width),-1/0);return{x:e.size>0?n+dt:L,y:t}}function ln(e,t,n,r){let i=R(e,`box`).filter(e=>e.at===null&&e.near!==null),a=new Set(i.map(e=>e.id)),o=(i,s)=>{let c=n.get(i.id);if(c||!i.near)return c;let l=e.elements[i.near.of],u=l?.kind===`box`&&!s.has(l.id)&&(n.has(l.id)||a.has(l.id))?o(l,new Set([...s,i.id])):void 0;u||r.push(`box ${i.id} sits near ${i.near.of}, which is not placed on the board`);let d=u?sn(e.planStepById,i,i.near,u):an(e.planStepById,i,cn(n,t));return n.set(i.id,d),d};for(let e of i)o(e,new Set)}function un(e){return e.shape===`panel`&&e.step===null&&e.near===null&&e.at===null}function dn(e,t,n,r){let i=R(e,`box`).filter(un).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id));if(i.length===0)return;let a=[...r.values()].reduce((e,t)=>Math.max(e,t.x+t.width+(n.has(t.id)?146:0)),-1/0),o=r.size>0?Math.round(a+dt):L,s=t;for(let t of i){let i=an(e.planStepById,t,{x:o,y:s});r.set(t.id,i),s+=Math.max(i.height,(n.get(t.id)??0)-At)+ft}}function fn(e,t,n,r){let i=new Map,a=[];for(let t of R(e,`box`)){let n=r.get(t.id);n&&i.set(t.id,an(e.planStepById,t,n))}for(let t of R(e,`box`))t.at&&i.set(t.id,an(e.planStepById,t,t.at));ln(e,t,i,a),dn(e,t,n,i);for(let n of R(e,`box`))i.has(n.id)||i.set(n.id,an(e.planStepById,n,cn(i,t)));return{boxesById:i,warnings:a}}function pn(e,t){let n=ye(e.contains.flatMap(e=>t.get(e)??[]));return n?{kind:`frame`,id:e.id,title:e.title,isLoop:e.loop,x:n.x-St,y:n.y-St-Ct,width:n.width+36,height:n.height+36+Ct}:null}function mn(e,t){return R(e,`frame`).flatMap(e=>pn(e,t)??[])}function hn(e){return{x:e.x,y:e.y,width:e.width,height:Ct}}function gn(e){return e.resolvedBy?`resolved by ${e.resolvedBy}`:e.author?`from ${e.author}`:``}function _n(e,t,n){let{lines:r,height:i}=tn(e);return{kind:`note`,id:e.id,x:t.x+t.width-kt,y:n,width:wt,height:i,lines:r,byline:gn(e),isResolved:e.resolvedBy!==null}}function vn(e,t){let n=new Map;return R(e,`note`).flatMap(e=>{let r=t.get(e.on);if(!r)return[];let i=_n(e,r,n.get(e.on)??r.y-At);return n.set(e.on,i.y+i.height+Dt),[i]})}function yn(e){return{x:0,y:0,width:L,height:e}}function bn(e){return e?{x:Math.min(0,e.x-L),y:Math.min(0,e.y-L),width:e.width+80,height:e.height+80}:{x:0,y:0,width:80,height:80}}function xn(e,t,n){let r=e.flatMap(e=>e.kind===`wire`?[]:[e]);return bn(ye([...r,...t?[t]:[],yn(n)]))}function Sn(e,t){return`box ${e} overlaps box ${t}`}function Cn(e,t){return`box ${e} covers the title of frame ${t}`}function wn(e,t,n){let r=[...e.values()],i=oe(r).flatMap(([e,t])=>{let n=r[e],i=r[t];return n&&i&&ie(n,i)?[Sn(n.id,i.id)]:[]}),a=new Map(R(n,`frame`).map(e=>[e.id,new Set(e.contains)])),o=ue(r,Ft),s=t.flatMap(e=>{let t=hn(e),n=[];return pe(o,t,i=>{let o=r[i];o&&!a.get(e.id)?.has(o.id)&&ie(o,t)&&n.push(i)}),n.sort((e,t)=>e-t).map(t=>Cn(r[t]?.id??``,e.id))});return[...i,...s]}function Tn(e,t,n){let{boxesById:r,warnings:i}=fn(e,t.boxesTop,t.stackHeightByBoxId,t.stepBandPositions),a=mn(e,r),o=vn(e,r);return{boxesById:r,frames:a,notes:o,routing:le({wires:R(e,`wire`),boxesById:r,softObstacles:[...o,...a.map(hn)],loopFrames:a.filter(e=>e.isLoop),contentTop:t.contentTop},n),collectPlacementWarnings:()=>[...i,...wn(r,a,e)]}}function En(e){return e.step!==null&&e.near===null&&e.at===null}function Dn(e){let t=new Map;for(let n of Object.values(e.elements))n.kind===`box`&&En(n)&&t.set(n.id,n);let n=new Map;if(t.size===0)return{positionById:n,bottom:L,columns:[]};let r=new Map;for(let n of nt(e)){let e=t.get(n.boxId);e&&r.set(n.level,[...r.get(n.level)??[],e])}let i=L,a=L,o=[];for(let e of[...r.keys()].sort((e,t)=>e-t)){let t=r.get(e)??[],s=70,c=s;for(let e of t)n.set(e.id,{x:i,y:s}),s+=Zt(e).height,c=s,a=Math.max(a,s),s+=ft;t.length>0&&o.push({x:i,bottom:c,boxCount:t.length}),i+=Math.max(...t.map(Vt))+dt}return{positionById:n,bottom:a+jt,columns:o}}function On(e){return e-pt}function kn(e,t){let n=(e?.columns??[]).flatMap(e=>{let n=t.filter(t=>t.x===e.x);return n.length>=e.boxCount?[]:[e.bottom-n.reduce((e,t)=>e+t.height+ft,0)]});return n.length===0?0:Math.max(L,...n)+jt-L}function An(e,t){if(t===0)return e;let n=Object.fromEntries(Object.entries(e.elements).map(([e,n])=>n.kind!==`box`||!n.at?[e,n]:[e,{...n,at:{x:n.at.x,y:n.at.y+t}}]));return{...e,elements:n}}var jn={plain:null,fail:`failure path`,join:`joins`};function Mn(e,t,n){return`${e}|${t}|${n}`}function Nn(e,t,n){let r=[jn[e],n?`returns to an earlier step`:null,t&&!n?`optional`:null].filter(e=>e!==null);return r.length>0?r.join(`, `):null}var Pn={added:`added by this change`,removed:`removed by this change`,relabeled:`renamed, old title struck through`};function Fn(e){return y.flatMap(t=>t===`none`||!e.has(t)?[]:[{label:Pn[t],swatch:{kind:`change`,change:t}}])}function In(e){return e?T.map(e=>({label:`plan step ${e}`,swatch:{kind:`status`,status:e}})):[]}function Ln(e){return Rn(e.legend,R(e,`wire`),new Set(R(e,`box`).map(e=>e.change)),e.planStepById.size>0)}function Rn(e,t,n,r){let i=new Map(e.map(e=>[Mn(e.tone,e.dashed||e.back,e.back),e.label])),a=new Set,o=[...t].flatMap(e=>{let t=e.dashed||e.back,n=Mn(e.tone,t,e.back),r=i.get(n)??Nn(e.tone,t,e.back);return a.has(n)||r===null?[]:(a.add(n),[{key:n,label:r,swatch:{kind:`wire`,tone:e.tone,isDashed:t,isBack:e.back}}])}).sort((e,t)=>e.key.localeCompare(t.key)),s=e.filter(e=>!a.has(Mn(e.tone,e.dashed||e.back,e.back))).map(e=>({label:e.label,swatch:{kind:`wire`,tone:e.tone,isDashed:e.dashed||e.back,isBack:e.back}}));return[...o.map(({label:e,swatch:t})=>({label:e,swatch:t})),...s,...Fn(n),...In(r)]}function zn(e){return Bn(e,null).layout}function Bn(e,t){let{positionById:n,bottom:r,columns:i}=Dn(e),a=r-L,o=en(An(e,a)),s=nn(o),c=r,l=Tn(o,{boxesTop:c,contentTop:On(r),stackHeightByBoxId:s,stepBandPositions:n},t?.route??null),u={route:l.routing.memory},d=[...l.frames,...l.routing.wires,...l.boxesById.values(),...l.notes],f=Vn(o.caption,xn(d,l.routing.extent,c),Ln(o),n.size>0?i:[],a),p=[...l.routing.collectWarnings(),j(l.collectPlacementWarnings())];return{layout:{elements:d,...f,warnings:ne(p)},memory:u,warningLists:p}}function Vn(e,t,n,r,i){let a=t.y+t.height,o=n.map((e,t)=>({...e,x:L,y:a+t*Ot})),s=a+o.length*Ot+(o.length>0?12:0),c=e?{text:e,x:L,y:s}:null,l=o.length*Ot+(c?30:0)+(o.length>0?12:0);return{legend:o,caption:c,pinnedOffsetY:i,plan:r.length>0?{titleAt:{x:L,y:56},columns:[...r]}:null,bounds:{...t,height:t.height+l}}}function Hn(e){return JSON.stringify(e)}function Un(e,t,n){let r=e.outputs.map(e=>({...e,port:{x:e.port.x+t,y:e.port.y+n}})),i=e.media?{...e.media,x:e.media.x+t,y:e.media.y+n}:null,a=e.device?{...e.device,x:e.device.x+t,y:e.device.y+n,screen:{...e.device.screen,x:e.device.screen.x+t,y:e.device.screen.y+n}}:null;return{...e,x:e.x+t,y:e.y+n,outputs:r,media:i,device:a}}function Wn(e,t){let n=new Set(t),r=!0;for(;r;){r=!1;for(let t of Object.values(e.elements)){let e=t.kind===`box`?t.near?.of:t.kind===`note`?t.on:void 0;!n.has(t.id)&&e&&n.has(e)&&(n.add(t.id),r=!0)}}return n}function Gn(e,t,n){let r=Wn(e,n),i=new Map,a=[],o=[],s=[];for(let e of t.elements)e.kind===`box`&&i.set(e.id,e),e.kind===`note`&&r.has(e.id)&&o.push(e),e.kind===`note`&&!r.has(e.id)&&a.push(e),e.kind===`frame`&&a.push(hn(e)),e.kind===`frame`&&e.isLoop&&s.push(e);let c=[...r].flatMap(e=>i.get(e)??[]),l=Object.values(e.elements).flatMap(e=>e.kind===`wire`&&(r.has(e.from)||r.has(e.to))?[e]:[]),u=On(t.pinnedOffsetY+L);return(e,t)=>{let n=c.map(n=>Un(n,e,t));for(let e of n)i.set(e.id,e);let r=o.map(n=>({...n,x:n.x+e,y:n.y+t}));return[...n,...r,...ge({wires:l,boxesById:i,softObstacles:[...a,...r],loopFrames:s,contentTop:u})]}}var Kn=4,qn=200,Jn=2e4,Yn=1.1,Xn=[`wire`,`note`,`frame`,`box`],Zn={v:`select`,r:`box`,d:`decision`,p:`panel`,i:`icon`,m:`device`,a:`wire`},Qn=new Set([1,2]);function $n(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}function er(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function tr(){return document.documentElement.dataset.layout===`phone`}function nr(e){return e===`box`||e===`decision`||e===`panel`||e===`icon`||e===`device`}var rr={box:`Box`,decision:`Decision`,panel:`Panel`,icon:`Icon`,device:`Device`};function ir(e,t,n,r){let i={kind:`box`,id:er(`box`),title:t,icon:null,refs:[],change:`none`,was:null,near:null,order:0,at:e,width:null,step:null};switch(r){case`icon`:return{...i,shape:r,icon:c};case`device`:return{...i,shape:r,device:o,fit:`fill`,media:n};case`decision`:return{...i,shape:r,lines:[],media:n,outputs:[{id:`yes`,label:`yes`},{id:`no`,label:`no`}]};case`box`:case`panel`:return{...i,shape:r,lines:[],media:n}}}function ar(e){return e?.part!==`media`||!e.media?null:{boxId:e.id,href:e.media.href,alt:e.media.alt}}var or={body:`pointer`,port:`crosshair`,resize:`ew-resize`,link:`pointer`,media:`zoom-in`};function sr(e){return e?e.part===`body`&&e.kind===`box`?`move`:or[e.part]:``}var cr=2,lr=12/10;function ur(e){let{viewport:n,world:r,svg:i,canvas:a,renderer:o}=e,s=new Map,c=new Set,l={x:0,y:0,scale:1},u=null,d=null,f=null,p=`select`,m=null,h=!1;function g(t){p=t,n.dataset.tool=t,e.onToolChange(t)}function _(){r.style.transform=`translate(${-l.x*l.scale}px, ${-l.y*l.scale}px) scale(${l.scale})`,o.setCamera(l)}function v(){return(n.clientWidth||1)/l.scale}function y(){let e=n.getBoundingClientRect(),t=[...a.querySelectorAll(`.wb-island`)].filter(e=>e.checkVisibility()).map(e=>e.getBoundingClientRect()),r=e.top+e.height/2,i=t.filter(e=>e.top+e.height/2<r).map(t=>t.bottom-e.top),o=t.filter(e=>e.top+e.height/2>=r).map(t=>t.top-e.top),s=Math.max(0,...i),c=Math.min(e.height,...o)-s;return c<e.height/2?{topPx:0,heightPx:e.height}:{topPx:s,heightPx:c}}function b(){let e=o.layout();if(!e)return;let{bounds:t}=e,r=n.clientWidth,i=n.clientHeight;if(r===0||i===0){l={x:t.x,y:t.y,scale:1},_(),h=!0;return}h=!1;let a=y(),s=e.elements.length===0?1:cr,c=Math.max(1/s,t.width/r,t.height/a.heightPx),u=c>lr,d=u?lr:c,f=r*d,p=t.y+t.height/2,m=a.topPx+a.heightPx/2;l={x:t.x-Math.max(0,f-t.width)/2,y:u?t.y-a.topPx*d:p-m*d,scale:1/d},_()}function x(e,t){let r=n.getBoundingClientRect();return{x:l.x+(e-r.left-n.clientLeft)/l.scale,y:l.y+(t-r.top-n.clientTop)/l.scale}}function C(){return 1/l.scale}function w(e,t){let n=v(),r=Math.min(Jn,Math.max(qn,n*t))/n;l={x:e.x-(e.x-l.x)*r,y:e.y-(e.y-l.y)*r,scale:l.scale/r},_()}function T(e,t){l={...l,x:l.x-e/l.scale,y:l.y-t/l.scale},_()}function E(t){c=t,o.setSelection(c),e.onSelectionChange(c)}function D(e,t){if(!t){E(c.has(e)&&c.size===1?new Set:new Set([e]));return}let n=new Set(c);n.delete(e)||n.add(e),E(n)}function O(e,t){return{x:Math.round(t.x+e.latest.x-e.origin.x),y:Math.round(t.y+e.latest.y-e.origin.y-e.pinnedOffsetY)}}function ee(e,n){let r=Math.round(n.width+e.latest.x-e.origin.x);return Math.min(t.boxWidthMax,Math.max(t.boxWidthMin,r))}function te(t){if(t.mode===`resize`)return t.movingBoxes.map(e=>({boxId:e.boxId,fields:{width:ee(t,e.start)}}));let n=t.movingBoxes.map(e=>({boxId:e.boxId,at:O(t,e.start)})),r=e.currentBoard(),i=t.movingBoxes.filter(e=>{let t=r?.elements[e.boxId];return t?.kind===`box`&&En(t)}),a=t.pinnedOffsetY-kn(o.layout()?.plan??null,i.map(e=>e.start));return n.map(({boxId:e,at:t})=>({boxId:e,fields:{at:{x:t.x,y:t.y+a}}}))}function k(){f!==null&&cancelAnimationFrame(f),f=null}function A(e){return{x:Math.round(e.latest.x-e.origin.x),y:Math.round(e.latest.y-e.origin.y)}}function ne(e,t){let n=o.layout();if(e.mode!==`move`||!e.hasMoved||!n)return!1;let r=A(e);if(!e.preview||e.previewLayout!==n){let r=n.elements.find(t=>t.kind===`box`&&t.id===e.boxId),i=r?.kind===`box`?r:null;e.laidOutOffset=i?{x:i.x-e.start.x,y:i.y-e.start.y}:{x:0,y:0},e.preview=Gn(t,n,new Set(e.movingBoxes.map(e=>e.boxId))),e.previewLayout=n}return o.paintElements(e.preview(r.x-e.laidOutOffset.x,r.y-e.laidOutOffset.y)),!0}function re(e,t,n){let r=new Set(e.movingBoxes.map(e=>e.boxId)),i=new Map(n.elements.flatMap(e=>e.kind===`box`&&r.has(e.id)?[[e.id,e]]:[])),a={};for(let{boxId:n,fields:r}of te(e)){let e=t.elements[n],o=i.get(n);e?.kind===`box`&&o&&(a[n]={...e,...r,near:null,step:null,at:{x:o.x,y:o.y}})}let o=new Map;for(let e of zn({...t,elements:a}).elements){let t=i.get(e.id);e.kind===`box`&&t&&o.set(e.id,Un(e,t.x-e.x,t.y-e.y))}return Gn(t,{...n,elements:n.elements.map(e=>o.get(e.id)??e)},new Set(o.keys()))(0,0)}function ie(e,t){let n=o.layout();return e.mode!==`resize`||!e.hasMoved||!n?!1:(o.paintElements(re(e,t,n)),!0)}function j(){k();let t=e.currentBoard();u?.kind!==`drag`||!t?e.repaint():ne(u,t)||ie(u,t)||e.repaint()}function ae(){let t=e.currentBoard();u?.kind===`drag`&&t&&(ne(u,t)||ie(u,t))}function oe(){f===null&&(f=requestAnimationFrame(j))}function se(e){u?.kind===`drag`&&e?.elements[u.boxId]?.kind!==`box`&&(u=null),u?.kind===`drag`&&u.hasMoved&&(u.movingBoxes=u.movingBoxes.filter(t=>e?.elements[t.boxId]?.kind===`box`));let t=new Set([...c].filter(t=>e?.elements[t]));t.size!==c.size&&E(t)}function M(e,t){return o.hitTest(x(e,t))}function ce(){let[e,t]=[...s.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function le(){u?.kind===`wire`&&ye(u,!1),u={kind:`pinch`,distance:ce(),viewWidth:v()}}function ue(e){e.preventDefault(),s.set(e.pointerId,{x:e.clientX,y:e.clientY}),n.setPointerCapture(e.pointerId),u={kind:`pan`,pointerId:e.pointerId,lastClient:{x:e.clientX,y:e.clientY},hasMoved:!1,isAuxiliaryButton:!0,tappedBoxId:null,pressedImage:null}}function N(e){let t=x(e.clientX,e.clientY),n=document.createElementNS(`http://www.w3.org/2000/svg`,`rect`);n.setAttribute(`class`,`wb-wire-line wb-dashed wb-wire-draft`),u={kind:`marquee`,pointerId:e.pointerId,origin:t,latest:t,hasMoved:!1,isAdditive:e.shiftKey,baseSelection:e.shiftKey?new Set(c):new Set,outline:n}}function de(t,n,r){if(r||!c.has(t))return[{boxId:t,start:n}];let i=e.currentBoard();return[...c].flatMap(e=>{let t=i?.elements[e]?.kind===`box`?o.boundsOf(e):null;return t?[{boxId:e,start:t}]:[]})}function fe(t){if(d)return;if(t.pointerType===`mouse`&&Qn.has(t.button)&&!u){ue(t);return}if(t.button!==0)return;let r=M(t.clientX,t.clientY);if(r?.part===`link`&&r.linkedBoardId){e.onOpenLinkedBoard(r.linkedBoardId);return}if(s.set(t.pointerId,{x:t.clientX,y:t.clientY}),n.setPointerCapture(t.pointerId),s.size===2){le();return}if(nr(p)){pe(p,x(t.clientX,t.clientY));return}let i=r?.kind===`box`?o.boundsOf(r.id):null,a=r?.part===`resize`&&!tr()?i:null;if(r&&a){let e=x(t.clientX,t.clientY);u={kind:`drag`,mode:`resize`,pointerId:t.pointerId,boxId:r.id,origin:e,start:a,movingBoxes:de(r.id,a,!1),pinnedOffsetY:0,latest:e,hasMoved:!1,isAdditive:!1,pressedImage:null,preview:null,previewLayout:null,laidOutOffset:{x:0,y:0}};return}if(r?.kind===`box`&&r.port&&!tr()){ge(t.pointerId,r.id,r.port);return}let c=p===`wire`?i:null;if(r&&c){ge(t.pointerId,r.id,{x:c.x+c.width/2,y:c.y+c.height/2});return}let l=tr()?null:i;if(r&&l){let e=x(t.clientX,t.clientY),n=o.layout()?.pinnedOffsetY??0;u={kind:`drag`,mode:`move`,pointerId:t.pointerId,boxId:r.id,origin:e,start:l,movingBoxes:de(r.id,l,t.shiftKey),pinnedOffsetY:n,latest:e,hasMoved:!1,isAdditive:t.shiftKey,pressedImage:ar(r),preview:null,previewLayout:null,laidOutOffset:{x:0,y:0}};return}if(r&&!tr()){D(r.id,t.shiftKey);return}if(!r&&t.pointerType===`mouse`&&!tr()){N(t);return}let f=r?.kind===`box`?r.id:null;u={kind:`pan`,pointerId:t.pointerId,lastClient:{x:t.clientX,y:t.clientY},hasMoved:!1,isAuxiliaryButton:!1,tappedBoxId:f,pressedImage:ar(r)}}async function pe(t,n){if(g(`select`),!e.currentBoard())return;let r=o.layout()?.pinnedOffsetY??0,i=ir({x:Math.round(n.x),y:Math.round(n.y-r)},rr[t],null,t);m=i.id;let a=await e.sendOps([{op:`add`,element:i}]);a||(m=null),a&&E(new Set([i.id])),he()}async function me(t,r,i){if(!e.currentBoard())return!1;let a=i?x(i.x,i.y):{x:l.x+v()/2,y:l.y+(n.clientHeight||1)/l.scale/2},s=o.layout()?.pinnedOffsetY??0,c=ir({x:Math.round(a.x),y:Math.round(a.y-s)},t,r,`box`),u=await e.sendOps([{op:`add`,element:c}]);return u&&E(new Set([c.id])),u}function he(){if(!m||!o.boundsOf(m)||!e.currentBoard()?.elements[m])return;let t=m;m=null,je(t)}function ge(e,t,n){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);r.setAttribute(`class`,`wb-wire-line wb-dashed wb-wire-draft`),r.setAttribute(`d`,`M ${n.x} ${n.y} L ${n.x} ${n.y}`),i.append(r),u={kind:`wire`,pointerId:e,fromBoxId:t,start:n,draftLine:r,targetBoxId:null}}function _e(e,t){e.targetBoxId=t,o.setWireTarget(t)}function ve(e,t){let n=x(t.clientX,t.clientY);e.draftLine.setAttribute(`d`,`M ${e.start.x} ${e.start.y} L ${n.x} ${n.y}`);let r=o.hitTest(n);_e(e,r?.kind===`box`&&r.id!==e.fromBoxId?r.id:null)}function ye(t,n){let r=t.targetBoxId;_e(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function be(e,t){let n=x(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<Kn*C()||(e.hasMoved=!0,e.latest=n,oe())}function xe(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<Kn||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},T(n,r))}function Se(e,t){let n=x(t.clientX,t.clientY);if(!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<Kn*C())return;e.hasMoved||i.append(e.outline),e.hasMoved=!0,e.latest=n;let r=$n(e.origin,n);e.outline.setAttribute(`x`,String(r.x)),e.outline.setAttribute(`y`,String(r.y)),e.outline.setAttribute(`width`,String(r.width)),e.outline.setAttribute(`height`,String(r.height));let a=new Set([...e.baseSelection,...o.elementsInRect(r)]);a.size===c.size&&[...a].every(e=>c.has(e))||E(a)}function Ce(e){e.outline.remove(),e.hasMoved||e.isAdditive||E(new Set)}function we(e){let t=ce();if(t<=0||e.distance<=0)return;let n=[...s.values()];w(x(n.reduce((e,t)=>e+t.x,0)/n.length,n.reduce((e,t)=>e+t.y,0)/n.length),e.viewWidth*(e.distance/t)/v())}function Te(e){if(e.pointerType!==`mouse`||tr())return;let t=M(e.clientX,e.clientY);o.setHover(t?.kind===`box`?t.id:null),n.dataset.hoverKind=t?.kind??``,n.style.cursor=p===`select`?sr(t):``}function P(e){u||Te(e),s.has(e.pointerId)&&(s.set(e.pointerId,{x:e.clientX,y:e.clientY}),u?.kind===`pinch`?we(u):u?.kind===`drag`&&u.pointerId===e.pointerId?be(u,e):u?.kind===`wire`&&u.pointerId===e.pointerId?ve(u,e):u?.kind===`marquee`&&u.pointerId===e.pointerId?Se(u,e):u?.kind===`pan`&&u.pointerId===e.pointerId&&xe(u,e))}async function Ee(t,n){if(!t.hasMoved&&t.mode===`resize`)return;if(!t.hasMoved){D(t.boxId,t.isAdditive),t.pressedImage&&!t.isAdditive&&e.onOpenImage(t.pressedImage);return}k(),t.latest=x(n.clientX,n.clientY);let r=te(t),i=e.currentBoard();i&&!ne(t,i)&&ie(t,i),await e.sendOps(r.map(({boxId:e,fields:t})=>({op:`set`,id:e,fields:t})))||j()}function De(t){if(!s.delete(t.pointerId))return;let n=u;n?.kind===`pinch`?u=null:(u=null,n?.kind===`drag`&&n.pointerId===t.pointerId?Ee(n,t):n?.kind===`wire`?(ye(n,n.pointerId===t.pointerId),p===`wire`&&g(`select`)):n?.kind===`marquee`?Ce(n):n?.kind!==`pan`||n.hasMoved||n.isAuxiliaryButton||(n.pressedImage&&tr()?e.onOpenImage(n.pressedImage):n.tappedBoxId&&tr()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||E(new Set)))}function Oe(e){s.delete(e.pointerId);let t=u?.kind===`drag`;u?.kind===`wire`&&ye(u,!1),u?.kind===`marquee`&&u.outline.remove(),u=null,t&&j()}function ke(e){e.preventDefault(),e.ctrlKey||e.metaKey?w(x(e.clientX,e.clientY),e.deltaY>0?Yn:1/Yn):T(-e.deltaX,-e.deltaY)}function Ae(){let e=d;d=null,e?.remove()}function je(t){let r=e.currentBoard()?.elements[t],i=o.boundsOf(t);if(r?.kind!==`box`||!i)return;Ae();let s=a.getBoundingClientRect(),c=n.getBoundingClientRect(),u={left:c.left+n.clientLeft+(i.x-l.x)*l.scale,top:c.top+n.clientTop+(i.y-l.y)*l.scale,width:i.width*l.scale},f=S(`input`,`wb-title-input`);f.type=`text`,f.value=r.title,f.maxLength=80,f.setAttribute(`aria-label`,r.shape===`panel`?`Panel title`:`Box title`),f.style.left=`${u.left-s.left}px`,f.style.top=`${u.top-s.top}px`,f.style.width=`${Math.max(160,u.width)}px`,d=f,a.append(f),f.addEventListener(`keydown`,i=>{if(i.key===`Escape`){i.preventDefault(),Ae(),n.focus();return}if(i.key!==`Enter`)return;i.preventDefault();let a=f.value.trim();Ae(),n.focus(),a&&a!==r.title&&e.sendOps([{op:`set`,id:t,fields:{title:a}}])}),f.addEventListener(`blur`,Ae),f.focus(),f.select()}function F(e){if(tr())return;let t=M(e.clientX,e.clientY);t?.kind===`box`&&je(t.id)}function Me(){let t=e.currentBoard();if(!t||c.size===0)return;let n=[...c].flatMap(e=>t.elements[e]??[]),r=Xn.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));E(new Set),e.sendOps(r)}function Ne(e){if(e.target!==n||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),Me();return}let t=Zn[e.key.toLowerCase()];t&&!e.shiftKey?(e.preventDefault(),g(t)):e.key===`Escape`&&(E(new Set),g(`select`))}return r.style.transition=`none`,n.tabIndex=0,n.addEventListener(`pointerdown`,fe),n.addEventListener(`pointermove`,P),n.addEventListener(`pointerup`,De),n.addEventListener(`pointercancel`,Oe),n.addEventListener(`wheel`,ke,{passive:!1}),n.addEventListener(`dblclick`,F),n.addEventListener(`contextmenu`,e=>e.preventDefault()),n.addEventListener(`keydown`,Ne),n.addEventListener(`pointerleave`,()=>{u||(o.setHover(null),n.dataset.hoverKind=``)}),new ResizeObserver(()=>{h&&n.clientWidth>0&&n.clientHeight>0&&b()}).observe(n),{fit:b,selectedIds:()=>c,clearSelection:()=>E(new Set),pruneSelection:se,repaintPreview:ae,closeTitleInput:Ae,setTool:g,placeMediaBox:me,openPendingTitleEdit:he,focusCanvas:()=>n.focus()}}var dr=Object.freeze({box:b,frame:m,wire:w,note:E});Object.freeze({id:`operator`,name:`operator`});function fr(e){return C.some(t=>t===e)}function pr(e,t){if(e.kind!==`box`||t.shape===void 0||t.shape===e.shape||!fr(t.shape))return e;let r=n(t.shape);return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}Object.freeze({x:0,y:0});function mr(e,t,n){if(n[0]===`put`)return n[1].id===t?n[1]:null;if(n[0]===`remove`||!e)return null;let r=dr[e.kind].safeParse({...pr(e,n[1]),...n[1]});return r.success&&r.data.id===t?r.data:null}function hr(e,n,r,i){let a={...e.elements};for(let[e,t]of Object.entries(n.elements)){let n=a[e];if(t[0]===`remove`){if(!n)return null;delete a[e];continue}let r=mr(n,e,t);if(!r)return null;t[0]===`put`&&delete a[e],a[e]=r}return Object.keys(a).length>t.elements?null:{...e,...n.fields,elements:a,version:r,updatedAt:i}}var gr=Object.freeze({undo:[],redo:[]}),_r=new Set([`box`]),vr=[`wire`,`note`,`frame`,`box`],yr=new Set([`kind`,`id`]);function br(e,t){return JSON.stringify(e)===JSON.stringify(t)}function xr(e){return e.kind===`box`&&e.near?[e.near.of]:[]}function Sr(e){let t=new Set(e.map(e=>e.id)),n=[];for(;t.size>0;){let r=e.filter(e=>t.has(e.id)&&xr(e).every(e=>!t.has(e))),i=r.length>0?r:e.filter(e=>t.has(e.id));for(let e of i)t.delete(e.id);n.push(...i)}return n}function Cr(e,t){let n={...e},r=Object.fromEntries(Object.entries(t).filter(([e,t])=>!yr.has(e)&&!br(n[e],t)));return t.kind!==`note`||Object.keys(r).length===0?r:{...r,author:t.author,resolvedBy:t.resolvedBy}}function wr(e,t){let n={...e.title===t.title?{}:{title:t.title},...e.caption===t.caption?{}:{caption:t.caption},...br(e.legend,t.legend)?{}:{legend:t.legend},...e.codeSessionId===t.codeSessionId?{}:{codeSessionId:t.codeSessionId}};return Object.keys(n).length===0?[]:[{op:`board`,...n}]}function Tr(e,t){let n=Object.values(e.elements),r=Object.values(t.elements),i=vr.flatMap(e=>n.filter(n=>n.kind===e&&!t.elements[n.id])),a=Sr(r.filter(t=>!e.elements[t.id])),o=r.flatMap(t=>{let n=e.elements[t.id];if(!n||n===t)return[];let r=Cr(n,t);return Object.keys(r).length===0?[]:[{op:`set`,id:t.id,fields:r}]});return[...i.map(e=>({op:`remove`,id:e.id})),...a.filter(e=>_r.has(e.kind)).map(e=>({op:`add`,element:e})),...o,...a.filter(e=>!_r.has(e.kind)).map(e=>({op:`add`,element:e})),...wr(e,t)]}var Er=Object.freeze({id:`touched`,title:`touched`,version:0,caption:null,legend:[],codeSessionId:null,project:null,createdAt:0,updatedAt:0});function Dr(e,t){let n=Object.fromEntries(Object.entries(e.elements).flatMap(([e,t])=>t?[[e,t]]:[])),r={...Er,...e.fields,elements:n},i=hr(r,t,0,0);return i?Tr(i,r):[]}function Or(e,t){return t.length===0?[...e]:[...e,t].slice(-100)}function kr(e,t){return t.length===0?e:{undo:Or(e.undo,t),redo:[]}}function Ar(e,t){let n=e[t].at(-1);return n?{entry:n,history:{...e,[t]:e[t].slice(0,-1)}}:null}function jr(e,t,n){let r=t===`undo`?`redo`:`undo`;return{...e,[r]:Or(e[r],n)}}var Mr=16;function Nr(t){let n=we(24,24);return n.setAttribute(`width`,String(Mr)),n.setAttribute(`height`,String(Mr)),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.innerHTML=e[t].elements.join(``),n}function Pr(t){let n=S(`span`,`wb-icon-current`);return t?(n.append(Nr(t),S(`span`,`wb-icon-current-label`,e[t].label)),n):(n.append(S(`span`,`wb-icon-current-label`,`none`)),n)}function Fr(t,n){return t.includes(n)||e[t].label.toLowerCase().includes(n)}function Ir({field:t,icon:n,isRequired:r,accessibleName:i,commit:a}){let o=S(`div`,`wb-icon-picker`);o.dataset.field=t;let c=S(`div`,`wb-icon-popover`);c.hidden=!0,c.tabIndex=-1;let l=S(`input`,`wb-inspect-input wb-icon-search`);l.type=`search`,l.placeholder=`search icons`,l.setAttribute(`aria-label`,`Search icons for ${i}`);let u=new Map,d=()=>{c.hidden=!0,p.setAttribute(`aria-expanded`,`false`)},f=e=>{d(),p.focus(),e!==n&&a(e)},p=P({variant:`quiet`,size:`small`,label:`icon`,action:`icon-pick`,onClick:()=>{let e=c.hidden;c.hidden=!e,p.setAttribute(`aria-expanded`,String(e)),e&&l.focus()}});p.setAttribute(`aria-label`,i),p.setAttribute(`aria-expanded`,`false`),p.setAttribute(`aria-haspopup`,`true`);let m=_.map(t=>{let r=S(`div`,`wb-icon-group`),i=S(`div`,`wb-icon-grid`);for(let r of s.filter(n=>e[n].category===t)){let t=P({variant:`icon`,size:`small`,label:e[r].label,icon:Nr(r),action:`icon-choice`,onClick:()=>f(r)});t.dataset.icon=r,t.classList.add(`wb-icon-choice`),t.setAttribute(`aria-pressed`,String(r===n)),u.set(r,t),i.append(t)}return r.append(S(`span`,`wb-icon-group-label`,t),i),{group:r,grid:i}});l.addEventListener(`input`,()=>{let e=l.value.trim().toLowerCase();for(let[t,n]of u)n.hidden=!Fr(t,e);for(let{group:e,grid:t}of m)e.hidden=[...t.children].every(e=>e instanceof HTMLElement&&e.hidden)}),l.addEventListener(`keydown`,e=>{if(e.key!==`Enter`)return;e.preventDefault();let t=[...u].find(([,e])=>!e.hidden);t&&f(t[0])}),c.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),d(),p.focus())});let h=P({variant:`quiet`,size:`small`,label:`no icon`,action:`icon-clear`,onClick:()=>f(null),disabled:r||n===null});return c.append(l,...m.map(({group:e})=>e),h),o.append(Pr(n),p,c),o}var Lr=8,Rr=12,zr=30,Br=40,Vr=40,Hr=400,Ur=200,Wr=8,Gr=`README.md`,Kr=[`text`,`code`,`item`,`numbered`,`kv`],qr=[`plain`,`fail`,`join`],Jr=ii(Kr),Yr=ii(qr),Xr=ii(C),Zr={box:`Box`,decision:`Decision`,panel:`Panel`,icon:`Icon`,device:`Device`},Qr=ii(a),$r=ii(i),ei=ii(y),ti=ii(T),ni=[{value:``,text:`auto`},...ii([`left`,`right`,`top`,`bottom`])],ri=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function ii(e){return e.map(e=>({value:e,text:e}))}function ai(e){return S(`h3`,`wb-inspect-heading`,e)}function z(e,t){let n=S(`label`,`wb-inspect-field`);return n.append(S(`span`,`wb-inspect-label`,e),t),n}function oi(e,t){let n=S(`div`,`wb-inspect-field`);return n.append(S(`span`,`wb-inspect-label`,e),t),n}function B(e,t,n,r,i){let a=S(`input`,`wb-inspect-input`);return a.type=`text`,a.value=t,a.maxLength=n,a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.addEventListener(`change`,()=>r(a.value)),a}function V(e,t,n,r,i){let a=S(`select`,`wb-inspect-select`);return a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.append(...t.map(e=>{let t=S(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),a.addEventListener(`change`,()=>r(a.value)),a}function si(e,t,n,r){let i=S(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let a=S(`label`,`wb-inspect-toggle`);return a.append(i,S(`span`,null,t)),a}function H(e,t,n,r){let i=P({variant:`quiet`,size:`small`,label:t,action:t.replaceAll(` `,`-`),onClick:n});return i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i}function ci(e,t,n){let r=S(`div`,`wb-inspect-list`);return r.append(S(`span`,`wb-inspect-label`,e),...t,n),r}function li(e,t){return{edit(n,r){let i=e(),a=i?.[n];i&&a!==void 0&&t(i.map((e,t)=>t===n?r(a):e))},remove(n){let r=e();r&&t(r.filter((e,t)=>t!==n))},append(n){let r=e();r&&t([...r,n(r)])}}}function ui(e){let t=e.trim();return x.safeParse(t).success?t:null}function di(e,t,n,r){let i=B(e,t??``,Ur,e=>{if(!e.trim()){n(null);return}let t=ui(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function fi(e,t,n,r){let i=li(n,r),a=t.map((e,t)=>{let n=S(`div`,`wb-inspect-row`);return n.append(B(`ref-${t}`,e,Ur,e=>{let n=ui(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),H(`ref-${t}-remove`,`remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),o=H(`ref-add`,`add ref`,()=>i.append(()=>Gr),`Add a ref to ${e}`);return o.disabled=t.length>=Wr,ci(`Refs`,a,o)}function pi(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function mi(e,n,r,i){let a=li(r,i),o=n.map((e,n)=>{let r=S(`div`,`wb-inspect-row`),i=n+1;return r.append(V(`line-${n}-style`,Jr,e.style,e=>{let t=Kr.find(t=>t===e);t&&a.edit(n,e=>pi(e,t))},`Line ${i} style`)),e.style===`kv`&&r.append(B(`line-${n}-key`,e.key??``,Vr,e=>{e.trim()&&a.edit(n,t=>({...t,key:e.trim()}))},`Line ${i} key`)),r.append(Ir({field:`line-${n}-icon`,icon:e.icon,isRequired:!1,accessibleName:`Line ${i} icon`,commit:e=>a.edit(n,t=>({...t,icon:e}))}),B(`line-${n}-text`,e.text,t.line,e=>a.edit(n,t=>({...t,text:e})),`Line ${i} text`),di(`line-${n}-ref`,e.ref,e=>a.edit(n,t=>({...t,ref:e})),`Line ${i} ref`),H(`line-${n}-remove`,`remove`,()=>a.remove(n),`Remove line ${i}`)),r}),s=H(`line-add`,`add line`,()=>a.append(()=>({text:`new line`,muted:!1,style:`text`,key:null,ref:null,icon:null})),`Add a line to ${e}`);return s.disabled=n.length>=t.linesPerBox,ci(`Lines`,o,s)}function hi(e){let t=new Set(e.map(e=>e.id)),n=e.length+1;for(;t.has(`exit-${n}`);)n+=1;return`exit-${n}`}function gi(e,t,n){let r=li(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=S(`div`,`wb-inspect-row`);return n.append(B(`output-${e.id}-label`,e.label,zr,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),H(`output-${e.id}-remove`,`remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),a=H(`output-add`,`add output`,()=>r.append(e=>({id:hi(e),label:`exit`})));return a.disabled=e.outputs.length>=Lr,ci(`Outputs`,i,a)}function _i(e,n,r,i){let a=()=>{let e=n();return e?.kind===`box`?e:null},s=()=>{let e=a();return e&&`lines`in e?e.lines??null:null},c=()=>{let e=a();return e?.shape===`decision`?e.outputs:null},l=()=>{let t=r?.elements.find(t=>t.id===e.id);return!r||t?.kind!==`box`?null:{x:t.x,y:t.y-r.pinnedOffsetY}},u=()=>{let e=a(),t=e&&un(e)?l():null;return t?{at:t}:{}};return[ai(Zr[e.shape]),z(`Title`,B(`title`,e.title,t.title,e=>{e.trim()&&i({title:e.trim()})})),oi(`Icon`,Ir({field:`icon`,icon:e.icon,isRequired:e.shape===`icon`,accessibleName:`Box icon`,commit:e=>i({icon:e})})),z(`Shape`,V(`shape`,Xr,e.shape,e=>{e===`decision`&&i({shape:e,outputs:c()??ri,...u()}),e===`box`&&i({shape:e,...u()}),e===`panel`&&i({shape:e}),e===`icon`&&i({shape:e,icon:a()?.icon??`component`,...u()}),e===`device`&&i({shape:e,device:o,...u()})})),z(`Change`,V(`change`,ei,e.change,t=>{i(t===`relabeled`?{change:t,was:a()?.was??e.title}:{change:t,was:null})})),...e.change===`relabeled`?[z(`Was`,B(`was`,e.was??``,t.title,e=>{e.trim()&&i({was:e.trim()})}))]:[],...e.shape===`decision`?[gi(e,c,i)]:[],...e.shape===`device`?vi(e,i):[],fi(`this box`,e.refs,()=>a()?.refs??null,e=>i({refs:e})),...e.shape===`icon`||e.shape===`device`?[]:[mi(`this box`,e.lines,s,e=>i({lines:e}))],...e.step?Ci(e.step,i):[]]}function vi(e,t){return[z(`Device`,V(`device`,Qr,e.device,e=>t({device:e}))),z(`Fit`,V(`fit`,$r,e.fit,e=>t({fit:e})))]}function yi(e,t,n){let r=e.elements[t.from],i=r?.kind===`box`&&r.shape===`decision`?r.outputs:null,a=!r&&t.fromOutput?[{id:t.fromOutput,label:t.fromOutput}]:[],o=i??a,s=o.length>0?[{value:``,text:`none`},...o.map(e=>({value:e.id,text:e.label}))]:[];return[ai(`Wire`),z(`Label`,B(`label`,t.label??``,Br,e=>n({label:e.trim()||null}))),z(`Tone`,V(`tone`,Yr,t.tone,e=>n({tone:e}))),si(`dashed`,`dashed`,t.dashed,e=>n({dashed:e})),si(`back`,`returns to an earlier step`,t.back,e=>n({back:e})),z(`Leaves from`,V(`fromSide`,ni,t.fromSide??``,e=>n({fromSide:e||null}))),z(`Arrives at`,V(`toSide`,ni,t.toSide??``,e=>n({toSide:e||null}))),...s.length>0?[z(`From output`,V(`fromOutput`,s,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function bi(e,n){return[ai(`Frame`),z(`Title`,B(`title`,e.title,t.title,e=>n({title:e.trim()}))),si(`loop`,`repeats as a loop`,e.loop,e=>n({loop:e}))]}function xi(e,t,n){let r=li(t,n),i=e.map((e,t)=>{let n=S(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(V(`legend-${t}-tone`,Yr,e.tone,e=>{let n=qr.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),B(`legend-${t}-label`,e.label,Br,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),si(`legend-${t}-dashed`,`dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),si(`legend-${t}-back`,`returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),H(`legend-${t}-remove`,`remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),a=H(`legend-add`,`add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return a.disabled=e.length>=Rr,ci(`Legend`,i,a)}function Si(e,t){return[ai(`Note`),z(`Ref`,di(`ref`,e.ref,e=>t({ref:e}),`Ref`)),S(`p`,`wb-inspect-hint`,`Edit a note from its box.`)]}function Ci(e,t){return[ai(`Step`),z(`Status`,V(`step-status`,ti,e.status,e=>{let n=T.find(t=>t===e);n&&t({step:{status:n}})})),S(`p`,`wb-inspect-hint`,`A wire from one step to another means the second is built after the first.`)]}function wi(e,n,r,i,a){let o=[{value:``,text:`none`},...i];return[ai(`Board`),H(`board-settings-close`,`close`,a,`Close board settings`),z(`Title`,B(`board-title`,e.title,t.title,e=>{e.trim()&&r([{op:`board`,title:e.trim()}])})),z(`Caption`,B(`board-caption`,e.caption??``,Hr,e=>r([{op:`board`,caption:e.trim()||null}]))),z(`Code session`,V(`board-code-session`,o,e.codeSessionId??``,e=>r([{op:`board`,codeSessionId:e||null}]))),xi(e.legend,()=>n()?.legend??null,e=>r([{op:`board`,legend:e}]))]}function Ti(e,t,n,r,i){let a=e=>i([{op:`set`,id:t.id,fields:e}]),o=()=>n()?.elements[t.id];switch(t.kind){case`box`:return _i(t,o,r,a);case`wire`:return yi(e,t,a);case`frame`:return bi(t,a);case`note`:return Si(t,a)}}function Ei(e,t,n){let r=ct(t);if(r.length===0)return[];let i=e.codeSessionId!==null,a=r.map((e,t)=>{let r=S(`div`,`wb-inspect-row wb-inspect-review-row`),a=H(`review-${t}`,`open in review`,()=>n(e),`Open ${e} in review`);return a.disabled=!i,r.append(S(`code`,`wb-inspect-ref`,e),a),r}),o=i?[]:[S(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[ai(`In review`),...a,...o]}function Di(e,t,n){let r=S(`div`,`wb-inspect-review`);return r.append(...Ei(e,t,n)),r}function Oi(e){let t=document.activeElement;return!t||!e.contains(t)?!1:t instanceof HTMLInputElement&&t.type===`text`||t.closest(`.wb-icon-popover`)!==null}function ki(e){let{container:t}=e;t.setAttribute(`aria-label`,`Properties`);let n=t=>void e.sendOps(t),r=new Set,i=!1,a=!1;function o(e,t){if(t.size!==1)return;let[n]=t;return n===void 0?void 0:e.elements[n]}function s(n,r){let i=o(n,r),a=t.querySelector(`.wb-inspect-review`);i&&a&&a.replaceChildren(...Ei(n,i,e.openRef))}function c(t,r){if(r.size>1)return[ai(`${r.size} selected`)];let i=o(t,r);return i?[...Ti(t,i,e.currentBoard,e.layout(),n),Di(t,i,e.openRef)]:wi(t,e.currentBoard,n,e.codeSessionChoices(),d)}function l(n){r=n,n.size>0&&(a=!1);let o=e.currentBoard();if(t.hidden=!o||n.size===0&&!a,!o||t.hidden)return;if(Oi(t)){s(o,n);return}let l=document.activeElement,u=l instanceof HTMLElement&&t.contains(l)?l.dataset.field:void 0;i=!0,t.replaceChildren(...c(o,n)),u&&t.querySelector(`[data-field="${CSS.escape(u)}"]`)?.focus(),i=!1}function u(){a=!0,l(r),t.querySelector(`[data-field="board-caption"]`)?.focus()}function d(){a&&(a=!1,l(r))}return t.addEventListener(`keydown`,e=>{e.key===`Escape`&&a&&(e.preventDefault(),d())}),t.addEventListener(`focusout`,e=>{i||t.hidden||e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||queueMicrotask(()=>l(r))}),{paint:l,openBoardSettings:u,closeBoardSettings:d}}var Ai=`http://www.w3.org/2000/svg`,ji=`Plan`,Mi=`open linked board`,Ni=8,Pi=12,Fi=7.2,Ii=2.2,Li=9.6;Object.freeze({fill:`xMidYMid slice`,fit:`xMidYMid meet`});function Ri(e){return Object.entries(e).flatMap(([e,t])=>t===null?[]:[` ${e}="${te(t)}"`]).join(``)}function zi(e,t,n=``){return`<${e}${Ri(t)}>${n}</${e}>`}function Bi(e){let t=e.x+e.width,n=e.y+e.height,r=e.y+e.headerHeight/2,i=[{x:e.x+Pi,y:e.y},{x:t-Pi,y:e.y},{x:t,y:r}];return e.outputs.length===0?[...i,{x:t-Pi,y:n},{x:e.x+Pi,y:n},{x:e.x,y:r}]:[...i,{x:t,y:n},{x:e.x,y:n},{x:e.x,y:r}]}function Vi(e){return`${Bi(e).map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `)} Z`}function Hi(e){let t={fill:`black`,stroke:`black`,"stroke-width":12,"stroke-linejoin":`round`};return e.kind===`box`&&e.shape===`decision`?zi(`path`,{d:Vi(e),...t}):zi(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:Ni,...t})}function Ui(e,t){if(t.length===0)return null;let n={x:e.x,y:e.y,width:e.width,height:e.height},r=zi(`mask`,{id:`page-mask`,maskUnits:`userSpaceOnUse`,...n},[zi(`rect`,{...n,fill:`white`}),...t.map(Hi)].join(``)),i=zi(`svg`,{xmlns:Ai,viewBox:`${e.x} ${e.y} ${e.width} ${e.height}`,width:e.width,height:e.height,preserveAspectRatio:`none`},zi(`defs`,{},r)+zi(`rect`,{...n,mask:`url(#page-mask)`}));return`url("data:image/svg+xml,${encodeURIComponent(i)}")`}var Wi=2048,Gi=4,Ki=37,qi=73,Ji=Gi+49,Yi=Math.floor(Wi/Ki),Xi=1540,Zi=Math.log2(Wi)+1,Qi=33,$i=126,ea=8,ta=ea*Xi,na=`?`;function ra(){let e=(typeof OffscreenCanvas==`function`?new OffscreenCanvas(Ki,qi):Object.assign(document.createElement(`canvas`),{width:Ki,height:qi})).getContext(`2d`,{willReadFrequently:!0});if(!e)throw Error(`this browser cannot draw text for the whiteboard`);return e}function ia(e){let t=ra(),n=new Map,r=[],i=[],a=null,o=0;function s(n,r){t.clearRect(0,0,Ki,qi),t.font=`${r?700:400} 48px ${e}`,t.textBaseline=`alphabetic`,t.fillStyle=`#fff`,t.fillText(n,Gi,Ji);let i=t.getImageData(0,0,Ki,qi).data,a=new Uint8Array(2701);for(let e=0;e<a.length;e+=1)a[e]=i[e*4+3]??0;return a}function c(e,t){let a=r.length,o=Math.floor(a/Xi),c=a%Xi,l=c%Yi*Ki,u=Math.floor(c/Yi)*qi,d={cell:{u0:l/Wi,v0:u/Wi,u1:(l+Ki)/Wi,v1:(u+qi)/Wi,page:o},index:a,character:e,isBold:t,coverage:s(e,t)};return n.set(`${t?`b`:`r`}${e}`,d),r.push(d),i.push(d),d}function l(e,t){let i=n.get(`${t?`b`:`r`}${e}`);return i?i.cell:r.length>=ta?l(na,t):c(e,t).cell}function u(){for(let e=Qi;e<=$i;e+=1)l(String.fromCharCode(e),!1),l(String.fromCharCode(e),!0)}function d(){n.clear(),r.length=0,i=[],u()}function f(e,t){a&&e.deleteTexture(a),a=e.createTexture(),o=Math.max(1,t),e.bindTexture(e.TEXTURE_2D_ARRAY,a),e.texStorage3D(e.TEXTURE_2D_ARRAY,Zi,e.R8,Wi,Wi,o),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i=[...r]}function p(e,t){let n=Math.ceil(r.length/Xi);if((!a||n>o)&&f(e,Math.min(n*2,ea)),e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D_ARRAY,a),i.length!==0){e.pixelStorei(e.UNPACK_ALIGNMENT,1);for(let t of i){let n=t.index%Xi,r=n%Yi*Ki,i=Math.floor(n/Yi)*qi;e.texSubImage3D(e.TEXTURE_2D_ARRAY,0,r,i,t.cell.page,Ki,qi,1,e.RED,e.UNSIGNED_BYTE,t.coverage)}e.generateMipmap(e.TEXTURE_2D_ARRAY),i=[]}}function m(){for(let e of r)e.coverage=s(e.character,e.isBold);i=[...r]}return u(),{cellOf:l,cellWidthEm:Ki/48,cellHeightEm:qi/48,padLeftEm:Gi/48,ascentEm:Ji/48,bind:p,forgetTexture:()=>{a=null,o=0},release:e=>{a&&e.deleteTexture(a),a=null,o=0},rasterizeAgain:m,isFull:()=>r.length>=ta,forgetUnusedGlyphs:d}}var aa=8,oa=4,sa=4,ca=/<(\w+)([^>]*)\/?>/g,la=/([\w-]+)="([^"]*)"/g,ua=/[a-zA-Z]|-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?/g,da=new Map;function fa(e){return new Map([...e.matchAll(la)].map(e=>[e[1]??``,e[2]??``]))}function U(e,t){return Number(e.get(t)??0)}function pa(e){let t=e.trim().split(/[\s,]+/).map(Number),n=[];for(let e=0;e+1<t.length;e+=2)n.push({x:t[e]??0,y:t[e+1]??0});return n}function ma(e,t,n){return Array.from({length:17},(r,i)=>{let a=i/16*Math.PI*2;return{x:e.x+Math.cos(a)*t,y:e.y+Math.sin(a)*n}})}function ha(e,t,n,r,i){let a=Math.min(i,n/2,r/2);if(a<=0)return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r},{x:e,y:t}];let o=[{x:e+n-a,y:t+a,startAngle:-Math.PI/2},{x:e+n-a,y:t+r-a,startAngle:0},{x:e+a,y:t+r-a,startAngle:Math.PI/2},{x:e+a,y:t+a,startAngle:Math.PI}].flatMap(e=>Array.from({length:5},(t,n)=>{let r=e.startAngle+n/sa*(Math.PI/2);return{x:e.x+Math.cos(r)*a,y:e.y+Math.sin(r)*a}})),[s]=o;return s?[...o,s]:o}function ga(e,t,n,r){return Array.from({length:aa},(i,a)=>{let o=(a+1)/aa,s=1-o,c=s*s*s,l=3*s*s*o,u=3*s*o*o,d=o*o*o;return{x:c*e.x+l*t.x+u*n.x+d*r.x,y:c*e.y+l*t.y+u*n.y+d*r.y}})}function _a(e,t,n,r){return Math.atan2(e*r-t*n,e*n+t*r)}function va(e,t,n,r,i,a,o){if(t===0||n===0)return[o];let s=r*Math.PI/180,c=Math.cos(s),l=Math.sin(s),u=(e.x-o.x)/2,d=(e.y-o.y)/2,f=c*u+l*d,p=-l*u+c*d,m=f*f/(t*t)+p*p/(n*n),h=m>1?Math.sqrt(m):1,g=Math.abs(t)*h,_=Math.abs(n)*h,v=g*g*_*_-g*g*p*p-_*_*f*f,y=g*g*p*p+_*_*f*f,b=y===0?0:(i===a?-1:1)*Math.sqrt(Math.max(0,v/y)),x=b*(g*p/_),S=b*(-(_*f)/g),C=c*x-l*S+(e.x+o.x)/2,w=l*x+c*S+(e.y+o.y)/2,T=_a(1,0,(f-x)/g,(p-S)/_),E=_a((f-x)/g,(p-S)/_,(-f-x)/g,(-p-S)/_);!a&&E>0&&(E-=Math.PI*2),a&&E<0&&(E+=Math.PI*2);let D=Math.max(2,Math.ceil(Math.abs(E)/(Math.PI/2)*oa));return Array.from({length:D},(e,t)=>{let n=T+E*(t+1)/D,r=Math.cos(n)*g,i=Math.sin(n)*_;return{x:c*r-l*i+C,y:l*r+c*i+w}})}function ya(e){let t=e.match(ua)??[],n=[],r=[],i={x:0,y:0},a={x:0,y:0},o=null,s=``,c=0,l=()=>Number(t[c++]??0),u=()=>c<t.length&&!/^[a-zA-Z]$/.test(t[c]??``),d=e=>{r.length===0&&r.push(i),r.push(e),i=e},f=()=>{r.length>1&&n.push(r),r=[]};for(;c<t.length;){u()||(s=t[c++]??``);let e=s===s.toLowerCase(),n=e?i.x:0,r=e?i.y:0,p=s.toUpperCase();switch(p!==`C`&&p!==`S`&&(o=null),p){case`M`:f(),i={x:n+l(),y:r+l()},a=i,s=e?`l`:`L`;break;case`L`:d({x:n+l(),y:r+l()});break;case`H`:d({x:n+l(),y:i.y});break;case`V`:d({x:i.x,y:r+l()});break;case`C`:{let e={x:n+l(),y:r+l()},t={x:n+l(),y:r+l()},a={x:n+l(),y:r+l()},s=i;for(let n of ga(s,e,t,a))d(n);o=t;break}case`S`:{let e=o?{x:i.x*2-o.x,y:i.y*2-o.y}:i,t={x:n+l(),y:r+l()},a={x:n+l(),y:r+l()},s=i;for(let n of ga(s,e,t,a))d(n);o=t;break}case`A`:{let e=l(),t=l(),a=l(),o=l()!==0,s=l()!==0,c={x:n+l(),y:r+l()},u=i;for(let n of va(u,e,t,a,o,s,c))d(n);break}case`Z`:d(a),f();break;default:c+=1}}return f(),n}function ba(e,t){switch(e){case`path`:return{polylines:ya(t.get(`d`)??``),circles:[]};case`line`:return{polylines:[[{x:U(t,`x1`),y:U(t,`y1`)},{x:U(t,`x2`),y:U(t,`y2`)}]],circles:[]};case`polyline`:return{polylines:[pa(t.get(`points`)??``)],circles:[]};case`polygon`:{let e=pa(t.get(`points`)??``),[n]=e;return{polylines:[n?[...e,n]:e],circles:[]}}case`rect`:{let e=U(t,t.has(`rx`)?`rx`:`ry`);return{polylines:[ha(U(t,`x`),U(t,`y`),U(t,`width`),U(t,`height`),e)],circles:[]}}case`circle`:return{polylines:[],circles:[{center:{x:U(t,`cx`),y:U(t,`cy`)},radius:U(t,`r`),isFilled:t.get(`fill`)===`currentColor`}]};case`ellipse`:return{polylines:[ma({x:U(t,`cx`),y:U(t,`cy`)},U(t,`rx`),U(t,`ry`))],circles:[]};default:return{polylines:[],circles:[]}}}function xa(t){let n=da.get(t);if(n)return n;let r={polylines:[],circles:[]};for(let n of e[t].elements)for(let e of n.matchAll(ca)){let t=ba(e[1]??``,fa(e[2]??``));r.polylines.push(...t.polylines),r.circles.push(...t.circles)}return da.set(t,r),r}var Sa=0,Ca=0,wa=3,Ta={frame:1,wire:2,box:4,note:5},Ea=4,Da=12,Oa=8,ka=4,Aa=12.8,ja=5.12,Ma=1.28,Na=1.6,Pa=1.6,Fa=.08,Ia=Fi/12,La=3,Ra=12,za=4,W=0,Ba=24,Va=2,Ha=[0,0,0,0];function Ua(e,t,n){let r=1-n;return[e[0]*n+t[0]*r,e[1]*n+t[1]*r,e[2]*n+t[2]*r,e[3]*n+t[3]*r]}function G(e,t){return t===1?e:[e[0],e[1],e[2],e[3]*t]}function Wa(){return{rects:[],segments:[],triangles:[],glyphs:[]}}function Ga(e){return{rects:Float32Array.from(e.rects),segments:Float32Array.from(e.segments),triangles:Float32Array.from(e.triangles),glyphs:Float32Array.from(e.glyphs)}}var K={on:0,off:0};function q(e,t,n,r,i,a,o){e.rects.push(t.x,t.y,t.width,t.height,n,a,r[0],r[1],r[2],r[3],i[0],i[1],i[2],i[3],o,Sa)}function Ka(e,t,n,r,i,a,o){q(e,{x:t.x-n,y:t.y-n,width:n*2,height:n*2},n,r,i,a,o)}function J(e,t,n,r,i,a){let o=0;for(let s=1;s<t.length;s+=1){let c=t[s-1],l=t[s];c&&l&&(e.segments.push(c.x,c.y,l.x,l.y,n,i.on,i.off,o,r[0],r[1],r[2],r[3],a,Sa),o+=Math.hypot(l.x-c.x,l.y-c.y))}}function qa(e,t,n,r){for(let i of t)e.triangles.push(i.x,i.y,n[0],n[1],n[2],n[3],r,Sa)}function Ja(e,t,n,r){let[i]=t;if(i)for(let a=2;a<t.length;a+=1){let o=t[a-1],s=t[a];o&&s&&qa(e,[i,o,s],n,r)}}function Ya(e,t,n,r,i){let a=Math.hypot(n.x-t.x,n.y-t.y);if(a===0)return;let o=(n.x-t.x)/a,s=(n.y-t.y)/a,c={x:n.x+o*Ma,y:n.y+s*Ma},l=c.x-o*Aa,u=c.y-s*Aa;qa(e,[c,{x:l-s*ja,y:u+o*ja},{x:l+s*ja,y:u-o*ja}],r,i)}function Xa(e,t){let n=[{x:e.x+e.width-t,y:e.y+t,startAngle:-Math.PI/2},{x:e.x+e.width-t,y:e.y+e.height-t,startAngle:0},{x:e.x+t,y:e.y+e.height-t,startAngle:Math.PI/2},{x:e.x+t,y:e.y+t,startAngle:Math.PI}],r=[{x:e.x+t,y:e.y}];for(let e of n)for(let n=0;n<=za;n+=1){let i=e.startAngle+n/za*(Math.PI/2);r.push({x:e.x+Math.cos(i)*t,y:e.y+Math.sin(i)*t})}return r.push({x:e.x+t,y:e.y}),r}function Za(e,t,n,r,i,a,o,s){o.on===0?q(e,t,n,r,i,a,s):(q(e,t,n,r,r,0,s),J(e,Xa(t,n),a,i,o,s))}function Qa(e){return e.size*(Ia+(e.isUppercase?Fa:0))}function $a(e,t){return[...e].length*Qa(t)}function eo(e){return(e.minPixels??Ea)/e.size}function Y(e,t,n,r,i,a){let o=a.isUppercase?n.toUpperCase():n,s=Qa(a),c=$a(o,a),l=r-(a.anchor===`middle`?c/2:a.anchor===`end`?c:0),u=eo(a),d=t.cellWidthEm*a.size,f=t.cellHeightEm*a.size,p=i-t.ascentEm*a.size,{color:m}=a,h=0;for(let n of o){if(n!==` `){let r=t.cellOf(n,a.isBold===!0);e.glyphs.push(l+h*s-t.padLeftEm*a.size,p,d,f,r.u0,r.v0,r.u1,r.v1,r.page,m[0],m[1],m[2],m[3],u,Sa)}h+=1}a.isStruckThrough&&J(e,[{x:l,y:i-a.size*.3},{x:l+c,y:i-a.size*.3}],1,m,K,u),a.isUnderlined&&J(e,[{x:l,y:i+2},{x:l+c,y:i+2}],1,m,K,u)}function to(e,t,n,r,i,a,o){let s=i/Ba,c=Va*s,l=xa(t);for(let t of l.polylines)J(e,t.map(e=>({x:n+e.x*s,y:r+e.y*s})),c,a,K,o);for(let t of l.circles)Ka(e,{x:n+t.center.x*s,y:r+t.center.y*s},t.radius*s,t.isFilled?a:Ha,a,c,o)}function no(e,t){let n=e.map(e=>e.x),r=e.map(e=>e.y),i=Math.min(...n)-t,a=Math.min(...r)-t;return{x:i,y:a,width:Math.max(...n)+t-i,height:Math.max(...r)+t-a}}function ro(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function io(e,t){return e.style===`code`?t.accent:e.muted?t.inkDim:t.ink}function ao(e,t,n,r,i,a,o,s){let{palette:c,glyphs:l}=t,u=c.metaSize;n.forEach((t,n)=>{let d=a+n*18,f=r+12+(t.muted?14:0),p=t.icon?f+3*Fi:f;t.icon&&t.isFirstRow&&to(e,t.icon,f,d-10,13,G(c.inkDim,o),s),t.style===`code`&&q(e,{x:p-4,y:d-13,width:r+i-12+8-p,height:17},3,G(c.codeBand,o),G(c.codeBand,o),0,s),t.style===`item`&&t.isFirstRow&&Ka(e,{x:p+4,y:d-4},Ii,G(c.inkDim,o),G(c.inkDim,o),0,s),t.marker!==null&&Y(e,l,t.marker,p,d,{size:u,color:G(c.inkDim,o),isBold:t.style===`kv`}),t.text&&Y(e,l,t.text,p+t.indentChars*Fi,d,{size:u,color:G(io(t,c),o)})})}function oo(e,t){let n=e.shape===`panel`,r=n&&!e.step?1.4:Pa,i=e.step?t.accent:null,a=n?t.panelFill:t.board;return e.change===`added`?{fill:a,stroke:i??t.running,dash:{on:7,off:5},width:r}:e.change===`removed`?{fill:[0,0,0,0],stroke:i??t.failed,dash:{on:7,off:5},width:r}:e.change===`relabeled`?{fill:a,stroke:i??t.noteStroke,dash:K,width:r}:{fill:a,stroke:i??(n?t.line:t.inkDim),dash:K,width:r}}function so(e,t){return e===`building`?t.waiting:e===`landed`?t.running:t.muted}function co(e,t,n,r,i,a){let{base:o}=u[t.name];if(!o)return;let s=o.height*t.scale,c=t.x+t.width/2;if(o.overhang>0){q(e,{x:t.x,y:n,width:t.width,height:s},s/3,r,i,1,a);return}let l=24*t.scale,d=180*t.scale,f=520*t.scale;q(e,{x:c-d/2,y:n,width:d,height:s-l},0,r,i,1,a),q(e,{x:c-f/2,y:n+s-l,width:f,height:l},l/3,r,i,1,a)}function lo(e,t,n,r,i,a){let{palette:o,glyphs:s}=t,c=u[r.name],l=G(Ua(o.ink,o.board,.12),i),d=G(o.inkDim,i),f=G(o.board,i),p=(c.base?.overhang??0)*r.scale,m=r.x+p,h=r.width-p*2,g=(c.bezel.top+c.toolbarHeight+c.screen.height+c.bezel.bottom)*r.scale;if(q(e,{x:m,y:r.y,width:h,height:g},c.bezel.radius*r.scale,l,d,1,a),co(e,r,r.y+g,l,d,a),c.toolbarHeight>0){let t=r.y+c.bezel.top*r.scale,n=c.toolbarHeight*r.scale,s=t+n/2,l=22*r.scale,u=96*r.scale,p=G(Ua(o.ink,o.board,.06),i);q(e,{x:m,y:t,width:h,height:n},0,p,p,0,a);for(let t of[1,2,3])Ka(e,{x:m+t*22*r.scale,y:s},6*r.scale,d,d,0,a);q(e,{x:m+u,y:s-l/2,width:h-u*2,height:l},l/2,f,f,0,a)}q(e,r.screen,c.bezel.screenRadius*r.scale,f,f,0,a),n.media||Y(e,s,n.titleLines.join(` `),r.screen.x+r.screen.width/2,r.screen.y+r.screen.height/2+4,{size:o.metaSize,color:G(o.inkDim,i),anchor:`middle`})}function uo(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=e.change===`removed`?.6:1,o=Da/Math.max(1,e.height),s=oo(e,n),c=G(s.fill,a),l=G(s.stroke,a);if(e.shape===`decision`){let t=Bi(e);Ja(i,t,c,W);let[n]=t;n&&J(i,[...t,n],s.width,l,s.dash,W)}e.shape!==`decision`&&Za(i,e,8,c,l,s.width,s.dash,W);for(let t of e.outputs){let s=(e.height-e.headerHeight)/e.outputs.length/2,c=t.port.y-s;J(i,[{x:e.x,y:c},{x:e.x+e.width,y:c}],1,G(n.line,a),K,o),Y(i,r,t.label,e.x+12,t.port.y+4,{size:n.metaSize,color:G(n.ink,a),isBold:!0,isUppercase:!0}),Ka(i,t.port,3,G(n.inkDim,a),G(n.inkDim,a),0,o)}let u=e.step?18:0;e.step&&(Y(i,r,e.step.label,e.x+12,e.y+22,{size:n.metaSize,color:G(n.accent,a),isBold:!0}),Y(i,r,e.step.status,e.x+e.width-12,e.y+22,{size:n.metaSize,color:G(so(e.step.status,n),a),anchor:`end`}));let d=e.shape===`icon`,f=d?56:0,p=e.x+e.width/2;d&&e.icon&&to(i,e.icon,p-24,e.y+12+u,48,G(n.accent,a),o);let m=d?p:e.x+12,h=d?`middle`:`start`;e.wasLines.forEach((t,o)=>{Y(i,r,t,m,e.y+26+u+f+o*20,{size:n.titleSize,color:G(n.inkDim,a),isStruckThrough:!0,anchor:h})});let g=e.y+26+u+f+e.wasLines.length*20,_=d?null:e.icon;_&&to(i,_,m,g-12,14,G(n.ink,a),o);let v=_?m+2*Li:m;e.titleLines.forEach((t,o)=>{Y(i,r,t,v,g+o*20,{size:n.titleSize,color:G(n.ink,a),isBold:!0,isStruckThrough:e.change===`removed`,anchor:h})}),e.device&&lo(i,t,e,e.device,a,o);let y=g+e.titleLines.length*20;e.shape===`panel`&&e.bodyLines.length>0&&J(i,[{x:e.x+12,y:y-12},{x:e.x+e.width-12,y:y-12}],1,G(n.line,a),K,o),ao(i,t,e.bodyLines,e.x,e.width,y,a,o);let b=e.media!==null&&t.hasDrawnMedia(e);if(e.media&&!b){let t=e.media.alt||e.media.kind;Za(i,e.media,6,G(n.placeholderFill,a),G(n.inkDim,a),1,{on:4,off:4},o),Y(i,r,t,e.media.x+e.media.width/2,e.media.y+e.media.height/2+4,{size:n.metaSize,color:G(n.inkDim,a),anchor:`middle`})}let x=e.step?.linkedBoardId??null;if(!x)return{part:i,hitShape:{kind:`rect`,rect:e,linkRect:null,mediaRect:e.media,hasDrawnMedia:b}};let S={size:n.metaSize,color:G(n.accent,a),isUnderlined:!0},C=y+e.bodyLines.length*18;return Y(i,r,Mi,e.x+12,C,S),{part:i,hitShape:{kind:`rect`,rect:e,linkRect:{x:e.x+12,y:C-n.metaSize,width:$a(Mi,S),height:n.metaSize+4,linkedBoardId:x},mediaRect:e.media,hasDrawnMedia:b}}}function fo(e,t,n,r){return Array.from({length:13},(i,a)=>{let o=n+a/Ra*r;return{x:e.x+Math.cos(o)*t,y:e.y+Math.sin(o)*t}})}function po(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=e.isLoop?n.accent:n.line;Za(i,e,12,n.frameFill,a,1.4,{on:10,off:6},W);let o={size:n.metaSize,color:n.inkDim,isBold:!0};if(Y(i,r,e.title,e.x+14,e.y+18,o),e.isLoop){let t=fo({x:e.x+e.width-20,y:e.y+6+6},6,0,-Math.PI*1.5);J(i,t,Pa,n.accent,K,Da/e.height);let r=t[t.length-2],a=t[t.length-1];r&&a&&Ya(i,r,a,n.accent,ka/Aa)}return{part:i,hitShape:{kind:`outline`,rect:e,titleRect:{x:e.x,y:e.y,width:28+$a(e.title,o),height:26}}}}function mo(e,t){return e.tone===`fail`?t.failed:e.tone===`join`||e.isBack?t.accent:t.inkDim}function ho(e,t,n){let r=t[t.length-2],i=t[t.length-1];r&&i&&Ya(e,r,i,n,ka/Aa)}function go(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=Wa(),o=fe(e.path),s=mo(e,n);J(i,o,Na,s,e.isDashed?{on:7,off:6}:K,W),e.hasArrowhead&&ho(i,o,s);let c=ka/6;Ka(i,e.start,3,n.inkDim,n.inkDim,0,c),e.joinAt&&Ka(i,e.joinAt,3,n.inkDim,n.inkDim,0,c);let l=no(o.length>0?o:[e.start,e.end],8);if(e.label){let t={size:n.metaSize,color:n.ink,anchor:`middle`,minPixels:Oa},i=$a(e.label,t),o={x:e.labelAt.x-i/2-La,y:e.labelAt.y-n.metaSize,width:i+6,height:n.metaSize+La+2};q(a,o,3,n.board,n.board,0,eo(t)),Y(a,r,e.label,e.labelAt.x,e.labelAt.y,t),l=ro(l,o)}return{parts:[{layer:Ta.wire,part:Ga(i)},{layer:wa,part:Ga(a)}],hitShape:{kind:`path`,points:o},bounds:l}}function _o(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a=e.isResolved?.5:1;return q(i,e,4,G(n.noteCard,a),G(n.noteStroke,a),1.2,W),e.lines.forEach((t,o)=>{Y(i,r,t,e.x+10,e.y+22+o*17,{size:n.metaSize,color:G(n.noteText,a)})}),e.byline&&Y(i,r,e.byline,e.x+10,e.y+22+e.lines.length*17,{size:n.metaSize,color:G(n.noteByline,a)}),{part:i,hitShape:{kind:`rect`,rect:e,linkRect:null,mediaRect:null,hasDrawnMedia:!1}}}function vo(e,t){return{parts:[{layer:Ta[e.kind],part:Ga(t.part)}],hitShape:t.hitShape,bounds:yo(e,t.hitShape)}}function yo(e,t){if(t.kind!==`outline`)return e;let n=Math.max(e.x+e.width,t.titleRect.x+t.titleRect.width);return{x:e.x,y:e.y,width:n-e.x,height:e.height}}function bo(e,t){switch(e.kind){case`box`:return vo(e,uo(e,t));case`frame`:return vo(e,po(e,t));case`wire`:return go(e,t);case`note`:return vo(e,_o(e,t))}}function xo(e,t,n){let{parts:r,hitShape:i,bounds:a}=bo(e,n);return{id:e.id,kind:e.kind,paintRank:t,bounds:a,parts:r,hitShape:i}}function So(e,t,n){let{swatch:r}=t;if(r.kind===`status`){q(e,{x:t.x,y:t.y,width:14,height:14},3,so(r.status,n),n.accent,Pa,W);return}if(r.kind===`change`){let i={x:t.x,y:t.y,width:28,height:14},a=oo({change:r.change,shape:`box`,step:null},n),o=r.change===`removed`?.6:1;Za(e,i,3,G(a.fill,o),G(a.stroke,o),a.width,a.dash,W);return}let i=mo(r,n),a=[{x:t.x,y:t.y+7},{x:t.x+28,y:t.y+7}];J(e,a,Na,i,r.isDashed?{on:7,off:6}:K,W),ho(e,a,i)}function Co(e,t){let{palette:n,glyphs:r}=t,i=Wa(),a={size:n.metaSize,color:n.inkDim,isBold:!0,isUppercase:!0};e.plan&&Y(i,r,ji,e.plan.titleAt.x,e.plan.titleAt.y,a);for(let t of e.legend){So(i,t,n);let e=t.x+(t.swatch.kind===`status`?22:40);Y(i,r,t.label,e,t.y+12,{size:n.metaSize,color:n.inkDim})}return e.caption&&Y(i,r,e.caption.text,e.caption.x,e.caption.y+16,{size:n.bodySize,color:n.inkDim}),{id:``,kind:`frame`,paintRank:-1,bounds:e.bounds,parts:[{layer:Ca,part:Ga(i)}],hitShape:{kind:`path`,points:[]}}}function wo(e,t,n,r){if(t.kind===`wire`)J(e,fe(t.path),2.6,n,K,W);else if(t.kind===`box`&&t.shape===`decision`){let i=Bi(t),[a]=i;a&&J(e,[...i,a],r,n,K,W)}else q(e,t,{box:8,note:4,frame:12}[t.kind],[0,0,0,0],n,r,W)}function To(e){let t=e.x+e.width/2,n=e.y+e.height/2;return[{x:t,y:e.y},{x:e.x+e.width,y:n},{x:t,y:e.y+e.height},{x:e.x,y:n}]}function Eo(e){return{x:e.x+e.width-10,y:e.y+e.height-10,width:10,height:10}}function Do(e,t){let{palette:n,glyphs:r}=t,i=Wa();for(let t of e){if(t.kind===`selected`||t.kind===`wire-target`){wo(i,t.element,n.accent,2.4);continue}if(t.kind===`flagged`){wo(i,t.element,n.waiting,2.4);continue}if(t.kind===`hover-handles`){for(let e of To(t.box))Ka(i,e,5,n.board,n.accent,Pa,W);q(i,Eo(t.box),2,n.board,n.accent,Pa,W);continue}let e={x:t.element.x+t.element.width,y:t.element.y};Ka(i,e,9,n.waiting,n.cardBackground,2,W),Y(i,r,`!`,e.x,e.y+4,{size:n.metaSize,color:n.cardBackground,isBold:!0,anchor:`middle`,minPixels:0})}return Ga(i)}function Oo(e,t,n){let r=e.elements.map((e,t)=>({element:e,index:t})).sort((e,t)=>Ta[e.element.kind]-Ta[t.element.kind]||e.index-t.index).map(({element:e},r)=>{let i=n(e);return i?{...i,paintRank:r}:xo(e,r,t)});return{chrome:Co(e,t),elements:r}}var ko={worthALookIds:new Set,flaggedStepIds:new Set},Ao=512,jo=.75,Mo=4,No=7,Po=6,Fo=3,Io=6,Lo=4096,Ro=`#version 300 es
|
|
2
2
|
precision highp float;
|
|
3
3
|
uniform vec2 uCamera;
|
|
4
4
|
uniform float uScale;
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,r as n,t as r}from"./lane-read-token-step-DHtlaeJz.js";import{c as i,i as a,s as o,t as s}from"./action-status-B5J9yJlM.js";import{b as c,d as l,f as u,s as d}from"./dom-helpers-C7CaSePf.js";import{a as f,t as p}from"./button-C8v9_rcy.js";import{A as m,G as ee,Ga as h,M as g,N as _,O as v,P as y,Ui as b,Ur as x,V as te,Vi as S,Wa as C,Yi as w,ea as T,j as ne,k as re,ki as ie,qi as E,ra as ae,rt as oe,tt as se}from"./index-TGlDg84u.js";import{t as ce}from"./pr-queue-columns-pl8VzlPc.js";import{o as le}from"./card-registry-Ct6a2qHl.js";import{i as ue}from"./modal-DAfPARiv.js";import{d as de,f as fe}from"./control-ws-D6gk3ZJu.js";import{n as D}from"./setup-step-DHKUfmEv.js";var pe={HIGH:`High confidence`,MEDIUM:`Medium confidence`,LOW:`Low confidence`},me={HIGH:`ok`,MEDIUM:`warn`,LOW:`muted`},O={pending:`Waiting to be checked`,queued:`Waiting to be researched`,running:`Researching`,error:`Research failed`,aside:`Set aside`},he={forum:`Forum`,discord:`Discord`};function k(e){return e.status===`ready`&&e.verdict?{text:pe[e.verdict],tone:me[e.verdict]}:e.status===`ready`?{text:`Researched`,tone:`muted`}:e.status===`error`?{text:O.error,tone:`danger`}:{text:O[e.status],tone:`muted`}}function A(e){let t=he[e.item.source];return e.item.channel?`${t} #${e.item.channel}`:t}function ge(e){return e.entry.item.title||`Untitled question`}function _e(e){return e.status!==`running`&&e.status!==`queued`}function ve(e){return e.status!==`aside`}function ye(e){let t=e.find(e=>e.id===`working`)?.items.length??0;return t===0?`No community question needs you right now.`:`No community question needs you right now. ${t} ${t===1?`question is`:`questions are`} being researched.`}function j(e){return e?e.configured===!1?e.reason??`The community lane is not set up yet.`:`No community questions yet. New ones asked after you turned this on show up here.`:`Waiting for the community lane to report.`}function be(e){return e.filter(e=>!e.isWorkspace&&!e.isEphemeral).map(({id:e,name:t})=>({id:e,name:t})).toSorted((e,t)=>e.name.localeCompare(t.name))}var M=[`key`,`readToken`,`project`,`skill`,`discord`];function N(e){let t=e===`finished`?M.length:M.indexOf(e),n=e=>e<t?`done`:e===t?`current`:`upcoming`;return{key:n(0),readToken:n(1),project:n(2),skill:n(3),discord:n(4)}}function xe(e){let t=e.split(/[\s,]+/).map(e=>e.replace(/^#/,``)).filter(Boolean);return[...new Set(t)]}var P=2;function F(e){de({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`onboarding`,action:e}})}function I(){let e=se().community,t=typeof e==`object`&&e?e:{},n=Array.isArray(t.discordChannels)?t.discordChannels.filter(e=>typeof e==`string`):[];return{projectId:typeof t.projectId==`number`?t.projectId:P,skill:typeof t.skill==`string`?t.skill:``,discordChannels:n}}function Se(e,t,n,r){let i=d(`input`,`dialog-input repo-roots-adder-input`);return i.id=e,i.type=r,i.value=t,i.placeholder=n,i.autocomplete=`off`,i.spellcheck=!1,i}function Ce({onFinish:t}){let i=d(`section`,`first-run-checklist review-setup`);i.setAttribute(`aria-labelledby`,`community-setup-title`);let c=d(`h2`,`first-run-title`,`Answer community questions`);c.id=`community-setup-title`;let l=d(`ol`,`first-run-steps`),u=d(`p`,`first-run-step-hint review-setup-foot`,`Each question gets a researched draft reply. Nothing posts until you post it yourself. `);u.append(te(`lanes-community`,`community-enabled`,`All community settings`));let f=d(`div`,`first-run-step-actions`),m=p({variant:`primary`,label:`Finish setup`,action:`finish-community-setup`});f.append(m),f.hidden=!0,i.append(d(`span`,`first-run-eyebrow`,`SET UP COMMUNITY`),c,l,f,u);let h=null;m.addEventListener(`click`,()=>{F(`finish-community-setup`),h=null,t()});function g(){return r(`posthog.apiKey`)?e()?null:`readToken`:`key`}function _(t){h=t===`readToken`&&e()?`project`:t,w(),(l.querySelector(`[aria-current="step"] input`)??(f.hidden?null:m))?.focus()}async function v(e,t,n,r){t.disabled=!0,n.show(`busy`,`Saving`);try{let t=await fe(`update-settings`,{settings:e},{timeoutMs:s});if(t.type===`settings-error`){n.show(`error`,t.message);return}if(t.type!==`settings-updated`){n.show(`error`,`The server did not confirm the save.`);return}ee(t.settings),_(r)}catch(e){n.show(`error`,o(e,s))}finally{t.disabled=!1}}function y(e){let t=Se(e.inputId,e.initialValue,e.placeholder,e.inputType),n=d(`label`,`repo-roots-adder-label`,e.label);n.htmlFor=t.id;let r=d(`div`,`first-run-step-actions`),i=a(),o=p({variant:`primary`,label:e.saveLabel,action:e.action}),s=()=>{let n=e.settingsPatch(t.value);typeof n==`string`?i.show(`error`,n):(F(e.action),v(n,o,i,e.nextProgress))};if(o.addEventListener(`click`,s),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),s())}),r.append(o),e.isSkippable){let t=p({variant:`secondary`,label:`Skip`,action:`skip-community-setup-step`,onClick:()=>_(e.nextProgress)});r.append(t)}return r.append(i.element),[d(`p`,`first-run-step-text`,e.advice),n,t,r]}let b=()=>y({advice:`Glimmervoid reads new forum and Discord questions through your PostHog personal API key. Create one in PostHog under Settings, Personal API keys. Community needs only the query:read scope on the project that holds the questions. PostHog error monitoring shares this key, so add error tracking read and write if you turn that on.`,label:`PERSONAL API KEY`,inputId:`community-setup-key`,inputType:`password`,initialValue:``,placeholder:`phx_`,saveLabel:`Save key`,action:`save-community-key`,nextProgress:`readToken`,isSkippable:!1,settingsPatch:e=>e.trim()?{posthog:{apiKey:e.trim()}}:`Paste a PostHog personal API key.`}),x=()=>y({advice:`The PostHog project that holds the synced community forum table and the Discord bot events. PostHog's own community lives in project 2.`,label:`PROJECT ID`,inputId:`community-setup-project`,inputType:`number`,initialValue:String(I().projectId),placeholder:String(P),saveLabel:`Use project`,action:`save-community-project`,nextProgress:`skill`,isSkippable:!1,settingsPatch:e=>{let t=Number(e.trim());return Number.isInteger(t)&&t>0?{community:{projectId:t}}:`Type the project id as a whole number, such as 2.`}}),S=()=>y({advice:`The Claude Code skill the research agent follows for each question, typed by name. A skill that knows your docs and support playbook gives the best drafts. Skip to research with whatever skills the agent has.`,label:`SKILL`,inputId:`community-setup-skill`,inputType:`text`,initialValue:I().skill,placeholder:`skill name`,saveLabel:`Save skill`,action:`save-community-skill`,nextProgress:`discord`,isSkippable:!0,settingsPatch:e=>({community:{skill:e.trim().replace(/^\//,``)}})}),C=()=>y({advice:`Discord questions come from a Discord bot that sends message_sent and thread_created events into the project above. With that bot in place, list the channels to watch by name, without the #. A cheap model picks out the real questions; only those are researched.`,label:`CHANNELS`,inputId:`community-setup-discord`,inputType:`text`,initialValue:I().discordChannels.join(`, `),placeholder:`community-questions, help`,saveLabel:`Save channels`,action:`save-community-discord`,nextProgress:`finished`,isSkippable:!0,settingsPatch:e=>{let t=xe(e);return t.length>0?{community:{discordChannels:t}}:`Type at least one channel, or skip.`}});function w(){if(!h)return;let e=N(h);l.replaceChildren(D({title:`1. PostHog personal API key`,state:e.key,summary:`Key saved`,badge:`NEEDED`,body:b}),D({title:`2. Read-only GitHub token`,state:e.readToken,summary:`Token saved`,badge:`REQUIRED`,body:()=>n({laneWork:`Community research reads the GitHub issues, code and pages a question links.`,onSaved:()=>_(`project`)})}),D({title:`3. PostHog project`,state:e.project,summary:`Project ${I().projectId}`,badge:``,body:x}),D({title:`4. Research skill (optional)`,state:e.skill,summary:I().skill||`No skill`,badge:``,body:S}),D({title:`5. Discord (optional)`,state:e.discord,summary:I().discordChannels.map(e=>`#${e}`).join(` `)||`Forum only`,badge:``,body:C})),f.hidden=h!==`finished`}function T(){h=g()??`key`,w()}return oe(t=>{t.kind===`broadcast`&&(h===`key`&&r(`posthog.apiKey`)&&_(`readToken`),h===`readToken`&&e()&&_(`project`))}),{element:i,open:T,isOpen:()=>h!==null,needsSetup:()=>g()!==null}}var L=null,R=null,z=null,B=[],V=null,H=!1,U=null,W=null,G=``,K=new Map,q=null;function we(){return be([...le].map(([e,t])=>({id:e,name:t.nameEl.textContent??e,isWorkspace:t.card.dataset.workspace!==void 0,isEphemeral:t.card.dataset.ephemeral!==void 0})))}function J(e,t,n){let r=d(`ul`,e);r.setAttribute(`aria-label`,t);for(let e of n)r.append(d(`li`,null,e));return r}function Te(e){let t=d(`div`,`pr-detail-heading`),n=d(`div`,`pr-detail-title`);n.append(d(`h2`,null,e.item.title||`Untitled question`));let r=d(`div`,`pr-detail-meta`),i=Date.parse(e.item.createdAt);r.append(d(`span`,null,e.item.author),d(`span`,null,A(e))),Number.isNaN(i)||r.append(d(`span`,null,`Asked ${x(i)}`));for(let t of e.item.tags)r.append(d(`span`,`author-org-tag`,t));return t.append(n,r),t}function Ee(e){let t=d(`section`,`community-question`);return t.setAttribute(`aria-label`,`Question as asked`),t.append(d(`h3`,`pr-section-heading`,`Question as asked`),d(`p`,`community-question-body`,e.item.body)),t}function De(e){let t=d(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Research`);let n=k(e),r=d(`div`,`pr-verdict-line`),i=d(`strong`,`community-badge`,n.text);if(i.dataset.tone=n.tone,r.append(i),t.append(r),e.error&&t.append(d(`p`,`pr-attention-detail`,e.error)),e.summary&&t.append(d(`p`,`pr-verdict-summary`,e.summary)),e.goal&&t.append(d(`p`,`community-goal`,`Goal: ${e.goal}`)),e.gaps.length>0&&t.append(J(`pr-verdict-gaps`,`Not covered`,e.gaps)),e.checked.length===0)return t;let a=d(`details`,`pr-verdict-checked`);return a.append(d(`summary`,null,`What it checked (${e.checked.length})`),J(`community-checked`,`What it checked`,e.checked)),t.append(a),t}function Oe(e){if(!e.draft)return null;let t=d(`section`,`community-draft`);t.setAttribute(`aria-label`,`Draft reply`),t.append(d(`h3`,`pr-section-heading`,`Draft reply`),d(`p`,`community-draft-body`,e.draft.body));let n=e.draft.publicLinks.filter(h);if(n.length===0)return t;let r=d(`ul`,`community-links`);for(let e of n){let t=d(`li`);t.append(p({variant:`secondary`,size:`small`,label:e,action:`open-public-link`,onClick:()=>C(e)})),r.append(t)}return t.append(r),t}function ke(e,t){let n=e.draft?c(e.draft.body):null;n?n.then(()=>t.show(`ok`,`Draft copied. Post it yourself where the question was asked.`),()=>t.show(`error`,`Copying failed. Select the draft text instead.`)):t.show(`error`,`This browser does not allow copying here. Select the draft text instead.`)}async function Ae(e,t){if(!G){t.show(`error`,`Pick a session to start from first.`);return}let n=await i(`open-community-session`,{key:e.item.key,projectId:G},t,{busyText:`Starting a session with the research.`});n?.type===`open-community-session-result`&&(n.ok?(t.show(`ok`,`Started ${n.sessionName??`a session`}.`),n.sessionId&&ie()?.openTerminal(n.sessionId)):t.show(`error`,n.error??`The session did not start.`))}async function Y(e,t,n){let r=t===`rerun`?`Queuing the research again.`:`Setting the question aside.`,a=await i(`community-action`,{key:e.item.key,action:t},n,{busyText:r});a?.type===`community-action-result`&&(a.ok||n.show(`error`,a.error??`The change did not apply.`))}function je(){let e=d(`select`,`community-session-picker`);e.setAttribute(`aria-label`,`Session to start from`);let t=we();t.some(e=>e.id===G)||(G=t[0]?.id??``);for(let n of t){let t=d(`option`,null,n.name);t.value=n.id,t.selected=n.id===G,e.append(t)}return e.disabled=t.length===0,e.addEventListener(`change`,()=>{G=e.value}),e}function Me(e){let t=d(`div`,`community-actions`),n=a(`pr-action-status`),r=d(`div`,`community-action-buttons`);return r.append(p({variant:`secondary`,label:`Copy draft`,action:`copy-draft`,disabled:e.draft===null,onClick:()=>ke(e,n)}),p({variant:`secondary`,label:`Open thread`,action:`open-thread`,disabled:!h(e.item.url),onClick:()=>C(e.item.url)}),je(),p({variant:`primary`,label:`Start session`,action:`start-session`,onClick:()=>void Ae(e,n)}),p({variant:`secondary`,label:`Re-run`,action:`rerun-community-research`,disabled:!_e(e),onClick:()=>void Y(e,`rerun`,n)}),p({variant:`secondary`,label:`Set aside`,action:`set-aside-community-question`,disabled:!ve(e),onClick:()=>void Y(e,`set-aside`,n)})),t.append(r,n.element),t}function Ne(e){let t=d(`article`,`pr-detail community-detail`),n=Oe(e);return t.append(Te(e),Me(e),...n?[n]:[],De(e),Ee(e)),t}function X(){if(!z)return;let e=E(B,V),n=e?JSON.stringify(e.entry):`empty:${ae(B).length}`;if(n===W)return;if(W=n,e){z.replaceChildren(Ne(e.entry));return}let r=B.some(e=>e.items.length>0);z.replaceChildren(r?t({title:`All caught up`,detail:ye(B)}):d(`p`,`pr-empty`,j(m())))}function Pe(e,t){_(b(e))&&t.querySelector(`.pr-queue-unseen`)?.remove()}function Z(e){V=e;for(let[t,n]of K)n.setAttribute(`aria-current`,String(t===e));let t=E(B,e),n=K.get(e);t&&n&&Pe(t,n),X(),L&&(L.dataset.detailOpen=`true`)}function Fe(){L&&(L.dataset.detailOpen=`false`),V&&K.get(V)?.focus({preventScroll:!0})}function Ie(e){let t=E(B,e);if(!t)return;B.find(e=>e.items.includes(t))?.id===`aside`&&(H=!0),V=e,$(),Z(e);let n=K.get(e);n?.focus({preventScroll:!0}),n?.scrollIntoView({block:`nearest`})}function Le(e){if(e.repeat||e.defaultPrevented||!L||l(L)||ue()||u(e)||document.activeElement?.classList.contains(`xterm-helper-textarea`))return;let t=w(e);if(t!==`next-row`&&t!==`previous-row`)return;let n=T([...K.keys()],V,t===`next-row`?1:-1);n&&(e.preventDefault(),n!==V&&Ie(n))}function Re(e,t){let n=f(`pr-queue-row pr-queue-row-quiet`);n.dataset.queueKey=e.key,n.setAttribute(`aria-current`,String(e.key===V));let r=k(e.entry),i=d(`span`,`review-queue-action community-badge`,r.text);i.dataset.tone=r.tone;let a=d(`span`,`pr-queue-top`);if(a.append(i,d(`span`,`pr-queue-title`,ge(e))),n.append(a,d(`span`,`pr-queue-elapsed`,A(e.entry))),t&&g(b(e))){let e=d(`span`,`tab-activity active pr-queue-unseen`);e.setAttribute(`aria-hidden`,`true`),n.append(e)}return n.addEventListener(`click`,()=>Z(e.key)),K.set(e.key,n),n}function Q(e){let t=d(`h3`,`pr-section-heading review-group-heading`),n=d(`span`,`review-group-count`,String(e.items.length));if(e.id!==`aside`)return t.append(d(`span`,null,e.title),n),t;let r=f(`review-group-toggle`),i=d(`span`,`review-group-chevron`,`▸`);return i.setAttribute(`aria-hidden`,`true`),r.append(i,e.title),r.setAttribute(`aria-expanded`,String(H)),r.addEventListener(`click`,()=>{H=!H,U=null,$()}),t.append(r,n),t}function ze(e){let t=d(`section`,`pr-queue-section`);if(t.dataset.group=e.id,t.append(Q(e)),e.id===`aside`&&!H)return t;for(let n of e.items)t.append(Re(n,e.id===`turn`));return t}function Be(){if(!L||!q)return!1;m()?.configured===!1&&q.needsSetup()&&!q.isOpen()&&q.open();let e=q.isOpen();return L.dataset.setup=String(e),q.element.hidden=!e,e}function $(){if(!R||Be())return;B=re(),V=S(B.filter(e=>e.id!==`aside`||H),V);let e=JSON.stringify([B,V,H,ne(),m()?.error??null]);if(e!==U){U=e,K.clear();let t=m()?.error,n=t?[d(`p`,`my-pr-note`,t)]:[],r=B.filter(e=>e.items.length>0).map(ze);R.replaceChildren(...n,...r.length>0?r:[d(`p`,`pr-empty`,j(m()))])}X()}function Ve(e){if(L)return;L=d(`div`,`pr-content review-queue community-queue`),e.append(L);let t=ce({queueLabel:`Community questions`,scopeTabs:null,resizerLabel:`Resize community queue`});R=t.queue,z=d(`div`,`review-queue-detail`);let n=d(`div`,`review-queue-phone-bar`);n.append(p({variant:`secondary`,label:`Back to queue`,action:`back-to-queue`,onClick:Fe})),t.detail.append(n,z),q=Ce({onFinish:$}),q.element.hidden=!0,L.append(q.element,t.columns),L.dataset.detailOpen=`false`,v(()=>!l(L)),y(e=>{e.kind===`status`&&$()}),document.addEventListener(`keydown`,Le),$()}var He={mount:Ve,refresh:()=>{W=null,$()}};export{He as view};
|
|
1
|
+
import{n as e,o as t,r as n,t as r}from"./lane-read-token-step-CcLCpi7I.js";import{c as i,i as a,s as o,t as s}from"./action-status-B5J9yJlM.js";import{b as c,d as l,f as u,s as d}from"./dom-helpers-C7CaSePf.js";import{a as f,t as p}from"./button-C8v9_rcy.js";import{A as m,G as ee,Ga as h,M as g,N as _,O as v,P as y,Ui as b,Ur as x,V as te,Vi as S,Wa as C,Yi as w,ea as T,j as ne,k as re,ki as ie,qi as E,ra as ae,rt as oe,tt as se}from"./index-CS1WCbXX.js";import{t as ce}from"./pr-queue-columns-B-x0t1Iv.js";import{o as le}from"./card-registry-Ct6a2qHl.js";import{i as ue}from"./modal-DAfPARiv.js";import{d as de,f as fe}from"./control-ws-D6gk3ZJu.js";import{n as D}from"./setup-step-DHKUfmEv.js";var pe={HIGH:`High confidence`,MEDIUM:`Medium confidence`,LOW:`Low confidence`},me={HIGH:`ok`,MEDIUM:`warn`,LOW:`muted`},O={pending:`Waiting to be checked`,queued:`Waiting to be researched`,running:`Researching`,error:`Research failed`,aside:`Set aside`},he={forum:`Forum`,discord:`Discord`};function k(e){return e.status===`ready`&&e.verdict?{text:pe[e.verdict],tone:me[e.verdict]}:e.status===`ready`?{text:`Researched`,tone:`muted`}:e.status===`error`?{text:O.error,tone:`danger`}:{text:O[e.status],tone:`muted`}}function A(e){let t=he[e.item.source];return e.item.channel?`${t} #${e.item.channel}`:t}function ge(e){return e.entry.item.title||`Untitled question`}function _e(e){return e.status!==`running`&&e.status!==`queued`}function ve(e){return e.status!==`aside`}function ye(e){let t=e.find(e=>e.id===`working`)?.items.length??0;return t===0?`No community question needs you right now.`:`No community question needs you right now. ${t} ${t===1?`question is`:`questions are`} being researched.`}function j(e){return e?e.configured===!1?e.reason??`The community lane is not set up yet.`:`No community questions yet. New ones asked after you turned this on show up here.`:`Waiting for the community lane to report.`}function be(e){return e.filter(e=>!e.isWorkspace&&!e.isEphemeral).map(({id:e,name:t})=>({id:e,name:t})).toSorted((e,t)=>e.name.localeCompare(t.name))}var M=[`key`,`readToken`,`project`,`skill`,`discord`];function N(e){let t=e===`finished`?M.length:M.indexOf(e),n=e=>e<t?`done`:e===t?`current`:`upcoming`;return{key:n(0),readToken:n(1),project:n(2),skill:n(3),discord:n(4)}}function xe(e){let t=e.split(/[\s,]+/).map(e=>e.replace(/^#/,``)).filter(Boolean);return[...new Set(t)]}var P=2;function F(e){de({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`onboarding`,action:e}})}function I(){let e=se().community,t=typeof e==`object`&&e?e:{},n=Array.isArray(t.discordChannels)?t.discordChannels.filter(e=>typeof e==`string`):[];return{projectId:typeof t.projectId==`number`?t.projectId:P,skill:typeof t.skill==`string`?t.skill:``,discordChannels:n}}function Se(e,t,n,r){let i=d(`input`,`dialog-input repo-roots-adder-input`);return i.id=e,i.type=r,i.value=t,i.placeholder=n,i.autocomplete=`off`,i.spellcheck=!1,i}function Ce({onFinish:t}){let i=d(`section`,`first-run-checklist review-setup`);i.setAttribute(`aria-labelledby`,`community-setup-title`);let c=d(`h2`,`first-run-title`,`Answer community questions`);c.id=`community-setup-title`;let l=d(`ol`,`first-run-steps`),u=d(`p`,`first-run-step-hint review-setup-foot`,`Each question gets a researched draft reply. Nothing posts until you post it yourself. `);u.append(te(`lanes-community`,`community-enabled`,`All community settings`));let f=d(`div`,`first-run-step-actions`),m=p({variant:`primary`,label:`Finish setup`,action:`finish-community-setup`});f.append(m),f.hidden=!0,i.append(d(`span`,`first-run-eyebrow`,`SET UP COMMUNITY`),c,l,f,u);let h=null;m.addEventListener(`click`,()=>{F(`finish-community-setup`),h=null,t()});function g(){return r(`posthog.apiKey`)?e()?null:`readToken`:`key`}function _(t){h=t===`readToken`&&e()?`project`:t,w(),(l.querySelector(`[aria-current="step"] input`)??(f.hidden?null:m))?.focus()}async function v(e,t,n,r){t.disabled=!0,n.show(`busy`,`Saving`);try{let t=await fe(`update-settings`,{settings:e},{timeoutMs:s});if(t.type===`settings-error`){n.show(`error`,t.message);return}if(t.type!==`settings-updated`){n.show(`error`,`The server did not confirm the save.`);return}ee(t.settings),_(r)}catch(e){n.show(`error`,o(e,s))}finally{t.disabled=!1}}function y(e){let t=Se(e.inputId,e.initialValue,e.placeholder,e.inputType),n=d(`label`,`repo-roots-adder-label`,e.label);n.htmlFor=t.id;let r=d(`div`,`first-run-step-actions`),i=a(),o=p({variant:`primary`,label:e.saveLabel,action:e.action}),s=()=>{let n=e.settingsPatch(t.value);typeof n==`string`?i.show(`error`,n):(F(e.action),v(n,o,i,e.nextProgress))};if(o.addEventListener(`click`,s),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),s())}),r.append(o),e.isSkippable){let t=p({variant:`secondary`,label:`Skip`,action:`skip-community-setup-step`,onClick:()=>_(e.nextProgress)});r.append(t)}return r.append(i.element),[d(`p`,`first-run-step-text`,e.advice),n,t,r]}let b=()=>y({advice:`Glimmervoid reads new forum and Discord questions through your PostHog personal API key. Create one in PostHog under Settings, Personal API keys. Community needs only the query:read scope on the project that holds the questions. PostHog error monitoring shares this key, so add error tracking read and write if you turn that on.`,label:`PERSONAL API KEY`,inputId:`community-setup-key`,inputType:`password`,initialValue:``,placeholder:`phx_`,saveLabel:`Save key`,action:`save-community-key`,nextProgress:`readToken`,isSkippable:!1,settingsPatch:e=>e.trim()?{posthog:{apiKey:e.trim()}}:`Paste a PostHog personal API key.`}),x=()=>y({advice:`The PostHog project that holds the synced community forum table and the Discord bot events. PostHog's own community lives in project 2.`,label:`PROJECT ID`,inputId:`community-setup-project`,inputType:`number`,initialValue:String(I().projectId),placeholder:String(P),saveLabel:`Use project`,action:`save-community-project`,nextProgress:`skill`,isSkippable:!1,settingsPatch:e=>{let t=Number(e.trim());return Number.isInteger(t)&&t>0?{community:{projectId:t}}:`Type the project id as a whole number, such as 2.`}}),S=()=>y({advice:`The Claude Code skill the research agent follows for each question, typed by name. A skill that knows your docs and support playbook gives the best drafts. Skip to research with whatever skills the agent has.`,label:`SKILL`,inputId:`community-setup-skill`,inputType:`text`,initialValue:I().skill,placeholder:`skill name`,saveLabel:`Save skill`,action:`save-community-skill`,nextProgress:`discord`,isSkippable:!0,settingsPatch:e=>({community:{skill:e.trim().replace(/^\//,``)}})}),C=()=>y({advice:`Discord questions come from a Discord bot that sends message_sent and thread_created events into the project above. With that bot in place, list the channels to watch by name, without the #. A cheap model picks out the real questions; only those are researched.`,label:`CHANNELS`,inputId:`community-setup-discord`,inputType:`text`,initialValue:I().discordChannels.join(`, `),placeholder:`community-questions, help`,saveLabel:`Save channels`,action:`save-community-discord`,nextProgress:`finished`,isSkippable:!0,settingsPatch:e=>{let t=xe(e);return t.length>0?{community:{discordChannels:t}}:`Type at least one channel, or skip.`}});function w(){if(!h)return;let e=N(h);l.replaceChildren(D({title:`1. PostHog personal API key`,state:e.key,summary:`Key saved`,badge:`NEEDED`,body:b}),D({title:`2. Read-only GitHub token`,state:e.readToken,summary:`Token saved`,badge:`REQUIRED`,body:()=>n({laneWork:`Community research reads the GitHub issues, code and pages a question links.`,onSaved:()=>_(`project`)})}),D({title:`3. PostHog project`,state:e.project,summary:`Project ${I().projectId}`,badge:``,body:x}),D({title:`4. Research skill (optional)`,state:e.skill,summary:I().skill||`No skill`,badge:``,body:S}),D({title:`5. Discord (optional)`,state:e.discord,summary:I().discordChannels.map(e=>`#${e}`).join(` `)||`Forum only`,badge:``,body:C})),f.hidden=h!==`finished`}function T(){h=g()??`key`,w()}return oe(t=>{t.kind===`broadcast`&&(h===`key`&&r(`posthog.apiKey`)&&_(`readToken`),h===`readToken`&&e()&&_(`project`))}),{element:i,open:T,isOpen:()=>h!==null,needsSetup:()=>g()!==null}}var L=null,R=null,z=null,B=[],V=null,H=!1,U=null,W=null,G=``,K=new Map,q=null;function we(){return be([...le].map(([e,t])=>({id:e,name:t.nameEl.textContent??e,isWorkspace:t.card.dataset.workspace!==void 0,isEphemeral:t.card.dataset.ephemeral!==void 0})))}function J(e,t,n){let r=d(`ul`,e);r.setAttribute(`aria-label`,t);for(let e of n)r.append(d(`li`,null,e));return r}function Te(e){let t=d(`div`,`pr-detail-heading`),n=d(`div`,`pr-detail-title`);n.append(d(`h2`,null,e.item.title||`Untitled question`));let r=d(`div`,`pr-detail-meta`),i=Date.parse(e.item.createdAt);r.append(d(`span`,null,e.item.author),d(`span`,null,A(e))),Number.isNaN(i)||r.append(d(`span`,null,`Asked ${x(i)}`));for(let t of e.item.tags)r.append(d(`span`,`author-org-tag`,t));return t.append(n,r),t}function Ee(e){let t=d(`section`,`community-question`);return t.setAttribute(`aria-label`,`Question as asked`),t.append(d(`h3`,`pr-section-heading`,`Question as asked`),d(`p`,`community-question-body`,e.item.body)),t}function De(e){let t=d(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Research`);let n=k(e),r=d(`div`,`pr-verdict-line`),i=d(`strong`,`community-badge`,n.text);if(i.dataset.tone=n.tone,r.append(i),t.append(r),e.error&&t.append(d(`p`,`pr-attention-detail`,e.error)),e.summary&&t.append(d(`p`,`pr-verdict-summary`,e.summary)),e.goal&&t.append(d(`p`,`community-goal`,`Goal: ${e.goal}`)),e.gaps.length>0&&t.append(J(`pr-verdict-gaps`,`Not covered`,e.gaps)),e.checked.length===0)return t;let a=d(`details`,`pr-verdict-checked`);return a.append(d(`summary`,null,`What it checked (${e.checked.length})`),J(`community-checked`,`What it checked`,e.checked)),t.append(a),t}function Oe(e){if(!e.draft)return null;let t=d(`section`,`community-draft`);t.setAttribute(`aria-label`,`Draft reply`),t.append(d(`h3`,`pr-section-heading`,`Draft reply`),d(`p`,`community-draft-body`,e.draft.body));let n=e.draft.publicLinks.filter(h);if(n.length===0)return t;let r=d(`ul`,`community-links`);for(let e of n){let t=d(`li`);t.append(p({variant:`secondary`,size:`small`,label:e,action:`open-public-link`,onClick:()=>C(e)})),r.append(t)}return t.append(r),t}function ke(e,t){let n=e.draft?c(e.draft.body):null;n?n.then(()=>t.show(`ok`,`Draft copied. Post it yourself where the question was asked.`),()=>t.show(`error`,`Copying failed. Select the draft text instead.`)):t.show(`error`,`This browser does not allow copying here. Select the draft text instead.`)}async function Ae(e,t){if(!G){t.show(`error`,`Pick a session to start from first.`);return}let n=await i(`open-community-session`,{key:e.item.key,projectId:G},t,{busyText:`Starting a session with the research.`});n?.type===`open-community-session-result`&&(n.ok?(t.show(`ok`,`Started ${n.sessionName??`a session`}.`),n.sessionId&&ie()?.openTerminal(n.sessionId)):t.show(`error`,n.error??`The session did not start.`))}async function Y(e,t,n){let r=t===`rerun`?`Queuing the research again.`:`Setting the question aside.`,a=await i(`community-action`,{key:e.item.key,action:t},n,{busyText:r});a?.type===`community-action-result`&&(a.ok||n.show(`error`,a.error??`The change did not apply.`))}function je(){let e=d(`select`,`community-session-picker`);e.setAttribute(`aria-label`,`Session to start from`);let t=we();t.some(e=>e.id===G)||(G=t[0]?.id??``);for(let n of t){let t=d(`option`,null,n.name);t.value=n.id,t.selected=n.id===G,e.append(t)}return e.disabled=t.length===0,e.addEventListener(`change`,()=>{G=e.value}),e}function Me(e){let t=d(`div`,`community-actions`),n=a(`pr-action-status`),r=d(`div`,`community-action-buttons`);return r.append(p({variant:`secondary`,label:`Copy draft`,action:`copy-draft`,disabled:e.draft===null,onClick:()=>ke(e,n)}),p({variant:`secondary`,label:`Open thread`,action:`open-thread`,disabled:!h(e.item.url),onClick:()=>C(e.item.url)}),je(),p({variant:`primary`,label:`Start session`,action:`start-session`,onClick:()=>void Ae(e,n)}),p({variant:`secondary`,label:`Re-run`,action:`rerun-community-research`,disabled:!_e(e),onClick:()=>void Y(e,`rerun`,n)}),p({variant:`secondary`,label:`Set aside`,action:`set-aside-community-question`,disabled:!ve(e),onClick:()=>void Y(e,`set-aside`,n)})),t.append(r,n.element),t}function Ne(e){let t=d(`article`,`pr-detail community-detail`),n=Oe(e);return t.append(Te(e),Me(e),...n?[n]:[],De(e),Ee(e)),t}function X(){if(!z)return;let e=E(B,V),n=e?JSON.stringify(e.entry):`empty:${ae(B).length}`;if(n===W)return;if(W=n,e){z.replaceChildren(Ne(e.entry));return}let r=B.some(e=>e.items.length>0);z.replaceChildren(r?t({title:`All caught up`,detail:ye(B)}):d(`p`,`pr-empty`,j(m())))}function Pe(e,t){_(b(e))&&t.querySelector(`.pr-queue-unseen`)?.remove()}function Z(e){V=e;for(let[t,n]of K)n.setAttribute(`aria-current`,String(t===e));let t=E(B,e),n=K.get(e);t&&n&&Pe(t,n),X(),L&&(L.dataset.detailOpen=`true`)}function Fe(){L&&(L.dataset.detailOpen=`false`),V&&K.get(V)?.focus({preventScroll:!0})}function Ie(e){let t=E(B,e);if(!t)return;B.find(e=>e.items.includes(t))?.id===`aside`&&(H=!0),V=e,$(),Z(e);let n=K.get(e);n?.focus({preventScroll:!0}),n?.scrollIntoView({block:`nearest`})}function Le(e){if(e.repeat||e.defaultPrevented||!L||l(L)||ue()||u(e)||document.activeElement?.classList.contains(`xterm-helper-textarea`))return;let t=w(e);if(t!==`next-row`&&t!==`previous-row`)return;let n=T([...K.keys()],V,t===`next-row`?1:-1);n&&(e.preventDefault(),n!==V&&Ie(n))}function Re(e,t){let n=f(`pr-queue-row pr-queue-row-quiet`);n.dataset.queueKey=e.key,n.setAttribute(`aria-current`,String(e.key===V));let r=k(e.entry),i=d(`span`,`review-queue-action community-badge`,r.text);i.dataset.tone=r.tone;let a=d(`span`,`pr-queue-top`);if(a.append(i,d(`span`,`pr-queue-title`,ge(e))),n.append(a,d(`span`,`pr-queue-elapsed`,A(e.entry))),t&&g(b(e))){let e=d(`span`,`tab-activity active pr-queue-unseen`);e.setAttribute(`aria-hidden`,`true`),n.append(e)}return n.addEventListener(`click`,()=>Z(e.key)),K.set(e.key,n),n}function Q(e){let t=d(`h3`,`pr-section-heading review-group-heading`),n=d(`span`,`review-group-count`,String(e.items.length));if(e.id!==`aside`)return t.append(d(`span`,null,e.title),n),t;let r=f(`review-group-toggle`),i=d(`span`,`review-group-chevron`,`▸`);return i.setAttribute(`aria-hidden`,`true`),r.append(i,e.title),r.setAttribute(`aria-expanded`,String(H)),r.addEventListener(`click`,()=>{H=!H,U=null,$()}),t.append(r,n),t}function ze(e){let t=d(`section`,`pr-queue-section`);if(t.dataset.group=e.id,t.append(Q(e)),e.id===`aside`&&!H)return t;for(let n of e.items)t.append(Re(n,e.id===`turn`));return t}function Be(){if(!L||!q)return!1;m()?.configured===!1&&q.needsSetup()&&!q.isOpen()&&q.open();let e=q.isOpen();return L.dataset.setup=String(e),q.element.hidden=!e,e}function $(){if(!R||Be())return;B=re(),V=S(B.filter(e=>e.id!==`aside`||H),V);let e=JSON.stringify([B,V,H,ne(),m()?.error??null]);if(e!==U){U=e,K.clear();let t=m()?.error,n=t?[d(`p`,`my-pr-note`,t)]:[],r=B.filter(e=>e.items.length>0).map(ze);R.replaceChildren(...n,...r.length>0?r:[d(`p`,`pr-empty`,j(m()))])}X()}function Ve(e){if(L)return;L=d(`div`,`pr-content review-queue community-queue`),e.append(L);let t=ce({queueLabel:`Community questions`,scopeTabs:null,resizerLabel:`Resize community queue`});R=t.queue,z=d(`div`,`review-queue-detail`);let n=d(`div`,`review-queue-phone-bar`);n.append(p({variant:`secondary`,label:`Back to queue`,action:`back-to-queue`,onClick:Fe})),t.detail.append(n,z),q=Ce({onFinish:$}),q.element.hidden=!0,L.append(q.element,t.columns),L.dataset.detailOpen=`false`,v(()=>!l(L)),y(e=>{e.kind===`status`&&$()}),document.addEventListener(`keydown`,Le),$()}var He={mount:Ve,refresh:()=>{W=null,$()}};export{He as view};
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,s as t,t as n}from"./action-status-B5J9yJlM.js";import{f as r}from"./control-ws-D6gk3ZJu.js";import{a as i,dn as a,et as o,fn as s,ft as c,mt as l,pt as u,t as d}from"./button-C8v9_rcy.js";import{D as f,Kr as p,Ur as m,at as h,h as g,ii as _,oo as v,ot as y,st as b}from"./index-
|
|
1
|
+
import{i as e,s as t,t as n}from"./action-status-B5J9yJlM.js";import{f as r}from"./control-ws-D6gk3ZJu.js";import{a as i,dn as a,et as o,fn as s,ft as c,mt as l,pt as u,t as d}from"./button-C8v9_rcy.js";import{D as f,Kr as p,Ur as m,at as h,h as g,ii as _,oo as v,ot as y,st as b}from"./index-CS1WCbXX.js";import{g as x,h as S,nn as C,s as w}from"./dom-helpers-C7CaSePf.js";import{t as T}from"./repo-roots-adder-DtEMQL0F.js";import{n as E,r as ee,t as te}from"./modal-DAfPARiv.js";import{P as D,_ as ne,i as re,n as ie,r as ae,s as oe,t as se}from"./agent-core-QaO-cL5S.js";import{t as ce}from"./agent-mark-DLq6N-1P.js";import{o as le,v as ue}from"./card-registry-Ct6a2qHl.js";import{Ct as de,N as fe,St as pe,bt as me,n as he,wt as ge,xt as _e,yt as ve}from"./ui-prefs-BAxLE-L1.js";import{n as O}from"./session-tick-BAmaQ-9h.js";var ye=`<h2 class="dialog-title" id="add-session-title">New session</h2>
|
|
2
2
|
<p class="add-session-sentence"><span class="add-session-place" id="add-session-place" hidden>On <span id="add-session-place-word-slot"></span>, </span><span id="add-session-start-word">Start</span> <span id="add-session-agent-word-slot"></span> in <span id="add-session-repo-word-slot"></span></p>
|
|
3
3
|
<div class="add-session-pick" id="add-session-pick">
|
|
4
4
|
<input type="text" class="dialog-input add-session-find" id="add-session-find" placeholder="Find a project" autocomplete="off" spellcheck="false" aria-label="Find a project">
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e,t}from"./action-status-B5J9yJlM.js";import{f as n}from"./control-ws-D6gk3ZJu.js";import{_i as r,no as i}from"./index-
|
|
1
|
+
import{s as e,t}from"./action-status-B5J9yJlM.js";import{f as n}from"./control-ws-D6gk3ZJu.js";import{_i as r,no as i}from"./index-CS1WCbXX.js";import{s as a}from"./dom-helpers-C7CaSePf.js";import{a as o,r as s,t as c}from"./modal-DAfPARiv.js";import{O as l,t as u,u as d,yn as f}from"./button-C8v9_rcy.js";var p=[`wc`,`awk`,`frag`,`tense`,`unclear`,`para`,`good`,`must`,`end`],m=`{>>`,h=`<<}`,g=`~>`,_=[{opener:`{--`,closer:`--}`,markKind:`deletion`},{opener:`{++`,closer:`++}`,markKind:`insertion`},{opener:`{~~`,closer:`~~}`,markKind:`substitution`},{opener:`{==`,closer:`==}`,markKind:`highlight`},{opener:m,closer:h,markKind:`comment`}],v=[..._.flatMap(({opener:e,closer:t})=>[e,t]),g],y=RegExp(`^(${p.join(`|`)}):\\s*`,`i`);function b(e){return p.includes(e)}function x(e){if(e===void 0||e.trim()===``)return null;let t=y.exec(e),n=t?.[1]?.toLowerCase()??``;return!t||!b(n)?{code:null,body:e.trim()}:{code:n,body:e.slice(t[0].length).trim()}}function ee(e){let t=new Map;return(n,r)=>{let i=t.get(n);if(i!==void 0&&i.searchedFrom<=r&&(i.foundAt===-1||i.foundAt>=r))return i.foundAt;let a=e.indexOf(n,r);return t.set(n,{searchedFrom:r,foundAt:a}),a}}function S(e,t,n){if(!e.startsWith(m,n))return{rawNote:void 0,end:n};let r=t(h,n+3);return r===-1?{rawNote:void 0,end:n}:{rawNote:e.slice(n+3,r),end:r+3}}function te(e,t,n){let r=t(g,n);if(r===-1)return null;let i=t(`~~}`,r+2);return i===-1?null:{oldText:e.slice(n,r),newText:e.slice(r+2,i),closeAt:i}}function ne(e,t,n){let r=_.find(({opener:t})=>e.startsWith(t,n));if(!r)return null;let i=n+r.opener.length;if(r.markKind===`substitution`){let a=te(e,t,i);if(!a)return null;let o=S(e,t,a.closeAt+r.closer.length);return{kind:`mark`,markKind:`substitution`,start:n,end:o.end,oldText:a.oldText,newText:a.newText,note:x(o.rawNote)}}let a=t(r.closer,i);if(a===-1)return null;let o=e.slice(i,a),s=a+r.closer.length;if(r.markKind===`comment`)return{kind:`mark`,markKind:`comment`,start:n,end:s,oldText:``,newText:``,note:x(o)};let c=S(e,t,s),l=r.markKind===`insertion`;return{kind:`mark`,markKind:r.markKind,start:n,end:c.end,oldText:l?``:o,newText:l?o:``,note:x(c.rawNote)}}function C(e){let t=[],n=ee(e),r=0,i=e.indexOf(`{`);for(;i!==-1;){let a=ne(e,n,i);a?(a.start>r&&t.push({kind:`text`,start:r,text:e.slice(r,a.start)}),t.push(a),r=a.end,i=e.indexOf(`{`,a.end)):i=e.indexOf(`{`,i+1)}return r<e.length&&t.push({kind:`text`,start:r,text:e.slice(r)}),t}function re(e){return e.markKind===`comment`&&e.note?.code===`end`}function ie(e,t){let n=t===`accept`;switch(e.markKind){case`deletion`:return n?``:e.oldText;case`insertion`:return n?e.newText:``;case`substitution`:return n?e.newText:e.oldText;case`highlight`:return e.oldText;case`comment`:return``}}function ae(e,t,n){return e.slice(0,t.start)+ie(t,n)+e.slice(t.end)}function w(e){return v.some(t=>e.includes(t))}function T(e){return{kind:`refused`,reason:e}}function E(e){return C(e).filter(e=>e.kind===`mark`)}function D(e){return e.start===e.end}function O(e,t,n){switch(e){case`insertion`:return`{++${n}++}`;case`deletion`:return`{--${t}--}`;case`substitution`:return`{~~${t}~>${n}~~}`}}function k(e,t,n,r=``){let i=!n.endsWith(h)&&e.startsWith(m,t.end),a=r+n+(i?`${m}${h}`:``),o=e.slice(0,t.start)+a+e.slice(t.end),s=t.start+r.length,c=t.start+a.length;return E(o).some(e=>e.start===s&&e.end===c)?{source:o,markEnd:c}:null}function A(e,t,n){return{kind:`applied`,source:e.source,caret:t,run:n}}function oe(e,t,n){if(!n||!D(t)||t.start!==n.markEnd)return null;let r=E(e).find(e=>e.start===n.markStart&&e.end===n.markEnd);return!r||r.note||r.markKind!==`insertion`&&r.markKind!==`substitution`?null:r}function se(e,t,n){if(n===``&&t.markKind===`insertion`)return{kind:`applied`,source:e.slice(0,t.start)+e.slice(t.end),caret:t.start,run:null};if(w(n))return T(`delimiter`);let r=k(e,t,O(t.markKind===`insertion`?`insertion`:`substitution`,t.oldText,n));return r?A(r,r.markEnd,{markStart:t.start,markEnd:r.markEnd}):T(`swallowed`)}function ce(e,t,n,r){if(n===``)return T(`nothing`);let i=oe(e,t,r);if(i)return se(e,i,i.newText+n);let a=e.slice(t.start,t.end);if(w(n)||w(a))return T(`delimiter`);let o=k(e,t,D(t)?O(`insertion`,``,n):O(`substitution`,a,n));return o?A(o,o.markEnd,{markStart:t.start,markEnd:o.markEnd}):T(`swallowed`)}function le(e,t){return t<0||t>=e.length||e[t]===`
|
|
2
2
|
`?!1:C(e).some(e=>e.kind===`text`&&e.start<=t&&t<e.start+e.text.length)}function ue(e,t,n){let r=e.slice(t.start,t.end);if(w(r))return T(`delimiter`);let i=E(e).filter(e=>e.markKind===`deletion`&&!e.note),a=i.find(e=>e.end===t.start),o=i.find(e=>e.start===t.end),s={start:a?.start??t.start,end:o?.end??t.end},c=k(e,s,O(`deletion`,(a?.oldText??``)+r+(o?.oldText??``),``));return c?A(c,n===`forward`?c.markEnd:s.start,null):T(`swallowed`)}function de(e,t,n,r){let i=oe(e,t,r);if(i&&n===`backward`)return se(e,i,i.newText.slice(0,-1));if(!D(t))return ue(e,t,n);let a=n===`backward`?t.start-1:t.start;return le(e,a)?ue(e,{start:a,end:a+1},n):T(`nothing`)}function fe(e,t,n){let r=n.trim();if(r===``)return T(`nothing`);let i=e.slice(t.start,t.end);if(w(r)||w(i))return T(`delimiter`);let a=`${m}${r}${h}`;return D(t)?pe(k(e,t,a,E(e).some(n=>n.end===t.start&&n.markKind!==`comment`&&!e.slice(n.start,n.end).endsWith(h))?`${m}${h}`:``)):pe(k(e,t,`{==${i}==}${a}`))}function pe(e){return e?A(e,e.markEnd,null):T(`swallowed`)}function me(e,t){return D(t)?!E(e).some(e=>e.start<t.start&&t.start<e.end):C(e).some(e=>e.kind===`text`&&e.start<=t.start&&t.end<=e.start+e.text.length)}function he(e,t,n){if(!me(e,t.selection))return T(`nested`);switch(t.kind){case`type`:return ce(e,t.selection,t.text,n);case`delete`:return de(e,t.selection,t.direction,n);case`paragraph`:return fe(e,{start:t.selection.end,end:t.selection.end},`para`);case`note`:return D(t.selection)?T(`nothing`):fe(e,t.selection,t.body)}}var j=/^ {0,3}(`{3,}|~{3,})/,M=/^ {0,3}#{1,6}[ \t]+/,ge=/^ {0,3}(?:>[ \t]?)+/,_e=/^[ \t]*(?:[-*+]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/,ve=/^[ \t]*\|/,ye=/(`+)(?!`)(.+?)(?<!`)\1(?!`)|(\*\*|__)(?=\S)(.+?)(?<=\S)\3|(?<![\w*])([*_])(?=[^\s*_])(.+?)(?<=[^\s*_])\5(?![\w*])/g,be=[`plain`,`h1`,`h2`,`h3`,`h3`,`h3`,`h3`],xe={h1:M,h2:M,h3:M,quote:ge,list:_e};function Se(e){let t=f(e,{overlongLine:`truncate`});return t?be[t.level]??`h3`:ge.test(e)?`quote`:_e.test(e)?`list`:ve.test(e)?`table`:`plain`}function Ce(e,t){let n=j.exec(e)?.[1];return n!==void 0&&n[0]===t[0]&&n.length>=t.length&&e.trim()===n}function we(e){let t=null;return e.split(`
|
|
3
3
|
`).map(e=>t===null?(t=j.exec(e)?.[1]??null,t===null?Se(e):`fence`):(Ce(e,t)&&(t=null),`fence`))}function N(e,t,n,r){return[{start:e,end:e+n,style:`syntax`},{start:e+n,end:t-n,style:r},{start:t-n,end:t,style:`syntax`}]}function Te(e,t,n){if(t===`fence`||t===`table`)return[];let r=[],i=n?xe[t]?.exec(e)?.[0]:void 0;i&&r.push({start:0,end:i.length,style:`syntax`});for(let t of e.matchAll(ye)){let e=t.index,n=e+t[0].length,[,i,,a,,o]=t;i&&r.push(...N(e,n,i.length,`code`)),a&&r.push(...N(e,n,a.length,`strong`)),o&&r.push(...N(e,n,o.length,`emphasis`))}return r}var Ee={unclear:`?`,para:`¶`},De={deletion:`Cut`,insertion:`Add`,substitution:`Change`,highlight:`Note`,comment:`Note`},Oe={delimiter:`That text holds CriticMarkup characters, so typing here cannot become a mark. Nothing changed.`,swallowed:`This mark would run into the mark beside it or an unclosed mark earlier in the doc. Nothing changed.`,nested:`Marks never nest. Edit text outside a mark, or accept or reject the mark first.`,nothing:``},ke=new Set([`deleteContentBackward`,`deleteByCut`]),Ae=new Set([`insertText`,`insertReplacementText`,`insertFromPaste`,`insertFromYank`]),je=new Set([`insertParagraph`,`insertLineBreak`]),Me=`http://www.w3.org/2000/svg`;function P(e,t){let n=document.createElementNS(Me,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function Ne(){let e=P(`svg`,{width:`0`,height:`0`,"aria-hidden":`true`,class:`doc-markup-defs`}),t=P(`filter`,{id:`doc-markup-ink`});return t.append(P(`feTurbulence`,{type:`fractalNoise`,baseFrequency:`0.05`,numOctaves:`2`,result:`grain`}),P(`feDisplacementMap`,{in:`SourceGraphic`,in2:`grain`,scale:`1.6`})),e.append(t),e}function Pe(){let e=P(`svg`,{viewBox:`0 0 16 16`,class:`doc-markup-check`,"aria-hidden":`true`});return e.append(P(`path`,{d:`M2 9 L6 13 L14 3`})),e}function Fe(){let e=u({variant:`primary`,size:`small`,label:`Accept`,action:`accept-mark`}),t=u({variant:`danger`,size:`small`,label:`Reject`,action:`reject-mark`}),n=a(`p`,`doc-markup-card-text`),r=a(`div`,`doc-markup-card-actions`);r.append(e,t);let i=a(`div`,`doc-markup-float doc-markup-card`);i.append(n,r);let o=u({variant:`secondary`,size:`small`,label:`Add note`,action:`add-note`});o.classList.add(`doc-markup-float`);let s=a(`input`,`plan-control doc-markup-input`);s.type=`text`,s.placeholder=`Note, or a code like wc: or awk:`,s.setAttribute(`aria-label`,`Note on the selected text`);let c=a(`div`,`doc-markup-float doc-markup-composer`);c.append(s);let l=a(`span`,`doc-markup-hint`);l.setAttribute(`role`,`status`);let d=a(`div`,`doc-markup-paper`);d.spellcheck=!1,d.setAttribute(`role`,`textbox`),d.setAttribute(`aria-multiline`,`true`),d.setAttribute(`aria-label`,`Doc in red pen; edits become marks`);let f=a(`div`,`doc-markup-end`),p=a(`div`,`doc-markup`);for(let e of[i,o,c])e.hidden=!0;p.append(Ne(),d,f,i,o,c);let m={root:p,paper:d,endNotes:f,markCard:i,markCardText:n,btnAccept:e,btnReject:t,btnAddNote:o,noteComposer:c,noteInput:s,hint:l,marginResizeObserver:new ResizeObserver(()=>Ye([...m.visibleRows])),rowObserver:null,listeners:new AbortController,rowsByElement:new Map,visibleRows:new Set,selection:null,noteSelection:null,compositionSelection:null,run:null,tip:``,marks:[],elementsByMarkIndex:[],selectedMarkIndex:null};return m.marginResizeObserver.observe(d),m}function Ie(e){e.marginResizeObserver.disconnect(),e.rowObserver?.disconnect(),e.listeners.abort()}function Le(e){let t=[De[e.markKind]];return e.oldText&&t.push(`"${e.oldText}"`),e.newText&&t.push(`to "${e.newText}"`),e.note&&t.push(`(${[e.note.code,e.note.body].filter(Boolean).join(`: `)})`),t.join(` `)}function Re(e,t){let n=a(`span`,`doc-markup-mark doc-markup-${e.markKind}`);if(n.dataset.markIndex=String(t),n.contentEditable=`false`,n.tabIndex=0,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,Le(e)),e.oldText&&e.markKind!==`highlight`&&n.append(a(`del`,null,e.oldText)),e.markKind===`highlight`&&n.append(a(`span`,`doc-markup-underline`,e.oldText)),e.newText){let t=a(`ruby`,`doc-markup-caret`,`^`);t.append(a(`rt`,null,e.newText)),n.append(t)}return e.markKind===`comment`&&n.append(a(`sup`,`doc-markup-pin`,`*`)),n}function ze(e){let t=a(`div`,`doc-markup-note`);return t.dataset.code=e.note?.code??``,e.note?.code===`good`&&t.append(Pe()),e.note?.code&&e.note.code!==`good`&&t.append(a(`span`,`doc-markup-code`,Ee[e.note.code]??e.note.code)),e.note?.body&&t.append(a(`span`,`doc-markup-note-body`,e.note.body)),t}function Be(e,t){let n=a(`div`,`doc-markup-end-note doc-markup-mark`);return n.dataset.markIndex=String(t),n.tabIndex=0,n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,`End note: ${e.note?.body??``}`),n.append(a(`span`,`doc-markup-code`,`End note`),a(`p`,`doc-markup-note-body`,e.note?.body??``)),n}function F(e,t,n,r){let i=a(`span`,`doc-markup-text`,e);return i.dataset.start=String(t),i.dataset.segmentStart=String(n),r&&(i.dataset.inline=r),i}function Ve(e,t,n,r,i){let a=[],o=0;for(let s of Te(e,r,i))s.start>o&&a.push(F(e.slice(o,s.start),t+o,n)),a.push(F(e.slice(s.start,s.end),t+s.start,n,s.style)),o=s.end;return o<e.length&&a.push(F(e.slice(o),t+o,n)),a}function He(e){let t=we(e),n=new Map,r=0;for(let[i,a]of e.split(`
|
|
4
4
|
`).entries())n.set(r,t[i]??`plain`),r+=a.length+1;return n}function Ue(e,t){let n=a(`div`,`doc-markup-line`);n.dataset.start=String(e),n.dataset.block=t;let r=a(`div`,`doc-markup-row-margin`);r.setAttribute(`aria-hidden`,`true`),r.contentEditable=`false`;let i=a(`div`,`doc-markup-row`);return i.append(n,r),{row:i,line:n,margin:r,notesWithAnchors:[],block:t}}function We(e,t,n){let r=t.start;t.text.split(`
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Bt as e,t}from"./button-C8v9_rcy.js";import{n,r,t as i}from"./flying-animal-preview-D5dhy9Eo.js";import{d as a}from"./control-ws-D6gk3ZJu.js";import{s as o}from"./dom-helpers-C7CaSePf.js";import{B as s,Wa as c,hi as l,mi as u}from"./index-
|
|
1
|
+
import{Bt as e,t}from"./button-C8v9_rcy.js";import{n,r,t as i}from"./flying-animal-preview-D5dhy9Eo.js";import{d as a}from"./control-ws-D6gk3ZJu.js";import{s as o}from"./dom-helpers-C7CaSePf.js";import{B as s,Wa as c,hi as l,mi as u}from"./index-CS1WCbXX.js";import{kt as d}from"./ui-prefs-BAxLE-L1.js";var f={teamReview:e=>`${e} pull requests reviewed this week. Reviews lines up every PR waiting on you, and it is off right now.`,issues:e=>`${e} issues touched this week. The Issues tab keeps them in one list and starts a session on any of them, and it is off right now.`,usage:()=>`Keeping an eye on tokens? Usage tracks spend per session and warns before a limit hits, and it is off right now.`,posthog:()=>`Hunting errors again? Radar watches PostHog error tracking and can investigate an issue for you, and it is off right now.`,benchmarks:()=>`Comparing agents by hand? Bench runs the same review cases across agent setups side by side, and it is off right now.`};function p(e){return`${f[e.feature](e.distinctTargetCount)} Show me takes you to its switch in Settings.`}function m(e){let t=s.find(t=>t.rule===e);return t?{sectionId:t.sectionId,settingId:t.settingId}:null}var h=null,g=!1;function _(e,t){a({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`hints`,action:t,feature:e}})}function v(e,t){try{return l(localStorage,u(e,t),Date.now())}catch{return!0}}function y(t,n){if(n.isFeatureEnabled(t)){n.openView(e[t]);return}let r=m(t);r&&n.openSetting(r.sectionId,r.settingId)}function b(){return h?.isConnected===!0}function x({text:e,ariaLabel:r,openLabel:a=`Show me`,onOpen:s,onDismiss:c}){let l=o(`aside`,`feature-hint`);l.setAttribute(`aria-live`,`polite`),l.setAttribute(`aria-label`,r);let u=o(`div`,`feature-hint-bubble`),f=t({variant:`primary`,label:a}),p=t({variant:`secondary`,label:`Dismiss`}),m=o(`div`,`feature-hint-actions`);m.append(p,f),u.append(o(`p`,`feature-hint-text`,e),m);let _=n()??d[0];l.append(u,i(_,`feature-hint-animal`));function v(){l.remove(),h=null,g&&(g=!1,w())}f.addEventListener(`click`,()=>{v(),s()}),p.addEventListener(`click`,()=>{v(),c()}),document.body.append(l),h=l}function S(e,t){b()||v(`feature-hint`,`${e.feature}-${e.raisedAt}`)&&(x({text:p(e),ariaLabel:`Feature tip`,onOpen:()=>{_(e.feature,`open`),y(e.feature,t)},onDismiss:()=>_(e.feature,`dismiss`)}),_(e.feature,`shown`))}function C(e){a({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`star`,action:e}})}function w(){b()?g=!0:v(`star-hint`,`card`)&&(x({text:`Enjoying Glimmervoid? A star on GitHub helps other people find it.`,ariaLabel:`Star Glimmervoid on GitHub`,openLabel:`Star on GitHub`,onOpen:()=>{C(`open`),c(`https://github.com/${r}`)},onDismiss:()=>C(`dismiss`)}),C(`shown`))}export{b as isHintCardShown,S as showFeatureHint,x as showHintCard,w as showStarHint};
|
|
Binary file
|
package/dist/client/assets/{first-run-checklist-B3TjARXd.js → first-run-checklist-Cg545_cC.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,s as t,t as n}from"./action-status-B5J9yJlM.js";import{d as r,f as i}from"./control-ws-D6gk3ZJu.js";import{c as a,s as o}from"./dom-helpers-C7CaSePf.js";import{$a as s,_ as c,di as l,eo as u,fi as d,ii as f,lo as p,to as m}from"./index-
|
|
1
|
+
import{i as e,s as t,t as n}from"./action-status-B5J9yJlM.js";import{d as r,f as i}from"./control-ws-D6gk3ZJu.js";import{c as a,s as o}from"./dom-helpers-C7CaSePf.js";import{$a as s,_ as c,di as l,eo as u,fi as d,ii as f,lo as p,to as m}from"./index-CS1WCbXX.js";import{J as h}from"./ui-prefs-BAxLE-L1.js";import{a as g,c as ee,d as _,f as v,h as y,i as b,l as te,m as x,n as S,o as C,p as ne,r as re,s as ie,t as ae,u as w}from"./repo-roots-adder-DtEMQL0F.js";import{P as oe,_ as se,s as ce,t as le,u as ue}from"./agent-core-QaO-cL5S.js";import{a as T,t as E}from"./button-C8v9_rcy.js";import{n as D,t as de}from"./setup-step-DHKUfmEv.js";function O(e,t,...n){let r=o(`div`,`first-run-start-field`),i=o(`label`,`first-run-eyebrow`,e);return i.htmlFor=t,r.append(i,...n),r}function fe(e){let t=o(`span`,`first-run-start-project-path`);return t.append(o(`bdi`,null,e)),t}function pe({onAction:r}){let a=[],s=null,c=le,l=!1,u=o(`input`,`first-run-start-filter`);u.id=`first-run-start-filter`,u.type=`search`,u.placeholder=`Filter`,u.autocomplete=`off`;let d=o(`ul`,`first-run-start-projects`);d.setAttribute(`role`,`listbox`),d.setAttribute(`aria-label`,`Project`);let p=o(`div`,`first-run-start-agents`);p.id=`first-run-start-agents`,p.setAttribute(`role`,`group`);let m=o(`textarea`,`first-run-start-task`);m.id=`first-run-start-task`,m.value=re,m.maxLength=4e3;let h=E({variant:`primary`,label:`Start session`}),g=E({variant:`quiet`,label:`Advanced`}),_=e(`first-run-start-status`),v=o(`div`,`first-run-start-foot`);v.append(h,_.element,g);let y=o(`div`,`first-run-start`);y.append(O(`Project`,`first-run-start-filter`,u,d),O(`Agent`,`first-run-start-agents`,p),O(`First task`,`first-run-start-task`,m),v);function b(){let e=te(a,u.value,s);s=e.selectedPath,d.replaceChildren(...e.visibleProjects.map(e=>{let t=o(`li`,`first-run-start-project`),n=T(`first-run-start-project-choice`);return n.append(o(`span`,`first-run-start-project-name`,e.name),fe(e.path)),e.lastActivityMs!==null&&n.append(o(`span`,`first-run-start-project-age`,f(e.lastActivityMs,Date.now()))),n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(e.path===s)),n.addEventListener(`click`,()=>{s=e.path,b()}),t.append(n),t})),h.disabled=l||s===null}function x(e){let t=ee(e);c=t.selectedId,p.replaceChildren(...t.options.map(e=>{let t=T(`dialog-mode-button`,e.label);return t.setAttribute(`aria-pressed`,String(e.id===c)),t.addEventListener(`click`,()=>{c=e.id;for(let e of p.children)e.setAttribute(`aria-pressed`,String(e===t))}),t}))}function S(){let e=a.find(e=>e.path===s);if(!e||l)return;l=!0,h.disabled=!0,_.show(`busy`,`Starting the session`),r(`start-session`);let o={name:oe(e.name),path:e.path,prompt:m.value};c!==`claude-code`&&(o.agent=c),i(`add-session`,o,{timeoutMs:n}).then(e=>{e.type===`add-session-result`&&e.ok?(_.clear(),se(e.sessionId)):_.show(`error`,ce(e))}).catch(e=>{_.show(`error`,`The session was not started: ${t(e,n)}`)}).finally(()=>{l=!1,h.disabled=s===null})}u.addEventListener(`input`,b),h.addEventListener(`click`,S),g.addEventListener(`click`,()=>{r(`open-advanced`),ue()});function C({agentListing:e,startableProjects:t}){a=t,b(),x(e)}return{element:y,update:C,focusTask:()=>m.focus()}}var me=`npm install -g @anthropic-ai/claude-code`,k=null,A=null,j=null,M=null,N=`unloaded`,P=null,F=null,I={steps:b,agentSummary:``,installableAgents:w(null),repoRoots:[],notificationChoice:`ask`,agentListing:null,startableProjects:[]},L=0,R=!1,z=!1,B=new Set,V=e(`first-run-load-status`),H=pe({onAction:U});function U(e){r({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`onboarding`,action:e}})}function he(e){for(let t of ie(B,e))r({type:`dashboard-telemetry`,event:`onboarding_step`,properties:t})&&B.add(ne(t))}function ge(){return p()?`No agent found on PATH of the machine running Glimmervoid.`:`No agent found on PATH.`}function _e(){let e=o(`div`,`first-run-step-actions`);P=E({variant:`primary`,label:`Rescan`}),P.addEventListener(`click`,()=>{U(`rescan`),X({rescanAgents:!0})}),e.append(P);let t=[o(`p`,`first-run-step-text`,ge()),de(me),e];return R?[...t,o(`p`,`first-run-step-hint`,`Still missing after a rescan? Restart Glimmervoid from a terminal where the command runs. Other terminal agents go under customAgents.`)]:t}function ve(){let e=F??ae({onAdded:e=>{U(e===`typed`?`add-root-typed`:`add-root-suggested`),X({rescanAgents:!1})}});return F=e,[e.element]}var ye=`auth-refactor needs attention`;function W(e){U(e===`allow`?`allow-notifications`:`skip-notifications`),e===`skip`?(h(!1),X({rescanAgents:!1})):d().then(()=>X({rescanAgents:!1}))}function be(){let e=o(`div`,`first-run-sample-notification`);e.setAttribute(`aria-hidden`,`true`),e.append(Z(`first-run-sample-mark`),o(`span`,null,ye));let t=E({variant:`primary`,label:`Allow notifications`}),n=E({variant:`quiet`,label:`Skip`});t.addEventListener(`click`,()=>{t.disabled=!0,W(`allow`)}),n.addEventListener(`click`,()=>W(`skip`));let r=o(`div`,`first-run-step-actions`);return r.append(t,n),[o(`p`,`first-run-step-text`,`Know when a session needs you.`),e,r]}function G(){let{steps:e,agentSummary:t,repoRoots:n,notificationChoice:r}=I;return[D({title:`1. Agent CLI`,state:e.agent,summary:t,badge:``,body:_e}),D({title:`2. Repository roots`,state:e.repoRoots,summary:n.join(`, `),badge:``,body:ve}),D({title:`3. Notifications`,state:e.notifications,summary:v(r),badge:``,body:be})]}function xe(){let{agentSummary:e,repoRoots:t,notificationChoice:n}=I,r=`notifications ${v(n).toLowerCase()}`,i=[e,t.join(`, `),r].filter(Boolean).join(` · `);return D({title:`Setup done`,state:`done`,summary:i,badge:``,body:()=>[]})}function Se(e){H.update({agentListing:I.agentListing,startableProjects:I.startableProjects}),e.contains(H.element)||e.append(H.element),e.hidden=!1}function K(){A&&j&&N!==`folding`&&(_(I.steps)?(A.replaceChildren(xe()),Se(j)):(A.replaceChildren(...G()),j.hidden=!0))}var Ce=200,q=250,J=480,Y=`cubic-bezier(0.22, 1, 0.36, 1)`,we=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);function Te(){return!we?.matches&&!document.hidden}function Ee(e){[...e.querySelectorAll(`.first-run-step-icon circle, .first-run-step-icon path`)].forEach((e,t)=>{e.setAttribute(`pathLength`,`1`),e.animate([{strokeDasharray:`1`,strokeDashoffset:`1`},{strokeDasharray:`1`,strokeDashoffset:`0`}],{duration:q,delay:t*q,easing:Y,fill:`backwards`})})}function De(){let e=M?.querySelector(`svg`),t=e?.querySelector(`.first-run-mark-dial`),n=e?.querySelector(`.first-run-mark-light`),r=e?.querySelector(`.first-run-mark-halo`);return!e||!t||!n||!r?Promise.resolve():c({mark:e,dial:t,light:n,halo:r})}function Oe(e){return new Promise(t=>{setTimeout(t,e)})}async function ke(e,t){N=`folding`,await e.querySelector(`[aria-current="step"] .first-run-step-body`)?.animate([{opacity:1},{opacity:0}],{duration:Ce,fill:`forwards`}).finished;let n=G();e.replaceChildren(...n);let[r,...i]=n,a=n.at(-1);a&&Ee(a),await De();for(let e of i)e.animate([{transform:`none`,opacity:1},{opacity:0,offset:.35},{transform:`translateY(${r.offsetTop-e.offsetTop}px)`,opacity:0}],{duration:J,easing:Y,fill:`forwards`});r.querySelector(`.first-run-step-head`)?.animate([{opacity:1},{opacity:0}],{duration:q,fill:`forwards`}),await Oe(J),N=`done`,K(),e.firstElementChild?.animate([{opacity:0},{opacity:1}],{duration:q,easing:Y}),t.animate([{transform:`translateY(12px)`,opacity:0},{transform:`none`,opacity:1}],{duration:J,easing:Y}),H.focusTask()}function Ae(){if(N===`folding`)return;let e=_(I.steps),t=N===`in-progress`&&e&&Te();N=e?`done`:`in-progress`,!t||!A||!j?K():ke(A,j)}async function X({rescanAgents:e}){L+=1;let r=L;P&&(P.disabled=!0);try{let[t,a]=await Promise.all([i(`list-agents`,e?{rescan:!0}:{},{timeoutMs:n}),i(`scan-repo-roots`,{includeSuggestions:!0,includeActivity:!0},{timeoutMs:n})]);if(r!==L)return;let o=a.type===`repo-roots-scanned`,s=o?a.directories.map(e=>e.root):[],c=o?a.suggestions??[]:[],u=x(s,c);if(u.length>0&&!z){z=!0;let e=await S(u).catch(e=>String(e));if(r!==L)return;if(!e){X({rescanAgents:!1});return}}let d=l(),f=C({agentListing:t,repoRoots:s,notificationChoice:d});e&&(R=f.agent===`current`),I={steps:f,agentSummary:g(t),installableAgents:w(t),repoRoots:s,notificationChoice:d,agentListing:t,startableProjects:o?y(a.directories):[]},V.clear(),Ae(),he(I.steps),F?.setSuggestions(c)}catch(e){if(P&&(P.disabled=!1),r!==L)return;V.show(`error`,`The checklist could not load: ${t(e,n)} It loads again once the server answers. If it stays like this, check the terminal running Glimmervoid, or run glimmervoid doctor.`)}}function Z(e){let t=s.map(({side:e,d:t})=>`<path class="first-run-mark-bracket" data-side="${e}" d="${t}"/>`).join(``);return a(`span`,e,`<svg viewBox="${m}" aria-hidden="true"><path class="first-run-mark-halo" d="${u}"/><g class="first-run-mark-dial">${t}</g><path class="first-run-mark-light" d="${u}"/></svg>`)}var je=5e3,Q=-1/0;function $(){document.visibilityState===`visible`&&I.steps.agent===`current`&&k&&!k.hidden&&k.isConnected&&(performance.now()-Q<je||(Q=performance.now(),X({rescanAgents:!0})))}function Me(){if(k)return k;let e=o(`section`,`first-run-checklist`);e.setAttribute(`aria-label`,`Glimmervoid setup`);let t=o(`div`,`first-run-lockup`);return M=t,t.append(Z(`first-run-mark`),o(`span`,`first-run-wordmark`,`GLIMMERVOID`)),A=o(`ol`,`first-run-steps`),j=o(`div`,`first-run-start-host`),e.append(t,A,V.element,j),k=e,document.addEventListener(`visibilitychange`,$),window.addEventListener(`focus`,$),K(),e}function Ne(e,t){if(!t){k?.parentElement===e&&!k.hidden&&(k.hidden=!0);return}let n=Me(),r=!n.hidden&&n.parentElement===e;n.parentElement!==e&&e.append(n),n.hidden=!1,r||X({rescanAgents:!1})}function Pe(){k&&!k.hidden&&k.isConnected&&X({rescanAgents:!1})}export{Pe as refreshFirstRunChecklist,Ne as showFirstRunChecklist};
|
|
Binary file
|