glimmervoid 0.53.1 → 0.53.2-next.966

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/bin/glimmervoid.js +13 -13
  2. package/dist/chunks/{adapters-DOEJEKS0.js → adapters-L_kCsJoV.js} +1 -1
  3. package/dist/chunks/{adapters-CNSwsGdu.js → adapters-mKn9rSYO.js} +2 -2
  4. package/dist/chunks/agent-api-cli-BfjInV6a.js +1 -0
  5. package/dist/chunks/{agent-api-cli-ChxXRS3d.js → agent-api-cli-EA42jg6w.js} +1 -1
  6. package/dist/chunks/{agent-api-core-DfuQ4RDS.js → agent-api-core-D0w78vXc.js} +1 -1
  7. package/dist/chunks/{config-wPv6Of22.js → config-DjZbYmaB.js} +3 -0
  8. package/dist/chunks/{config-store-BE5X4H-R.js → config-store-D0ubZ2ez.js} +4 -3
  9. package/dist/chunks/config-store-imHubfK9.js +1 -0
  10. package/dist/chunks/{host-cli-SIyKKMs0.js → host-cli-CdlM5GxF.js} +1 -1
  11. package/dist/chunks/{main-DsOePgO6.js → main-Bl8sEyrl.js} +117 -18
  12. package/dist/chunks/{packs-cli-CYC7S_8E.js → packs-cli-CBKiDwJT.js} +1 -1
  13. package/dist/chunks/{pair-cli-X12JQ9zW.js → pair-cli-BPg8tauu.js} +2 -2
  14. package/dist/chunks/{pr-flows-cli-BsTY76Tt.js → pr-flows-cli-CihO3h7H.js} +2 -2
  15. package/dist/chunks/{remote-config-BPeUod_r.js → remote-config-BfGYhhKn.js} +1 -1
  16. package/dist/chunks/settings-cli-BcK_pgdx.js +1 -0
  17. package/dist/chunks/{settings-cli-Dk5QXFJ2.js → settings-cli-CkVAoy96.js} +4 -4
  18. package/dist/chunks/{settings-readout-core-CtpKozFQ.js → settings-readout-core-KDIYBU8v.js} +1 -1
  19. package/dist/chunks/{ssh-sign-cli-DQkDNLZ7.js → ssh-sign-cli-DvXSmQm4.js} +1 -1
  20. package/dist/chunks/{watch-cli-BwyiTVnT.js → watch-cli-COS_8B_E.js} +12 -7
  21. package/dist/chunks/{watcher-link-BKWi5aJM.js → watcher-link-xW9PMs77.js} +8 -1
  22. package/dist/client/assets/{agent-core-BQ1THBfW.js → agent-core-BjRsd_gB.js} +2 -2
  23. package/dist/client/assets/agent-core-BjRsd_gB.js.br +0 -0
  24. package/dist/client/assets/{agent-mark-CAPAtm4S.js → agent-mark-CDiDVO9j.js} +1 -1
  25. package/dist/client/assets/agent-mark-CDiDVO9j.js.br +0 -0
  26. package/dist/client/assets/{arena-panel-By7u9GDX.js → arena-panel-CseMEQvb.js} +2 -2
  27. package/dist/client/assets/arena-panel-CseMEQvb.js.br +0 -0
  28. package/dist/client/assets/{benchmark-panel-BlxS_Jak.js → benchmark-panel-C70lz2RD.js} +1 -1
  29. package/dist/client/assets/benchmark-panel-C70lz2RD.js.br +0 -0
  30. package/dist/client/assets/{boards-view-DRP8Y4Pm.js → boards-view-DVuZx8aO.js} +2 -2
  31. package/dist/client/assets/boards-view-DVuZx8aO.js.br +0 -0
  32. package/dist/client/assets/{community-panel-IgihcWNO.js → community-panel-DlYOXeZ0.js} +1 -1
  33. package/dist/client/assets/community-panel-DlYOXeZ0.js.br +0 -0
  34. package/dist/client/assets/{dialogs-BYL3z6t7.js → dialogs-Vj2cSZa1.js} +1 -1
  35. package/dist/client/assets/dialogs-Vj2cSZa1.js.br +0 -0
  36. package/dist/client/assets/{doc-editor-ui-BfVu_JmF.js → doc-editor-ui-BakXuPjb.js} +1 -1
  37. package/dist/client/assets/doc-editor-ui-BakXuPjb.js.br +0 -0
  38. package/dist/client/assets/{feature-hint-AN1kNwT4.js → feature-hint-DrInq99N.js} +1 -1
  39. package/dist/client/assets/feature-hint-DrInq99N.js.br +0 -0
  40. package/dist/client/assets/{first-run-checklist-JZUS8rV5.js → first-run-checklist-BM8OOWJL.js} +1 -1
  41. package/dist/client/assets/first-run-checklist-BM8OOWJL.js.br +0 -0
  42. package/dist/client/assets/{hooks-panel-CtgJU9I5.js → hooks-panel-2UGBYtKp.js} +1 -1
  43. package/dist/client/assets/hooks-panel-2UGBYtKp.js.br +0 -0
  44. package/dist/client/assets/{index-CwndYdst.js → index-k6lh2SOM.js} +5 -5
  45. package/dist/client/assets/index-k6lh2SOM.js.br +0 -0
  46. package/dist/client/assets/{issues-panel-TIPTD8Vb.js → issues-panel-DUaYxMKd.js} +1 -1
  47. package/dist/client/assets/issues-panel-DUaYxMKd.js.br +0 -0
  48. package/dist/client/assets/{lane-read-token-step-Y47rPFjy.js → lane-read-token-step-B2OUP3Ve.js} +1 -1
  49. package/dist/client/assets/lane-read-token-step-B2OUP3Ve.js.br +0 -0
  50. package/dist/client/assets/{my-prs-panel-ixPcAIf5.js → my-prs-panel-CCQ4BCqV.js} +1 -1
  51. package/dist/client/assets/my-prs-panel-CCQ4BCqV.js.br +0 -0
  52. package/dist/client/assets/{nyan-cat-Jrakmyyn.js → nyan-cat-CpNy7YH7.js} +1 -1
  53. package/dist/client/assets/nyan-cat-CpNy7YH7.js.br +0 -0
  54. package/dist/client/assets/{phone-shell-JTIcmTAI.js → phone-shell-B4cWHH1y.js} +1 -1
  55. package/dist/client/assets/phone-shell-B4cWHH1y.js.br +0 -0
  56. package/dist/client/assets/{plan-face-f3XlmdyU.js → plan-face-CjhU3G9b.js} +1 -1
  57. package/dist/client/assets/plan-face-CjhU3G9b.js.br +0 -0
  58. package/dist/client/assets/{plan-render-usK70-q6.js → plan-render-DY2Uplgx.js} +1 -1
  59. package/dist/client/assets/plan-render-DY2Uplgx.js.br +0 -0
  60. package/dist/client/assets/{pr-queue-columns-C6P-i4sW.js → pr-queue-columns-CW_j5U77.js} +1 -1
  61. package/dist/client/assets/pr-queue-columns-CW_j5U77.js.br +0 -0
  62. package/dist/client/assets/{radar-panel-C6LP7HCQ.js → radar-panel-Br_Ycirr.js} +1 -1
  63. package/dist/client/assets/radar-panel-Br_Ycirr.js.br +0 -0
  64. package/dist/client/assets/{repo-roots-adder-Cpil4nGt.js → repo-roots-adder-BHxNnfhf.js} +1 -1
  65. package/dist/client/assets/repo-roots-adder-BHxNnfhf.js.br +0 -0
  66. package/dist/client/assets/{resume-dialog-cLXYHy0O.js → resume-dialog-D7j5M1ii.js} +1 -1
  67. package/dist/client/assets/resume-dialog-D7j5M1ii.js.br +0 -0
  68. package/dist/client/assets/{review-queue-panel-CGD1xd_j.js → review-queue-panel-BXn-FdBS.js} +1 -1
  69. package/dist/client/assets/review-queue-panel-BXn-FdBS.js.br +0 -0
  70. package/dist/client/assets/{session-row-uYdktTlg.js → session-row-BCKiSx86.js} +1 -1
  71. package/dist/client/assets/session-row-BCKiSx86.js.br +0 -0
  72. package/dist/client/assets/{settings-panel-B6noGsUs.js → settings-panel-BeQeq5Re.js} +2 -2
  73. package/dist/client/assets/settings-panel-BeQeq5Re.js.br +0 -0
  74. package/dist/client/assets/{trace-panel-DifdxBXF.js → trace-panel-D6kgTDzM.js} +1 -1
  75. package/dist/client/assets/trace-panel-D6kgTDzM.js.br +0 -0
  76. package/dist/client/assets/{usage-panel-nE5xBTjg.js → usage-panel-BTxYkMQA.js} +1 -1
  77. package/dist/client/assets/usage-panel-BTxYkMQA.js.br +0 -0
  78. package/dist/client/assets/{whiteboard-undo-core-CAnu7_EN.js → whiteboard-undo-core-CPx7qi5j.js} +1 -1
  79. package/dist/client/assets/whiteboard-undo-core-CPx7qi5j.js.br +0 -0
  80. package/dist/client/assets/{your-day-tip-D-IUmo2O.js → your-day-tip-BxvmMpdt.js} +1 -1
  81. package/dist/client/assets/your-day-tip-BxvmMpdt.js.br +0 -0
  82. package/dist/client/index.html +4 -4
  83. package/dist/client/index.html.br +0 -0
  84. package/dist/server/index.js +1 -1
  85. package/package.json +1 -4
  86. package/dist/chunks/agent-api-cli-D6Ld1V9y.js +0 -1
  87. package/dist/chunks/config-store-2h_954wK.js +0 -1
  88. package/dist/chunks/settings-cli-CvlYk8mL.js +0 -1
  89. package/dist/client/assets/agent-core-BQ1THBfW.js.br +0 -0
  90. package/dist/client/assets/agent-mark-CAPAtm4S.js.br +0 -0
  91. package/dist/client/assets/arena-panel-By7u9GDX.js.br +0 -0
  92. package/dist/client/assets/benchmark-panel-BlxS_Jak.js.br +0 -0
  93. package/dist/client/assets/boards-view-DRP8Y4Pm.js.br +0 -0
  94. package/dist/client/assets/community-panel-IgihcWNO.js.br +0 -0
  95. package/dist/client/assets/dialogs-BYL3z6t7.js.br +0 -0
  96. package/dist/client/assets/doc-editor-ui-BfVu_JmF.js.br +0 -0
  97. package/dist/client/assets/feature-hint-AN1kNwT4.js.br +0 -0
  98. package/dist/client/assets/first-run-checklist-JZUS8rV5.js.br +0 -0
  99. package/dist/client/assets/hooks-panel-CtgJU9I5.js.br +0 -0
  100. package/dist/client/assets/index-CwndYdst.js.br +0 -0
  101. package/dist/client/assets/issues-panel-TIPTD8Vb.js.br +0 -0
  102. package/dist/client/assets/lane-read-token-step-Y47rPFjy.js.br +0 -0
  103. package/dist/client/assets/my-prs-panel-ixPcAIf5.js.br +0 -0
  104. package/dist/client/assets/nyan-cat-Jrakmyyn.js.br +0 -0
  105. package/dist/client/assets/phone-shell-JTIcmTAI.js.br +0 -0
  106. package/dist/client/assets/plan-face-f3XlmdyU.js.br +0 -0
  107. package/dist/client/assets/plan-render-usK70-q6.js.br +0 -0
  108. package/dist/client/assets/pr-queue-columns-C6P-i4sW.js.br +0 -0
  109. package/dist/client/assets/radar-panel-C6LP7HCQ.js.br +0 -0
  110. package/dist/client/assets/repo-roots-adder-Cpil4nGt.js.br +0 -0
  111. package/dist/client/assets/resume-dialog-cLXYHy0O.js.br +0 -0
  112. package/dist/client/assets/review-queue-panel-CGD1xd_j.js.br +0 -0
  113. package/dist/client/assets/session-row-uYdktTlg.js.br +0 -0
  114. package/dist/client/assets/settings-panel-B6noGsUs.js.br +0 -0
  115. package/dist/client/assets/trace-panel-DifdxBXF.js.br +0 -0
  116. package/dist/client/assets/usage-panel-nE5xBTjg.js.br +0 -0
  117. package/dist/client/assets/whiteboard-undo-core-CAnu7_EN.js.br +0 -0
  118. package/dist/client/assets/your-day-tip-D-IUmo2O.js.br +0 -0
@@ -1,4 +1,4 @@
1
- import{$n as e,An as t,Bn as n,Fn as r,Gn as i,In as a,Jn as o,Pn as s,Qn as c,Sn as l,Un as u,Wn as d,Xn as f,Yn as p,Zn as m,_n as h,dn as g,er as _,f as v,gn as y,hn as b,ir as x,mn as S,nr as C,pn as w,rr as T,s as E,tr as ee,vn as D,zn as O}from"./dom-helpers-1xKy7VX6.js";import{$t as te,M as ne,Ti as k,a as re,an as ie,c as ae,cn as A,d as oe,en as se,f as j,i as ce,in as M,l as le,m as ue,n as de,nn as N,no as P,o as fe,on as pe,p as me,r as he,rn as ge,s as _e,sn as ve,t as ye,tn as be,u as xe,xi as Se,yi as Ce}from"./index-CwndYdst.js";import{a as we,i as Te,n as Ee,o as De,r as Oe,t as ke}from"./whiteboard-undo-core-CAnu7_EN.js";import{Ct as Ae,O as je,a as Me,bt as Ne,k as F,r as Pe,t as I}from"./button-CfhUK7Jn.js";import{i as Fe}from"./action-status-rETkOMJb.js";import{n as Ie,t as Le}from"./menu-DzZGGGGN.js";import{a as Re,r as ze}from"./card-registry-D1_v6Lbm.js";import{a as Be,i as Ve,n as He}from"./modal-CjIIQMho.js";import{n as Ue}from"./session-tick-DrUXWyvz.js";import{i as We,t as Ge}from"./plan-render-usK70-q6.js";Object.freeze({stepWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedStepIds:[],notChecked:null});var Ke=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function qe(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function Je(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function Ye(e){let t=Ke.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(qe(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:Je(n),startLine:r,endLine:i}}function Xe(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function Ze(e){let t=`${e.kind} ${e.id}`;switch(e.kind){case`box`:return[...e.refs.map(n=>({elementId:e.id,ref:n,where:t})),...Xe(t,e.id,o(e))];case`frame`:case`wire`:case`stroke`:return[]}}function Qe(e){return[...new Set(Ze(e).map(e=>e.ref))]}function $e(e){let t=Ye(e);return`path`in t?t.path:null}var et=4,tt=200,nt=2e4,rt=1.1,it=[`stroke`,`wire`,`frame`,`box`],at={v:`select`,r:`box`,d:`decision`,p:`panel`,s:`sticky`,t:`text`,i:`icon`,m:`device`,a:`wire`,b:`pen`},ot=new WeakMap;function L(e){let t=ot.get(e);if(t)return t;let n=new Map;for(let t of e.elements.valuesOfKind(`frame`)){let e=t.collapsed?t.contains[0]:void 0;e!==void 0&&n.set(e,t)}return ot.set(e,n),n}var st=new Set([1,2]);function ct(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 lt(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function ut(){return document.documentElement.dataset.layout===`phone`}function dt(e){return e!==`select`&&e!==`wire`&&e!==`pen`}var ft={box:`Box`,decision:`Decision`,panel:`Panel`,sticky:`Note`,text:`Text`,icon:`Icon`,device:`Device`};function pt(e,t,n,r){let i={kind:`box`,id:lt(`box`),title:t,icon:null,refs:[],change:`none`,was:null,near:null,order:0,at:e,width:null,height:null,step:null};switch(r){case`icon`:return{...i,shape:r,icon:_};case`device`:return{...i,shape:r,device:x,fit:`fill`,media:n,params:{}};case`decision`:return{...i,shape:r,lines:[],media:n,outputs:[{id:`yes`,label:`yes`},{id:`no`,label:`no`}],params:{}};case`sticky`:return{...i,shape:r,tone:`yellow`,lines:[],media:n,params:{}};case`text`:return{...i,shape:r,lines:[]};case`box`:case`panel`:return{...i,shape:r,lines:[],media:n,params:{}}}}function mt(e){return e?.part!==`media`||!e.media?null:{boxId:e.id,href:e.media.href,alt:e.media.alt}}var ht=4,gt=2,_t={body:`pointer`,port:`crosshair`,resize:`nwse-resize`,link:`pointer`,media:`zoom-in`};function vt(e){return e?e.part===`body`&&e.kind===`box`?`move`:_t[e.part]:``}var yt=2,bt=12/10,xt=1.25;function St(e,t,n){return Math.max(e.width/t,e.height/Math.max(1,n))}function Ct(e){let{viewport:t,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,p=null,m=`select`,h=null,g=!1;function _(n){m=n,t.dataset.tool=n,e.onToolChange(n)}function v(){r.style.transform=`translate(${-l.x*l.scale}px, ${-l.y*l.scale}px) scale(${l.scale})`,o.setCamera(l)}function y(){return(t.clientWidth||1)/l.scale}function b(){let e=o.layout(),n=t.clientWidth||1;if(!e)return nt;let r=n*St(e.bounds,n,t.clientHeight)*xt;return Math.max(nt,r)}function x(){let e=t.getBoundingClientRect(),n=[...a.querySelectorAll(`.wb-island`)].filter(e=>e.checkVisibility()).map(e=>e.getBoundingClientRect()),r=e.top+e.height/2,i=n.filter(e=>e.top+e.height/2<r).map(t=>t.bottom-e.top),o=n.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 S(){let e=o.layout();if(!e)return;let{bounds:n}=e,r=t.clientWidth,i=t.clientHeight;if(r===0||i===0){l={x:n.x,y:n.y,scale:1},v(),g=!0;return}g=!1;let a=x(),s=e.elements.length===0?1:yt,c=Math.max(1/s,St(n,r,a.heightPx)),u=c>bt,d=u?bt:c,f=r*d,p=n.y+n.height/2,m=a.topPx+a.heightPx/2;l={x:n.x-Math.max(0,f-n.width)/2,y:u?n.y-a.topPx*d:p-m*d,scale:1/d},v()}function C(e,n){let r=t.getBoundingClientRect();return{x:l.x+(e-r.left-t.clientLeft)/l.scale,y:l.y+(n-r.top-t.clientTop)/l.scale}}function w(){return 1/l.scale}function T(e,t){let n=y(),r=Math.min(b(),Math.max(tt,n*t))/n;l={x:e.x-(e.x-l.x)*r,y:e.y-(e.y-l.y)*r,scale:l.scale/r},v()}function ee(e,t){l={...l,x:l.x-e/l.scale,y:l.y-t/l.scale},v()}function D(t){c=t,o.setSelection(c),e.onSelectionChange(c)}function O(e,t){if(!t){D(c.has(e)&&c.size===1?new Set:new Set([e]));return}let n=new Set(c);n.delete(e)||n.add(e),D(n)}function te(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 ne(e,t){let r=Math.round(t.width+e.latest.x-e.origin.x);return Math.min(n.boxWidthMax,Math.max(n.boxWidthMin,r))}function k(e){return Math.abs(e.latest.y-e.origin.y)>=ht*w()}function ie(e,t){let r=Math.round(t.height+e.latest.y-e.origin.y);return Math.min(n.boxHeightMax,Math.max(1,r))}function ae(t){if(t.mode===`resize`)return t.movingBoxes.map(e=>({boxId:e.boxId,fields:{width:ne(t,e.start),...k(t)?{height:ie(t,e.start)}:{}}}));let n=t.movingBoxes.map(e=>({boxId:e.boxId,at:te(t,e.start)})),r=e.currentBoard(),i=t.movingBoxes.filter(e=>{let t=r?.elements.get(e.boxId);return t?.kind===`box`&&_e(t)}),a=t.pinnedOffsetY-oe(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 A(){p!==null&&cancelAnimationFrame(p),p=null}function se(e){return{x:Math.round(e.latest.x-e.origin.x),y:Math.round(e.latest.y-e.origin.y)}}function j(e,t){let n=o.layout();if(e.mode!==`move`||!e.hasMoved||!n)return!1;let r=se(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=re(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 ce(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=f();for(let{boxId:n,fields:r}of ae(e)){let e=t.elements.get(n),o=i.get(n);e?.kind===`box`&&o&&a.put({...e,...r,step:null,at:{x:o.x,y:o.y}})}let o=new Map;for(let e of le({...t,elements:a}).elements){let t=i.get(e.id);e.kind===`box`&&t&&o.set(e.id,xe(e,t.x-e.x,t.y-e.y))}let s={...n,elements:n.elements.map(e=>o.get(e.id)??e)};return re(t,s,new Set(o.keys()))(0,0)}function M(e,t){let n=o.layout();return e.mode!==`resize`||!e.hasMoved||!n?!1:(o.paintElements(ce(e,t,n)),!0)}function ue(){A();let t=e.currentBoard();u?.kind!==`drag`||!t?e.repaint():j(u,t)||M(u,t)||e.repaint()}function de(){let t=e.currentBoard();u?.kind===`drag`&&t&&(j(u,t)||M(u,t))}function N(){p===null&&(p=requestAnimationFrame(ue))}function P(e){u?.kind===`drag`&&e?.elements.get(u.boxId)?.kind!==`box`&&(u=null),u?.kind===`drag`&&u.hasMoved&&(u.movingBoxes=u.movingBoxes.filter(t=>e?.elements.get(t.boxId)?.kind===`box`));let t=new Set([...c].filter(t=>e?.elements.get(t)));t.size!==c.size&&D(t)}function fe(e,t){return o.hitTest(C(e,t))}function pe(){let[e,t]=[...s.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function me(){u?.kind===`wire`&&Me(u,!1),u?.kind===`ink`&&u.draftLine.remove(),u={kind:`pinch`,distance:pe(),viewWidth:y()}}function he(e){e.preventDefault(),s.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.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 ge(e){let t=document.createElementNS(`http://www.w3.org/2000/svg`,`polyline`);t.setAttribute(`class`,`wb-ink-draft`),i.append(t),u={kind:`ink`,pointerId:e.pointerId,points:[C(e.clientX,e.clientY)],draftLine:t},ve(u)}function ve(e){e.draftLine.setAttribute(`points`,e.points.map(e=>`${e.x},${e.y}`).join(` `))}function ye(e,t){let r=C(t.clientX,t.clientY),i=e.points[e.points.length-1];e.points.length>=n.strokePoints||i&&Math.hypot(r.x-i.x,r.y-i.y)<gt*w()||(e.points.push(r),ve(e))}async function be(t){let n=o.layout()?.pinnedOffsetY??0,r=(t.points.length===1&&t.points[0]?[t.points[0],t.points[0]]:t.points).flatMap(e=>[Math.round(e.x),Math.round(e.y-n)]),i=await e.sendOps([{op:`add`,element:{kind:`stroke`,id:lt(`stroke`),points:r,width:3,tone:`ink`}}]);t.draftLine.remove(),i||ue()}function Se(e){let t=C(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 Ce(t){let n=e.currentBoard();return n?L(n).get(t):void 0}function we(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.get(e)?.kind===`box`?o.boundsOf(e):null;return t?[{boxId:e,start:t}]:[]})}function Te(n){if(d)return;if(n.pointerType===`mouse`&&st.has(n.button)&&!u){he(n);return}if(n.button!==0)return;let r=fe(n.clientX,n.clientY);if(r?.part===`link`&&r.linkedBoardId){e.onOpenLinkedBoard(r.linkedBoardId);return}if(s.set(n.pointerId,{x:n.clientX,y:n.clientY}),t.setPointerCapture(n.pointerId),s.size===2){me();return}if(dt(m)){Ee(m,C(n.clientX,n.clientY));return}if(m===`pen`){ge(n);return}let i=r?.kind===`box`?o.boundsOf(r.id):null,a=r?.part===`resize`&&!ut()?i:null;if(r&&a){let e=C(n.clientX,n.clientY);u={kind:`drag`,mode:`resize`,pointerId:n.pointerId,boxId:r.id,origin:e,start:a,movingBoxes:we(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&&!ut()){ke(n.pointerId,r.id,r.port);return}let c=m===`wire`?i:null;if(r&&c){ke(n.pointerId,r.id,{x:c.x+c.width/2,y:c.y+c.height/2});return}let l=ut()?null:i;if(r&&l){let e=C(n.clientX,n.clientY),t=o.layout()?.pinnedOffsetY??0;u={kind:`drag`,mode:`move`,pointerId:n.pointerId,boxId:r.id,origin:e,start:l,movingBoxes:we(r.id,l,n.shiftKey),pinnedOffsetY:t,latest:e,hasMoved:!1,isAdditive:n.shiftKey,pressedImage:mt(r),preview:null,previewLayout:null,laidOutOffset:{x:0,y:0}};return}if(r&&!ut()){O(r.id,n.shiftKey);return}if(!r&&n.pointerType===`mouse`&&!ut()){Se(n);return}let f=r?.kind===`box`?r.id:null;u={kind:`pan`,pointerId:n.pointerId,lastClient:{x:n.clientX,y:n.clientY},hasMoved:!1,isAuxiliaryButton:!1,tappedBoxId:f,pressedImage:mt(r)}}async function Ee(t,n){if(_(`select`),!e.currentBoard())return;let r=o.layout()?.pinnedOffsetY??0,i=pt({x:Math.round(n.x),y:Math.round(n.y-r)},ft[t],null,t);h=i.id;let a=await e.sendOps([{op:`add`,element:i}]);a||(h=null),a&&D(new Set([i.id])),Oe()}async function De(n,r,i){if(!e.currentBoard())return!1;let a=i?C(i.x,i.y):{x:l.x+y()/2,y:l.y+(t.clientHeight||1)/l.scale/2},s=o.layout()?.pinnedOffsetY??0,c=pt({x:Math.round(a.x),y:Math.round(a.y-s)},n,r,`box`),u=await e.sendOps([{op:`add`,element:c}]);return u&&D(new Set([c.id])),u}function Oe(){if(!h||!o.boundsOf(h)||!e.currentBoard()?.elements.get(h))return;let t=h;h=null,Ge(t)}function ke(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 Ae(e,t){e.targetBoxId=t,o.setWireTarget(t)}function je(e,t){let n=C(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);Ae(e,r?.kind===`box`&&r.id!==e.fromBoxId?r.id:null)}function Me(t,n){let r=t.targetBoxId;Ae(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function Ne(e,t){let n=C(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<et*w()||(e.hasMoved=!0,e.latest=n,o.setWireTarget(F(e)),N())}function F(e){return e.mode!==`move`||e.movingBoxes.length!==1||Ce(e.boxId)?null:o.boxIdsAt(e.latest).find(t=>t!==e.boxId)??null}function Pe(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<et||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},ee(n,r))}function I(e,t){let n=C(t.clientX,t.clientY);if(!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<et*w())return;e.hasMoved||i.append(e.outline),e.hasMoved=!0,e.latest=n;let r=ct(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))||D(a)}function Fe(e){e.outline.remove(),e.hasMoved||e.isAdditive||D(new Set)}function Ie(e){let t=pe();if(t<=0||e.distance<=0)return;let n=[...s.values()];T(C(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)/y())}function Le(e){if(e.pointerType!==`mouse`||ut())return;let n=fe(e.clientX,e.clientY);o.setHover(n?.kind===`box`?n.id:null),t.dataset.hoverKind=n?.kind??``,t.style.cursor=m===`select`?vt(n):``}function Re(e){u||Le(e),s.has(e.pointerId)&&(s.set(e.pointerId,{x:e.clientX,y:e.clientY}),u?.kind===`pinch`?Ie(u):u?.kind===`drag`&&u.pointerId===e.pointerId?Ne(u,e):u?.kind===`wire`&&u.pointerId===e.pointerId?je(u,e):u?.kind===`marquee`&&u.pointerId===e.pointerId?I(u,e):u?.kind===`ink`&&u.pointerId===e.pointerId?ye(u,e):u?.kind===`pan`&&u.pointerId===e.pointerId&&Pe(u,e))}async function ze(t,n){if(!t.hasMoved&&t.mode===`resize`)return;if(!t.hasMoved){Be(t);return}A(),t.latest=C(n.clientX,n.clientY),o.setWireTarget(null);let r=F(t);if(r){ue(),e.onStackBoxes(r,t.boxId,Ce(r)??null);return}let i=ae(t),a=e.currentBoard();a&&!j(t,a)&&M(t,a),await e.sendOps(i.map(({boxId:e,fields:t})=>({op:`set`,id:e,fields:t})))||ue()}function Be(t){O(t.boxId,t.isAdditive);let n=t.isAdditive?void 0:Ce(t.boxId);n?e.onOpenStack(n.id):t.pressedImage&&!t.isAdditive&&e.onOpenImage(t.pressedImage)}function Ve(t){if(!s.delete(t.pointerId))return;let n=u;n?.kind===`pinch`?u=null:(u=null,n?.kind===`drag`&&n.pointerId===t.pointerId?ze(n,t):n?.kind===`wire`?(Me(n,n.pointerId===t.pointerId),m===`wire`&&_(`select`)):n?.kind===`marquee`?Fe(n):n?.kind===`ink`?be(n):n?.kind!==`pan`||n.hasMoved||n.isAuxiliaryButton||(n.pressedImage&&ut()?e.onOpenImage(n.pressedImage):n.tappedBoxId&&ut()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||D(new Set)))}function He(e){s.delete(e.pointerId);let t=u?.kind===`drag`;u?.kind===`wire`&&Me(u,!1),u?.kind===`marquee`&&u.outline.remove(),u?.kind===`ink`&&u.draftLine.remove(),u=null,t&&(o.setWireTarget(null),ue())}function Ue(e){e.preventDefault(),e.ctrlKey||e.metaKey?T(C(e.clientX,e.clientY),e.deltaY>0?rt:1/rt):ee(-e.deltaX,-e.deltaY)}function We(){let e=d;d=null,e?.remove()}function Ge(n){let r=e.currentBoard()?.elements.get(n),i=o.boundsOf(n);if(r?.kind!==`box`||!i)return;We();let s=a.getBoundingClientRect(),c=t.getBoundingClientRect(),u={left:c.left+t.clientLeft+(i.x-l.x)*l.scale,top:c.top+t.clientTop+(i.y-l.y)*l.scale,width:i.width*l.scale},f=E(`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(),We(),t.focus();return}if(i.key!==`Enter`)return;i.preventDefault();let a=f.value.trim();We(),t.focus(),a&&a!==r.title&&e.sendOps([{op:`set`,id:n,fields:{title:a}}])}),f.addEventListener(`blur`,We),f.focus(),f.select()}function Ke(e){if(ut())return;let t=fe(e.clientX,e.clientY);t?.kind===`box`&&Ge(t.id)}function qe(){let t=e.currentBoard();if(!t||c.size===0)return;let n=[...c].flatMap(e=>t.elements.get(e)??[]),r=it.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));D(new Set),e.sendOps(r)}function Je(e){if(e.target!==t||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),qe();return}let n=at[e.key.toLowerCase()];n&&!e.shiftKey?(e.preventDefault(),_(n)):e.key===`Escape`&&(D(new Set),_(`select`))}return r.style.transition=`none`,t.tabIndex=0,t.addEventListener(`pointerdown`,Te),t.addEventListener(`pointermove`,Re),t.addEventListener(`pointerup`,Ve),t.addEventListener(`pointercancel`,He),t.addEventListener(`wheel`,Ue,{passive:!1}),t.addEventListener(`dblclick`,Ke),t.addEventListener(`contextmenu`,e=>e.preventDefault()),t.addEventListener(`keydown`,Je),t.addEventListener(`pointerleave`,()=>{u||(o.setHover(null),t.dataset.hoverKind=``)}),new ResizeObserver(()=>{g&&t.clientWidth>0&&t.clientHeight>0&&S()}).observe(t),{fit:S,selectedIds:()=>c,clearSelection:()=>D(new Set),pruneSelection:P,repaintPreview:de,closeTitleInput:We,setTool:_,placeMediaBox:De,openPendingTitleEdit:Oe,focusCanvas:()=>t.focus(),removeSelected:qe,zoomAroundClientPoint:(e,t,n)=>T(C(e,t),n),panByPixels:ee}}var wt=16;function Tt(e){let t=F(24,24);return t.setAttribute(`width`,String(wt)),t.setAttribute(`height`,String(wt)),t.setAttribute(`fill`,`none`),t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-width`,`2`),t.setAttribute(`stroke-linecap`,`round`),t.setAttribute(`stroke-linejoin`,`round`),t.innerHTML=m[e].elements.join(``),t}function Et(e){let t=E(`span`,`wb-icon-current`);return e?(t.append(Tt(e),E(`span`,`wb-icon-current-label`,m[e].label)),t):(t.append(E(`span`,`wb-icon-current-label`,`none`)),t)}function Dt(e,t){return e.includes(t)||m[e].label.toLowerCase().includes(t)}function Ot({field:t,icon:n,isRequired:r,accessibleName:i,commit:a}){let o=E(`div`,`wb-icon-picker`);o.dataset.field=t;let s=E(`div`,`wb-icon-popover`);s.hidden=!0,s.tabIndex=-1;let l=E(`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=()=>{s.hidden=!0,p.setAttribute(`aria-expanded`,`false`)},f=e=>{d(),p.focus(),e!==n&&a(e)},p=I({variant:`quiet`,size:`small`,label:`icon`,action:`icon-pick`,onClick:()=>{let e=s.hidden;s.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 h=c.map(t=>{let r=E(`div`,`wb-icon-group`),i=E(`div`,`wb-icon-grid`);for(let r of e.filter(e=>m[e].category===t)){let e=I({variant:`icon`,size:`small`,label:m[r].label,icon:Tt(r),action:`icon-choice`,onClick:()=>f(r)});e.dataset.icon=r,e.classList.add(`wb-icon-choice`),e.setAttribute(`aria-pressed`,String(r===n)),u.set(r,e),i.append(e)}return r.append(E(`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=!Dt(t,e);for(let{group:e,grid:t}of h)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])}),s.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),d(),p.focus())});let g=I({variant:`quiet`,size:`small`,label:`no icon`,action:`icon-clear`,onClick:()=>f(null),disabled:r||n===null});return s.append(l,...h.map(({group:e})=>e),g),o.append(Et(n),p,s),o}var kt=8,At=12,jt=30,Mt=40,Nt=40,Pt=400,Ft=200,It=8,Lt=`README.md`,Rt=[`text`,`code`,`item`,`numbered`,`kv`],zt=[`plain`,`fail`,`join`],Bt=Qt(Rt),Vt=Qt(zt),Ht=Qt(D),Ut={box:`Box`,decision:`Decision`,panel:`Panel`,icon:`Icon`,device:`Device`,sticky:`Sticky`,note:`Note`,text:`Text`},Wt=Qt(T),Gt=Qt(C),Kt=Qt(r),qt=Qt(h),Jt=Qt(s),Yt=[{value:``,text:`Auto`},...Qt([`left`,`right`,`top`,`bottom`])],Xt={status:`planned`,linkedBoardId:null},Zt=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function Qt(e){return e.map(e=>({value:e,text:e}))}function $t(e){return E(`h3`,`wb-inspect-heading`,e)}function R(e,t){let n=E(`label`,`wb-inspect-field`);return n.append(E(`span`,`wb-inspect-label`,e),t),n}function en(e,t){let n=E(`div`,`wb-inspect-field`);return n.append(E(`span`,`wb-inspect-label`,e),t),n}function z(e,t,n,r,i){let a=E(`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 B(e,t,n,r,i){let a=E(`select`,`wb-inspect-select`);return a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.append(...t.map(e=>{let t=E(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),a.addEventListener(`change`,()=>r(a.value)),a}function tn(e,t,n,r){let i=E(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let a=E(`label`,`wb-inspect-toggle`);return a.append(i,E(`span`,null,t)),a}function V(e,t,n,r){let i=I({variant:`quiet`,size:`small`,label:t,action:t.toLowerCase().replaceAll(` `,`-`),onClick:n});return i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i}function nn(e,t,n){let r=E(`div`,`wb-inspect-list`);return r.append(E(`span`,`wb-inspect-label`,e),...t,n),r}function rn(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 an(e){let t=e.trim();return g.safeParse(t).success?t:null}function on(e,t,n,r){let i=z(e,t??``,Ft,e=>{if(!e.trim()){n(null);return}let t=an(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function sn(e,t,n,r){let i=rn(n,r),a=t.map((e,t)=>{let n=E(`div`,`wb-inspect-row`);return n.append(z(`ref-${t}`,e,Ft,e=>{let n=an(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),V(`ref-${t}-remove`,`Remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),o=V(`ref-add`,`Add ref`,()=>i.append(()=>Lt),`Add a ref to ${e}`);return o.disabled=t.length>=It,nn(`Refs`,a,o)}function cn(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function ln(e,t,r,i){let a=rn(r,i),o=t.map((e,t)=>{let r=E(`div`,`wb-inspect-row`),i=t+1;return r.append(B(`line-${t}-style`,Bt,e.style,e=>{let n=Rt.find(t=>t===e);n&&a.edit(t,e=>cn(e,n))},`Line ${i} style`)),e.style===`kv`&&r.append(z(`line-${t}-key`,e.key??``,Nt,e=>{e.trim()&&a.edit(t,t=>({...t,key:e.trim()}))},`Line ${i} key`)),r.append(Ot({field:`line-${t}-icon`,icon:e.icon,isRequired:!1,accessibleName:`Line ${i} icon`,commit:e=>a.edit(t,t=>({...t,icon:e}))}),z(`line-${t}-text`,e.text,n.line,e=>a.edit(t,t=>({...t,text:e})),`Line ${i} text`),on(`line-${t}-ref`,e.ref,e=>a.edit(t,t=>({...t,ref:e})),`Line ${i} ref`),V(`line-${t}-remove`,`Remove`,()=>a.remove(t),`Remove line ${i}`)),r}),s=V(`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=t.length>=n.linesPerBox,nn(`Lines`,o,s)}function un(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 dn(e,t,n){let r=rn(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=E(`div`,`wb-inspect-row`);return n.append(z(`output-${e.id}-label`,e.label,jt,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),V(`output-${e.id}-remove`,`Remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),a=V(`output-add`,`Add output`,()=>r.append(e=>({id:un(e),label:`exit`})));return a.disabled=e.outputs.length>=kt,nn(`Outputs`,i,a)}function fn(e,t,r,i,a){let o=()=>{let e=t();return e?.kind===`box`?e:null},s=()=>{let e=o();return e&&`lines`in e?e.lines??null:null},c=()=>{let e=o();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=o(),t=e&&ae(e)?l():null;return t?{at:t}:{}},d=e=>{e===`decision`&&a({shape:e,outputs:c()??Zt,...u()}),e===`box`&&a({shape:e,...u()}),e===`panel`&&a({shape:e}),e===`icon`&&a({shape:e,icon:o()?.icon??`component`,...u()}),e===`device`&&a({shape:e,device:x,...u()}),(e===`sticky`||e===`text`)&&a({shape:e,...u()})},f=e=>{if(e){a({step:Xt});return}let t=o(),n=t!==null&&t.at===null?l():null;a({step:null,...n?{at:n}:{}})};return[$t(Ut[e.shape]),R(`Title`,z(`title`,e.title,n.title,e=>{e.trim()&&a({title:e.trim()})})),en(`Icon`,Ot({field:`icon`,icon:e.icon,isRequired:e.shape===`icon`,accessibleName:`Box icon`,commit:e=>a({icon:e})})),R(`Shape`,B(`shape`,Ht,e.shape,d)),R(`Change`,B(`change`,qt,e.change,t=>{a(t===`relabeled`?{change:t,was:o()?.was??e.title}:{change:t,was:null})})),...e.change===`relabeled`?[R(`Was`,z(`was`,e.was??``,n.title,e=>{e.trim()&&a({was:e.trim()})}))]:[],...e.shape===`decision`?[dn(e,c,a)]:[],...e.shape===`device`?gn(e,a):[],...e.shape===`sticky`?[R(`Tone`,B(`tone`,Kt,e.tone,e=>a({tone:e})))]:[],...hn(e,o,a),sn(`this box`,e.refs,()=>o()?.refs??null,e=>a({refs:e})),...e.shape===`icon`||e.shape===`device`?[]:[ln(`this box`,e.lines,s,e=>a({lines:e}))],tn(`is-step`,`Plan step`,e.step!==null,f),...e.step?bn(e.step,i,a):[]]}function pn(e,t,n){let r=`dial-${e.id}`;switch(e.kind){case`toggle`:return tn(r,e.label,t===!0,n);case`choice`:return R(e.label,B(r,e.options.map(e=>({value:e,text:e})),String(t),n));case`color`:return R(e.label,mn(r,`color`,String(t),e=>n(e.value)));case`range`:{let i=mn(r,`range`,String(t),e=>n(Number(e.value)));return i.min=String(e.min),i.max=String(e.max),i.step=String(e.step),i.value=String(t),R(e.label,i)}}}function mn(e,t,n,r){let i=E(`input`,`wb-inspect-dial`);return i.type=t,i.value=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i)),i}function hn(e,t,n){let r=p(e);if(r?.kind!==`page`||r.dials.length===0)return[];let a=i(e),o=(e,r)=>{let i=t();n({params:{...i&&i.shape!==`icon`?i.params:{},[e]:r}})};return[$t(`Dials`),...r.dials.map(e=>pn(e,a[e.id]??e.default,t=>o(e.id,t)))]}function gn(e,t){return[R(`Device`,B(`device`,Wt,e.device,e=>t({device:e}))),R(`Fit`,B(`fit`,Gt,e.fit,e=>t({fit:e})))]}function _n(e,t,n){let r=e.elements.get(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[$t(`Wire`),R(`Label`,z(`label`,t.label??``,Mt,e=>n({label:e.trim()||null}))),R(`Tone`,B(`tone`,Vt,t.tone,e=>n({tone:e}))),tn(`dashed`,`Dashed`,t.dashed,e=>n({dashed:e})),tn(`back`,`Returns to an earlier step`,t.back,e=>n({back:e})),R(`Leaves from`,B(`fromSide`,Yt,t.fromSide??``,e=>n({fromSide:e||null}))),R(`Arrives at`,B(`toSide`,Yt,t.toSide??``,e=>n({toSide:e||null}))),...s.length>0?[R(`From output`,B(`fromOutput`,s,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function vn(e,t){return[$t(`Frame`),R(`Title`,z(`title`,e.title,n.title,e=>t({title:e.trim()}))),tn(`loop`,`Repeats as a loop`,e.loop,e=>t({loop:e})),tn(`collapsed`,`Stacked as one card`,e.collapsed,e=>t({collapsed:e}))]}function yn(e,t,n){let r=rn(t,n),i=e.map((e,t)=>{let n=E(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(B(`legend-${t}-tone`,Vt,e.tone,e=>{let n=zt.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),z(`legend-${t}-label`,e.label,Mt,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),tn(`legend-${t}-dashed`,`Dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),tn(`legend-${t}-back`,`Returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),V(`legend-${t}-remove`,`Remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),a=V(`legend-add`,`Add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return a.disabled=e.length>=At,nn(`Legend`,i,a)}function bn(e,t,n){let r=e.linkedBoardId===null||t.some(t=>t.value===e.linkedBoardId),i=e.linkedBoardId&&!r?[{value:e.linkedBoardId,text:e.linkedBoardId}]:[],a=[{value:``,text:`None`},...t,...i];return[$t(`Step`),R(`Status`,B(`step-status`,Jt,e.status,e=>{let t=s.find(t=>t===e);t&&n({step:{status:t}})})),R(`Linked board`,B(`step-linked-board`,a,e.linkedBoardId??``,e=>n({step:{linkedBoardId:e||null}}))),E(`p`,`wb-inspect-hint`,`A wire from one step to another means the second is built after the first.`)]}function xn(e,t,r,i,a){let o=[{value:``,text:`None`},...i];return[$t(`Board`),V(`board-settings-close`,`Close`,a,`Close board settings`),R(`Title`,z(`board-title`,e.title,n.title,e=>{e.trim()&&r([{op:`board`,title:e.trim()}])})),R(`Caption`,z(`board-caption`,e.caption??``,Pt,e=>r([{op:`board`,caption:e.trim()||null}]))),R(`Code session`,B(`board-code-session`,o,e.codeSessionId??``,e=>r([{op:`board`,codeSessionId:e||null}]))),yn(e.legend,()=>t()?.legend??null,e=>r([{op:`board`,legend:e}]))]}function Sn(e,t){let n=e.filter(e=>e.kind===`box`),[r]=n,i=E(`div`,`wb-inspect-actions`);r&&e.length===1&&i.append(V(`add-note`,`Add note`,()=>t.addNoteOn(r.id))),n.length>0&&i.append(V(`add-frame`,`Frame`,t.frameSelectedBoxes,n.length===1?`Frame this box`:`Frame selected boxes`)),n.length>1&&i.append(V(`add-stack`,`Stack`,t.stackSelectedBoxes,`Stack selected boxes`));let a=I({variant:`danger`,size:`small`,label:`Delete`,action:`delete-selection`,onClick:t.removeSelected});return a.classList.add(`wb-inspect-delete`),i.append(a),i}function Cn(e,t,n,r,i,a){let o=e=>a([{op:`set`,id:t.id,fields:e}]),s=()=>n()?.elements.get(t.id);switch(t.kind){case`box`:return fn(t,s,r,i,o);case`wire`:return _n(e,t,o);case`frame`:return vn(t,o);case`stroke`:return[$t(`Ink`)]}}function wn(e,t,n){let r=Qe(t);if(r.length===0)return[];let i=e.codeSessionId!==null,a=r.map((e,t)=>{let r=E(`div`,`wb-inspect-row wb-inspect-review-row`),a=V(`review-${t}`,`Open in review`,()=>n(e),`Open ${e} in review`);return a.disabled=!i,r.append(E(`code`,`wb-inspect-ref`,e),a),r}),o=i?[]:[E(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[$t(`In review`),...a,...o]}function Tn(e,t,n){let r=E(`div`,`wb-inspect-review`);return r.append(...wn(e,t,n)),r}function En(e){let t=document.activeElement;return!t||!e.contains(t)?!1:t instanceof HTMLInputElement&&t.type===`text`||t.closest(`.wb-icon-popover`)!==null}function Dn(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.get(n)}function s(n,r){let i=o(n,r),a=t.querySelector(`.wb-inspect-review`);i&&a&&a.replaceChildren(...wn(n,i,e.openRef))}function c(t,r){let i=[...r].flatMap(e=>t.elements.get(e)??[]);if(r.size>1)return[$t(`${i.length} selected`),Sn(i,e)];let a=o(t,r);return a?[...Cn(t,a,e.currentBoard,e.layout(),e.linkedBoardChoices(),n),Tn(t,a,e.openRef),Sn(i,e)]:xn(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(En(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 On=`http://www.w3.org/2000/svg`,kn=`Plan`,An=`open linked board`,jn=8,Mn=12,Nn=7.2,Pn=2.2,Fn=9.6;Object.freeze({fill:`xMidYMid slice`,fit:`xMidYMid meet`}),`${r.map(e=>`.wb-tone-${e} .wb-box-outline { fill: ${a[e]}; fill-opacity: 0.3; stroke: ${a[e]}; }`).join(`
1
+ import{$n as e,An as t,Bn as n,Fn as r,Gn as i,In as a,Jn as o,Pn as s,Qn as c,Sn as l,Un as u,Wn as d,Xn as f,Yn as p,Zn as m,_n as h,dn as g,er as _,f as v,gn as y,hn as b,ir as x,mn as S,nr as C,pn as w,rr as T,s as E,tr as ee,vn as D,zn as O}from"./dom-helpers-1xKy7VX6.js";import{$t as te,M as ne,Ti as k,a as re,an as ie,c as ae,cn as A,d as oe,en as se,f as j,i as ce,in as M,l as le,m as ue,n as de,nn as N,no as P,o as fe,on as pe,p as me,r as he,rn as ge,s as _e,sn as ve,t as ye,tn as be,u as xe,xi as Se,yi as Ce}from"./index-k6lh2SOM.js";import{a as we,i as Te,n as Ee,o as De,r as Oe,t as ke}from"./whiteboard-undo-core-CPx7qi5j.js";import{Ct as Ae,O as je,a as Me,bt as Ne,k as F,r as Pe,t as I}from"./button-CfhUK7Jn.js";import{i as Fe}from"./action-status-rETkOMJb.js";import{n as Ie,t as Le}from"./menu-DzZGGGGN.js";import{a as Re,r as ze}from"./card-registry-D1_v6Lbm.js";import{a as Be,i as Ve,n as He}from"./modal-CjIIQMho.js";import{n as Ue}from"./session-tick-DrUXWyvz.js";import{i as We,t as Ge}from"./plan-render-DY2Uplgx.js";Object.freeze({stepWarnings:[],uncoveredPaths:[],worthALookPaths:[],flaggedStepIds:[],notChecked:null});var Ke=/^([^#\s]+)(?:#L([1-9]\d*)(?:-L([1-9]\d*))?)?$/;function qe(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function Je(e){return e.split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`)}function Ye(e){let t=Ke.exec(e);if(!t?.[1])return{error:`a ref is path, path#L12 or path#L12-L30`};let n=t[1];if(qe(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:Je(n),startLine:r,endLine:i}}function Xe(e,t,n){return n.flatMap((n,r)=>n.ref?[{elementId:t,ref:n.ref,where:`line ${r+1} of ${e}`}]:[])}function Ze(e){let t=`${e.kind} ${e.id}`;switch(e.kind){case`box`:return[...e.refs.map(n=>({elementId:e.id,ref:n,where:t})),...Xe(t,e.id,o(e))];case`frame`:case`wire`:case`stroke`:return[]}}function Qe(e){return[...new Set(Ze(e).map(e=>e.ref))]}function $e(e){let t=Ye(e);return`path`in t?t.path:null}var et=4,tt=200,nt=2e4,rt=1.1,it=[`stroke`,`wire`,`frame`,`box`],at={v:`select`,r:`box`,d:`decision`,p:`panel`,s:`sticky`,t:`text`,i:`icon`,m:`device`,a:`wire`,b:`pen`},ot=new WeakMap;function L(e){let t=ot.get(e);if(t)return t;let n=new Map;for(let t of e.elements.valuesOfKind(`frame`)){let e=t.collapsed?t.contains[0]:void 0;e!==void 0&&n.set(e,t)}return ot.set(e,n),n}var st=new Set([1,2]);function ct(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 lt(e){let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}${t}`}function ut(){return document.documentElement.dataset.layout===`phone`}function dt(e){return e!==`select`&&e!==`wire`&&e!==`pen`}var ft={box:`Box`,decision:`Decision`,panel:`Panel`,sticky:`Note`,text:`Text`,icon:`Icon`,device:`Device`};function pt(e,t,n,r){let i={kind:`box`,id:lt(`box`),title:t,icon:null,refs:[],change:`none`,was:null,near:null,order:0,at:e,width:null,height:null,step:null};switch(r){case`icon`:return{...i,shape:r,icon:_};case`device`:return{...i,shape:r,device:x,fit:`fill`,media:n,params:{}};case`decision`:return{...i,shape:r,lines:[],media:n,outputs:[{id:`yes`,label:`yes`},{id:`no`,label:`no`}],params:{}};case`sticky`:return{...i,shape:r,tone:`yellow`,lines:[],media:n,params:{}};case`text`:return{...i,shape:r,lines:[]};case`box`:case`panel`:return{...i,shape:r,lines:[],media:n,params:{}}}}function mt(e){return e?.part!==`media`||!e.media?null:{boxId:e.id,href:e.media.href,alt:e.media.alt}}var ht=4,gt=2,_t={body:`pointer`,port:`crosshair`,resize:`nwse-resize`,link:`pointer`,media:`zoom-in`};function vt(e){return e?e.part===`body`&&e.kind===`box`?`move`:_t[e.part]:``}var yt=2,bt=12/10,xt=1.25;function St(e,t,n){return Math.max(e.width/t,e.height/Math.max(1,n))}function Ct(e){let{viewport:t,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,p=null,m=`select`,h=null,g=!1;function _(n){m=n,t.dataset.tool=n,e.onToolChange(n)}function v(){r.style.transform=`translate(${-l.x*l.scale}px, ${-l.y*l.scale}px) scale(${l.scale})`,o.setCamera(l)}function y(){return(t.clientWidth||1)/l.scale}function b(){let e=o.layout(),n=t.clientWidth||1;if(!e)return nt;let r=n*St(e.bounds,n,t.clientHeight)*xt;return Math.max(nt,r)}function x(){let e=t.getBoundingClientRect(),n=[...a.querySelectorAll(`.wb-island`)].filter(e=>e.checkVisibility()).map(e=>e.getBoundingClientRect()),r=e.top+e.height/2,i=n.filter(e=>e.top+e.height/2<r).map(t=>t.bottom-e.top),o=n.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 S(){let e=o.layout();if(!e)return;let{bounds:n}=e,r=t.clientWidth,i=t.clientHeight;if(r===0||i===0){l={x:n.x,y:n.y,scale:1},v(),g=!0;return}g=!1;let a=x(),s=e.elements.length===0?1:yt,c=Math.max(1/s,St(n,r,a.heightPx)),u=c>bt,d=u?bt:c,f=r*d,p=n.y+n.height/2,m=a.topPx+a.heightPx/2;l={x:n.x-Math.max(0,f-n.width)/2,y:u?n.y-a.topPx*d:p-m*d,scale:1/d},v()}function C(e,n){let r=t.getBoundingClientRect();return{x:l.x+(e-r.left-t.clientLeft)/l.scale,y:l.y+(n-r.top-t.clientTop)/l.scale}}function w(){return 1/l.scale}function T(e,t){let n=y(),r=Math.min(b(),Math.max(tt,n*t))/n;l={x:e.x-(e.x-l.x)*r,y:e.y-(e.y-l.y)*r,scale:l.scale/r},v()}function ee(e,t){l={...l,x:l.x-e/l.scale,y:l.y-t/l.scale},v()}function D(t){c=t,o.setSelection(c),e.onSelectionChange(c)}function O(e,t){if(!t){D(c.has(e)&&c.size===1?new Set:new Set([e]));return}let n=new Set(c);n.delete(e)||n.add(e),D(n)}function te(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 ne(e,t){let r=Math.round(t.width+e.latest.x-e.origin.x);return Math.min(n.boxWidthMax,Math.max(n.boxWidthMin,r))}function k(e){return Math.abs(e.latest.y-e.origin.y)>=ht*w()}function ie(e,t){let r=Math.round(t.height+e.latest.y-e.origin.y);return Math.min(n.boxHeightMax,Math.max(1,r))}function ae(t){if(t.mode===`resize`)return t.movingBoxes.map(e=>({boxId:e.boxId,fields:{width:ne(t,e.start),...k(t)?{height:ie(t,e.start)}:{}}}));let n=t.movingBoxes.map(e=>({boxId:e.boxId,at:te(t,e.start)})),r=e.currentBoard(),i=t.movingBoxes.filter(e=>{let t=r?.elements.get(e.boxId);return t?.kind===`box`&&_e(t)}),a=t.pinnedOffsetY-oe(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 A(){p!==null&&cancelAnimationFrame(p),p=null}function se(e){return{x:Math.round(e.latest.x-e.origin.x),y:Math.round(e.latest.y-e.origin.y)}}function j(e,t){let n=o.layout();if(e.mode!==`move`||!e.hasMoved||!n)return!1;let r=se(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=re(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 ce(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=f();for(let{boxId:n,fields:r}of ae(e)){let e=t.elements.get(n),o=i.get(n);e?.kind===`box`&&o&&a.put({...e,...r,step:null,at:{x:o.x,y:o.y}})}let o=new Map;for(let e of le({...t,elements:a}).elements){let t=i.get(e.id);e.kind===`box`&&t&&o.set(e.id,xe(e,t.x-e.x,t.y-e.y))}let s={...n,elements:n.elements.map(e=>o.get(e.id)??e)};return re(t,s,new Set(o.keys()))(0,0)}function M(e,t){let n=o.layout();return e.mode!==`resize`||!e.hasMoved||!n?!1:(o.paintElements(ce(e,t,n)),!0)}function ue(){A();let t=e.currentBoard();u?.kind!==`drag`||!t?e.repaint():j(u,t)||M(u,t)||e.repaint()}function de(){let t=e.currentBoard();u?.kind===`drag`&&t&&(j(u,t)||M(u,t))}function N(){p===null&&(p=requestAnimationFrame(ue))}function P(e){u?.kind===`drag`&&e?.elements.get(u.boxId)?.kind!==`box`&&(u=null),u?.kind===`drag`&&u.hasMoved&&(u.movingBoxes=u.movingBoxes.filter(t=>e?.elements.get(t.boxId)?.kind===`box`));let t=new Set([...c].filter(t=>e?.elements.get(t)));t.size!==c.size&&D(t)}function fe(e,t){return o.hitTest(C(e,t))}function pe(){let[e,t]=[...s.values()];return!e||!t?0:Math.hypot(e.x-t.x,e.y-t.y)}function me(){u?.kind===`wire`&&Me(u,!1),u?.kind===`ink`&&u.draftLine.remove(),u={kind:`pinch`,distance:pe(),viewWidth:y()}}function he(e){e.preventDefault(),s.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.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 ge(e){let t=document.createElementNS(`http://www.w3.org/2000/svg`,`polyline`);t.setAttribute(`class`,`wb-ink-draft`),i.append(t),u={kind:`ink`,pointerId:e.pointerId,points:[C(e.clientX,e.clientY)],draftLine:t},ve(u)}function ve(e){e.draftLine.setAttribute(`points`,e.points.map(e=>`${e.x},${e.y}`).join(` `))}function ye(e,t){let r=C(t.clientX,t.clientY),i=e.points[e.points.length-1];e.points.length>=n.strokePoints||i&&Math.hypot(r.x-i.x,r.y-i.y)<gt*w()||(e.points.push(r),ve(e))}async function be(t){let n=o.layout()?.pinnedOffsetY??0,r=(t.points.length===1&&t.points[0]?[t.points[0],t.points[0]]:t.points).flatMap(e=>[Math.round(e.x),Math.round(e.y-n)]),i=await e.sendOps([{op:`add`,element:{kind:`stroke`,id:lt(`stroke`),points:r,width:3,tone:`ink`}}]);t.draftLine.remove(),i||ue()}function Se(e){let t=C(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 Ce(t){let n=e.currentBoard();return n?L(n).get(t):void 0}function we(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.get(e)?.kind===`box`?o.boundsOf(e):null;return t?[{boxId:e,start:t}]:[]})}function Te(n){if(d)return;if(n.pointerType===`mouse`&&st.has(n.button)&&!u){he(n);return}if(n.button!==0)return;let r=fe(n.clientX,n.clientY);if(r?.part===`link`&&r.linkedBoardId){e.onOpenLinkedBoard(r.linkedBoardId);return}if(s.set(n.pointerId,{x:n.clientX,y:n.clientY}),t.setPointerCapture(n.pointerId),s.size===2){me();return}if(dt(m)){Ee(m,C(n.clientX,n.clientY));return}if(m===`pen`){ge(n);return}let i=r?.kind===`box`?o.boundsOf(r.id):null,a=r?.part===`resize`&&!ut()?i:null;if(r&&a){let e=C(n.clientX,n.clientY);u={kind:`drag`,mode:`resize`,pointerId:n.pointerId,boxId:r.id,origin:e,start:a,movingBoxes:we(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&&!ut()){ke(n.pointerId,r.id,r.port);return}let c=m===`wire`?i:null;if(r&&c){ke(n.pointerId,r.id,{x:c.x+c.width/2,y:c.y+c.height/2});return}let l=ut()?null:i;if(r&&l){let e=C(n.clientX,n.clientY),t=o.layout()?.pinnedOffsetY??0;u={kind:`drag`,mode:`move`,pointerId:n.pointerId,boxId:r.id,origin:e,start:l,movingBoxes:we(r.id,l,n.shiftKey),pinnedOffsetY:t,latest:e,hasMoved:!1,isAdditive:n.shiftKey,pressedImage:mt(r),preview:null,previewLayout:null,laidOutOffset:{x:0,y:0}};return}if(r&&!ut()){O(r.id,n.shiftKey);return}if(!r&&n.pointerType===`mouse`&&!ut()){Se(n);return}let f=r?.kind===`box`?r.id:null;u={kind:`pan`,pointerId:n.pointerId,lastClient:{x:n.clientX,y:n.clientY},hasMoved:!1,isAuxiliaryButton:!1,tappedBoxId:f,pressedImage:mt(r)}}async function Ee(t,n){if(_(`select`),!e.currentBoard())return;let r=o.layout()?.pinnedOffsetY??0,i=pt({x:Math.round(n.x),y:Math.round(n.y-r)},ft[t],null,t);h=i.id;let a=await e.sendOps([{op:`add`,element:i}]);a||(h=null),a&&D(new Set([i.id])),Oe()}async function De(n,r,i){if(!e.currentBoard())return!1;let a=i?C(i.x,i.y):{x:l.x+y()/2,y:l.y+(t.clientHeight||1)/l.scale/2},s=o.layout()?.pinnedOffsetY??0,c=pt({x:Math.round(a.x),y:Math.round(a.y-s)},n,r,`box`),u=await e.sendOps([{op:`add`,element:c}]);return u&&D(new Set([c.id])),u}function Oe(){if(!h||!o.boundsOf(h)||!e.currentBoard()?.elements.get(h))return;let t=h;h=null,Ge(t)}function ke(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 Ae(e,t){e.targetBoxId=t,o.setWireTarget(t)}function je(e,t){let n=C(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);Ae(e,r?.kind===`box`&&r.id!==e.fromBoxId?r.id:null)}function Me(t,n){let r=t.targetBoxId;Ae(t,null),t.draftLine.remove(),n&&r&&e.onConnectBoxes(t.fromBoxId,r)}function Ne(e,t){let n=C(t.clientX,t.clientY);!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<et*w()||(e.hasMoved=!0,e.latest=n,o.setWireTarget(F(e)),N())}function F(e){return e.mode!==`move`||e.movingBoxes.length!==1||Ce(e.boxId)?null:o.boxIdsAt(e.latest).find(t=>t!==e.boxId)??null}function Pe(e,t){let n=t.clientX-e.lastClient.x,r=t.clientY-e.lastClient.y;!e.hasMoved&&Math.hypot(n,r)<et||(e.hasMoved=!0,e.lastClient={x:t.clientX,y:t.clientY},ee(n,r))}function I(e,t){let n=C(t.clientX,t.clientY);if(!e.hasMoved&&Math.hypot(n.x-e.origin.x,n.y-e.origin.y)<et*w())return;e.hasMoved||i.append(e.outline),e.hasMoved=!0,e.latest=n;let r=ct(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))||D(a)}function Fe(e){e.outline.remove(),e.hasMoved||e.isAdditive||D(new Set)}function Ie(e){let t=pe();if(t<=0||e.distance<=0)return;let n=[...s.values()];T(C(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)/y())}function Le(e){if(e.pointerType!==`mouse`||ut())return;let n=fe(e.clientX,e.clientY);o.setHover(n?.kind===`box`?n.id:null),t.dataset.hoverKind=n?.kind??``,t.style.cursor=m===`select`?vt(n):``}function Re(e){u||Le(e),s.has(e.pointerId)&&(s.set(e.pointerId,{x:e.clientX,y:e.clientY}),u?.kind===`pinch`?Ie(u):u?.kind===`drag`&&u.pointerId===e.pointerId?Ne(u,e):u?.kind===`wire`&&u.pointerId===e.pointerId?je(u,e):u?.kind===`marquee`&&u.pointerId===e.pointerId?I(u,e):u?.kind===`ink`&&u.pointerId===e.pointerId?ye(u,e):u?.kind===`pan`&&u.pointerId===e.pointerId&&Pe(u,e))}async function ze(t,n){if(!t.hasMoved&&t.mode===`resize`)return;if(!t.hasMoved){Be(t);return}A(),t.latest=C(n.clientX,n.clientY),o.setWireTarget(null);let r=F(t);if(r){ue(),e.onStackBoxes(r,t.boxId,Ce(r)??null);return}let i=ae(t),a=e.currentBoard();a&&!j(t,a)&&M(t,a),await e.sendOps(i.map(({boxId:e,fields:t})=>({op:`set`,id:e,fields:t})))||ue()}function Be(t){O(t.boxId,t.isAdditive);let n=t.isAdditive?void 0:Ce(t.boxId);n?e.onOpenStack(n.id):t.pressedImage&&!t.isAdditive&&e.onOpenImage(t.pressedImage)}function Ve(t){if(!s.delete(t.pointerId))return;let n=u;n?.kind===`pinch`?u=null:(u=null,n?.kind===`drag`&&n.pointerId===t.pointerId?ze(n,t):n?.kind===`wire`?(Me(n,n.pointerId===t.pointerId),m===`wire`&&_(`select`)):n?.kind===`marquee`?Fe(n):n?.kind===`ink`?be(n):n?.kind!==`pan`||n.hasMoved||n.isAuxiliaryButton||(n.pressedImage&&ut()?e.onOpenImage(n.pressedImage):n.tappedBoxId&&ut()?e.onPhoneTapBox(n.tappedBoxId):n.tappedBoxId||D(new Set)))}function He(e){s.delete(e.pointerId);let t=u?.kind===`drag`;u?.kind===`wire`&&Me(u,!1),u?.kind===`marquee`&&u.outline.remove(),u?.kind===`ink`&&u.draftLine.remove(),u=null,t&&(o.setWireTarget(null),ue())}function Ue(e){e.preventDefault(),e.ctrlKey||e.metaKey?T(C(e.clientX,e.clientY),e.deltaY>0?rt:1/rt):ee(-e.deltaX,-e.deltaY)}function We(){let e=d;d=null,e?.remove()}function Ge(n){let r=e.currentBoard()?.elements.get(n),i=o.boundsOf(n);if(r?.kind!==`box`||!i)return;We();let s=a.getBoundingClientRect(),c=t.getBoundingClientRect(),u={left:c.left+t.clientLeft+(i.x-l.x)*l.scale,top:c.top+t.clientTop+(i.y-l.y)*l.scale,width:i.width*l.scale},f=E(`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(),We(),t.focus();return}if(i.key!==`Enter`)return;i.preventDefault();let a=f.value.trim();We(),t.focus(),a&&a!==r.title&&e.sendOps([{op:`set`,id:n,fields:{title:a}}])}),f.addEventListener(`blur`,We),f.focus(),f.select()}function Ke(e){if(ut())return;let t=fe(e.clientX,e.clientY);t?.kind===`box`&&Ge(t.id)}function qe(){let t=e.currentBoard();if(!t||c.size===0)return;let n=[...c].flatMap(e=>t.elements.get(e)??[]),r=it.flatMap(e=>n.filter(t=>t.kind===e)).map(e=>({op:`remove`,id:e.id}));D(new Set),e.sendOps(r)}function Je(e){if(e.target!==t||e.metaKey||e.ctrlKey||e.altKey)return;if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),qe();return}let n=at[e.key.toLowerCase()];n&&!e.shiftKey?(e.preventDefault(),_(n)):e.key===`Escape`&&(D(new Set),_(`select`))}return r.style.transition=`none`,t.tabIndex=0,t.addEventListener(`pointerdown`,Te),t.addEventListener(`pointermove`,Re),t.addEventListener(`pointerup`,Ve),t.addEventListener(`pointercancel`,He),t.addEventListener(`wheel`,Ue,{passive:!1}),t.addEventListener(`dblclick`,Ke),t.addEventListener(`contextmenu`,e=>e.preventDefault()),t.addEventListener(`keydown`,Je),t.addEventListener(`pointerleave`,()=>{u||(o.setHover(null),t.dataset.hoverKind=``)}),new ResizeObserver(()=>{g&&t.clientWidth>0&&t.clientHeight>0&&S()}).observe(t),{fit:S,selectedIds:()=>c,clearSelection:()=>D(new Set),pruneSelection:P,repaintPreview:de,closeTitleInput:We,setTool:_,placeMediaBox:De,openPendingTitleEdit:Oe,focusCanvas:()=>t.focus(),removeSelected:qe,zoomAroundClientPoint:(e,t,n)=>T(C(e,t),n),panByPixels:ee}}var wt=16;function Tt(e){let t=F(24,24);return t.setAttribute(`width`,String(wt)),t.setAttribute(`height`,String(wt)),t.setAttribute(`fill`,`none`),t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-width`,`2`),t.setAttribute(`stroke-linecap`,`round`),t.setAttribute(`stroke-linejoin`,`round`),t.innerHTML=m[e].elements.join(``),t}function Et(e){let t=E(`span`,`wb-icon-current`);return e?(t.append(Tt(e),E(`span`,`wb-icon-current-label`,m[e].label)),t):(t.append(E(`span`,`wb-icon-current-label`,`none`)),t)}function Dt(e,t){return e.includes(t)||m[e].label.toLowerCase().includes(t)}function Ot({field:t,icon:n,isRequired:r,accessibleName:i,commit:a}){let o=E(`div`,`wb-icon-picker`);o.dataset.field=t;let s=E(`div`,`wb-icon-popover`);s.hidden=!0,s.tabIndex=-1;let l=E(`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=()=>{s.hidden=!0,p.setAttribute(`aria-expanded`,`false`)},f=e=>{d(),p.focus(),e!==n&&a(e)},p=I({variant:`quiet`,size:`small`,label:`icon`,action:`icon-pick`,onClick:()=>{let e=s.hidden;s.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 h=c.map(t=>{let r=E(`div`,`wb-icon-group`),i=E(`div`,`wb-icon-grid`);for(let r of e.filter(e=>m[e].category===t)){let e=I({variant:`icon`,size:`small`,label:m[r].label,icon:Tt(r),action:`icon-choice`,onClick:()=>f(r)});e.dataset.icon=r,e.classList.add(`wb-icon-choice`),e.setAttribute(`aria-pressed`,String(r===n)),u.set(r,e),i.append(e)}return r.append(E(`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=!Dt(t,e);for(let{group:e,grid:t}of h)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])}),s.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),d(),p.focus())});let g=I({variant:`quiet`,size:`small`,label:`no icon`,action:`icon-clear`,onClick:()=>f(null),disabled:r||n===null});return s.append(l,...h.map(({group:e})=>e),g),o.append(Et(n),p,s),o}var kt=8,At=12,jt=30,Mt=40,Nt=40,Pt=400,Ft=200,It=8,Lt=`README.md`,Rt=[`text`,`code`,`item`,`numbered`,`kv`],zt=[`plain`,`fail`,`join`],Bt=Qt(Rt),Vt=Qt(zt),Ht=Qt(D),Ut={box:`Box`,decision:`Decision`,panel:`Panel`,icon:`Icon`,device:`Device`,sticky:`Sticky`,note:`Note`,text:`Text`},Wt=Qt(T),Gt=Qt(C),Kt=Qt(r),qt=Qt(h),Jt=Qt(s),Yt=[{value:``,text:`Auto`},...Qt([`left`,`right`,`top`,`bottom`])],Xt={status:`planned`,linkedBoardId:null},Zt=[{id:`yes`,label:`yes`},{id:`no`,label:`no`}];function Qt(e){return e.map(e=>({value:e,text:e}))}function $t(e){return E(`h3`,`wb-inspect-heading`,e)}function R(e,t){let n=E(`label`,`wb-inspect-field`);return n.append(E(`span`,`wb-inspect-label`,e),t),n}function en(e,t){let n=E(`div`,`wb-inspect-field`);return n.append(E(`span`,`wb-inspect-label`,e),t),n}function z(e,t,n,r,i){let a=E(`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 B(e,t,n,r,i){let a=E(`select`,`wb-inspect-select`);return a.dataset.field=e,i&&a.setAttribute(`aria-label`,i),a.append(...t.map(e=>{let t=E(`option`,null,e.text);return t.value=e.value,t.selected=e.value===n,t})),a.addEventListener(`change`,()=>r(a.value)),a}function tn(e,t,n,r){let i=E(`input`,`wb-inspect-check`);i.type=`checkbox`,i.checked=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i.checked));let a=E(`label`,`wb-inspect-toggle`);return a.append(i,E(`span`,null,t)),a}function V(e,t,n,r){let i=I({variant:`quiet`,size:`small`,label:t,action:t.toLowerCase().replaceAll(` `,`-`),onClick:n});return i.dataset.field=e,r&&i.setAttribute(`aria-label`,r),i}function nn(e,t,n){let r=E(`div`,`wb-inspect-list`);return r.append(E(`span`,`wb-inspect-label`,e),...t,n),r}function rn(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 an(e){let t=e.trim();return g.safeParse(t).success?t:null}function on(e,t,n,r){let i=z(e,t??``,Ft,e=>{if(!e.trim()){n(null);return}let t=an(e);t&&n(t)},r);return i.placeholder=`ref: path#L12`,i}function sn(e,t,n,r){let i=rn(n,r),a=t.map((e,t)=>{let n=E(`div`,`wb-inspect-row`);return n.append(z(`ref-${t}`,e,Ft,e=>{let n=an(e);n&&i.edit(t,()=>n)},`Ref ${t+1}`),V(`ref-${t}-remove`,`Remove`,()=>i.remove(t),`Remove ref ${e}`)),n}),o=V(`ref-add`,`Add ref`,()=>i.append(()=>Lt),`Add a ref to ${e}`);return o.disabled=t.length>=It,nn(`Refs`,a,o)}function cn(e,t){return t===`kv`?{...e,style:t,key:e.key||`key`}:{...e,style:t}}function ln(e,t,r,i){let a=rn(r,i),o=t.map((e,t)=>{let r=E(`div`,`wb-inspect-row`),i=t+1;return r.append(B(`line-${t}-style`,Bt,e.style,e=>{let n=Rt.find(t=>t===e);n&&a.edit(t,e=>cn(e,n))},`Line ${i} style`)),e.style===`kv`&&r.append(z(`line-${t}-key`,e.key??``,Nt,e=>{e.trim()&&a.edit(t,t=>({...t,key:e.trim()}))},`Line ${i} key`)),r.append(Ot({field:`line-${t}-icon`,icon:e.icon,isRequired:!1,accessibleName:`Line ${i} icon`,commit:e=>a.edit(t,t=>({...t,icon:e}))}),z(`line-${t}-text`,e.text,n.line,e=>a.edit(t,t=>({...t,text:e})),`Line ${i} text`),on(`line-${t}-ref`,e.ref,e=>a.edit(t,t=>({...t,ref:e})),`Line ${i} ref`),V(`line-${t}-remove`,`Remove`,()=>a.remove(t),`Remove line ${i}`)),r}),s=V(`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=t.length>=n.linesPerBox,nn(`Lines`,o,s)}function un(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 dn(e,t,n){let r=rn(t,e=>n({outputs:e})),i=e.outputs.map((e,t)=>{let n=E(`div`,`wb-inspect-row`);return n.append(z(`output-${e.id}-label`,e.label,jt,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Output ${e.id} label`),V(`output-${e.id}-remove`,`Remove`,()=>r.remove(t),`Remove output ${e.label}`)),n}),a=V(`output-add`,`Add output`,()=>r.append(e=>({id:un(e),label:`exit`})));return a.disabled=e.outputs.length>=kt,nn(`Outputs`,i,a)}function fn(e,t,r,i,a){let o=()=>{let e=t();return e?.kind===`box`?e:null},s=()=>{let e=o();return e&&`lines`in e?e.lines??null:null},c=()=>{let e=o();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=o(),t=e&&ae(e)?l():null;return t?{at:t}:{}},d=e=>{e===`decision`&&a({shape:e,outputs:c()??Zt,...u()}),e===`box`&&a({shape:e,...u()}),e===`panel`&&a({shape:e}),e===`icon`&&a({shape:e,icon:o()?.icon??`component`,...u()}),e===`device`&&a({shape:e,device:x,...u()}),(e===`sticky`||e===`text`)&&a({shape:e,...u()})},f=e=>{if(e){a({step:Xt});return}let t=o(),n=t!==null&&t.at===null?l():null;a({step:null,...n?{at:n}:{}})};return[$t(Ut[e.shape]),R(`Title`,z(`title`,e.title,n.title,e=>{e.trim()&&a({title:e.trim()})})),en(`Icon`,Ot({field:`icon`,icon:e.icon,isRequired:e.shape===`icon`,accessibleName:`Box icon`,commit:e=>a({icon:e})})),R(`Shape`,B(`shape`,Ht,e.shape,d)),R(`Change`,B(`change`,qt,e.change,t=>{a(t===`relabeled`?{change:t,was:o()?.was??e.title}:{change:t,was:null})})),...e.change===`relabeled`?[R(`Was`,z(`was`,e.was??``,n.title,e=>{e.trim()&&a({was:e.trim()})}))]:[],...e.shape===`decision`?[dn(e,c,a)]:[],...e.shape===`device`?gn(e,a):[],...e.shape===`sticky`?[R(`Tone`,B(`tone`,Kt,e.tone,e=>a({tone:e})))]:[],...hn(e,o,a),sn(`this box`,e.refs,()=>o()?.refs??null,e=>a({refs:e})),...e.shape===`icon`||e.shape===`device`?[]:[ln(`this box`,e.lines,s,e=>a({lines:e}))],tn(`is-step`,`Plan step`,e.step!==null,f),...e.step?bn(e.step,i,a):[]]}function pn(e,t,n){let r=`dial-${e.id}`;switch(e.kind){case`toggle`:return tn(r,e.label,t===!0,n);case`choice`:return R(e.label,B(r,e.options.map(e=>({value:e,text:e})),String(t),n));case`color`:return R(e.label,mn(r,`color`,String(t),e=>n(e.value)));case`range`:{let i=mn(r,`range`,String(t),e=>n(Number(e.value)));return i.min=String(e.min),i.max=String(e.max),i.step=String(e.step),i.value=String(t),R(e.label,i)}}}function mn(e,t,n,r){let i=E(`input`,`wb-inspect-dial`);return i.type=t,i.value=n,i.dataset.field=e,i.addEventListener(`change`,()=>r(i)),i}function hn(e,t,n){let r=p(e);if(r?.kind!==`page`||r.dials.length===0)return[];let a=i(e),o=(e,r)=>{let i=t();n({params:{...i&&i.shape!==`icon`?i.params:{},[e]:r}})};return[$t(`Dials`),...r.dials.map(e=>pn(e,a[e.id]??e.default,t=>o(e.id,t)))]}function gn(e,t){return[R(`Device`,B(`device`,Wt,e.device,e=>t({device:e}))),R(`Fit`,B(`fit`,Gt,e.fit,e=>t({fit:e})))]}function _n(e,t,n){let r=e.elements.get(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[$t(`Wire`),R(`Label`,z(`label`,t.label??``,Mt,e=>n({label:e.trim()||null}))),R(`Tone`,B(`tone`,Vt,t.tone,e=>n({tone:e}))),tn(`dashed`,`Dashed`,t.dashed,e=>n({dashed:e})),tn(`back`,`Returns to an earlier step`,t.back,e=>n({back:e})),R(`Leaves from`,B(`fromSide`,Yt,t.fromSide??``,e=>n({fromSide:e||null}))),R(`Arrives at`,B(`toSide`,Yt,t.toSide??``,e=>n({toSide:e||null}))),...s.length>0?[R(`From output`,B(`fromOutput`,s,t.fromOutput??``,e=>n({fromOutput:e||null})))]:[]]}function vn(e,t){return[$t(`Frame`),R(`Title`,z(`title`,e.title,n.title,e=>t({title:e.trim()}))),tn(`loop`,`Repeats as a loop`,e.loop,e=>t({loop:e})),tn(`collapsed`,`Stacked as one card`,e.collapsed,e=>t({collapsed:e}))]}function yn(e,t,n){let r=rn(t,n),i=e.map((e,t)=>{let n=E(`div`,`wb-inspect-row wb-inspect-legend-row`),i=t+1;return n.append(B(`legend-${t}-tone`,Vt,e.tone,e=>{let n=zt.find(t=>t===e);n&&r.edit(t,e=>({...e,tone:n}))},`Legend entry ${i} tone`),z(`legend-${t}-label`,e.label,Mt,e=>{e.trim()&&r.edit(t,t=>({...t,label:e.trim()}))},`Legend entry ${i} label`),tn(`legend-${t}-dashed`,`Dashed`,e.dashed,e=>r.edit(t,t=>({...t,dashed:e}))),tn(`legend-${t}-back`,`Returns`,e.back,e=>r.edit(t,t=>({...t,back:e}))),V(`legend-${t}-remove`,`Remove`,()=>r.remove(t),`Remove legend entry ${e.label}`)),n}),a=V(`legend-add`,`Add entry`,()=>r.append(()=>({tone:`plain`,dashed:!1,back:!1,label:`meaning`})));return a.disabled=e.length>=At,nn(`Legend`,i,a)}function bn(e,t,n){let r=e.linkedBoardId===null||t.some(t=>t.value===e.linkedBoardId),i=e.linkedBoardId&&!r?[{value:e.linkedBoardId,text:e.linkedBoardId}]:[],a=[{value:``,text:`None`},...t,...i];return[$t(`Step`),R(`Status`,B(`step-status`,Jt,e.status,e=>{let t=s.find(t=>t===e);t&&n({step:{status:t}})})),R(`Linked board`,B(`step-linked-board`,a,e.linkedBoardId??``,e=>n({step:{linkedBoardId:e||null}}))),E(`p`,`wb-inspect-hint`,`A wire from one step to another means the second is built after the first.`)]}function xn(e,t,r,i,a){let o=[{value:``,text:`None`},...i];return[$t(`Board`),V(`board-settings-close`,`Close`,a,`Close board settings`),R(`Title`,z(`board-title`,e.title,n.title,e=>{e.trim()&&r([{op:`board`,title:e.trim()}])})),R(`Caption`,z(`board-caption`,e.caption??``,Pt,e=>r([{op:`board`,caption:e.trim()||null}]))),R(`Code session`,B(`board-code-session`,o,e.codeSessionId??``,e=>r([{op:`board`,codeSessionId:e||null}]))),yn(e.legend,()=>t()?.legend??null,e=>r([{op:`board`,legend:e}]))]}function Sn(e,t){let n=e.filter(e=>e.kind===`box`),[r]=n,i=E(`div`,`wb-inspect-actions`);r&&e.length===1&&i.append(V(`add-note`,`Add note`,()=>t.addNoteOn(r.id))),n.length>0&&i.append(V(`add-frame`,`Frame`,t.frameSelectedBoxes,n.length===1?`Frame this box`:`Frame selected boxes`)),n.length>1&&i.append(V(`add-stack`,`Stack`,t.stackSelectedBoxes,`Stack selected boxes`));let a=I({variant:`danger`,size:`small`,label:`Delete`,action:`delete-selection`,onClick:t.removeSelected});return a.classList.add(`wb-inspect-delete`),i.append(a),i}function Cn(e,t,n,r,i,a){let o=e=>a([{op:`set`,id:t.id,fields:e}]),s=()=>n()?.elements.get(t.id);switch(t.kind){case`box`:return fn(t,s,r,i,o);case`wire`:return _n(e,t,o);case`frame`:return vn(t,o);case`stroke`:return[$t(`Ink`)]}}function wn(e,t,n){let r=Qe(t);if(r.length===0)return[];let i=e.codeSessionId!==null,a=r.map((e,t)=>{let r=E(`div`,`wb-inspect-row wb-inspect-review-row`),a=V(`review-${t}`,`Open in review`,()=>n(e),`Open ${e} in review`);return a.disabled=!i,r.append(E(`code`,`wb-inspect-ref`,e),a),r}),o=i?[]:[E(`p`,`wb-inspect-hint`,`Set the board code session to open refs in review.`)];return[$t(`In review`),...a,...o]}function Tn(e,t,n){let r=E(`div`,`wb-inspect-review`);return r.append(...wn(e,t,n)),r}function En(e){let t=document.activeElement;return!t||!e.contains(t)?!1:t instanceof HTMLInputElement&&t.type===`text`||t.closest(`.wb-icon-popover`)!==null}function Dn(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.get(n)}function s(n,r){let i=o(n,r),a=t.querySelector(`.wb-inspect-review`);i&&a&&a.replaceChildren(...wn(n,i,e.openRef))}function c(t,r){let i=[...r].flatMap(e=>t.elements.get(e)??[]);if(r.size>1)return[$t(`${i.length} selected`),Sn(i,e)];let a=o(t,r);return a?[...Cn(t,a,e.currentBoard,e.layout(),e.linkedBoardChoices(),n),Tn(t,a,e.openRef),Sn(i,e)]:xn(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(En(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 On=`http://www.w3.org/2000/svg`,kn=`Plan`,An=`open linked board`,jn=8,Mn=12,Nn=7.2,Pn=2.2,Fn=9.6;Object.freeze({fill:`xMidYMid slice`,fit:`xMidYMid meet`}),`${r.map(e=>`.wb-tone-${e} .wb-box-outline { fill: ${a[e]}; fill-opacity: 0.3; stroke: ${a[e]}; }`).join(`
2
2
  `)}${P}${P}${P}${P}${P}${P}${P}`;function In(e){return Object.entries(e).flatMap(([e,t])=>t===null?[]:[` ${e}="${k(t)}"`]).join(``)}function Ln(e,t,n=``){return`<${e}${In(t)}>${n}</${e}>`}function Rn(e){let t=e.x+e.width,n=e.y+e.height,r=e.y+e.headerHeight/2,i=[{x:e.x+Mn,y:e.y},{x:t-Mn,y:e.y},{x:t,y:r}];return e.outputs.length===0?[...i,{x:t-Mn,y:n},{x:e.x+Mn,y:n},{x:e.x,y:r}]:[...i,{x:t,y:n},{x:e.x,y:n},{x:e.x,y:r}]}function zn(e){return`${Rn(e).map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `)} Z`}function Bn(e){let t={fill:`black`,stroke:`black`,"stroke-width":12,"stroke-linejoin":`round`};return e.kind===`box`&&e.shape===`decision`?Ln(`path`,{d:zn(e),...t}):Ln(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:jn,...t})}function Vn(e,t){if(t.length===0)return null;let n={x:e.x,y:e.y,width:e.width,height:e.height},r=Ln(`mask`,{id:`page-mask`,maskUnits:`userSpaceOnUse`,...n},[Ln(`rect`,{...n,fill:`white`}),...t.map(Bn)].join(``)),i=Ln(`svg`,{xmlns:On,viewBox:`${e.x} ${e.y} ${e.width} ${e.height}`,width:e.width,height:e.height,preserveAspectRatio:`none`},Ln(`defs`,{},r)+Ln(`rect`,{...n,mask:`url(#page-mask)`}));return`url("data:image/svg+xml,${encodeURIComponent(i)}")`}var Hn=2048,Un=4,Wn=37,Gn=73,Kn=Un+49,qn=Math.floor(Hn/Wn),Jn=1540,Yn=Math.log2(Hn)+1,Xn=33,Zn=126,Qn=8,$n=Qn*Jn,er=`?`;function tr(){let e=(typeof OffscreenCanvas==`function`?new OffscreenCanvas(Wn,Gn):Object.assign(document.createElement(`canvas`),{width:Wn,height:Gn})).getContext(`2d`,{willReadFrequently:!0});if(!e)throw Error(`this browser cannot draw text for the whiteboard`);return e}function nr(e){let t=tr(),n=new Map,r=[],i=[],a=null,o=0;function s(n,r){t.clearRect(0,0,Wn,Gn),t.font=`${r?700:400} 48px ${e}`,t.textBaseline=`alphabetic`,t.fillStyle=`#fff`,t.fillText(n,Un,Kn);let i=t.getImageData(0,0,Wn,Gn).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/Jn),c=a%Jn,l=c%qn*Wn,u=Math.floor(c/qn)*Gn,d={cell:{u0:l/Hn,v0:u/Hn,u1:(l+Wn)/Hn,v1:(u+Gn)/Hn,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>=$n?l(er,t):c(e,t).cell}function u(){for(let e=Xn;e<=Zn;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,Yn,e.R8,Hn,Hn,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/Jn);if((!a||n>o)&&f(e,Math.min(n*2,Qn)),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%Jn,r=n%qn*Wn,i=Math.floor(n/qn)*Gn;e.texSubImage3D(e.TEXTURE_2D_ARRAY,0,r,i,t.cell.page,Wn,Gn,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:Wn/48,cellHeightEm:Gn/48,padLeftEm:Un/48,ascentEm:Kn/48,bind:p,forgetTexture:()=>{a=null,o=0},release:e=>{a&&e.deleteTexture(a),a=null,o=0},rasterizeAgain:m,isFull:()=>r.length>=$n,forgetUnusedGlyphs:d}}var rr=8,ir=4,ar=4,or=/<(\w+)([^>]*)\/?>/g,sr=/([\w-]+)="([^"]*)"/g,cr=/[a-zA-Z]|-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?/g,lr=new Map;function ur(e){return new Map([...e.matchAll(sr)].map(e=>[e[1]??``,e[2]??``]))}function H(e,t){return Number(e.get(t)??0)}function dr(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 fr(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 pr(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/ar*(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 mr(e,t,n,r){return Array.from({length:rr},(i,a)=>{let o=(a+1)/rr,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 hr(e,t,n,r){return Math.atan2(e*r-t*n,e*n+t*r)}function gr(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=hr(1,0,(f-x)/g,(p-S)/_),E=hr((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 ee=Math.max(2,Math.ceil(Math.abs(E)/(Math.PI/2)*ir));return Array.from({length:ee},(e,t)=>{let n=T+E*(t+1)/ee,r=Math.cos(n)*g,i=Math.sin(n)*_;return{x:c*r-l*i+C,y:l*r+c*i+w}})}function _r(e){let t=e.match(cr)??[],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 mr(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 mr(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 gr(u,e,t,a,o,s,c))d(n);break}case`Z`:d(a),f();break;default:c+=1}}return f(),n}function vr(e,t){switch(e){case`path`:return{polylines:_r(t.get(`d`)??``),circles:[]};case`line`:return{polylines:[[{x:H(t,`x1`),y:H(t,`y1`)},{x:H(t,`x2`),y:H(t,`y2`)}]],circles:[]};case`polyline`:return{polylines:[dr(t.get(`points`)??``)],circles:[]};case`polygon`:{let e=dr(t.get(`points`)??``),[n]=e;return{polylines:[n?[...e,n]:e],circles:[]}}case`rect`:{let e=H(t,t.has(`rx`)?`rx`:`ry`);return{polylines:[pr(H(t,`x`),H(t,`y`),H(t,`width`),H(t,`height`),e)],circles:[]}}case`circle`:return{polylines:[],circles:[{center:{x:H(t,`cx`),y:H(t,`cy`)},radius:H(t,`r`),isFilled:t.get(`fill`)===`currentColor`}]};case`ellipse`:return{polylines:[fr({x:H(t,`cx`),y:H(t,`cy`)},H(t,`rx`),H(t,`ry`))],circles:[]};default:return{polylines:[],circles:[]}}}function yr(e){let t=lr.get(e);if(t)return t;let n={polylines:[],circles:[]};for(let t of m[e].elements)for(let e of t.matchAll(or)){let t=vr(e[1]??``,ur(e[2]??``));n.polylines.push(...t.polylines),n.circles.push(...t.circles)}return lr.set(e,n),n}var br=0,xr=0,Sr=3,Cr={frame:1,wire:2,box:4,stroke:5},wr=4,Tr=12,Er=8,Dr=4,Or=12.8,kr=5.12,Ar=1.28,jr=1.6,Mr=1.6,Nr=.08,Pr=Nn/12,Fr=3,Ir=12,Lr=4,U=0,Rr=24,zr=2,Br=[0,0,0,0];function Vr(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 W(e,t){return t===1?e:[e[0],e[1],e[2],e[3]*t]}function Hr(){return{rects:[],segments:[],triangles:[],glyphs:[]}}function Ur(e){return{rects:Float32Array.from(e.rects),segments:Float32Array.from(e.segments),triangles:Float32Array.from(e.triangles),glyphs:Float32Array.from(e.glyphs)}}var G={on:0,off:0};function K(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,br)}function Wr(e,t,n,r,i,a,o){K(e,{x:t.x-n,y:t.y-n,width:n*2,height:n*2},n,r,i,a,o)}function q(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,br),o+=Math.hypot(l.x-c.x,l.y-c.y))}}function Gr(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,br)}function Kr(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&&Gr(e,[i,o,s],n,r)}}function qr(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*Ar,y:n.y+s*Ar},l=c.x-o*Or,u=c.y-s*Or;Gr(e,[c,{x:l-s*kr,y:u+o*kr},{x:l+s*kr,y:u-o*kr}],r,i)}function Jr(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<=Lr;n+=1){let i=e.startAngle+n/Lr*(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 Yr(e,t,n,r,i,a,o,s){o.on===0?K(e,t,n,r,i,a,s):(K(e,t,n,r,r,0,s),q(e,Jr(t,n),a,i,o,s))}function Xr(e){return e.size*(Pr+(e.isUppercase?Nr:0))}function Zr(e,t){return[...e].length*Xr(t)}function Qr(e){return(e.minPixels??wr)/e.size}function J(e,t,n,r,i,a){let o=a.isUppercase?n.toUpperCase():n,s=Xr(a),c=Zr(o,a),l=r-(a.anchor===`middle`?c/2:a.anchor===`end`?c:0),u=Qr(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,br)}h+=1}a.isStruckThrough&&q(e,[{x:l,y:i-a.size*.3},{x:l+c,y:i-a.size*.3}],1,m,G,u),a.isUnderlined&&q(e,[{x:l,y:i+2},{x:l+c,y:i+2}],1,m,G,u)}function $r(e,t,n,r,i,a,o){let s=i/Rr,c=zr*s,l=yr(t);for(let t of l.polylines)q(e,t.map(e=>({x:n+e.x*s,y:r+e.y*s})),c,a,G,o);for(let t of l.circles)Wr(e,{x:n+t.center.x*s,y:r+t.center.y*s},t.radius*s,t.isFilled?a:Br,a,c,o)}function ei(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 ti(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 ni(e,t){return e.style===`code`?t.accent:e.muted?t.inkDim:t.ink}function ri(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*Nn:f;t.icon&&t.isFirstRow&&$r(e,t.icon,f,d-10,13,W(c.inkDim,o),s),t.style===`code`&&K(e,{x:p-4,y:d-13,width:r+i-12+8-p,height:17},3,W(c.codeBand,o),W(c.codeBand,o),0,s),t.style===`item`&&t.isFirstRow&&Wr(e,{x:p+4,y:d-4},Pn,W(c.inkDim,o),W(c.inkDim,o),0,s),t.marker!==null&&J(e,l,t.marker,p,d,{size:u,color:W(c.inkDim,o),isBold:t.style===`kv`}),t.text&&J(e,l,t.text,p+t.indentChars*Nn,d,{size:u,color:W(ni(t,c),o)})})}function ii(e,t){let n=e.shape===`panel`&&!e.step?1.4:Mr,r=e.step?t.accent:null,i=ai(e,t);return e.change===`added`?{fill:i,stroke:r??t.running,dash:{on:7,off:5},width:n}:e.change===`removed`?{fill:[0,0,0,0],stroke:r??t.failed,dash:{on:7,off:5},width:n}:e.change===`relabeled`?{fill:i,stroke:r??t.noteStroke,dash:G,width:n}:{fill:i,stroke:r??oi(e,t),dash:G,width:n}}function ai(e,t){return e.tone?t.stickyFillByTone[e.tone]:e.shape===`note`?t.noteCard:e.shape===`text`?Br:e.shape===`panel`?t.panelFill:t.board}function oi(e,t){return e.tone?t.stickyEdgeByTone[e.tone]:e.shape===`note`?t.noteStroke:e.shape===`text`?Br:e.shape===`panel`?t.line:t.inkDim}function si(e,t){return e===`building`?t.waiting:e===`landed`?t.running:t.muted}function ci(e,t,n,r,i,a){let{base:o}=ee[t.name];if(!o)return;let s=o.height*t.scale,c=t.x+t.width/2;if(o.overhang>0){K(e,{x:t.x,y:n,width:t.width,height:s},s/3,r,i,1,a);return}let l=24*t.scale,u=180*t.scale,d=520*t.scale;K(e,{x:c-u/2,y:n,width:u,height:s-l},0,r,i,1,a),K(e,{x:c-d/2,y:n+s-l,width:d,height:l},l/3,r,i,1,a)}function li(e,t,n,r,i,a){let{palette:o,glyphs:s}=t,c=ee[r.name],l=W(Vr(o.ink,o.board,.12),i),u=W(o.inkDim,i),d=W(o.board,i),f=(c.base?.overhang??0)*r.scale,p=r.x+f,m=r.width-f*2,h=(c.bezel.top+c.toolbarHeight+c.screen.height+c.bezel.bottom)*r.scale;if(K(e,{x:p,y:r.y,width:m,height:h},c.bezel.radius*r.scale,l,u,1,a),ci(e,r,r.y+h,l,u,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,f=96*r.scale,h=W(Vr(o.ink,o.board,.06),i);K(e,{x:p,y:t,width:m,height:n},0,h,h,0,a);for(let t of[1,2,3])Wr(e,{x:p+t*22*r.scale,y:s},6*r.scale,u,u,0,a);K(e,{x:p+f,y:s-l/2,width:m-f*2,height:l},l/2,d,d,0,a)}K(e,r.screen,c.bezel.screenRadius*r.scale,d,d,0,a),n.media||J(e,s,n.titleLines.join(` `),r.screen.x+r.screen.width/2,r.screen.y+r.screen.height/2+4,{size:o.metaSize,color:W(o.inkDim,i),anchor:`middle`})}function ui(e,t){let{palette:n,glyphs:r}=t,i=Hr(),a=e.change===`removed`?.6:1,o=Tr/Math.max(1,e.height),s=ii(e,n),c=W(s.fill,a),l=W(s.stroke,a);if(e.shape===`decision`){let t=Rn(e);Kr(i,t,c,U);let[n]=t;n&&q(i,[...t,n],s.width,l,s.dash,U)}e.shape!==`decision`&&Yr(i,e,8,c,l,s.width,s.dash,U);for(let t of e.outputs){let s=(e.height-e.headerHeight)/e.outputs.length/2,c=t.port.y-s;q(i,[{x:e.x,y:c},{x:e.x+e.width,y:c}],1,W(n.line,a),G,o),J(i,r,t.label,e.x+12,t.port.y+4,{size:n.metaSize,color:W(n.ink,a),isBold:!0,isUppercase:!0}),Wr(i,t.port,3,W(n.inkDim,a),W(n.inkDim,a),0,o)}let u=e.step?18:0;e.step&&(J(i,r,e.step.label,e.x+12,e.y+22,{size:n.metaSize,color:W(n.accent,a),isBold:!0}),J(i,r,e.step.status,e.x+e.width-12,e.y+22,{size:n.metaSize,color:W(si(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&&$r(i,e.icon,p-24,e.y+12+u,48,W(n.accent,a),o);let m=d?p:e.x+12,h=d?`middle`:`start`;e.wasLines.forEach((t,o)=>{J(i,r,t,m,e.y+26+u+f+o*20,{size:n.titleSize,color:W(n.inkDim,a),isStruckThrough:!0,anchor:h})});let g=e.y+26+u+f+e.wasLines.length*20,_=d?null:e.icon;_&&$r(i,_,m,g-12,14,W(n.ink,a),o);let v=_?m+2*Fn:m;e.titleLines.forEach((t,o)=>{J(i,r,t,v,g+o*20,{size:n.titleSize,color:W(n.ink,a),isBold:!0,isStruckThrough:e.change===`removed`,anchor:h})}),e.device&&li(i,t,e,e.device,a,o);let y=g+e.titleLines.length*20;e.shape===`panel`&&e.bodyLines.length>0&&q(i,[{x:e.x+12,y:y-12},{x:e.x+e.width-12,y:y-12}],1,W(n.line,a),G,o),ri(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;Yr(i,e.media,6,W(n.placeholderFill,a),W(n.inkDim,a),1,{on:4,off:4},o),J(i,r,t,e.media.x+e.media.width/2,e.media.y+e.media.height/2+4,{size:n.metaSize,color:W(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:W(n.accent,a),isUnderlined:!0},C=y+e.bodyLines.length*18;return J(i,r,An,e.x+12,C,S),{part:i,hitShape:{kind:`rect`,rect:e,linkRect:{x:e.x+12,y:C-n.metaSize,width:Zr(An,S),height:n.metaSize+4,linkedBoardId:x},mediaRect:e.media,hasDrawnMedia:b}}}function di(e,t,n,r){return Array.from({length:13},(i,a)=>{let o=n+a/Ir*r;return{x:e.x+Math.cos(o)*t,y:e.y+Math.sin(o)*t}})}function fi(e,t,n){let{palette:r,glyphs:i}=n,a=Hr(),o={x:e.x,y:e.y+26,width:e.width-12,height:e.height-26-12};for(let e of[2,1])Yr(a,{...o,x:o.x+6*e,y:o.y+6*e},8,r.cardBackground,r.line,1.2,G,U);let s={size:r.metaSize,color:r.inkDim,isBold:!0},c=`${e.title} (${t})`;return J(a,i,c,e.x+4,e.y+18,s),{part:a,hitShape:{kind:`outline`,rect:e,titleRect:{x:e.x,y:e.y,width:8+Zr(c,s),height:26}}}}function pi(e,t){if(e.stackedBoxCount!==null)return fi(e,e.stackedBoxCount,t);let{palette:n,glyphs:r}=t,i=Hr(),a=e.isLoop?n.accent:n.line;Yr(i,e,12,n.frameFill,a,1.4,{on:10,off:6},U);let o={size:n.metaSize,color:n.inkDim,isBold:!0};if(J(i,r,e.title,e.x+14,e.y+18,o),e.isLoop){let t=di({x:e.x+e.width-20,y:e.y+6+6},6,0,-Math.PI*1.5);q(i,t,Mr,n.accent,G,Tr/e.height);let r=t[t.length-2],a=t[t.length-1];r&&a&&qr(i,r,a,n.accent,Dr/Or)}return{part:i,hitShape:{kind:`outline`,rect:e,titleRect:{x:e.x,y:e.y,width:28+Zr(e.title,o),height:26}}}}function mi(e,t){return e.tone===`fail`?t.failed:e.tone===`join`||e.isBack?t.accent:t.inkDim}function hi(e,t,n){let r=t[t.length-2],i=t[t.length-1];r&&i&&qr(e,r,i,n,Dr/Or)}function gi(e,t){let{palette:n,glyphs:r}=t,i=Hr(),a=Hr(),o=j(e.path),s=mi(e,n);q(i,o,jr,s,e.isDashed?{on:7,off:6}:G,U),e.hasArrowhead&&hi(i,o,s);let c=Dr/6;Wr(i,e.start,3,n.inkDim,n.inkDim,0,c),e.joinAt&&Wr(i,e.joinAt,3,n.inkDim,n.inkDim,0,c);let l=ei(o.length>0?o:[e.start,e.end],8);if(e.label){let t={size:n.metaSize,color:n.ink,anchor:`middle`,minPixels:Er},i=Zr(e.label,t),o={x:e.labelAt.x-i/2-Fr,y:e.labelAt.y-n.metaSize,width:i+6,height:n.metaSize+Fr+2};K(a,o,3,n.board,n.board,0,Qr(t)),J(a,r,e.label,e.labelAt.x,e.labelAt.y,t),l=ti(l,o)}return{parts:[{layer:Cr.wire,part:Ur(i)},{layer:Sr,part:Ur(a)}],hitShape:{kind:`path`,points:o},bounds:l}}function _i(e){let t=[];for(let n=0;n+1<e.points.length;n+=2)t.push({x:e.points[n]??0,y:e.points[n+1]??0});return t}function vi(e,t){return e.tone===`ink`?t.ink:t.stickyEdgeByTone[e.tone]}function yi(e,t){let n=Hr(),r=_i(e);return q(n,r,e.strokeWidth,vi(e,t.palette),G,U),{part:n,hitShape:{kind:`path`,points:r}}}function bi(e,t){return{parts:[{layer:Cr[e.kind],part:Ur(t.part)}],hitShape:t.hitShape,bounds:xi(e,t.hitShape)}}function xi(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 Si(e,t){switch(e.kind){case`box`:return bi(e,ui(e,t));case`frame`:return bi(e,pi(e,t));case`wire`:return gi(e,t);case`stroke`:return bi(e,yi(e,t))}}function Ci(e,t,n){let{parts:r,hitShape:i,bounds:a}=Si(e,n);return{id:e.id,kind:e.kind,paintRank:t,bounds:a,parts:r,hitShape:i}}function wi(e,t,n){let{swatch:r}=t;if(r.kind===`status`){K(e,{x:t.x,y:t.y,width:14,height:14},3,si(r.status,n),n.accent,Mr,U);return}if(r.kind===`change`){let i={x:t.x,y:t.y,width:28,height:14},a=ii({change:r.change,shape:`box`,tone:null,step:null},n),o=r.change===`removed`?.6:1;Yr(e,i,3,W(a.fill,o),W(a.stroke,o),a.width,a.dash,U);return}let i=mi(r,n),a=[{x:t.x,y:t.y+7},{x:t.x+28,y:t.y+7}];q(e,a,jr,i,r.isDashed?{on:7,off:6}:G,U),hi(e,a,i)}function Ti(e,t){let{palette:n,glyphs:r}=t,i=Hr(),a={size:n.metaSize,color:n.inkDim,isBold:!0,isUppercase:!0};e.plan&&J(i,r,kn,e.plan.titleAt.x,e.plan.titleAt.y,a);for(let t of e.legend){wi(i,t,n);let e=t.x+(t.swatch.kind===`status`?22:40);J(i,r,t.label,e,t.y+12,{size:n.metaSize,color:n.inkDim})}return e.caption&&J(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:xr,part:Ur(i)}],hitShape:{kind:`path`,points:[]}}}function Ei(e,t,n,r){if(t.kind===`wire`)q(e,j(t.path),2.6,n,G,U);else if(t.kind===`stroke`)q(e,_i(t),t.strokeWidth+4,n,G,U);else if(t.kind===`box`&&t.shape===`decision`){let i=Rn(t),[a]=i;a&&q(e,[...i,a],r,n,G,U)}else K(e,t,{box:8,frame:12}[t.kind],[0,0,0,0],n,r,U)}function Di(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 Oi(e){return{x:e.x+e.width-10,y:e.y+e.height-10,width:10,height:10}}function ki(e,t){let{palette:n,glyphs:r}=t,i=Hr();for(let t of e){if(t.kind===`selected`||t.kind===`wire-target`){Ei(i,t.element,n.accent,2.4);continue}if(t.kind===`flagged`){Ei(i,t.element,n.waiting,2.4);continue}if(t.kind===`hover-handles`){for(let e of Di(t.box))Wr(i,e,5,n.board,n.accent,Mr,U);K(i,Oi(t.box),2,n.board,n.accent,Mr,U);continue}let e={x:t.element.x+t.element.width,y:t.element.y};Wr(i,e,9,n.waiting,n.cardBackground,2,U),J(i,r,`!`,e.x,e.y+4,{size:n.metaSize,color:n.cardBackground,isBold:!0,anchor:`middle`,minPixels:0})}return Ur(i)}function Ai(e,t,n){let r=e.elements.map((e,t)=>({element:e,index:t})).sort((e,t)=>Cr[e.element.kind]-Cr[t.element.kind]||e.index-t.index).map(({element:e},r)=>{let i=n(e);return i?{...i,paintRank:r}:Ci(e,r,t)});return{chrome:Ti(e,t),elements:r}}var ji={worthALookIds:new Set,flaggedStepIds:new Set},Mi=512,Ni=.75,Pi=4,Fi=7,Ii=6,Li=3,Ri=6,zi=4096,Bi=`#version 300 es
3
3
  precision highp float;
4
4
  uniform vec2 uCamera;
@@ -179,5 +179,5 @@ out vec4 outColor;
179
179
  void main() {
180
180
  float alpha = texture(uImage, vUv).a * uTint.a;
181
181
  outColor = vec4(uTint.rgb * alpha, alpha);
182
- }`,Qi=.85,$i=[{location:1,size:4,offset:0},{location:2,size:2,offset:4},{location:3,size:4,offset:6},{location:4,size:4,offset:10},{location:5,size:1,offset:14},{location:6,size:1,offset:15}],ea=[{location:1,size:4,offset:0},{location:2,size:4,offset:4},{location:3,size:4,offset:8},{location:4,size:1,offset:12},{location:5,size:1,offset:13}],ta=[{location:0,size:2,offset:0},{location:1,size:4,offset:2},{location:2,size:1,offset:6},{location:3,size:1,offset:7}],na=[{location:1,size:4,offset:0},{location:2,size:4,offset:4},{location:3,size:1,offset:8},{location:4,size:4,offset:9},{location:5,size:1,offset:13},{location:6,size:1,offset:14}],ra=[`uCamera`,`uScale`,`uResolution`,`uLodScale`,`uAtlas`,`uRect`,`uImage`,`uDepth`,`uTint`,`uUvRect`,`uClipRadius`],ia=1024,aa=134217728,oa=4/3*4;function sa(e,t){let n={x:0,y:0,width:1,height:1},r=e.rect.width/t.width,i=e.rect.height/t.height;if(e.fit===`fill`){let n=Math.max(r,i),a=e.rect.width/(t.width*n),o=e.rect.height/(t.height*n);return{rect:e.rect,uv:{x:(1-a)/2,y:(1-o)/2,width:a,height:o}}}let a=Math.min(r,i),o=t.width*a,s=t.height*a;return{rect:{x:e.rect.x+(e.rect.width-o)/2,y:e.rect.y+(e.rect.height-s)/2,width:o,height:s},uv:n}}function ca(e){let t=u(e);return t?`${O}/${t}`:null}function la(){return{data:new Float32Array(zi),length:0}}function ua(e,t,n,r){let i=e.length,a=i+t.length;if(a>e.data.length){let t=new Float32Array(Math.max(a,e.data.length*2));t.set(e.data.subarray(0,i)),e.data=t}e.data.set(t,i);for(let t=i+n-1;t<a;t+=n)e.data[t]=r;e.length=a}function da(e,t,n){let r=e.createShader(t);if(!r)throw Error(`the GPU refused a whiteboard shader`);if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)||e.isContextLost())return r;throw Error(`a whiteboard shader did not compile: ${e.getShaderInfoLog(r)??``}`)}function fa(e,t,n){let r=e.createProgram();if(e.attachShader(r,da(e,e.VERTEX_SHADER,t)),e.attachShader(r,da(e,e.FRAGMENT_SHADER,n)),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)||e.isContextLost())return r;throw Error(`a whiteboard shader did not link: ${e.getProgramInfoLog(r)??``}`)}function pa(e,t,n,r,i,a){let o=fa(e,n[0],n[1]),s=e.createVertexArray(),c=e.createBuffer();e.bindVertexArray(s),a&&(e.bindBuffer(e.ARRAY_BUFFER,t),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0)),e.bindBuffer(e.ARRAY_BUFFER,c);for(let t of i)e.enableVertexAttribArray(t.location),a&&e.vertexAttribDivisor(t.location,1);return e.bindVertexArray(null),{program:o,vao:s,buffer:c,bufferFloats:0,strideFloats:r,attributes:i,isInstanced:a,uniforms:new Map(ra.map(t=>[t,e.getUniformLocation(o,t)]))}}function ma(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i,o=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/a));return Math.hypot(e.x-(t.x+o*r),e.y-(t.y+o*i))}function ha(e,t,n=0){return e.x>=t.x-n&&e.x<=t.x+t.width+n&&e.y>=t.y-n&&e.y<=t.y+t.height+n}function ga(e,t){return e.x>=t.x&&e.y>=t.y&&e.x+e.width<=t.x+t.width&&e.y+e.height<=t.y+t.height}function _a(e){let t=document.createElement(`span`);t.style.display=`none`,e.append(t);let n=Object.assign(document.createElement(`canvas`),{width:1,height:1}).getContext(`2d`,{willReadFrequently:!0});function r(e){if(!n)return[0,0,0,1];n.clearRect(0,0,1,1),n.fillStyle=`#000`,n.fillStyle=e,n.fillRect(0,0,1,1);let[t=0,r=0,i=0,a=0]=n.getImageData(0,0,1,1).data;return[t/255,r/255,i/255,a/255]}return{colorOf:e=>(t.style.color=``,t.style.color=e,r(getComputedStyle(t).color)),sizeOf:e=>(t.style.fontSize=e,Number.parseFloat(getComputedStyle(t).fontSize)||12),dispose:()=>t.remove()}}function va(e){return{yellow:e(`yellow`),pink:e(`pink`),green:e(`green`),blue:e(`blue`),violet:e(`violet`)}}function ya(e){let t=_a(e),n={board:t.colorOf(`var(--wb-board)`),ink:t.colorOf(`var(--wb-ink)`),inkDim:t.colorOf(`var(--wb-ink-dim)`),line:t.colorOf(`var(--wb-line)`),accent:t.colorOf(`var(--accent)`),running:t.colorOf(`var(--state-running)`),failed:t.colorOf(`var(--state-failed)`),waiting:t.colorOf(`var(--state-waiting)`),muted:t.colorOf(`var(--text-muted)`),cardBackground:t.colorOf(`var(--bg-card)`),noteStroke:t.colorOf(`var(--wb-note)`),noteCard:t.colorOf(`#2a2213`),codeBand:t.colorOf(`color-mix(in oklab, var(--accent) 14%, var(--wb-board))`),panelFill:t.colorOf(`color-mix(in oklab, var(--wb-board) 80%, var(--bg))`),stickyFillByTone:va(e=>t.colorOf(`color-mix(in oklab, ${a[e]} 30%, var(--wb-board))`)),stickyEdgeByTone:va(e=>t.colorOf(`color-mix(in oklab, ${a[e]} 70%, var(--wb-board))`)),frameFill:t.colorOf(`color-mix(in srgb, var(--accent) 4%, transparent)`),placeholderFill:t.colorOf(`color-mix(in oklab, var(--accent) 8%, var(--wb-board))`),metaSize:t.sizeOf(`var(--type-meta)`),bodySize:t.sizeOf(`var(--type-body)`),titleSize:t.sizeOf(`var(--type-title)`)};return t.dispose(),n}function ba(e){let t=document.documentElement;return[t.className,t.dataset.theme??``,t.getAttribute(`style`)??``,e.className].join(`|`)}function xa(e){let t=1/0;for(let n=13;n<e.glyphs.length;n+=15)t=Math.min(t,e.glyphs[n]??1/0);return t}function Sa(){return{rectStart:0,rectCount:0,segmentStart:0,segmentCount:0,triangleStart:0,triangleCount:0,glyphStart:0,glyphCount:0}}function Ca(e){let{canvas:t,viewport:n,mediaLayer:r,notice:i,onViewChange:a}=e,o={alpha:!0,antialias:!1,depth:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1},s=t.getContext(`webgl2`,o),c=null,l=[],u=new Map,d=``,f=null,p=new WeakMap,m=null,h=``,g=null,_=``,v=null,y=null,b={x:0,y:0,scale:1},x=new Set,S=ji,C=null,w=null,T=null,E=!0,D=null,O=NaN,te=Sa(),ne=Sa(),k=null,re=0,ie=Array.from({length:6},Sa),ae=[],A=new Map,oe=new WeakMap,se=la(),j=la(),ce=la(),M=la(),de=Array.from({length:7},Sa),N=new Map,P=0,pe=0;function he(e){i.hidden=e===null,i.textContent=e??``}function ge(){return g||ve(getComputedStyle(e.fontSource).fontFamily||`monospace`)}function _e(){let t=getComputedStyle(e.fontSource).fontFamily||`monospace`;return g&&(_===t||!e.fontSource.isConnected)?(!v&&!ye(_)&&be(g,_),g):(g&&s&&g.release(s),A.clear(),ve(t))}function ve(e){let t=nr(e);return g=t,_=e,be(t,e),t}function ye(e){return document.fonts.check(`400 48px ${e}`)&&document.fonts.check(`700 48px ${e}`)}function be(e,t){let n=Promise.all([document.fonts.load(`400 48px ${t}`),document.fonts.load(`700 48px ${t}`)]).then(()=>{e.rasterizeAgain(),L()},()=>{}).finally(()=>{v===n&&(v=null)});v=n}function xe(){let e=ba(n);return m&&e===h||(m=ya(n),h=e,A.clear()),m}function Se(e){let t=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW),c={rect:pa(e,t,[Vi,Hi],16,$i,!0),segment:pa(e,t,[Ui,Wi],14,ea,!0),triangle:pa(e,t,[Gi,Ki],8,ta,!1),glyph:pa(e,t,[qi,Ji],15,na,!0),image:pa(e,t,[Yi,Xi],2,[],!0),block:pa(e,t,[Yi,Zi],2,[],!0)};for(let n of[c.image,c.block])e.bindVertexArray(n.vao),e.bindBuffer(e.ARRAY_BUFFER,t),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),E=!0}function Ce(){s?Se(s):he(`This browser cannot draw boards: WebGL2 is turned off or unavailable.`)}function we(){let e=(t.clientWidth||1)/b.scale,n=(t.clientHeight||1)/b.scale;return{x:b.x,y:b.y,width:e,height:n}}function Te(e){return Math.floor(Math.log2(e)*Pi)}function Ee(e){return 2**((e+1)/Pi)}function De(e,t){if(e.glyphs.length===0)return!1;let n=oe.get(e);return n===void 0&&(n=xa(e),oe.set(e,n)),n<=t}function Oe(e,t,n){ua(se,e.rects,16,n),ua(j,e.segments,14,n),ua(ce,e.triangles,8,n),De(e,t)&&ua(M,e.glyphs,15,n)}function ke(e,t){return(e+1)/(t.geometries.length+1)}function Ae(e){e.rectStart=se.length/16,e.segmentStart=j.length/14,e.triangleStart=ce.length/8,e.glyphStart=M.length/15}function je(e){e.rectCount=se.length/16-e.rectStart,e.segmentCount=j.length/14-e.segmentStart,e.triangleCount=ce.length/8-e.triangleStart,e.glyphCount=M.length/15-e.glyphStart}function Me(e){se.length=e.rectStart*16,j.length=e.segmentStart*14,ce.length=e.triangleStart*8,M.length=e.glyphStart*15}function Ne(e,t){let n=[];return me(e.grid,t,e=>{n.push(e)}),n.sort((e,t)=>e-t)}function F(e,t){return k?.elementById.get(t)??e.elementById.get(t)}function Pe(e){let t=[];for(let n of S.flaggedStepIds){let r=F(e,n);r&&t.push({kind:`flagged`,element:r})}for(let n of x){let r=F(e,n);r&&t.push({kind:`selected`,element:r})}let n=C?F(e,C):void 0;n&&t.push({kind:`wire-target`,element:n});let r=document.documentElement.dataset.layout===`phone`?new Set:new Set([...x,...w?[w]:[]]);for(let n of r){let r=F(e,n);r?.kind===`box`&&t.push({kind:`hover-handles`,box:r})}for(let n of S.worthALookIds){let r=F(e,n);r&&r.kind!==`wire`&&t.push({kind:`look`,element:r})}return t}function I(e,t,n){Me(ne),ae.length=re;let r=Ee(O);for(let t=0;t<6;t+=1){let n=ie[t]??Sa();Ae(n);for(let n of k?.geometries??[]){for(let i of n.parts)i.layer===t&&Oe(i.part,r,ke(n.paintRank,e));t===4&&Re(e,n)}je(n)}te=Fe(),Ie(e,t,n)}function Fe(){return{...Sa(),rectStart:se.length/16,segmentStart:j.length/14,triangleStart:ce.length/8,glyphStart:M.length/15}}function Ie(e,t,n){Me(te);let r=de[Ri]??Sa();Ae(r),Oe(ki(Pe(e),{palette:t,glyphs:n,hasDrawnMedia:()=>!1}),1/0,1),je(r)}function Le(e,t,n){let i=we(),a=Te(b.scale),o=Ee(a),s={x:i.x-i.width*Ni,y:i.y-i.height*Ni,width:i.width*2.5,height:i.height*2.5},c=Ne(e,s);se.length=0,j.length=0,ce.length=0,M.length=0,ae=[],P+=1;for(let t=0;t<6;t+=1){let n=de[t]??Sa();Ae(n);for(let n of e.chrome.parts)n.layer===t&&Oe(n.part,o,0);for(let n of c){let r=e.geometries[n];if(r&&!k?.hiddenIds.has(r.id)){for(let n of r.parts)n.layer===t&&Oe(n.part,o,ke(r.paintRank,e));t===4&&Re(e,r)}}je(n)}ne=Fe(),re=ae.length,D=s,O=a,E=!1,I(e,t,n),We(),r.showArea(s)}function Re(e,t){if(t.hitShape.kind!==`rect`||!t.hitShape.hasDrawnMedia)return;let n=F(e,t.id);if(n?.kind!==`box`||!n.media)return;let r=ca(n.media);if(!r)return;let i=n.device?ee[n.device.name].bezel.screenRadius*n.device.scale:0;ae.push({href:r,rect:n.media,fit:n.media.fit,clipRadius:i,depth:ke(t.paintRank,e)}),ze(r,n.media)}function ze(e,t){let n=N.get(e);if(n){n.lastGatherNumber=P;return}let r=ia/Math.max(t.width,t.height,1),i={href:e,texture:null,width:Math.round(t.width*r),height:Math.round(t.height*r),image:new Image,isFailed:!1,textureBytes:0,lastGatherNumber:P};N.set(e,i);let a=i.image;a&&(a.decoding=`async`,a.src=e,a.decode().then(()=>{N.get(e)===i&&(i.width=a.naturalWidth||i.width,i.height=a.naturalHeight||i.height,He(i),L())},()=>{Be(i)}))}function Be(e){e.isFailed=!0;let t=y;t&&(A.clear(),gt(t.layout),L())}function Ve(e,t,n,r){let i=Math.min(1,r/Math.max(t,n)),a=document.createElement(`canvas`);a.width=Math.max(1,Math.floor(t*i)),a.height=Math.max(1,Math.floor(n*i));let o=a.getContext(`2d`);return o?(o.drawImage(e,0,0,a.width,a.height),a):null}function He(e){if(!s||!e.image||e.isFailed)return;let t=Number(s.getParameter(s.MAX_TEXTURE_SIZE)),n=Ve(e.image,e.width,e.height,t);if(!n){Be(e);return}for(;s.getError()!==s.NO_ERROR;);let r=s.createTexture();s.bindTexture(s.TEXTURE_2D,r),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,n),s.getError()===s.NO_ERROR?(s.generateMipmap(s.TEXTURE_2D),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),e.texture=r,e.textureBytes=Math.round(n.width*n.height*oa),We()):(s.deleteTexture(r),Be(e))}function Ue(e,t){s&&t.texture&&s.deleteTexture(t.texture),N.delete(e)}function We(){let e=0;for(let t of N.values())e+=t.textureBytes;if(e<=aa)return;let t=[...N].filter(([,e])=>e.lastGatherNumber!==P).sort(([,e],[,t])=>e.lastGatherNumber-t.lastGatherNumber);for(let[n,r]of t){if(e<=aa)return;e-=r.textureBytes,Ue(n,r)}}function Ge(e){let t=new Set(e.elements.flatMap(e=>{if(e.kind!==`box`||!e.media)return[];let t=ca(e.media);return t?[t]:[]}));for(let[e,n]of N)t.has(e)||Ue(e,n)}function Ke(){for(let[e,t]of N)Ue(e,t)}function qe(e,t){s&&t.length!==0&&(s.bindBuffer(s.ARRAY_BUFFER,e.buffer),t.length>e.bufferFloats&&(e.bufferFloats=t.data.length,s.bufferData(s.ARRAY_BUFFER,t.data.byteLength,s.DYNAMIC_DRAW)),s.bufferSubData(s.ARRAY_BUFFER,0,t.data,0,t.length))}function Je(e,t,n){e.bindBuffer(e.ARRAY_BUFFER,t.buffer);let r=t.strideFloats*4;for(let i of t.attributes)e.vertexAttribPointer(i.location,i.size,e.FLOAT,!1,r,(n*t.strideFloats+i.offset)*4)}function Ye(e,n){let r=window.devicePixelRatio||1;e.useProgram(n.program),e.uniform2f(n.uniforms.get(`uCamera`)??null,b.x,b.y),e.uniform1f(n.uniforms.get(`uScale`)??null,b.scale*r),e.uniform2f(n.uniforms.get(`uResolution`)??null,t.width,t.height),e.uniform1f(n.uniforms.get(`uLodScale`)??null,b.scale)}function Xe(e,t,n,r){r!==0&&(Ye(e,t),e.bindVertexArray(t.vao),Je(e,t,n),e.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,r))}function Ze(e,t,n,r){r!==0&&(Ye(e,t),e.bindVertexArray(t.vao),Je(e,t,0),e.drawArrays(e.TRIANGLES,n,r))}function Qe(e,t){let n=ae.flatMap(e=>{let t=N.get(e.href);return t?.texture?[{drawn:e,entry:t}]:[]});if(n.length!==0){Ye(e,t),e.bindVertexArray(t.vao),e.uniform1i(t.uniforms.get(`uImage`)??null,1),e.activeTexture(e.TEXTURE1);for(let{drawn:r,entry:i}of n){let n=sa(r,i);e.bindTexture(e.TEXTURE_2D,i.texture),e.uniform1f(t.uniforms.get(`uDepth`)??null,r.depth),e.uniform1f(t.uniforms.get(`uClipRadius`)??null,r.clipRadius),e.uniform4f(t.uniforms.get(`uRect`)??null,n.rect.x,n.rect.y,n.rect.width,n.rect.height),e.uniform4f(t.uniforms.get(`uUvRect`)??null,n.uv.x,n.uv.y,n.uv.width,n.uv.height),e.drawArrays(e.TRIANGLE_STRIP,0,4)}}}function $e(e,t){let n=u.get(t.id);if(n?.raster===t.raster)return n.texture;let r=n?.texture??e.createTexture();return e.bindTexture(e.TEXTURE_2D,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,64,64,0,e.RGBA,e.UNSIGNED_BYTE,t.raster),u.set(t.id,{raster:t.raster,texture:r}),r}function et(e){let t=new Set(e.map(e=>e.id));for(let[e,n]of u)t.has(e)||(s?.deleteTexture(n.texture),u.delete(e))}function tt(e,t,n){if(l.length!==0){e.disable(e.DEPTH_TEST),e.depthMask(!1),Ye(e,t),e.bindVertexArray(t.vao),e.uniform1i(t.uniforms.get(`uImage`)??null,1),e.uniform1f(t.uniforms.get(`uDepth`)??null,0),e.uniform4f(t.uniforms.get(`uTint`)??null,n[0],n[1],n[2],Qi),e.uniform4f(t.uniforms.get(`uUvRect`)??null,0,0,1,1),e.activeTexture(e.TEXTURE1);for(let n of l)e.bindTexture(e.TEXTURE_2D,$e(e,n)),e.uniform4f(t.uniforms.get(`uRect`)??null,n.rect.x,n.rect.y,n.rect.width,n.rect.height),e.drawArrays(e.TRIANGLE_STRIP,0,4);e.enable(e.DEPTH_TEST)}}function nt(){if(!a||b.scale<=0)return;let e={x:b.x,y:b.y,width:t.clientWidth/b.scale,height:t.clientHeight/b.scale},n=`${e.x}:${e.y}:${e.width}:${e.height}`;n!==d&&(d=n,a(e,b.scale))}function rt(e,t,n,r){let i=de[r];if(!i)return;let a=[i,...ie[r]?[ie[r]]:[]];r===Ri&&e.disable(e.DEPTH_TEST),e.depthMask(!0);for(let n of a)Ze(e,t.triangle,n.triangleStart,n.triangleCount);for(let n of a)Xe(e,t.rect,n.rectStart,n.rectCount);e.depthMask(!1);for(let n of a)Xe(e,t.segment,n.segmentStart,n.segmentCount);r===4&&Qe(e,t.image);let o=a.filter(e=>e.glyphCount>0);if(o.length!==0){n.bind(e,0),Ye(e,t.glyph),e.uniform1i(t.glyph.uniforms.get(`uAtlas`)??null,0),e.bindVertexArray(t.glyph.vao);for(let n of o)Je(e,t.glyph,n.glyphStart),e.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,n.glyphCount)}}function it(){return E||!D||Te(b.scale)!==O?!0:!ga(we(),D)}function at(){let e=window.devicePixelRatio||1,n=Math.max(1,Math.round(t.clientWidth*e)),r=Math.max(1,Math.round(t.clientHeight*e));(t.width!==n||t.height!==r)&&(t.width=n,t.height=r)}function ot(){T=null;let e=s,r=c;if(!e||!r||e.isContextLost())return;at(),e.viewport(0,0,t.width,t.height),e.clearColor(0,0,0,0),e.clearDepth(0),e.depthMask(!0),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.enable(e.DEPTH_TEST),e.depthFunc(e.GEQUAL),y&&ba(n)!==h&&gt(y.layout);let i=y;if(!i)return;let a=xe();tt(e,r.block,a.inkDim);let o=ge();it()&&Le(i,a,o),qe(r.rect,se),qe(r.segment,j),qe(r.triangle,ce),qe(r.glyph,M);for(let t=0;t<=6;t+=1)rt(e,r,o,t);t.dataset.drawnElements=String(i.geometries.length),t.dataset.mediaTextures=String(N.size)}function L(){T===null&&(T=requestAnimationFrame(ot))}function st(){let e=y;!e||E||Ie(e,xe(),ge()),L()}function ct(e){if(!e.media)return!1;let t=ca(e.media);return t!==null&&N.get(t)?.isFailed!==!0}function lt(e){let t=p.get(e);if(t!==void 0)return t;let n=fe(e);return p.set(e,n),n}function ut(e){if(f?.source===e&&y?.layout===f.layout)return f.layout;let t=le(e);return ht(t,[]),f={source:e,layout:t,blocks:[]},t}function dt(e){k&&(k=null,E=!0,e.hasPageMedia&&r.sync(e.layout,e.geometries.map(e=>e.id)),L())}function ft(e,t){let n=y;f?.source===e&&f.blocks===t&&n?.layout===e?dt(n):(ht(e,t),f={source:e,layout:e,blocks:t})}function pt(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function mt(e){y&&ba(n)!==h&&gt(y.layout);let t=y;if(!t)return;let i=xe(),a=_e(),o={palette:i,glyphs:a,hasDrawnMedia:ct},s=Ai({...t.layout,elements:[...e],legend:[],caption:null,plan:null},o,()=>null).elements.map(e=>({...e,paintRank:t.geometries[t.geometryIndexById.get(e.id)??-1]?.paintRank??0})),c=new Set(e.map(e=>e.id)),l=k!==null&&pt(k.hiddenIds,c);k={hiddenIds:l&&k?k.hiddenIds:c,geometries:s,elementById:new Map(e.map(e=>[e.id,e]))},l||(E=!0),t.hasPageMedia&&r.sync({...t.layout,elements:t.layout.elements.map(e=>k?.elementById.get(e.id)??e)},t.geometries.map(e=>e.id)),!E&&D&&I(t,i,a),L()}function ht(e,t){k=null,g?.isFull()&&(g.forgetUnusedGlyphs(),A.clear()),et(t),l=t,gt(e),L()}function gt(e){let n={palette:xe(),glyphs:_e(),hasDrawnMedia:ct},i=new Map(e.elements.map(e=>[e,lt(e)])),a=Ai(e,n,e=>A.get(i.get(e)??``)??null);A.clear();let o=new Map(e.elements.map(e=>[e.id,e]));for(let e of a.elements){let t=o.get(e.id);t&&A.set(i.get(t)??``,e)}y={layout:e,chrome:a.chrome,geometries:a.elements,geometryIndexById:new Map(a.elements.map((e,t)=>[e.id,t])),elementById:o,grid:ue(a.elements.map(e=>e.bounds),Mi),hasPageMedia:e.elements.some(e=>e.kind===`box`&&(e.media?.kind===`page`||e.media?.kind===`doc`))},Ge(e),r.sync(e,a.elements.map(e=>e.id)),E=!0,pe+=1,t.dataset.sceneBuilds=String(pe)}function _t(e,t,n,r){let i=F(e,t.id);if(!i)return null;let a={id:t.id,kind:t.kind,part:`body`,port:null,linkedBoardId:null,media:null},o=t.hitShape;if(o.kind===`path`){for(let e=1;e<o.points.length;e+=1){let t=o.points[e-1],i=o.points[e];if(t&&i&&ma(n,t,i)<=r)return a}return null}if(o.kind===`outline`){if(ha(n,o.titleRect))return a;let e=Ii/Fi*r;return ha(n,o.rect,e)&&!ha({x:n.x,y:n.y},{x:o.rect.x+e,y:o.rect.y+e,width:o.rect.width-e*2,height:o.rect.height-e*2})?a:null}let s=5+Li/Fi*r;if(i.kind===`box`&&ha(n,Oi(i),Li/Fi*r))return{...a,part:`resize`};if(i.kind===`box`){let e=Di(i).find(e=>Math.hypot(e.x-n.x,e.y-n.y)<=s);if(e)return{...a,part:`port`,port:e}}if(!ha(n,o.rect))return null;if(o.linkRect&&ha(n,o.linkRect))return{...a,part:`link`,linkedBoardId:o.linkRect.linkedBoardId};if(o.mediaRect&&i.kind===`box`&&i.media&&ha(n,o.mediaRect)){let e=i.media.kind===`image`?ca(i.media)??``:``;return{...a,part:`media`,media:{href:e,alt:i.media.alt}}}return a}function vt(e){let t=y;if(!t)return null;let n=Fi/b.scale,r=5+n,i=null,a=-1,o=r=>{if(r.paintRank<=a)return;let o=_t(t,r,e,n);o&&(i=o,a=r.paintRank)};me(t.grid,{x:e.x-r,y:e.y-r,width:r*2,height:r*2},e=>{let n=t.geometries[e];n&&!k?.hiddenIds.has(n.id)&&o(n)});for(let e of k?.geometries??[])o(e);return i}function yt(e){let t=y;if(!t)return null;let n=F(t,e);if(n&&n.kind!==`wire`)return{x:n.x,y:n.y,width:n.width,height:n.height};let r=k?.geometries.find(t=>t.id===e);if(r)return r.bounds;let i=t.geometryIndexById.get(e);return i===void 0?null:t.geometries[i]?.bounds??null}function bt(e){let t=y;if(!t)return[];let n=[];return me(t.grid,{x:e.x,y:e.y,width:1,height:1},r=>{let i=t.elementById.get(t.geometries[r]?.id??``),a=i?.kind===`box`&&e.x>=i.x&&e.x<=i.x+i.width&&e.y>=i.y&&e.y<=i.y+i.height;i&&a&&!n.includes(i.id)&&n.push(i.id)}),n}function xt(e){let t=y;if(!t)return[];let n=[];me(t.grid,e,r=>{let i=t.geometries[r]?.id??``,a=k?.hiddenIds.has(i)?void 0:t.elementById.get(i);a&&a.kind!==`wire`&&ga(a,e)&&n.push(a.id)});for(let t of k?.elementById.values()??[])t.kind!==`wire`&&ga(t,e)&&n.push(t.id);return n}function St(){y=null,k=null,f=null,et([]),l=[],d=``,nt(),A.clear(),Ke(),r.clear(),w=null,C=null,E=!0,L()}t.addEventListener(`webglcontextlost`,e=>{e.preventDefault(),c=null,g?.forgetTexture();for(let e of N.values())e.texture=null;u.clear(),he(`The board is redrawing after the graphics card reset.`)}),t.addEventListener(`webglcontextrestored`,()=>{s=t.getContext(`webgl2`,o),Ce();for(let e of N.values())He(e);he(null),L()}),new ResizeObserver(()=>{nt(),E=!0,L()}).observe(t);let Ct=()=>{y&&ba(n)!==h&&L()};return new MutationObserver(Ct).observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]}),new MutationObserver(Ct).observe(n,{attributes:!0,attributeFilter:[`class`]}),Ce(),{render:ut,renderLayout:ft,layout:()=>f?.layout??null,paintElements:mt,setCamera:e=>{b=e,nt(),L()},hitTest:vt,boundsOf:yt,elementsInRect:xt,boxIdsAt:bt,setSelection:e=>{x=e,st()},setReviewMarks:e=>{S=e,st()},setWireTarget:e=>{C!==e&&(C=e,st())},setHover:e=>{w!==e&&(w=e,st())},clear:St}}var wa={page:1280,doc:800},Ta=16384,Ea=`This document could not be read.`,Da=8,Oa={background:`--bg-card`,text:`--text`,accent:`--accent`,line:`--border`};function ka(e){return e?.kind===`page`||e?.kind===`doc`}function Aa(e){return JSON.stringify([e.asset,e.mime,e.alt])}function ja(e,t){e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`;let n=e.querySelector(`.wb-media-page, .wb-media-doc`);if(!n)return;let r=wa[t.kind],i=t.width/r;n.style.width=`${r}px`,n.style.height=`${t.height/i}px`,n.style.transform=`scale(${i})`}function Ma(e){return e.kind!==`wire`&&e.kind!==`frame`}function Na(e,t){return t.x-Da<e.x+e.width&&t.x+t.width+Da>e.x&&t.y-Da<e.y+e.height&&t.y+t.height+Da>e.y}function Pa(e,t,n){let r=n.findIndex(t=>t.id===e);return n.slice(r+1).filter(Ma).filter(e=>Na(t,e))}function Fa(e,t){let n=t??``;e.style.maskImage!==n&&(e.style.maskImage=n,e.style.setProperty(`-webkit-mask-image`,n))}async function Ia(e){let t=await fetch(`${O}/${d(e)}`).catch(()=>null);return t?.ok?t.text().catch(()=>null):null}function La(e){if(e.length<=Ta)return e;let t=e.lastIndexOf(`
182
+ }`,Qi=.85,$i=[{location:1,size:4,offset:0},{location:2,size:2,offset:4},{location:3,size:4,offset:6},{location:4,size:4,offset:10},{location:5,size:1,offset:14},{location:6,size:1,offset:15}],ea=[{location:1,size:4,offset:0},{location:2,size:4,offset:4},{location:3,size:4,offset:8},{location:4,size:1,offset:12},{location:5,size:1,offset:13}],ta=[{location:0,size:2,offset:0},{location:1,size:4,offset:2},{location:2,size:1,offset:6},{location:3,size:1,offset:7}],na=[{location:1,size:4,offset:0},{location:2,size:4,offset:4},{location:3,size:1,offset:8},{location:4,size:4,offset:9},{location:5,size:1,offset:13},{location:6,size:1,offset:14}],ra=[`uCamera`,`uScale`,`uResolution`,`uLodScale`,`uAtlas`,`uRect`,`uImage`,`uDepth`,`uTint`,`uUvRect`,`uClipRadius`],ia=1024,aa=134217728,oa=4/3*4;function sa(e,t){let n={x:0,y:0,width:1,height:1},r=e.rect.width/t.width,i=e.rect.height/t.height;if(e.fit===`fill`){let n=Math.max(r,i),a=e.rect.width/(t.width*n),o=e.rect.height/(t.height*n);return{rect:e.rect,uv:{x:(1-a)/2,y:(1-o)/2,width:a,height:o}}}let a=Math.min(r,i),o=t.width*a,s=t.height*a;return{rect:{x:e.rect.x+(e.rect.width-o)/2,y:e.rect.y+(e.rect.height-s)/2,width:o,height:s},uv:n}}function ca(e){let t=u(e);return t?`${O}/${t}`:null}function la(){return{data:new Float32Array(zi),length:0}}function ua(e,t,n,r){let i=e.length,a=i+t.length;if(a>e.data.length){let t=new Float32Array(Math.max(a,e.data.length*2));t.set(e.data.subarray(0,i)),e.data=t}e.data.set(t,i);for(let t=i+n-1;t<a;t+=n)e.data[t]=r;e.length=a}function da(e,t,n){let r=e.createShader(t);if(!r)throw Error(`the GPU refused a whiteboard shader`);if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)||e.isContextLost())return r;throw Error(`a whiteboard shader did not compile: ${e.getShaderInfoLog(r)??``}`)}function fa(e,t,n){let r=e.createProgram();if(e.attachShader(r,da(e,e.VERTEX_SHADER,t)),e.attachShader(r,da(e,e.FRAGMENT_SHADER,n)),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)||e.isContextLost())return r;throw Error(`a whiteboard shader did not link: ${e.getProgramInfoLog(r)??``}`)}function pa(e,t,n,r,i,a){let o=fa(e,n[0],n[1]),s=e.createVertexArray(),c=e.createBuffer();e.bindVertexArray(s),a&&(e.bindBuffer(e.ARRAY_BUFFER,t),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0)),e.bindBuffer(e.ARRAY_BUFFER,c);for(let t of i)e.enableVertexAttribArray(t.location),a&&e.vertexAttribDivisor(t.location,1);return e.bindVertexArray(null),{program:o,vao:s,buffer:c,bufferFloats:0,strideFloats:r,attributes:i,isInstanced:a,uniforms:new Map(ra.map(t=>[t,e.getUniformLocation(o,t)]))}}function ma(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i,o=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/a));return Math.hypot(e.x-(t.x+o*r),e.y-(t.y+o*i))}function ha(e,t,n=0){return e.x>=t.x-n&&e.x<=t.x+t.width+n&&e.y>=t.y-n&&e.y<=t.y+t.height+n}function ga(e,t){return e.x>=t.x&&e.y>=t.y&&e.x+e.width<=t.x+t.width&&e.y+e.height<=t.y+t.height}function _a(e){let t=document.createElement(`span`);t.style.display=`none`,e.append(t);let n=Object.assign(document.createElement(`canvas`),{width:1,height:1}).getContext(`2d`,{willReadFrequently:!0});function r(e){if(!n)return[0,0,0,1];n.clearRect(0,0,1,1),n.fillStyle=`#000`,n.fillStyle=e,n.fillRect(0,0,1,1);let[t=0,r=0,i=0,a=0]=n.getImageData(0,0,1,1).data;return[t/255,r/255,i/255,a/255]}return{colorOf:e=>(t.style.color=``,t.style.color=e,r(getComputedStyle(t).color)),sizeOf:e=>(t.style.fontSize=e,Number.parseFloat(getComputedStyle(t).fontSize)||12),dispose:()=>t.remove()}}function va(e){return{yellow:e(`yellow`),pink:e(`pink`),green:e(`green`),blue:e(`blue`),violet:e(`violet`)}}function ya(e){let t=_a(e),n={board:t.colorOf(`var(--wb-board)`),ink:t.colorOf(`var(--wb-ink)`),inkDim:t.colorOf(`var(--wb-ink-dim)`),line:t.colorOf(`var(--wb-line)`),accent:t.colorOf(`var(--accent)`),running:t.colorOf(`var(--state-running)`),failed:t.colorOf(`var(--state-failed)`),waiting:t.colorOf(`var(--state-waiting)`),muted:t.colorOf(`var(--text-muted)`),cardBackground:t.colorOf(`var(--bg-card)`),noteStroke:t.colorOf(`var(--wb-note)`),noteCard:t.colorOf(`#2a2213`),codeBand:t.colorOf(`color-mix(in oklab, var(--accent) 14%, var(--wb-board))`),panelFill:t.colorOf(`color-mix(in oklab, var(--wb-board) 80%, var(--bg))`),stickyFillByTone:va(e=>t.colorOf(`color-mix(in oklab, ${a[e]} 30%, var(--wb-board))`)),stickyEdgeByTone:va(e=>t.colorOf(`color-mix(in oklab, ${a[e]} 70%, var(--wb-board))`)),frameFill:t.colorOf(`color-mix(in srgb, var(--accent) 4%, transparent)`),placeholderFill:t.colorOf(`color-mix(in oklab, var(--accent) 8%, var(--wb-board))`),metaSize:t.sizeOf(`var(--type-meta)`),bodySize:t.sizeOf(`var(--type-body)`),titleSize:t.sizeOf(`var(--type-title)`)};return t.dispose(),n}function ba(e){let t=document.documentElement;return[t.className,t.dataset.theme??``,t.getAttribute(`style`)??``,e.className,e.isConnected].join(`|`)}function xa(e){let t=1/0;for(let n=13;n<e.glyphs.length;n+=15)t=Math.min(t,e.glyphs[n]??1/0);return t}function Sa(){return{rectStart:0,rectCount:0,segmentStart:0,segmentCount:0,triangleStart:0,triangleCount:0,glyphStart:0,glyphCount:0}}function Ca(e){let{canvas:t,viewport:n,mediaLayer:r,notice:i,onViewChange:a}=e,o={alpha:!0,antialias:!1,depth:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1},s=t.getContext(`webgl2`,o),c=null,l=[],u=new Map,d=``,f=null,p=new WeakMap,m=null,h=``,g=null,_=``,v=null,y=null,b={x:0,y:0,scale:1},x=new Set,S=ji,C=null,w=null,T=null,E=!0,D=null,O=NaN,te=Sa(),ne=Sa(),k=null,re=0,ie=Array.from({length:6},Sa),ae=[],A=new Map,oe=new WeakMap,se=la(),j=la(),ce=la(),M=la(),de=Array.from({length:7},Sa),N=new Map,P=0,pe=0;function he(e){i.hidden=e===null,i.textContent=e??``}function ge(){return g||ve(getComputedStyle(e.fontSource).fontFamily||`monospace`)}function _e(){let t=getComputedStyle(e.fontSource).fontFamily||`monospace`;return g&&(_===t||!e.fontSource.isConnected)?(!v&&!ye(_)&&be(g,_),g):(g&&s&&g.release(s),A.clear(),ve(t))}function ve(e){let t=nr(e);return g=t,_=e,be(t,e),t}function ye(e){return document.fonts.check(`400 48px ${e}`)&&document.fonts.check(`700 48px ${e}`)}function be(e,t){let n=Promise.all([document.fonts.load(`400 48px ${t}`),document.fonts.load(`700 48px ${t}`)]).then(()=>{e.rasterizeAgain(),L()},()=>{}).finally(()=>{v===n&&(v=null)});v=n}function xe(){let e=ba(n);return m&&e===h||(m=ya(n),h=e,A.clear()),m}function Se(e){let t=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW),c={rect:pa(e,t,[Vi,Hi],16,$i,!0),segment:pa(e,t,[Ui,Wi],14,ea,!0),triangle:pa(e,t,[Gi,Ki],8,ta,!1),glyph:pa(e,t,[qi,Ji],15,na,!0),image:pa(e,t,[Yi,Xi],2,[],!0),block:pa(e,t,[Yi,Zi],2,[],!0)};for(let n of[c.image,c.block])e.bindVertexArray(n.vao),e.bindBuffer(e.ARRAY_BUFFER,t),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),E=!0}function Ce(){s?Se(s):he(`This browser cannot draw boards: WebGL2 is turned off or unavailable.`)}function we(){let e=(t.clientWidth||1)/b.scale,n=(t.clientHeight||1)/b.scale;return{x:b.x,y:b.y,width:e,height:n}}function Te(e){return Math.floor(Math.log2(e)*Pi)}function Ee(e){return 2**((e+1)/Pi)}function De(e,t){if(e.glyphs.length===0)return!1;let n=oe.get(e);return n===void 0&&(n=xa(e),oe.set(e,n)),n<=t}function Oe(e,t,n){ua(se,e.rects,16,n),ua(j,e.segments,14,n),ua(ce,e.triangles,8,n),De(e,t)&&ua(M,e.glyphs,15,n)}function ke(e,t){return(e+1)/(t.geometries.length+1)}function Ae(e){e.rectStart=se.length/16,e.segmentStart=j.length/14,e.triangleStart=ce.length/8,e.glyphStart=M.length/15}function je(e){e.rectCount=se.length/16-e.rectStart,e.segmentCount=j.length/14-e.segmentStart,e.triangleCount=ce.length/8-e.triangleStart,e.glyphCount=M.length/15-e.glyphStart}function Me(e){se.length=e.rectStart*16,j.length=e.segmentStart*14,ce.length=e.triangleStart*8,M.length=e.glyphStart*15}function Ne(e,t){let n=[];return me(e.grid,t,e=>{n.push(e)}),n.sort((e,t)=>e-t)}function F(e,t){return k?.elementById.get(t)??e.elementById.get(t)}function Pe(e){let t=[];for(let n of S.flaggedStepIds){let r=F(e,n);r&&t.push({kind:`flagged`,element:r})}for(let n of x){let r=F(e,n);r&&t.push({kind:`selected`,element:r})}let n=C?F(e,C):void 0;n&&t.push({kind:`wire-target`,element:n});let r=document.documentElement.dataset.layout===`phone`?new Set:new Set([...x,...w?[w]:[]]);for(let n of r){let r=F(e,n);r?.kind===`box`&&t.push({kind:`hover-handles`,box:r})}for(let n of S.worthALookIds){let r=F(e,n);r&&r.kind!==`wire`&&t.push({kind:`look`,element:r})}return t}function I(e,t,n){Me(ne),ae.length=re;let r=Ee(O);for(let t=0;t<6;t+=1){let n=ie[t]??Sa();Ae(n);for(let n of k?.geometries??[]){for(let i of n.parts)i.layer===t&&Oe(i.part,r,ke(n.paintRank,e));t===4&&Re(e,n)}je(n)}te=Fe(),Ie(e,t,n)}function Fe(){return{...Sa(),rectStart:se.length/16,segmentStart:j.length/14,triangleStart:ce.length/8,glyphStart:M.length/15}}function Ie(e,t,n){Me(te);let r=de[Ri]??Sa();Ae(r),Oe(ki(Pe(e),{palette:t,glyphs:n,hasDrawnMedia:()=>!1}),1/0,1),je(r)}function Le(e,t,n){let i=we(),a=Te(b.scale),o=Ee(a),s={x:i.x-i.width*Ni,y:i.y-i.height*Ni,width:i.width*2.5,height:i.height*2.5},c=Ne(e,s);se.length=0,j.length=0,ce.length=0,M.length=0,ae=[],P+=1;for(let t=0;t<6;t+=1){let n=de[t]??Sa();Ae(n);for(let n of e.chrome.parts)n.layer===t&&Oe(n.part,o,0);for(let n of c){let r=e.geometries[n];if(r&&!k?.hiddenIds.has(r.id)){for(let n of r.parts)n.layer===t&&Oe(n.part,o,ke(r.paintRank,e));t===4&&Re(e,r)}}je(n)}ne=Fe(),re=ae.length,D=s,O=a,E=!1,I(e,t,n),We(),r.showArea(s)}function Re(e,t){if(t.hitShape.kind!==`rect`||!t.hitShape.hasDrawnMedia)return;let n=F(e,t.id);if(n?.kind!==`box`||!n.media)return;let r=ca(n.media);if(!r)return;let i=n.device?ee[n.device.name].bezel.screenRadius*n.device.scale:0;ae.push({href:r,rect:n.media,fit:n.media.fit,clipRadius:i,depth:ke(t.paintRank,e)}),ze(r,n.media)}function ze(e,t){let n=N.get(e);if(n){n.lastGatherNumber=P;return}let r=ia/Math.max(t.width,t.height,1),i={href:e,texture:null,width:Math.round(t.width*r),height:Math.round(t.height*r),image:new Image,isFailed:!1,textureBytes:0,lastGatherNumber:P};N.set(e,i);let a=i.image;a&&(a.decoding=`async`,a.src=e,a.decode().then(()=>{N.get(e)===i&&(i.width=a.naturalWidth||i.width,i.height=a.naturalHeight||i.height,He(i),L())},()=>{Be(i)}))}function Be(e){e.isFailed=!0;let t=y;t&&(A.clear(),gt(t.layout),L())}function Ve(e,t,n,r){let i=Math.min(1,r/Math.max(t,n)),a=document.createElement(`canvas`);a.width=Math.max(1,Math.floor(t*i)),a.height=Math.max(1,Math.floor(n*i));let o=a.getContext(`2d`);return o?(o.drawImage(e,0,0,a.width,a.height),a):null}function He(e){if(!s||!e.image||e.isFailed)return;let t=Number(s.getParameter(s.MAX_TEXTURE_SIZE)),n=Ve(e.image,e.width,e.height,t);if(!n){Be(e);return}for(;s.getError()!==s.NO_ERROR;);let r=s.createTexture();s.bindTexture(s.TEXTURE_2D,r),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,n),s.getError()===s.NO_ERROR?(s.generateMipmap(s.TEXTURE_2D),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),e.texture=r,e.textureBytes=Math.round(n.width*n.height*oa),We()):(s.deleteTexture(r),Be(e))}function Ue(e,t){s&&t.texture&&s.deleteTexture(t.texture),N.delete(e)}function We(){let e=0;for(let t of N.values())e+=t.textureBytes;if(e<=aa)return;let t=[...N].filter(([,e])=>e.lastGatherNumber!==P).sort(([,e],[,t])=>e.lastGatherNumber-t.lastGatherNumber);for(let[n,r]of t){if(e<=aa)return;e-=r.textureBytes,Ue(n,r)}}function Ge(e){let t=new Set(e.elements.flatMap(e=>{if(e.kind!==`box`||!e.media)return[];let t=ca(e.media);return t?[t]:[]}));for(let[e,n]of N)t.has(e)||Ue(e,n)}function Ke(){for(let[e,t]of N)Ue(e,t)}function qe(e,t){s&&t.length!==0&&(s.bindBuffer(s.ARRAY_BUFFER,e.buffer),t.length>e.bufferFloats&&(e.bufferFloats=t.data.length,s.bufferData(s.ARRAY_BUFFER,t.data.byteLength,s.DYNAMIC_DRAW)),s.bufferSubData(s.ARRAY_BUFFER,0,t.data,0,t.length))}function Je(e,t,n){e.bindBuffer(e.ARRAY_BUFFER,t.buffer);let r=t.strideFloats*4;for(let i of t.attributes)e.vertexAttribPointer(i.location,i.size,e.FLOAT,!1,r,(n*t.strideFloats+i.offset)*4)}function Ye(e,n){let r=window.devicePixelRatio||1;e.useProgram(n.program),e.uniform2f(n.uniforms.get(`uCamera`)??null,b.x,b.y),e.uniform1f(n.uniforms.get(`uScale`)??null,b.scale*r),e.uniform2f(n.uniforms.get(`uResolution`)??null,t.width,t.height),e.uniform1f(n.uniforms.get(`uLodScale`)??null,b.scale)}function Xe(e,t,n,r){r!==0&&(Ye(e,t),e.bindVertexArray(t.vao),Je(e,t,n),e.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,r))}function Ze(e,t,n,r){r!==0&&(Ye(e,t),e.bindVertexArray(t.vao),Je(e,t,0),e.drawArrays(e.TRIANGLES,n,r))}function Qe(e,t){let n=ae.flatMap(e=>{let t=N.get(e.href);return t?.texture?[{drawn:e,entry:t}]:[]});if(n.length!==0){Ye(e,t),e.bindVertexArray(t.vao),e.uniform1i(t.uniforms.get(`uImage`)??null,1),e.activeTexture(e.TEXTURE1);for(let{drawn:r,entry:i}of n){let n=sa(r,i);e.bindTexture(e.TEXTURE_2D,i.texture),e.uniform1f(t.uniforms.get(`uDepth`)??null,r.depth),e.uniform1f(t.uniforms.get(`uClipRadius`)??null,r.clipRadius),e.uniform4f(t.uniforms.get(`uRect`)??null,n.rect.x,n.rect.y,n.rect.width,n.rect.height),e.uniform4f(t.uniforms.get(`uUvRect`)??null,n.uv.x,n.uv.y,n.uv.width,n.uv.height),e.drawArrays(e.TRIANGLE_STRIP,0,4)}}}function $e(e,t){let n=u.get(t.id);if(n?.raster===t.raster)return n.texture;let r=n?.texture??e.createTexture();return e.bindTexture(e.TEXTURE_2D,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,64,64,0,e.RGBA,e.UNSIGNED_BYTE,t.raster),u.set(t.id,{raster:t.raster,texture:r}),r}function et(e){let t=new Set(e.map(e=>e.id));for(let[e,n]of u)t.has(e)||(s?.deleteTexture(n.texture),u.delete(e))}function tt(e,t,n){if(l.length!==0){e.disable(e.DEPTH_TEST),e.depthMask(!1),Ye(e,t),e.bindVertexArray(t.vao),e.uniform1i(t.uniforms.get(`uImage`)??null,1),e.uniform1f(t.uniforms.get(`uDepth`)??null,0),e.uniform4f(t.uniforms.get(`uTint`)??null,n[0],n[1],n[2],Qi),e.uniform4f(t.uniforms.get(`uUvRect`)??null,0,0,1,1),e.activeTexture(e.TEXTURE1);for(let n of l)e.bindTexture(e.TEXTURE_2D,$e(e,n)),e.uniform4f(t.uniforms.get(`uRect`)??null,n.rect.x,n.rect.y,n.rect.width,n.rect.height),e.drawArrays(e.TRIANGLE_STRIP,0,4);e.enable(e.DEPTH_TEST)}}function nt(){if(!a||b.scale<=0)return;let e={x:b.x,y:b.y,width:t.clientWidth/b.scale,height:t.clientHeight/b.scale},n=`${e.x}:${e.y}:${e.width}:${e.height}`;n!==d&&(d=n,a(e,b.scale))}function rt(e,t,n,r){let i=de[r];if(!i)return;let a=[i,...ie[r]?[ie[r]]:[]];r===Ri&&e.disable(e.DEPTH_TEST),e.depthMask(!0);for(let n of a)Ze(e,t.triangle,n.triangleStart,n.triangleCount);for(let n of a)Xe(e,t.rect,n.rectStart,n.rectCount);e.depthMask(!1);for(let n of a)Xe(e,t.segment,n.segmentStart,n.segmentCount);r===4&&Qe(e,t.image);let o=a.filter(e=>e.glyphCount>0);if(o.length!==0){n.bind(e,0),Ye(e,t.glyph),e.uniform1i(t.glyph.uniforms.get(`uAtlas`)??null,0),e.bindVertexArray(t.glyph.vao);for(let n of o)Je(e,t.glyph,n.glyphStart),e.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,n.glyphCount)}}function it(){return E||!D||Te(b.scale)!==O?!0:!ga(we(),D)}function at(){let e=window.devicePixelRatio||1,n=Math.max(1,Math.round(t.clientWidth*e)),r=Math.max(1,Math.round(t.clientHeight*e));(t.width!==n||t.height!==r)&&(t.width=n,t.height=r)}function ot(){T=null;let e=s,r=c;if(!e||!r||e.isContextLost())return;at(),e.viewport(0,0,t.width,t.height),e.clearColor(0,0,0,0),e.clearDepth(0),e.depthMask(!0),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.enable(e.DEPTH_TEST),e.depthFunc(e.GEQUAL),y&&ba(n)!==h&&gt(y.layout);let i=y;if(!i)return;let a=xe();tt(e,r.block,a.inkDim);let o=ge();it()&&Le(i,a,o),qe(r.rect,se),qe(r.segment,j),qe(r.triangle,ce),qe(r.glyph,M);for(let t=0;t<=6;t+=1)rt(e,r,o,t);t.dataset.drawnElements=String(i.geometries.length),t.dataset.mediaTextures=String(N.size)}function L(){T===null&&(T=requestAnimationFrame(ot))}function st(){let e=y;!e||E||Ie(e,xe(),ge()),L()}function ct(e){if(!e.media)return!1;let t=ca(e.media);return t!==null&&N.get(t)?.isFailed!==!0}function lt(e){let t=p.get(e);if(t!==void 0)return t;let n=fe(e);return p.set(e,n),n}function ut(e){if(f?.source===e&&y?.layout===f.layout)return f.layout;let t=le(e);return ht(t,[]),f={source:e,layout:t,blocks:[]},t}function dt(e){k&&(k=null,E=!0,e.hasPageMedia&&r.sync(e.layout,e.geometries.map(e=>e.id)),L())}function ft(e,t){let n=y;f?.source===e&&f.blocks===t&&n?.layout===e?dt(n):(ht(e,t),f={source:e,layout:e,blocks:t})}function pt(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function mt(e){y&&ba(n)!==h&&gt(y.layout);let t=y;if(!t)return;let i=xe(),a=_e(),o={palette:i,glyphs:a,hasDrawnMedia:ct},s=Ai({...t.layout,elements:[...e],legend:[],caption:null,plan:null},o,()=>null).elements.map(e=>({...e,paintRank:t.geometries[t.geometryIndexById.get(e.id)??-1]?.paintRank??0})),c=new Set(e.map(e=>e.id)),l=k!==null&&pt(k.hiddenIds,c);k={hiddenIds:l&&k?k.hiddenIds:c,geometries:s,elementById:new Map(e.map(e=>[e.id,e]))},l||(E=!0),t.hasPageMedia&&r.sync({...t.layout,elements:t.layout.elements.map(e=>k?.elementById.get(e.id)??e)},t.geometries.map(e=>e.id)),!E&&D&&I(t,i,a),L()}function ht(e,t){k=null,g?.isFull()&&(g.forgetUnusedGlyphs(),A.clear()),et(t),l=t,gt(e),L()}function gt(e){let n={palette:xe(),glyphs:_e(),hasDrawnMedia:ct},i=new Map(e.elements.map(e=>[e,lt(e)])),a=Ai(e,n,e=>A.get(i.get(e)??``)??null);A.clear();let o=new Map(e.elements.map(e=>[e.id,e]));for(let e of a.elements){let t=o.get(e.id);t&&A.set(i.get(t)??``,e)}y={layout:e,chrome:a.chrome,geometries:a.elements,geometryIndexById:new Map(a.elements.map((e,t)=>[e.id,t])),elementById:o,grid:ue(a.elements.map(e=>e.bounds),Mi),hasPageMedia:e.elements.some(e=>e.kind===`box`&&(e.media?.kind===`page`||e.media?.kind===`doc`))},Ge(e),r.sync(e,a.elements.map(e=>e.id)),E=!0,pe+=1,t.dataset.sceneBuilds=String(pe)}function _t(e,t,n,r){let i=F(e,t.id);if(!i)return null;let a={id:t.id,kind:t.kind,part:`body`,port:null,linkedBoardId:null,media:null},o=t.hitShape;if(o.kind===`path`){for(let e=1;e<o.points.length;e+=1){let t=o.points[e-1],i=o.points[e];if(t&&i&&ma(n,t,i)<=r)return a}return null}if(o.kind===`outline`){if(ha(n,o.titleRect))return a;let e=Ii/Fi*r;return ha(n,o.rect,e)&&!ha({x:n.x,y:n.y},{x:o.rect.x+e,y:o.rect.y+e,width:o.rect.width-e*2,height:o.rect.height-e*2})?a:null}let s=5+Li/Fi*r;if(i.kind===`box`&&ha(n,Oi(i),Li/Fi*r))return{...a,part:`resize`};if(i.kind===`box`){let e=Di(i).find(e=>Math.hypot(e.x-n.x,e.y-n.y)<=s);if(e)return{...a,part:`port`,port:e}}if(!ha(n,o.rect))return null;if(o.linkRect&&ha(n,o.linkRect))return{...a,part:`link`,linkedBoardId:o.linkRect.linkedBoardId};if(o.mediaRect&&i.kind===`box`&&i.media&&ha(n,o.mediaRect)){let e=i.media.kind===`image`?ca(i.media)??``:``;return{...a,part:`media`,media:{href:e,alt:i.media.alt}}}return a}function vt(e){let t=y;if(!t)return null;let n=Fi/b.scale,r=5+n,i=null,a=-1,o=r=>{if(r.paintRank<=a)return;let o=_t(t,r,e,n);o&&(i=o,a=r.paintRank)};me(t.grid,{x:e.x-r,y:e.y-r,width:r*2,height:r*2},e=>{let n=t.geometries[e];n&&!k?.hiddenIds.has(n.id)&&o(n)});for(let e of k?.geometries??[])o(e);return i}function yt(e){let t=y;if(!t)return null;let n=F(t,e);if(n&&n.kind!==`wire`)return{x:n.x,y:n.y,width:n.width,height:n.height};let r=k?.geometries.find(t=>t.id===e);if(r)return r.bounds;let i=t.geometryIndexById.get(e);return i===void 0?null:t.geometries[i]?.bounds??null}function bt(e){let t=y;if(!t)return[];let n=[];return me(t.grid,{x:e.x,y:e.y,width:1,height:1},r=>{let i=t.elementById.get(t.geometries[r]?.id??``),a=i?.kind===`box`&&e.x>=i.x&&e.x<=i.x+i.width&&e.y>=i.y&&e.y<=i.y+i.height;i&&a&&!n.includes(i.id)&&n.push(i.id)}),n}function xt(e){let t=y;if(!t)return[];let n=[];me(t.grid,e,r=>{let i=t.geometries[r]?.id??``,a=k?.hiddenIds.has(i)?void 0:t.elementById.get(i);a&&a.kind!==`wire`&&ga(a,e)&&n.push(a.id)});for(let t of k?.elementById.values()??[])t.kind!==`wire`&&ga(t,e)&&n.push(t.id);return n}function St(){y=null,k=null,f=null,et([]),l=[],d=``,nt(),A.clear(),Ke(),r.clear(),w=null,C=null,E=!0,L()}t.addEventListener(`webglcontextlost`,e=>{e.preventDefault(),c=null,g?.forgetTexture();for(let e of N.values())e.texture=null;u.clear(),he(`The board is redrawing after the graphics card reset.`)}),t.addEventListener(`webglcontextrestored`,()=>{s=t.getContext(`webgl2`,o),Ce();for(let e of N.values())He(e);he(null),L()}),new ResizeObserver(()=>{nt(),E=!0,L()}).observe(t);let Ct=()=>{y&&ba(n)!==h&&L()};return new MutationObserver(Ct).observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]}),new MutationObserver(Ct).observe(n,{attributes:!0,attributeFilter:[`class`]}),Ce(),{render:ut,renderLayout:ft,layout:()=>f?.layout??null,paintElements:mt,setCamera:e=>{b=e,nt(),L()},hitTest:vt,boundsOf:yt,elementsInRect:xt,boxIdsAt:bt,setSelection:e=>{x=e,st()},setReviewMarks:e=>{S=e,st()},setWireTarget:e=>{C!==e&&(C=e,st())},setHover:e=>{w!==e&&(w=e,st())},clear:St}}var wa={page:1280,doc:800},Ta=16384,Ea=`This document could not be read.`,Da=8,Oa={background:`--bg-card`,text:`--text`,accent:`--accent`,line:`--border`};function ka(e){return e?.kind===`page`||e?.kind===`doc`}function Aa(e){return JSON.stringify([e.asset,e.mime,e.alt])}function ja(e,t){e.style.left=`${t.x}px`,e.style.top=`${t.y}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`;let n=e.querySelector(`.wb-media-page, .wb-media-doc`);if(!n)return;let r=wa[t.kind],i=t.width/r;n.style.width=`${r}px`,n.style.height=`${t.height/i}px`,n.style.transform=`scale(${i})`}function Ma(e){return e.kind!==`wire`&&e.kind!==`frame`}function Na(e,t){return t.x-Da<e.x+e.width&&t.x+t.width+Da>e.x&&t.y-Da<e.y+e.height&&t.y+t.height+Da>e.y}function Pa(e,t,n){let r=n.findIndex(t=>t.id===e);return n.slice(r+1).filter(Ma).filter(e=>Na(t,e))}function Fa(e,t){let n=t??``;e.style.maskImage!==n&&(e.style.maskImage=n,e.style.setProperty(`-webkit-mask-image`,n))}async function Ia(e){let t=await fetch(`${O}/${d(e)}`).catch(()=>null);return t?.ok?t.text().catch(()=>null):null}function La(e){if(e.length<=Ta)return e;let t=e.lastIndexOf(`
183
183
  `,Ta);return e.slice(0,t>0?t:Ta)}function Ra(e){let t=Ge(We(La(e)));for(let e of t.querySelectorAll(`[id]`))e.removeAttribute(`id`);return t}function za(e){let t=E(`div`,`wb-media-doc`);return t.inert=!0,Ia(e).then(e=>{t.replaceChildren(e===null?E(`p`,`wb-media-doc-unread`,Ea):Ra(e))}),t}function Ba(e){let t=getComputedStyle(e);return Object.fromEntries(Object.entries(Oa).flatMap(([e,n])=>{let r=t.getPropertyValue(n).trim();return r?[[e,r]]:[]}))}function Va(e,t){e.contentWindow?.postMessage({type:S,colors:Ba(t)},`*`)}var Ha=new Map,Ua=!1;function Wa(){for(let e of Ha.keys())e.isConnected||Ha.delete(e)}function Ga(e,t){Wa(),Ha.set(e,t),Ua||(Ua=!0,new MutationObserver(()=>{Wa();for(let[e,t]of Ha)Va(e,t)}).observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]}))}function Ka(e,t,n){e.addEventListener(`load`,()=>{Va(e,t),qa(e,n()),Ga(e,t)})}function qa(e,t){e.contentWindow?.postMessage({type:w,values:t},`*`)}function Ja(e){let t=ne({source:{kind:`url`,url:`${O}/${d(e)}?${b}`},className:`wb-media-page`,title:e.alt||`page`,allowsScripts:!0});return t.tabIndex=-1,t}function Ya(e,t,n,r){let i=E(`div`,`wb-media`);if(i.dataset.boxId=e,i.dataset.mediaKind=t.kind,t.kind===`doc`)return i.append(za(t)),ja(i,t),{identity:n,node:i,frame:null,postedDialValues:`{}`};let a=Ja(t);i.append(a),ja(i,t);let o={identity:n,node:i,frame:a,postedDialValues:JSON.stringify(t.dialValues)};return Ka(a,i,()=>{let e=r();return o.postedDialValues=JSON.stringify(e),e}),o}function Xa(e,t){return Math.min(t,Math.max(-t,e))}function Za(e){let t=E(`div`,`wb-media-layer`),n=new Map,r=[],i=null,a=null,o=null;function s(e){return r.find(t=>t.boxId===e)?.media.dialValues??{}}function c(e,t){let n=e===a&&t.frame!==null;t.node.classList.toggle(`is-interactive`,n),t.frame&&(t.frame.tabIndex=n?0:-1)}function u(e,t){let n=JSON.stringify(e.media.dialValues);t.frame&&t.postedDialValues!==n&&(t.postedDialValues=n,qa(t.frame,e.media.dialValues))}function d(){o?.abort(),o=null,a!==null&&(o=new AbortController,window.addEventListener(`message`,t=>{let r=a===null?null:n.get(a)?.frame;if(!r||t.source!==r.contentWindow)return;if(t.data===`glimmervoid-board-page-escape`){e.onEscapeFromPage();return}let i=l.safeParse(t.data);i.success&&f(r,i.data)},{signal:o.signal}))}function f(t,n){let r=t.getBoundingClientRect(),i=t.offsetWidth>0?r.width/t.offsetWidth:1,a=e=>r.left+e*i,o=e=>r.top+e*i;switch(n.gesture){case`pinch`:e.onZoomFromPage(a(n.centerX),o(n.centerY),1/n.scaleFactor);return;case`pan`:e.onPanFromPage(Xa(n.deltaX,r.width),Xa(n.deltaY,r.height));return;case`wheel`:if(!n.isZoom)return;e.onZoomFromPage(a(n.centerX),o(n.centerY),n.deltaY>0?rt:1/rt);return;case`doubleTap`:return}}function p(e){if(e!==a){a=e;for(let[e,t]of n)c(e,t);d()}}function m(e){return i!==null&&Na(i,e.media)}function h(){let e=new Set;for(let i of r){if(!m(i))continue;e.add(i.boxId);let r=n.get(i.boxId);if(r?.identity===i.identity){ja(r.node,i.media),Fa(r.node,i.maskImage),u(i,r);continue}let a=Ya(i.boxId,i.media,i.identity,()=>s(i.boxId));Fa(a.node,i.maskImage),c(i.boxId,a),r&&r.node.replaceWith(a.node),r||t.append(a.node),n.set(i.boxId,a)}for(let[t,r]of n)e.has(t)||(r.node.remove(),n.delete(t))}function g(e,t){let n=new Map(e.elements.map(e=>[e.id,e])),i=t.flatMap(e=>n.get(e)??[]);r=e.elements.flatMap(e=>e.kind!==`box`||!ka(e.media)?[]:[{boxId:e.id,media:e.media,identity:Aa(e.media),maskImage:Vn(e.media,Pa(e.id,e.media,i))}]),h()}function _(e){i=e,h()}function v(){for(let e of n.values())e.node.remove();n.clear(),r=[],p(null)}return{element:t,sync:g,showArea:_,clear:v,setInteractiveBox:p}}var Qa={scale:1,offsetX:0,offsetY:0},$a=8,eo=2;function to(e,t){let n=Math.min($a,Math.max(1,e.scale));return{scale:n,offsetX:Math.min(0,Math.max(t.width*(1-n),e.offsetX)),offsetY:Math.min(0,Math.max(t.height*(1-n),e.offsetY))}}function no(e){return e.scale>1}function ro(e,t,n,r){let i=Math.min($a,Math.max(1,e.scale*n)),a=i/e.scale;return to({scale:i,offsetX:t.x-(t.x-e.offsetX)*a,offsetY:t.y-(t.y-e.offsetY)*a},r)}function io(e,t,n,r){return to({...e,offsetX:e.offsetX+t,offsetY:e.offsetY+n},r)}function ao(e,t,n){return no(e)?Qa:ro(e,t,eo,n)}function oo(e,t){return{x:e.offsetX+t.x*e.scale,y:e.offsetY+t.y*e.scale}}function so(e,t){return e>0?1/t:t}var co=6,lo=300,uo=30;function fo(e,t){switch(t.gesture){case`pinch`:e.zoomAt({x:t.centerX,y:t.centerY},t.scaleFactor);return;case`pan`:e.panBy(t.deltaX,t.deltaY);return;case`wheel`:if(t.isZoom){e.zoomAt({x:t.centerX,y:t.centerY},so(t.deltaY,rt));return}e.panBy(-t.deltaX,-t.deltaY);return;case`doubleTap`:e.toggleFitAt({x:t.centerX,y:t.centerY})}}function po(e,t,n){let r=Qa,i={kind:`idle`},a=null,o=``,s=new Map;t.classList.add(`wb-zoomable-media`);function c(){return{width:e.clientWidth,height:e.clientHeight}}function l(t,n){let r=e.getBoundingClientRect();return{x:t-r.left,y:n-r.top}}function u(e){let i=no(r);r=e,t.style.transform=`translate(${r.offsetX}px, ${r.offsetY}px) scale(${r.scale})`,i!==no(r)&&n(no(r))}function d(){let[e,t]=[...s.values()];return!e||!t?{distance:0,midpoint:{x:0,y:0}}:{distance:Math.hypot(e.x-t.x,e.y-t.y),midpoint:{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}}function f(e){let t=performance.now(),n=a;return a={at:t,point:e},!n||t-n.at>lo?!1:(a=null,Math.hypot(e.x-n.point.x,e.y-n.point.y)<=uo)}function p(e){if(e.pointerType===`mouse`&&e.button!==0)return;o=e.pointerType;let t=l(e.clientX,e.clientY);s.set(e.pointerId,t),s.size===2?i={kind:`pinching`,...d()}:s.size===1&&(i={kind:`pressed`,pointerId:e.pointerId,start:t})}function m(e){let{distance:t,midpoint:n}=d();t<=0||e.distance<=0||(u(ro(io(r,n.x-e.midpoint.x,n.y-e.midpoint.y,c()),n,t/e.distance,c())),i={kind:`pinching`,distance:t,midpoint:n})}function h(t){if(!s.has(t.pointerId))return;if(t.buttons===0){s.delete(t.pointerId),i={kind:`idle`};return}let n=l(t.clientX,t.clientY);if(s.set(t.pointerId,n),i.kind===`pinching`)m(i);else{if(i.kind===`pressed`&&i.pointerId===t.pointerId){if(!(Math.hypot(n.x-i.start.x,n.y-i.start.y)>co)||!no(r))return;e.setPointerCapture(t.pointerId),i={kind:`panning`,pointerId:t.pointerId,last:i.start}}i.kind===`panning`&&i.pointerId===t.pointerId&&(u(io(r,n.x-i.last.x,n.y-i.last.y,c())),i={...i,last:n})}}function g(e){if(!s.delete(e.pointerId))return;let t=i.kind===`pressed`&&i.pointerId===e.pointerId&&e.type===`pointerup`&&e.pointerType!==`mouse`;if(s.size===0&&(i={kind:`idle`}),s.size===1&&i.kind===`pinching`&&(i={kind:`idle`}),!t)return;let n=l(e.clientX,e.clientY);f(n)&&u(ao(r,n,c()))}function _(e){e.ctrlKey||e.metaKey?(e.preventDefault(),u(ro(r,l(e.clientX,e.clientY),so(e.deltaY,rt),c()))):no(r)&&(e.preventDefault(),u(io(r,-e.deltaX,-e.deltaY,c())))}return e.addEventListener(`pointerdown`,p),e.addEventListener(`pointermove`,h),e.addEventListener(`pointerup`,g),e.addEventListener(`pointercancel`,g),e.addEventListener(`wheel`,_,{passive:!1}),new ResizeObserver(()=>u(io(r,0,0,c()))).observe(e),e.addEventListener(`dblclick`,e=>{e.preventDefault(),o===`mouse`&&u(ao(r,l(e.clientX,e.clientY),c()))}),{zoomAt:(e,t)=>u(ro(r,oo(r,e),t,c())),panBy:(e,t)=>u(io(r,e,t,c())),toggleFitAt:e=>u(ao(r,oo(r,e),c())),isZoomed:()=>no(r)}}var mo=`http://www.w3.org/2000/svg`,ho=`No boards yet. Make one here, or have an agent run glimmervoid whiteboard new <title>.`,go=`Pick a board above.`,_o=`wb-board-title-rename`,vo=32,yo=`This document changed on the board since you opened it. Reload to see that version.`,bo=`This document is no longer on the board, so it cannot be saved.`,xo=`This document could not be read from the board.`,So=`Not saved: this text starts like a picture or an HTML page, so the board would not keep it as a document.`,Co=new Set([`video/mp4`,`video/webm`,`text/html`]),wo=/\.(png|jpe?g|gif|webp|svg|mp4|webm|html?)$/i,To=`M2.5 6V2.5H6 M10 2.5h3.5V6 M13.5 10v3.5H10 M6 13.5H2.5V10`,Eo=`M5.5 3.5l-3 3l3 3 M2.5 6.5h7a3.5 3.5 0 0 1 0 7H7`,Do=`M10.5 3.5l3 3l-3 3 M13.5 6.5h-7a3.5 3.5 0 0 0 0 7H9`,Oo=`Saved, but that change is too big to undo.`,ko=[{tool:`select`,label:`Select`,key:`V`,iconPath:`M4 2.5l8.5 5.8l-4 0.7l2.2 4.3l-1.5 0.8l-2.2-4.3L4 12.5z`,hint:null},{tool:`box`,label:`Box`,key:`R`,iconPath:`M2.5 4h11v8h-11z`,hint:`Click the board to place a box. Esc to cancel.`},{tool:`decision`,label:`Decision`,key:`D`,iconPath:`M8 2l6 6l-6 6l-6-6z`,hint:`Click the board to place a decision. Esc to cancel.`},{tool:`panel`,label:`Panel`,key:`P`,iconPath:`M2.5 3h11v10h-11z M2.5 6h11`,hint:`Click the board to place a panel. Esc to cancel.`},{tool:`sticky`,label:`Sticky note`,key:`S`,iconPath:`M2.5 2.5h11v7l-4 4h-7z M9.5 13.5v-4h4`,hint:`Click the board to place a sticky note. Esc to cancel.`},{tool:`text`,label:`Text`,key:`T`,iconPath:`M3 3.5h10 M8 3.5v9.5`,hint:`Click the board to place text. Esc to cancel.`},{tool:`icon`,label:`Icon`,key:`I`,iconPath:`M8 2.5l1.6 3.3l3.6 0.5l-2.6 2.5l0.6 3.6L8 10.7l-3.2 1.7l0.6-3.6L2.8 6.3l3.6-0.5z`,hint:`Click the board to place an icon. Esc to cancel.`},{tool:`device`,label:`Device`,key:`M`,iconPath:`M5 1.5h6v13h-6z M7 12.5h2`,hint:`Click the board to place a device mockup. Esc to cancel.`},{tool:`wire`,label:`Wire`,key:`A`,iconPath:`M2.5 13.5L13 3 M8.5 3H13v4.5`,hint:`Drag from one box to another to connect them. Esc to cancel.`},{tool:`pen`,label:`Pen`,key:`B`,iconPath:`M2.5 13.5c2-1 3-4 5-4s2 3 4 3s2-3 2-5`,hint:`Drag on the board to draw. Esc to stop drawing.`}],Y=null,X=null,Ao=null,Z=null,jo=null,Mo=!0,No=null,Po=null,Fo=null,Io=null,Q=Fe(`action-status wb-status`),Lo=new Map,Ro=Promise.resolve();function zo(e){let{dialog:t,close:n,actions:r,btnCancel:i}=He({title:e.title}),a=E(`input`,`dialog-input`);a.type=`text`,a.placeholder=e.placeholder,a.maxLength=e.maxLength,a.value=e.initialValue??``,a.autocomplete=`off`,a.setAttribute(`aria-label`,e.label);let o=E(`div`,`dialog-error`);o.setAttribute(`role`,`alert`);let s=I({variant:`primary`,label:e.confirmLabel,action:`confirm-board-dialog`});r.append(s),t.append(E(`label`,`dialog-label`,e.label),a,o,r);async function c(){let t=a.value.trim();if(!t){o.textContent=`${e.label} is empty.`;return}s.disabled=!0;let r=await e.onSubmit(t);s.disabled=!1,r?o.textContent=r:n()}i.addEventListener(`click`,n),s.addEventListener(`click`,()=>void c()),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),c())}),requestAnimationFrame(()=>a.focus())}function Bo(e){return ce(e)?.board??null}function $(){return Y?Bo(Y):null}function Vo(){return te().find(e=>e.id===Y)??null}function Ho(e){let t=Ro.then(e);return Ro=t.catch(()=>void 0),t}function Uo(e,t){return Ho(()=>Ko(e,t))}function Wo(e){return e.length<=n.opsPerPut&&new TextEncoder().encode(JSON.stringify(e)).length<=n.putBytes}function Go(e){if(!e)return[];let t=we(e.before,e.diff);return Wo(t)?t:null}async function Ko(e,t){let n=await pe(e,t);if(!n.ok)return n;let r=Go(n.patch);return r?(Lo.set(e,Ee(Lo.get(e)??ke,r)),{ok:!0,isUndoable:!0}):(Lo.set(e,ke),{ok:!0,isUndoable:!1})}function qo(e){return Ho(()=>Jo(e))}async function Jo(e){let t=Y;if(!t)return;let n=Te(Lo.get(t)??ke,e);if(!n)return;Lo.set(t,n.history);let r=await pe(t,n.entry);if(!r.ok){Q.show(`error`,`could not ${e} that change, so it was dropped: ${r.error}`);return}let i=Go(r.patch);i?(Q.clear(),Lo.set(t,Oe(Lo.get(t)??ke,e,i))):(Lo.set(t,ke),Q.show(`ok`,Oo))}async function Yo(e){if(!Y||e.length===0)return!1;let t=await Uo(Y,e);return t.ok&&!t.isUndoable?(Q.show(`ok`,Oo),!0):t.ok?(Q.clear(),!0):(Q.show(`error`,t.error),!1)}async function Xo(e){if(!Y)return`No board is open.`;let t=await Uo(Y,e);return t.ok?null:t.error}function Zo(e){let t=ze(e);return t?Re(t):`closed session`}function Qo(){let e=Vo()?.connectedSessionIds??[],t=$()?.codeSessionId;return(t&&!e.includes(t)?[t,...e]:e).map(e=>({value:e,text:Zo(e)}))}function $o(){return te().filter(e=>e.id!==Y).map(e=>({value:e.id,text:e.title}))}function es(e){let t=$();return[...Z?.selectedIds()??new Set].flatMap(e=>t?.elements.get(e)??[]).filter(t=>t.kind===e)}function ts(){if(!X)return;let e=$();for(let t of X.toolButtons.values())t.disabled=!e;for(let t of[X.buttons.fit,X.buttons.undo,X.buttons.redo])t.disabled=!e;jo?.paint(Z?.selectedIds()??new Set)}function ns(){if(!X)return;let e=te();Y&&!e.some(e=>e.id===Y)&&(Y=null);let t=e.find(e=>No!==null&&e.connectedSessionIds.includes(No))??e.find(e=>!e.isArchived)??e[0];!Y&&t&&Es(t.id),X.boardMenu.paintBoards(e),ds()}function rs(){return!!X?.boardIsland.querySelector(`.${_o}`)}function is(){let e=Vo();if(!X||!e||rs())return;let{boardTitle:t}=X,r=E(`input`,_o);r.type=`text`,r.value=e.title,r.maxLength=n.title,r.setAttribute(`aria-label`,`Board title`),t.replaceWith(r),r.focus(),r.select();let i=!1;function a(n){if(i||!e)return;i=!0;let a=r.value.trim();r.replaceWith(t),ds(),n&&a&&a!==e.title&&Yo([{op:`board`,title:a}])}r.addEventListener(`blur`,()=>a(!0)),r.addEventListener(`keydown`,e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),a(e.key===`Enter`))})}function as(e){let t=Le(e.title,`visible wb-board-menu-board`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(e.id===Y));let n=e.connectedSessionIds.length;return n>0&&t.append(E(`span`,`wb-board-menu-count`,String(n))),t.addEventListener(`click`,()=>Ts(e.id)),t}function os(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function ss(e,t){return t.updatedAt-e.updatedAt}function cs(e){let t=new Map;for(let n of e)n.isArchived||t.set(n.project,[...t.get(n.project)??[],n]);let n=[...t].flatMap(([e,t])=>e===null?[]:[{label:os(e),boards:t.sort(ss)}]);n.sort((e,t)=>(t.boards[0]?.updatedAt??0)-(e.boards[0]?.updatedAt??0));let r=t.get(null)?.sort(ss)??[];return{projectGroups:r.length>0?[...n,{label:`Unfiled`,boards:r}]:n,archivedBoards:e.filter(e=>e.isArchived).sort(ss)}}function ls(e){let t=E(`div`,`wb-board-menu-group`,e.label);return t.setAttribute(`role`,`presentation`),t}function us(e){let t=E(`div`,`session-overflow wb-board-menu`),n=E(`div`,`popup-menu session-overflow-menu`);n.setAttribute(`role`,`menu`),n.setAttribute(`aria-label`,`Board menu`);let r=()=>n.classList.contains(`open`),i=e=>{c.classList.toggle(`visible`,!fc()),n.classList.toggle(`open`,e),a.setAttribute(`aria-expanded`,String(e))},a=Pe({label:`Board actions`,action:`open-board-menu`,onClick:()=>i(!r())});a.setAttribute(`aria-haspopup`,`menu`),a.setAttribute(`aria-expanded`,`false`);let o=(e,t,n=``)=>{let r=Le(e,`visible ${n}`.trim());return r.addEventListener(`click`,t),r},s=E(`div`,`menu-divider`);s.setAttribute(`role`,`separator`);let c=o(`Board settings`,e),l=[s,o(`Rename board`,is),o(`New board`,Xs),c,o(`Delete board`,Ys,`wb-board-menu-danger`)];n.addEventListener(`click`,e=>{e.target instanceof HTMLElement&&e.target.closest(`[role^="menuitem"]`)&&i(!1)}),t.append(a,n),Ie({trigger:a,menu:n,menuItems:()=>[...n.querySelectorAll(`.visible[role^="menuitem"]`)],isOpen:r,open:()=>i(!0),close:()=>i(!1)}),document.addEventListener(`click`,e=>{r()&&e.target instanceof Node&&!t.contains(e.target)&&i(!1)});let u=[],d=Le(`Archived boards`,`visible wb-board-menu-archived`);d.setAttribute(`aria-expanded`,`false`),d.addEventListener(`click`,e=>{e.stopPropagation(),d.setAttribute(`aria-expanded`,String(d.getAttribute(`aria-expanded`)!==`true`)),f(u),d.focus()});let f=e=>{u=e;let{projectGroups:t,archivedBoards:r}=cs(e),i=d.getAttribute(`aria-expanded`)===`true`,a=t.flatMap(e=>[ls(e),...e.boards.map(as)]),o=r.length===0?[]:[d,...i?r.map(as):[]];n.replaceChildren(...a,...o,...l)};return{menuRoot:t,trigger:a,paintBoards:f}}function ds(){if(!X)return;let e=Vo(),t=te().length>0;X.canvas.hidden=!e,X.empty.hidden=!!e,X.emptyText.textContent=t?go:ho,e&&(X.boardTitle.textContent=e.title,X.boardMeta.dataset.boardVersion=String(e.version),ps(),ts(),gs())}var fs=60;function ps(){if(!X)return;let e=Vo();if(!e)return;let t=`edited ${Ae(Date.now()-e.updatedAt,{...Ne,justNowBelowSeconds:fs})}`;X.boardMeta.textContent!==t&&(X.boardMeta.textContent=t)}function ms(e){if(!X)return;let t=e.map(Zo),n=e.filter(e=>e!==No).map(Zo),r=E(`span`,t.length===0?`wb-presence-count wb-presence-none`:`wb-presence-count wb-presence-pill`,`${t.length} connected`);t.length>0&&r.append(E(`span`,`sr-only`,`: ${t.join(`, `)}`)),X.presence.replaceChildren(...n.map(e=>E(`span`,`wb-presence-pill`,e)),r),t.length===0&&X.presence.prepend(E(`span`,`wb-presence-none`,`no sessions connected`))}function hs(e,t){let n=Zo(t);if(!e?.connectedSessionIds.includes(t))return`${n} is not connected to this board`;let r=e.queuedBySessionId[t]??0;return r===0?`${n} has read every change`:`${r} board ${r===1?`edit`:`edits`} queued for ${n}`}function gs(){if(!X)return;let e=Vo();ms(e?.connectedSessionIds??[]),X.agentIsland.hidden=!No,No&&(X.agentIsland.toggleAttribute(`data-idle`,!_s(e,No)),X.queuedForSession.textContent=hs(e,No))}function _s(e,t){return!e?.connectedSessionIds.includes(t)||(e.queuedBySessionId[t]??0)>0}function vs(e,t){let n=new Set(t);return new Set([...e.elements.values()].filter(e=>Qe(e).some(e=>n.has($e(e)??``))).map(e=>e.id))}function ys(e){let t=$()?.codeSessionId,n=$e(e);t&&n&&M(t,n)}function bs(){if(!X||!Ao)return;let e=$(),t=e&&Po?.boardId===e.id?Po.review:null;Ao.setReviewMarks({worthALookIds:e&&t?vs(e,t.worthALookPaths):new Set,flaggedStepIds:new Set(t?.flaggedStepIds??[])})}function xs(e){let t=`${e.id}@${e.version}`;Fo!==t&&(Fo=t,ie(e.id).then(n=>{Fo===t&&(n.ok?(Po={boardId:e.id,review:n.review},bs()):Fo=null)}))}function Ss(){if(!Ao)return;let e=Y?ce(Y):null;if(!e){X&&(X.emptyBoardHint.hidden=!0);return}Ao.renderLayout(e.layout,e.blocks),Z?.repaintPreview();let{board:t}=e;xs(t),Z?.pruneSelection(t),X&&(X.emptyBoardHint.hidden=e.elementCount>0),bs(),Z?.openPendingTitleEdit(),Mo&&=(Z?.fit(),!1),ts()}var Cs=[];function ws(e){Cs.push(e)}function Ts(e){Es(e);for(let t of Cs)t(e)}function Es(e){Y!==e&&(Y=e,Mo=!0,Z?.clearSelection(),Z?.closeTitleInput(),jo?.closeBoardSettings(),Ao?.clear(),Q.clear(),ns(),Ss())}function Ds(e){if(e.size!==1)return null;let[t]=e,n=t===void 0?void 0:$()?.elements.get(t);return n?.kind!==`box`||p(n)?.kind!==`page`?null:n.id}function Os({boxId:e}){let t=e?$()?.elements.get(e):void 0;return t?.kind===`box`?i(t):{}}function ks({boxId:e}){let t=e?$()?.elements.get(e):void 0;return t?.kind===`box`?p(t):null}function As(e,t){let n=t?`${O}/${d(t)}`:e.href;if(t?.kind===`page`){let t=ne({source:{kind:`url`,url:`${n}?${b}`},className:`wb-image-viewer-page`,title:e.alt||`page`,allowsScripts:!0});return Ka(t,document.body,()=>Os(e)),t}if(t?.kind===`video`){let e=E(`video`,`wb-image-viewer-video`);return e.src=n,e.controls=!0,e.playsInline=!0,e.autoplay=!0,e}let r=E(`img`,`wb-image-viewer-picture`);return r.src=n,r.alt=e.alt,r.draggable=!1,r}function js(e,t){e.contentWindow?.postMessage({type:y,isZoomed:t},`*`)}function Ms(e,t,n,r){let i=new AbortController;window.addEventListener(`message`,t=>{if(t.source!==e.contentWindow)return;if(t.data===`glimmervoid-board-page-escape`){n();return}let i=l.safeParse(t.data);i.success&&fo(r,i.data)},{signal:i.signal}),e.addEventListener(`load`,()=>js(e,r.isZoomed()),{signal:i.signal});let a=new MutationObserver(()=>{t.isConnected||(i.abort(),a.disconnect())});a.observe(document.body,{childList:!0})}function Ns(e,t){let n=Io?.boardId===e&&Io.box.id===t,r=Bo(e)?.elements.get(t);return r?.kind===`box`?(n&&(Io={boardId:e,box:r}),r):n?Io?.box??null:null}function Ps(e,t){let n=Ns(e,t),r=n?p(n):null;return r?.kind===`doc`?r:null}function Fs(e){return`whiteboard:${e}`}async function Is(e,t,n,r){let i=Ps(e,t);if(!i||i.asset!==r)return{ok:!1,isConflict:!0,error:null};let a=await A(new File([n],`${t}.md`,{type:`text/markdown`}));if(!a.ok)return{ok:!1,isConflict:!1,error:a.error};if(a.media.kind!==`doc`)return{ok:!1,isConflict:!1,error:So};if(Ps(e,t)?.asset!==r)return{ok:!1,isConflict:!0,error:null};let o={...a.media,alt:i.alt},s=await Uo(e,[{op:`set`,id:t,fields:{media:o}}]);if(!s.ok)return{ok:!1,isConflict:!1,error:s.error};let c=Ns(e,t);return c&&c.shape!==`icon`&&c.shape!==`text`&&Io?.box.id===t&&(Io={boardId:e,box:{...c,media:o}}),{ok:!0,hash:a.media.asset}}function Ls(e,t,n){return{key:Fs(e),docs:()=>[{path:t,name:n}],isSaveable:()=>Ps(e,t)!==null,conflictText:yo,unsaveableText:bo,read:async()=>{let n=Ps(e,t);if(!n)return{ok:!1,error:bo};let r=await Ia(n);return r===null?{ok:!1,error:xo}:{ok:!0,text:r,hash:n.asset}},save:(n,r,i)=>Is(e,t,r,i)}}function Rs(e,t){let n=Bo(e)?.elements.get(t);n?.kind===`box`&&(Io={boardId:e,box:n},Se(Ls(e,t,n.title)))}function zs(e){let{alt:t}=e,n=ks(e);if(!n&&!e.href)return;if(n?.kind===`doc`&&Y&&e.boxId){Rs(Y,e.boxId);return}let{overlay:r,dialog:i,close:a,titleEl:o,btnCancel:s}=He({title:t||`Picture`,dialogClass:`dialog wb-image-viewer`,cancelLabel:`Close`}),c=E(`div`,`wb-image-viewer-header`);o.replaceWith(c),c.append(o,s),r.classList.add(`wb-image-viewer-overlay`),r.addEventListener(`wheel`,e=>{(e.ctrlKey||e.metaKey)&&e.preventDefault()},{passive:!1});let l=As(e,n),u=E(`div`,`wb-image-viewer-stage`);u.append(l),i.append(u);let d=po(u,l,e=>{l instanceof HTMLIFrameElement&&js(l,e)});l instanceof HTMLIFrameElement&&Ms(l,r,a,d),s.addEventListener(`click`,a),requestAnimationFrame(()=>s.focus())}var Bs=24;function Vs(e){zo({title:`Pin a note`,label:`Note`,placeholder:`what about retries?`,maxLength:n.noteText,confirmLabel:`Pin note`,onSubmit:n=>{let r=Ao?.boundsOf(e);if(!r)return Promise.resolve(`That box is not on the board any more.`);let i=Ao?.layout()?.pinnedOffsetY??0,a={x:Math.round(r.x+r.width+Bs),y:Math.round(r.y-i)},o=lt(`box`),{title:s,lines:c}=De(n);return Xo([{op:`add`,element:t.parse({kind:`box`,id:o,shape:`note`,title:s,lines:c.map(e=>({text:e})),at:a})},{op:`add`,element:t.parse({kind:`wire`,id:lt(`wire`),from:o,to:e,dashed:!0})}])}})}function Hs(e,t){let n=$();n&&e!==t&&([...n.elements.values()].some(n=>n.kind===`wire`&&n.from===e&&n.to===t)||Yo([{op:`add`,element:{kind:`wire`,id:lt(`wire`),from:e,to:t,fromOutput:null,dashed:!1,tone:`plain`,label:null,fromSide:null,toSide:null,back:!1}}]))}function Us(e,t){return t.flatMap(t=>{let n=e.elements.get(t);return n?.kind===`box`?[n.title]:[]}).join(`, `).slice(0,n.title)}function Ws(e,t){return Yo([{op:`add`,element:{kind:`frame`,id:lt(`frame`),title:Us(e,t),contains:t,loop:!1,collapsed:!0}}])}function Gs(e,t,n){let r=$();r&&(n?Yo([{op:`set`,id:n.id,fields:{contains:[...n.contains,t]}}]):Ws(r,[e,t]))}function Ks(){let e=$(),t=es(`box`).map(e=>e.id);if(!e||t.length<2)return;let n=L(e),r=t.flatMap(e=>n.get(e)??[])[0],i=t.filter(e=>!r?.contains.includes(e));(r?Yo([{op:`set`,id:r.id,fields:{contains:[...r.contains,...i]}}]):Ws(e,t)).then(e=>{e&&Z?.clearSelection()})}function qs(e){Yo([{op:`set`,id:e,fields:{collapsed:!1}}])}function Js(){let e=es(`box`).map(e=>e.id);e.length!==0&&zo({title:`Frame the selected boxes`,label:`Frame title`,placeholder:`intake`,maxLength:n.title,confirmLabel:`Add frame`,onSubmit:async t=>{let n=await Xo([{op:`add`,element:{kind:`frame`,id:lt(`frame`),title:t,contains:e,loop:!1,collapsed:!1}}]);return n||Z?.clearSelection(),n}})}function Ys(){let e=Vo();if(!e)return;let t=e.connectedSessionIds.map(Zo),n=t.length>0?` ${t.join(`, `)} ${t.length===1?`is`:`are`} connected and will lose it.`:``;Be({title:`Delete board`,message:`Delete "${e.title}" for good?${n}`,confirmLabel:`Delete board`,danger:!0,onConfirm:()=>{be(e.id).then(e=>{e.ok||Q.show(`error`,e.error)})}})}function Xs(){Zs(Ts)}function Zs(e){zo({title:`New board`,label:`Board title`,placeholder:`knowledge writer`,maxLength:n.title,confirmLabel:`Create board`,onSubmit:async t=>{let n=await se(t);return n.ok?(e(n.boardId),null):n.error}})}function Qs(e,t,n,r){return I({variant:`icon`,label:e,icon:je(t,`1.5`),action:n,onClick:r})}function $s(e,t,n,r){let i=Me(`wb-tool`);i.setAttribute(`aria-label`,t);let a=E(`span`,`wb-tool-key`,n);return a.setAttribute(`aria-hidden`,`true`),i.append(je(r,`1.5`),a),i.setAttribute(`aria-keyshortcuts`,n),i.setAttribute(`aria-pressed`,String(e===`select`)),i.addEventListener(`click`,()=>{Z?.setTool(e),Z?.focusCanvas()}),i}function ec(e,t,...n){let r=E(`div`,`wb-island ${e}`);return r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,t),r.append(...n),r}function tc(e){if(!X)return;for(let[t,n]of X.toolButtons)n.setAttribute(`aria-pressed`,String(t===e));let t=ko.find(({tool:t})=>t===e)?.hint??null;X.toolHint.textContent=t??``,X.toolHint.hidden=t===null}function nc(e){return!(e.metaKey||e.ctrlKey)||e.altKey||e.code!==`KeyZ`?null:e.shiftKey?`redo`:`undo`}function rc(e){return document.activeElement instanceof HTMLSelectElement?!1:v(e)}function ic(e,t){let n=nc(t);n&&e.checkVisibility()&&!Ve()&&!rc(t)&&(document.activeElement?.classList.contains(`xterm-helper-textarea`)||(t.preventDefault(),qo(n)))}function ac(e){return e.type.startsWith(`image/`)||Co.has(e.type)?!0:e.type===``&&wo.test(e.name)}function oc(e){return[...e?.files??[]].filter(ac)}function sc(e){return(e.name.replace(/\.[^.]+$/,``)||`Picture`).slice(0,n.title)}async function cc(e,t){if(Y&&e.length!==0){Q.show(`busy`,e.length===1?`adding ${e[0]?.name}`:`adding ${e.length} files`);for(let[r,i]of e.entries()){let e=await A(i);if(!e.ok){Q.show(`error`,e.error);return}let a=r*vo,o=t?{x:t.x+a,y:t.y+a}:null,s={...e.media,alt:i.name.slice(0,n.line)};if(!await Z?.placeMediaBox(sc(i),s,o))return}Q.clear()}}function lc(e,t){t.addEventListener(`dragover`,e=>{Y&&e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),t.addEventListener(`drop`,e=>{let t=oc(e.dataTransfer);t.length!==0&&(e.preventDefault(),cc(t,{x:e.clientX,y:e.clientY}))}),document.addEventListener(`paste`,t=>{if(!e.checkVisibility()||Ve()||uc())return;let n=oc(t.clipboardData);n.length!==0&&(t.preventDefault(),cc(n,null))})}function uc(){let e=document.activeElement;return e?.classList.contains(`xterm-helper-textarea`)?!0:e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function dc(){if(X)return X.host;let e=E(`div`,`boards-view`),t=us(()=>{Z?.clearSelection(),jo?.openBoardSettings()});t.trigger.dataset.phoneVisible=``;let n=Me(`wb-board-title pane-header-title`);n.addEventListener(`click`,is);let r=E(`span`,`wb-board-meta pane-header-subtitle`),i=E(`div`,`wb-presence`),a=ec(`wb-island-board`,`Board`,t.menuRoot,n,r,i,Q.element),o=new Map(ko.map(({tool:e,label:t,key:n,iconPath:r})=>[e,$s(e,t,n,r)])),s=E(`div`,`wb-tools`);s.setAttribute(`role`,`group`),s.setAttribute(`aria-label`,`Drawing tools`),s.append(...o.values());let c={fit:Qs(`Fit`,To,`fit-board`,()=>Z?.fit()),undo:Qs(`Undo`,Eo,`undo-board-edit`,()=>void qo(`undo`)),redo:Qs(`Redo`,Do,`redo-board-edit`,()=>void qo(`redo`))};c.fit.dataset.phoneVisible=``;let l=ec(`wb-island-tools`,`Board tools`,s),u=E(`p`,`wb-tool-hint`);u.setAttribute(`aria-live`,`polite`),u.hidden=!0;let d=ec(`wb-island-view`,`View`,c.fit,c.undo,c.redo),f=E(`div`,`wb-canvas`),p=E(`div`,`wb-viewport`);p.setAttribute(`role`,`application`),p.setAttribute(`aria-label`,`Whiteboard`);let m=E(`div`,`wb-world`),h=document.createElementNS(mo,`svg`);h.setAttribute(`class`,`wb-svg`),h.setAttribute(`aria-hidden`,`true`);let g=Za({onEscapeFromPage:()=>{Z?.clearSelection(),Z?.focusCanvas()},onZoomFromPage:(e,t,n)=>Z?.zoomAroundClientPoint(e,t,n),onPanFromPage:(e,t)=>Z?.panByPixels(e,t)});m.append(h,g.element);let _=E(`canvas`,`wb-gl`);_.setAttribute(`aria-hidden`,`true`);let v=E(`p`,`wb-gl-notice`);v.setAttribute(`role`,`status`),v.hidden=!0,p.append(_,m,v);let y=E(`aside`,`wb-inspect`),b=E(`span`,`wb-session-queued`),x=ec(`wb-island-agent`,`Session`,b);x.hidden=!0;let S=E(`div`,`wb-bottom-left`);S.append(x);let C=E(`div`,`wb-top-left`);C.append(a,d,l,u);let w=E(`div`,`wb-top-right`);w.append(y);let T=E(`div`,`wb-empty-board`);T.hidden=!0;let ee=E(`p`,`wb-empty-board-desc`);ee.append(E(`span`,`wb-empty-board-keys`,`Pick box (R) and click the board to place one, or ask a session to draw here.`),E(`span`,`wb-empty-board-touch`,`Ask a session to draw here.`)),T.append(E(`p`,`wb-empty-board-title`,`This board is empty.`),ee),f.append(p,T,w,C,S);let D=E(`p`,`wb-empty-text`,ho),O=E(`div`,`wb-empty`);O.append(D,I({variant:`secondary`,label:`new board`,action:`new-board`,onClick:Xs})),e.replaceChildren(f,O),X={boardIsland:a,boardMenu:t,boardTitle:n,boardMeta:r,presence:i,host:e,chrome:C,canvas:f,empty:O,emptyText:D,agentIsland:x,queuedForSession:b,buttons:c,toolButtons:o,toolHint:u,emptyBoardHint:T},Ue(ps);let te=Ca({canvas:_,viewport:p,fontSource:h,mediaLayer:g,notice:v,onViewChange:(e,t)=>{Y&&he(Y,e,t)}});return Ao=te,jo=Dn({container:y,currentBoard:$,layout:()=>te.layout(),sendOps:Yo,codeSessionChoices:Qo,openRef:ys,linkedBoardChoices:$o,addNoteOn:Vs,frameSelectedBoxes:Js,stackSelectedBoxes:Ks,removeSelected:()=>Z?.removeSelected()}),Z=Ct({viewport:p,world:m,svg:h,canvas:f,renderer:te,currentBoard:$,repaint:Ss,sendOps:Yo,onSelectionChange:e=>{ts(),g.setInteractiveBox(Ds(e))},onPhoneTapBox:Vs,onOpenLinkedBoard:Es,onOpenImage:zs,onConnectBoxes:Hs,onStackBoxes:Gs,onOpenStack:qs,onToolChange:tc}),document.addEventListener(`keydown`,t=>ic(e,t)),lc(e,f),ge(ns),N(e=>{Ce(Fs(e)),e===Y&&Ss()}),ye(()=>{Y&&Ce(Fs(Y)),Ss()}),ns(),e}function fc(){return document.documentElement.dataset.layout===`phone`}function pc(e){X&&(e?X.boardIsland.parentElement!==e&&e.append(X.boardIsland):X.chrome.firstElementChild!==X.boardIsland&&X.chrome.prepend(X.boardIsland))}function mc(e,t){No=t,e&&Es(e),gs()}function hc(){ns(),Fo=null,de(),Ss()}var gc=null;function _c(e){gc=e,e.replaceChildren(dc())}function vc(){let e=dc();gc&&e.parentElement!==gc&&gc.replaceChildren(e),pc(null),mc(ve()?.boardId??null,null),hc()}var yc={mount:_c,refresh:vc};export{dc as mountBoardHost,ws as onBoardPicked,pc as placeBoardTitle,hc as reopenSelectedBoard,mc as showBoardBeside,yc as view};
@@ -1 +1 @@
1
- import{_t as e,a as t,t as n}from"./button-CfhUK7Jn.js";import{n as r,o as i,r as a,t as o}from"./lane-read-token-step-Y47rPFjy.js";import{c as s,i as c,s as ee,t as l}from"./action-status-rETkOMJb.js";import{b as u,d,f,s as p}from"./dom-helpers-1xKy7VX6.js";import{F as m,I as h,Ja as g,K as te,Ki as _,Kr as v,L as y,Mi as b,N as x,P as S,Qi as C,R as w,Wi as ne,X as re,Xi as T,ct as ie,oa as ae,ot as E,qa as D,ra as oe,z as se}from"./index-CwndYdst.js";import{t as ce}from"./pr-queue-columns-C6P-i4sW.js";import{o as le}from"./card-registry-D1_v6Lbm.js";import{i as ue}from"./modal-CjIIQMho.js";import{d as de,f as fe}from"./control-ws-DEfwcMni.js";import{n as O}from"./setup-step-B9ALtknc.js";var pe={HIGH:`High confidence`,MEDIUM:`Medium confidence`,LOW:`Low confidence`},me={HIGH:`ok`,MEDIUM:`warn`,LOW:`muted`},k={queued:`Waiting to be researched`,running:`Researching`,error:`Research failed`,aside:`Set aside`},he={forum:`Forum`,discord:`Discord`};function A(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:k.error,tone:`danger`}:{text:k[e.status],tone:`muted`}}function j(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 M(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 N=[`key`,`readToken`,`project`,`skill`,`discord`];function xe(e){let t=e===`finished`?N.length:N.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 Se(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=E().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 Ce(e,t,n,r){let i=p(`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 we({onFinish:e}){let t=p(`section`,`first-run-checklist review-setup`);t.setAttribute(`aria-labelledby`,`community-setup-title`);let i=p(`h2`,`first-run-title`,`Answer community questions`);i.id=`community-setup-title`;let s=p(`ol`,`first-run-steps`),u=p(`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 d=p(`div`,`first-run-step-actions`),f=n({variant:`primary`,label:`Finish setup`,action:`finish-community-setup`});d.append(f),d.hidden=!0,t.append(p(`span`,`first-run-eyebrow`,`SET UP COMMUNITY`),i,s,d,u);let m=null;f.addEventListener(`click`,()=>{F(`finish-community-setup`),m=null,e()});function h(){return o(`posthog.apiKey`)?r()?null:`readToken`:`key`}function g(e){m=e===`readToken`&&r()?`project`:e,C(),(s.querySelector(`[aria-current="step"] input`)??(d.hidden?null:f))?.focus()}async function _(e,t,n,r){t.disabled=!0,n.show(`busy`,`Saving`);try{let t=await fe(`update-settings`,{settings:e},{timeoutMs:l});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}re(t.settings),g(r)}catch(e){n.show(`error`,ee(e,l))}finally{t.disabled=!1}}function v(e){let t=Ce(e.inputId,e.initialValue,e.placeholder,e.inputType),r=p(`label`,`repo-roots-adder-label`,e.label);r.htmlFor=t.id;let i=p(`div`,`first-run-step-actions`),a=c(),o=n({variant:`primary`,label:e.saveLabel,action:e.action}),s=()=>{let n=e.settingsPatch(t.value);typeof n==`string`?a.show(`error`,n):(F(e.action),_(n,o,a,e.nextProgress))};if(o.addEventListener(`click`,s),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),s())}),i.append(o),e.isSkippable){let t=n({variant:`secondary`,label:`Skip`,action:`skip-community-setup-step`,onClick:()=>g(e.nextProgress)});i.append(t)}return i.append(a.element),[p(`p`,`first-run-step-text`,e.advice),r,t,i]}let y=()=>v({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.`}),b=()=>v({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.`}}),x=()=>v({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(/^\//,``)}})}),S=()=>v({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=Se(e);return t.length>0?{community:{discordChannels:t}}:`Type at least one channel, or skip.`}});function C(){if(!m)return;let e=xe(m);s.replaceChildren(O({title:`1. PostHog personal API key`,state:e.key,summary:`Key saved`,badge:`NEEDED`,body:y}),O({title:`2. Read-only GitHub token`,state:e.readToken,summary:`Token saved`,badge:`REQUIRED`,body:()=>a({laneWork:`Community research reads the GitHub issues, code and pages a question links.`,onSaved:()=>g(`project`)})}),O({title:`3. PostHog project`,state:e.project,summary:`Project ${I().projectId}`,badge:``,body:b}),O({title:`4. Research skill (optional)`,state:e.skill,summary:I().skill||`No skill`,badge:``,body:x}),O({title:`5. Discord (optional)`,state:e.discord,summary:I().discordChannels.map(e=>`#${e}`).join(` `)||`Forum only`,badge:``,body:S})),d.hidden=m!==`finished`}function w(){m=h()??`key`,C()}return ie(e=>{e.kind===`broadcast`&&(m===`key`&&o(`posthog.apiKey`)&&g(`readToken`),m===`readToken`&&r()&&g(`project`))}),{element:t,open:w,isOpen:()=>m!==null,needsSetup:()=>h()!==null}}var L=null,R=null,z=null,B=[],V=null,H=!1,U=null,W=null,G=``,K=new Map,q=null;function Te(){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=p(`ul`,e);r.setAttribute(`aria-label`,t);for(let e of n)r.append(p(`li`,null,e));return r}function Ee(e){let t=p(`div`,`pr-detail-heading`),n=p(`div`,`pr-detail-title`);n.append(p(`h2`,null,e.item.title||`Untitled question`));let r=p(`div`,`pr-detail-meta`),i=Date.parse(e.item.createdAt);r.append(p(`span`,null,e.item.author),p(`span`,null,j(e))),Number.isNaN(i)||r.append(p(`span`,null,`Asked ${v(i)}`));for(let t of e.item.tags)r.append(p(`span`,`author-org-tag`,t));return t.append(n,r),t}function De(e){let t=p(`section`,`community-question`);return t.setAttribute(`aria-label`,`Question as asked`),t.append(p(`h3`,`pr-section-heading`,`Question as asked`),p(`p`,`community-question-body`,e.item.body)),t}function Oe(e){let t=p(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Research`);let n=A(e),r=p(`div`,`pr-verdict-line`),i=p(`strong`,`community-badge`,n.text);if(i.dataset.tone=n.tone,r.append(i),t.append(r),e.error&&t.append(p(`p`,`pr-attention-detail`,e.error)),e.summary&&t.append(p(`p`,`pr-verdict-summary`,e.summary)),e.goal&&t.append(p(`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=p(`details`,`pr-verdict-checked`);return a.append(p(`summary`,null,`What it checked (${e.checked.length})`),J(`community-checked`,`What it checked`,e.checked)),t.append(a),t}function ke(e){if(!e.draft)return null;let t=p(`section`,`community-draft`);t.setAttribute(`aria-label`,`Draft reply`),t.append(p(`h3`,`pr-section-heading`,`Draft reply`),p(`p`,`community-draft-body`,e.draft.body));let r=e.draft.publicLinks.filter(g);if(r.length===0)return t;let i=p(`ul`,`community-links`);for(let e of r){let t=p(`li`);t.append(n({variant:`secondary`,size:`small`,label:e,action:`open-public-link`,onClick:()=>D(e)})),i.append(t)}return t.append(i),t}function Ae(e,t){let n=e.draft?u(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 je(e,t){if(!G){t.show(`error`,`Pick a session to start from first.`);return}let n=await s(`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&&b()?.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.`,i=await s(`community-action`,{key:e.item.key,action:t},n,{busyText:r});i?.type===`community-action-result`&&(i.ok||n.show(`error`,i.error??`The change did not apply.`))}function Me(){let e=p(`select`,`community-session-picker`);e.setAttribute(`aria-label`,`Session to start from`);let t=Te();t.some(e=>e.id===G)||(G=t[0]?.id??``);for(let n of t){let t=p(`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 Ne(e){let t=p(`div`,`community-actions`),r=c(`pr-action-status`),i=p(`div`,`community-action-buttons`);return i.append(n({variant:`secondary`,label:`Copy draft`,action:`copy-draft`,disabled:e.draft===null,onClick:()=>Ae(e,r)}),n({variant:`secondary`,label:`Open thread`,action:`open-thread`,disabled:!g(e.item.url),onClick:()=>D(e.item.url)}),Me(),n({variant:`primary`,label:`Start session`,action:`start-session`,onClick:()=>void je(e,r)}),n({variant:`secondary`,label:`Re-run`,action:`rerun-community-research`,disabled:!_e(e),onClick:()=>void Y(e,`rerun`,r)}),n({variant:`secondary`,label:`Set aside`,action:`set-aside-community-question`,disabled:!ve(e),onClick:()=>void Y(e,`set-aside`,r)})),t.append(i,r.element),t}function Pe(e){let t=p(`article`,`pr-detail community-detail`),n=ke(e);return t.append(Ee(e),Ne(e),...n?[n]:[],Oe(e),De(e)),t}function X(){if(!z)return;let e=T(B,V),t=e?JSON.stringify(e.entry):`empty:${ae(B).length}`;if(t===W)return;if(W=t,e){z.replaceChildren(Pe(e.entry));return}let n=B.some(e=>e.items.length>0);z.replaceChildren(n?i({title:`All caught up`,detail:ye(B)}):p(`p`,`pr-empty`,M(m())))}function Fe(e,t){w(_(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=T(B,e),n=K.get(e);t&&n&&Fe(t,n),X(),L&&(L.dataset.detailOpen=`true`)}function Q(){L&&(L.dataset.detailOpen=`false`),V&&K.get(V)?.focus({preventScroll:!0})}function Ie(e){let t=T(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||d(L)||ue()||f(e)||document.activeElement?.classList.contains(`xterm-helper-textarea`))return;let t=C(e);if(t!==`next-row`&&t!==`previous-row`)return;let n=oe([...K.keys()],V,t===`next-row`?1:-1);n&&(e.preventDefault(),n!==V&&Ie(n))}function Re(e,n){let r=t(`pr-queue-row pr-queue-row-quiet`);r.dataset.queueKey=e.key,r.setAttribute(`aria-current`,String(e.key===V));let i=A(e.entry),a=p(`span`,`review-queue-action community-badge`,i.text);a.dataset.tone=i.tone;let o=p(`span`,`pr-queue-top`);if(o.append(a,p(`span`,`pr-queue-title`,ge(e))),r.append(o,p(`span`,`pr-queue-elapsed`,j(e.entry))),n&&y(_(e))){let e=p(`span`,`tab-activity active pr-queue-unseen`);e.setAttribute(`aria-hidden`,`true`),r.append(e)}return r.addEventListener(`click`,()=>Z(e.key)),K.set(e.key,r),r}function ze(e){let n=p(`h3`,`pr-section-heading review-group-heading`),r=p(`span`,`review-group-count`,String(e.items.length));if(e.id!==`aside`)return n.append(p(`span`,null,e.title),r),n;let i=t(`review-group-toggle`),a=p(`span`,`review-group-chevron`,`▸`);return a.setAttribute(`aria-hidden`,`true`),i.append(a,e.title),i.setAttribute(`aria-expanded`,String(H)),i.addEventListener(`click`,()=>{H=!H,U=null,$()}),n.append(i,r),n}function Be(e){let t=p(`section`,`pr-queue-section`);if(t.dataset.group=e.id,t.append(ze(e)),e.id===`aside`&&!H)return t;for(let n of e.items)t.append(Re(n,e.id===`turn`));return t}function Ve(){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||Ve())return;B=S(),V=ne(B.filter(e=>e.id!==`aside`||H),V);let t=JSON.stringify([B,V,H,h(),m()?.error??null,e(m())]);if(t!==U){U=t,K.clear();let n=m()?.error||e(m()),r=n?[p(`p`,`my-pr-note`,n)]:[],i=B.filter(e=>e.items.length>0).map(Be);R.replaceChildren(...r,...i.length>0?i:[p(`p`,`pr-empty`,M(m()))])}X()}function He(e){if(L)return;L=p(`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=p(`div`,`review-queue-detail`);let r=p(`div`,`review-queue-phone-bar`);r.append(n({variant:`secondary`,label:`Back to queue`,action:`back-to-queue`,onClick:Q})),t.detail.append(r,z),q=we({onFinish:$}),q.element.hidden=!0,L.append(q.element,t.columns),L.dataset.detailOpen=`false`,x(()=>!d(L)),se(e=>{e.kind===`status`&&$()}),document.addEventListener(`keydown`,Le),$()}var Ue={mount:He,refresh:()=>{W=null,$()}};export{Ue as view};
1
+ import{_t as e,a as t,t as n}from"./button-CfhUK7Jn.js";import{n as r,o as i,r as a,t as o}from"./lane-read-token-step-B2OUP3Ve.js";import{c as s,i as c,s as ee,t as l}from"./action-status-rETkOMJb.js";import{b as u,d,f,s as p}from"./dom-helpers-1xKy7VX6.js";import{F as m,I as h,Ja as g,K as te,Ki as _,Kr as v,L as y,Mi as b,N as x,P as S,Qi as C,R as w,Wi as ne,X as re,Xi as T,ct as ie,oa as ae,ot as E,qa as D,ra as oe,z as se}from"./index-k6lh2SOM.js";import{t as ce}from"./pr-queue-columns-CW_j5U77.js";import{o as le}from"./card-registry-D1_v6Lbm.js";import{i as ue}from"./modal-CjIIQMho.js";import{d as de,f as fe}from"./control-ws-DEfwcMni.js";import{n as O}from"./setup-step-B9ALtknc.js";var pe={HIGH:`High confidence`,MEDIUM:`Medium confidence`,LOW:`Low confidence`},me={HIGH:`ok`,MEDIUM:`warn`,LOW:`muted`},k={queued:`Waiting to be researched`,running:`Researching`,error:`Research failed`,aside:`Set aside`},he={forum:`Forum`,discord:`Discord`};function A(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:k.error,tone:`danger`}:{text:k[e.status],tone:`muted`}}function j(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 M(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 N=[`key`,`readToken`,`project`,`skill`,`discord`];function xe(e){let t=e===`finished`?N.length:N.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 Se(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=E().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 Ce(e,t,n,r){let i=p(`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 we({onFinish:e}){let t=p(`section`,`first-run-checklist review-setup`);t.setAttribute(`aria-labelledby`,`community-setup-title`);let i=p(`h2`,`first-run-title`,`Answer community questions`);i.id=`community-setup-title`;let s=p(`ol`,`first-run-steps`),u=p(`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 d=p(`div`,`first-run-step-actions`),f=n({variant:`primary`,label:`Finish setup`,action:`finish-community-setup`});d.append(f),d.hidden=!0,t.append(p(`span`,`first-run-eyebrow`,`SET UP COMMUNITY`),i,s,d,u);let m=null;f.addEventListener(`click`,()=>{F(`finish-community-setup`),m=null,e()});function h(){return o(`posthog.apiKey`)?r()?null:`readToken`:`key`}function g(e){m=e===`readToken`&&r()?`project`:e,C(),(s.querySelector(`[aria-current="step"] input`)??(d.hidden?null:f))?.focus()}async function _(e,t,n,r){t.disabled=!0,n.show(`busy`,`Saving`);try{let t=await fe(`update-settings`,{settings:e},{timeoutMs:l});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}re(t.settings),g(r)}catch(e){n.show(`error`,ee(e,l))}finally{t.disabled=!1}}function v(e){let t=Ce(e.inputId,e.initialValue,e.placeholder,e.inputType),r=p(`label`,`repo-roots-adder-label`,e.label);r.htmlFor=t.id;let i=p(`div`,`first-run-step-actions`),a=c(),o=n({variant:`primary`,label:e.saveLabel,action:e.action}),s=()=>{let n=e.settingsPatch(t.value);typeof n==`string`?a.show(`error`,n):(F(e.action),_(n,o,a,e.nextProgress))};if(o.addEventListener(`click`,s),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),s())}),i.append(o),e.isSkippable){let t=n({variant:`secondary`,label:`Skip`,action:`skip-community-setup-step`,onClick:()=>g(e.nextProgress)});i.append(t)}return i.append(a.element),[p(`p`,`first-run-step-text`,e.advice),r,t,i]}let y=()=>v({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.`}),b=()=>v({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.`}}),x=()=>v({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(/^\//,``)}})}),S=()=>v({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=Se(e);return t.length>0?{community:{discordChannels:t}}:`Type at least one channel, or skip.`}});function C(){if(!m)return;let e=xe(m);s.replaceChildren(O({title:`1. PostHog personal API key`,state:e.key,summary:`Key saved`,badge:`NEEDED`,body:y}),O({title:`2. Read-only GitHub token`,state:e.readToken,summary:`Token saved`,badge:`REQUIRED`,body:()=>a({laneWork:`Community research reads the GitHub issues, code and pages a question links.`,onSaved:()=>g(`project`)})}),O({title:`3. PostHog project`,state:e.project,summary:`Project ${I().projectId}`,badge:``,body:b}),O({title:`4. Research skill (optional)`,state:e.skill,summary:I().skill||`No skill`,badge:``,body:x}),O({title:`5. Discord (optional)`,state:e.discord,summary:I().discordChannels.map(e=>`#${e}`).join(` `)||`Forum only`,badge:``,body:S})),d.hidden=m!==`finished`}function w(){m=h()??`key`,C()}return ie(e=>{e.kind===`broadcast`&&(m===`key`&&o(`posthog.apiKey`)&&g(`readToken`),m===`readToken`&&r()&&g(`project`))}),{element:t,open:w,isOpen:()=>m!==null,needsSetup:()=>h()!==null}}var L=null,R=null,z=null,B=[],V=null,H=!1,U=null,W=null,G=``,K=new Map,q=null;function Te(){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=p(`ul`,e);r.setAttribute(`aria-label`,t);for(let e of n)r.append(p(`li`,null,e));return r}function Ee(e){let t=p(`div`,`pr-detail-heading`),n=p(`div`,`pr-detail-title`);n.append(p(`h2`,null,e.item.title||`Untitled question`));let r=p(`div`,`pr-detail-meta`),i=Date.parse(e.item.createdAt);r.append(p(`span`,null,e.item.author),p(`span`,null,j(e))),Number.isNaN(i)||r.append(p(`span`,null,`Asked ${v(i)}`));for(let t of e.item.tags)r.append(p(`span`,`author-org-tag`,t));return t.append(n,r),t}function De(e){let t=p(`section`,`community-question`);return t.setAttribute(`aria-label`,`Question as asked`),t.append(p(`h3`,`pr-section-heading`,`Question as asked`),p(`p`,`community-question-body`,e.item.body)),t}function Oe(e){let t=p(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Research`);let n=A(e),r=p(`div`,`pr-verdict-line`),i=p(`strong`,`community-badge`,n.text);if(i.dataset.tone=n.tone,r.append(i),t.append(r),e.error&&t.append(p(`p`,`pr-attention-detail`,e.error)),e.summary&&t.append(p(`p`,`pr-verdict-summary`,e.summary)),e.goal&&t.append(p(`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=p(`details`,`pr-verdict-checked`);return a.append(p(`summary`,null,`What it checked (${e.checked.length})`),J(`community-checked`,`What it checked`,e.checked)),t.append(a),t}function ke(e){if(!e.draft)return null;let t=p(`section`,`community-draft`);t.setAttribute(`aria-label`,`Draft reply`),t.append(p(`h3`,`pr-section-heading`,`Draft reply`),p(`p`,`community-draft-body`,e.draft.body));let r=e.draft.publicLinks.filter(g);if(r.length===0)return t;let i=p(`ul`,`community-links`);for(let e of r){let t=p(`li`);t.append(n({variant:`secondary`,size:`small`,label:e,action:`open-public-link`,onClick:()=>D(e)})),i.append(t)}return t.append(i),t}function Ae(e,t){let n=e.draft?u(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 je(e,t){if(!G){t.show(`error`,`Pick a session to start from first.`);return}let n=await s(`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&&b()?.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.`,i=await s(`community-action`,{key:e.item.key,action:t},n,{busyText:r});i?.type===`community-action-result`&&(i.ok||n.show(`error`,i.error??`The change did not apply.`))}function Me(){let e=p(`select`,`community-session-picker`);e.setAttribute(`aria-label`,`Session to start from`);let t=Te();t.some(e=>e.id===G)||(G=t[0]?.id??``);for(let n of t){let t=p(`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 Ne(e){let t=p(`div`,`community-actions`),r=c(`pr-action-status`),i=p(`div`,`community-action-buttons`);return i.append(n({variant:`secondary`,label:`Copy draft`,action:`copy-draft`,disabled:e.draft===null,onClick:()=>Ae(e,r)}),n({variant:`secondary`,label:`Open thread`,action:`open-thread`,disabled:!g(e.item.url),onClick:()=>D(e.item.url)}),Me(),n({variant:`primary`,label:`Start session`,action:`start-session`,onClick:()=>void je(e,r)}),n({variant:`secondary`,label:`Re-run`,action:`rerun-community-research`,disabled:!_e(e),onClick:()=>void Y(e,`rerun`,r)}),n({variant:`secondary`,label:`Set aside`,action:`set-aside-community-question`,disabled:!ve(e),onClick:()=>void Y(e,`set-aside`,r)})),t.append(i,r.element),t}function Pe(e){let t=p(`article`,`pr-detail community-detail`),n=ke(e);return t.append(Ee(e),Ne(e),...n?[n]:[],Oe(e),De(e)),t}function X(){if(!z)return;let e=T(B,V),t=e?JSON.stringify(e.entry):`empty:${ae(B).length}`;if(t===W)return;if(W=t,e){z.replaceChildren(Pe(e.entry));return}let n=B.some(e=>e.items.length>0);z.replaceChildren(n?i({title:`All caught up`,detail:ye(B)}):p(`p`,`pr-empty`,M(m())))}function Fe(e,t){w(_(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=T(B,e),n=K.get(e);t&&n&&Fe(t,n),X(),L&&(L.dataset.detailOpen=`true`)}function Q(){L&&(L.dataset.detailOpen=`false`),V&&K.get(V)?.focus({preventScroll:!0})}function Ie(e){let t=T(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||d(L)||ue()||f(e)||document.activeElement?.classList.contains(`xterm-helper-textarea`))return;let t=C(e);if(t!==`next-row`&&t!==`previous-row`)return;let n=oe([...K.keys()],V,t===`next-row`?1:-1);n&&(e.preventDefault(),n!==V&&Ie(n))}function Re(e,n){let r=t(`pr-queue-row pr-queue-row-quiet`);r.dataset.queueKey=e.key,r.setAttribute(`aria-current`,String(e.key===V));let i=A(e.entry),a=p(`span`,`review-queue-action community-badge`,i.text);a.dataset.tone=i.tone;let o=p(`span`,`pr-queue-top`);if(o.append(a,p(`span`,`pr-queue-title`,ge(e))),r.append(o,p(`span`,`pr-queue-elapsed`,j(e.entry))),n&&y(_(e))){let e=p(`span`,`tab-activity active pr-queue-unseen`);e.setAttribute(`aria-hidden`,`true`),r.append(e)}return r.addEventListener(`click`,()=>Z(e.key)),K.set(e.key,r),r}function ze(e){let n=p(`h3`,`pr-section-heading review-group-heading`),r=p(`span`,`review-group-count`,String(e.items.length));if(e.id!==`aside`)return n.append(p(`span`,null,e.title),r),n;let i=t(`review-group-toggle`),a=p(`span`,`review-group-chevron`,`▸`);return a.setAttribute(`aria-hidden`,`true`),i.append(a,e.title),i.setAttribute(`aria-expanded`,String(H)),i.addEventListener(`click`,()=>{H=!H,U=null,$()}),n.append(i,r),n}function Be(e){let t=p(`section`,`pr-queue-section`);if(t.dataset.group=e.id,t.append(ze(e)),e.id===`aside`&&!H)return t;for(let n of e.items)t.append(Re(n,e.id===`turn`));return t}function Ve(){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||Ve())return;B=S(),V=ne(B.filter(e=>e.id!==`aside`||H),V);let t=JSON.stringify([B,V,H,h(),m()?.error??null,e(m())]);if(t!==U){U=t,K.clear();let n=m()?.error||e(m()),r=n?[p(`p`,`my-pr-note`,n)]:[],i=B.filter(e=>e.items.length>0).map(Be);R.replaceChildren(...r,...i.length>0?i:[p(`p`,`pr-empty`,M(m()))])}X()}function He(e){if(L)return;L=p(`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=p(`div`,`review-queue-detail`);let r=p(`div`,`review-queue-phone-bar`);r.append(n({variant:`secondary`,label:`Back to queue`,action:`back-to-queue`,onClick:Q})),t.detail.append(r,z),q=we({onFinish:$}),q.element.hidden=!0,L.append(q.element,t.columns),L.dataset.detailOpen=`false`,x(()=>!d(L)),se(e=>{e.kind===`status`&&$()}),document.addEventListener(`keydown`,Le),$()}var Ue={mount:He,refresh:()=>{W=null,$()}};export{Ue as view};
@@ -1,4 +1,4 @@
1
- import{i as e,s as t,t as n}from"./action-status-rETkOMJb.js";import{f as r}from"./control-ws-DEfwcMni.js";import{a as i,et as a,ft as o,ln as s,mt as c,pt as l,t as u,un as d}from"./button-CfhUK7Jn.js";import{Kr as f,M as p,Yr as m,dt as h,ft as g,si as _,uo as v,ut as y,y as b}from"./index-CwndYdst.js";import{g as x,h as S,s as C,un as w}from"./dom-helpers-1xKy7VX6.js";import{t as T}from"./repo-roots-adder-Cpil4nGt.js";import{n as E,r as ee,t as te}from"./modal-CjIIQMho.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-BQ1THBfW.js";import{t as ce}from"./agent-mark-CAPAtm4S.js";import{o as le,v as ue}from"./card-registry-D1_v6Lbm.js";import{At as de,Dt as fe,Mt as pe,N as me,Ot as he,jt as ge,kt as _e,n as ve}from"./ui-prefs-D3kfa1nO.js";import{n as O}from"./session-tick-DrUXWyvz.js";var ye=`<h2 class="dialog-title" id="add-session-title">What are we working on?</h2>
1
+ import{i as e,s as t,t as n}from"./action-status-rETkOMJb.js";import{f as r}from"./control-ws-DEfwcMni.js";import{a as i,et as a,ft as o,ln as s,mt as c,pt as l,t as u,un as d}from"./button-CfhUK7Jn.js";import{Kr as f,M as p,Yr as m,dt as h,ft as g,si as _,uo as v,ut as y,y as b}from"./index-k6lh2SOM.js";import{g as x,h as S,s as C,un as w}from"./dom-helpers-1xKy7VX6.js";import{t as T}from"./repo-roots-adder-BHxNnfhf.js";import{n as E,r as ee,t as te}from"./modal-CjIIQMho.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-BjRsd_gB.js";import{t as ce}from"./agent-mark-CDiDVO9j.js";import{o as le,v as ue}from"./card-registry-D1_v6Lbm.js";import{At as de,Dt as fe,Mt as pe,N as me,Ot as he,jt as ge,kt as _e,n as ve}from"./ui-prefs-D3kfa1nO.js";import{n as O}from"./session-tick-DrUXWyvz.js";var ye=`<h2 class="dialog-title" id="add-session-title">What are we working on?</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">
@@ -1,4 +1,4 @@
1
- import{s as e,t}from"./action-status-rETkOMJb.js";import{f as n}from"./control-ws-DEfwcMni.js";import{bi as r,oo as i}from"./index-CwndYdst.js";import{s as a}from"./dom-helpers-1xKy7VX6.js";import{a as o,r as s,t as c}from"./modal-CjIIQMho.js";import{O as l,_n as u,t as d,u as f}from"./button-CfhUK7Jn.js";import{i as p,t as m}from"./plan-render-usK70-q6.js";import{i as h,n as g,r as _}from"./whiteboard-undo-core-CAnu7_EN.js";var v=[`wc`,`awk`,`frag`,`tense`,`unclear`,`para`,`good`,`must`,`end`],y=`{>>`,b=`<<}`,x=`~>`,ee=[{opener:`{--`,closer:`--}`,markKind:`deletion`},{opener:`{++`,closer:`++}`,markKind:`insertion`},{opener:`{~~`,closer:`~~}`,markKind:`substitution`},{opener:`{==`,closer:`==}`,markKind:`highlight`},{opener:y,closer:b,markKind:`comment`}],te=[...ee.flatMap(({opener:e,closer:t})=>[e,t]),x],ne=RegExp(`^(${v.join(`|`)}):\\s*`,`i`);function re(e){return v.includes(e)}function S(e){if(e===void 0||e.trim()===``)return null;let t=ne.exec(e),n=t?.[1]?.toLowerCase()??``;return!t||!re(n)?{code:null,body:e.trim()}:{code:n,body:e.slice(t[0].length).trim()}}function ie(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 ae(e,t,n){if(!e.startsWith(y,n))return{rawNote:void 0,end:n};let r=t(b,n+3);return r===-1?{rawNote:void 0,end:n}:{rawNote:e.slice(n+3,r),end:r+3}}function oe(e,t,n){let r=t(x,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 se(e,t,n){let r=ee.find(({opener:t})=>e.startsWith(t,n));if(!r)return null;let i=n+r.opener.length;if(r.markKind===`substitution`){let a=oe(e,t,i);if(!a)return null;let o=ae(e,t,a.closeAt+r.closer.length);return{kind:`mark`,markKind:`substitution`,start:n,end:o.end,oldText:a.oldText,newText:a.newText,note:S(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:S(o)};let c=ae(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:S(c.rawNote)}}function C(e){let t=[],n=ie(e),r=0,i=e.indexOf(`{`);for(;i!==-1;){let a=se(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 ce(e){return e.markKind===`comment`&&e.note?.code===`end`}function le(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 ue(e,t,n){return e.slice(0,t.start)+le(t,n)+e.slice(t.end)}function de(e){return C(e).map(e=>e.kind===`text`?e.text:le(e,`accept`)).join(``)}function w(e){return te.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(b)&&e.startsWith(y,t.end),a=r+n+(i?`${y}${b}`:``),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 fe(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 pe(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 me(e,t,n,r){if(n===``)return T(`nothing`);let i=fe(e,t,r);if(i)return pe(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 he(e,t){return t<0||t>=e.length||e[t]===`
1
+ import{s as e,t}from"./action-status-rETkOMJb.js";import{f as n}from"./control-ws-DEfwcMni.js";import{bi as r,oo as i}from"./index-k6lh2SOM.js";import{s as a}from"./dom-helpers-1xKy7VX6.js";import{a as o,r as s,t as c}from"./modal-CjIIQMho.js";import{O as l,_n as u,t as d,u as f}from"./button-CfhUK7Jn.js";import{i as p,t as m}from"./plan-render-DY2Uplgx.js";import{i as h,n as g,r as _}from"./whiteboard-undo-core-CPx7qi5j.js";var v=[`wc`,`awk`,`frag`,`tense`,`unclear`,`para`,`good`,`must`,`end`],y=`{>>`,b=`<<}`,x=`~>`,ee=[{opener:`{--`,closer:`--}`,markKind:`deletion`},{opener:`{++`,closer:`++}`,markKind:`insertion`},{opener:`{~~`,closer:`~~}`,markKind:`substitution`},{opener:`{==`,closer:`==}`,markKind:`highlight`},{opener:y,closer:b,markKind:`comment`}],te=[...ee.flatMap(({opener:e,closer:t})=>[e,t]),x],ne=RegExp(`^(${v.join(`|`)}):\\s*`,`i`);function re(e){return v.includes(e)}function S(e){if(e===void 0||e.trim()===``)return null;let t=ne.exec(e),n=t?.[1]?.toLowerCase()??``;return!t||!re(n)?{code:null,body:e.trim()}:{code:n,body:e.slice(t[0].length).trim()}}function ie(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 ae(e,t,n){if(!e.startsWith(y,n))return{rawNote:void 0,end:n};let r=t(b,n+3);return r===-1?{rawNote:void 0,end:n}:{rawNote:e.slice(n+3,r),end:r+3}}function oe(e,t,n){let r=t(x,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 se(e,t,n){let r=ee.find(({opener:t})=>e.startsWith(t,n));if(!r)return null;let i=n+r.opener.length;if(r.markKind===`substitution`){let a=oe(e,t,i);if(!a)return null;let o=ae(e,t,a.closeAt+r.closer.length);return{kind:`mark`,markKind:`substitution`,start:n,end:o.end,oldText:a.oldText,newText:a.newText,note:S(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:S(o)};let c=ae(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:S(c.rawNote)}}function C(e){let t=[],n=ie(e),r=0,i=e.indexOf(`{`);for(;i!==-1;){let a=se(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 ce(e){return e.markKind===`comment`&&e.note?.code===`end`}function le(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 ue(e,t,n){return e.slice(0,t.start)+le(t,n)+e.slice(t.end)}function de(e){return C(e).map(e=>e.kind===`text`?e.text:le(e,`accept`)).join(``)}function w(e){return te.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(b)&&e.startsWith(y,t.end),a=r+n+(i?`${y}${b}`:``),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 fe(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 pe(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 me(e,t,n,r){if(n===``)return T(`nothing`);let i=fe(e,t,r);if(i)return pe(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 he(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 ge(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 _e(e,t,n,r){let i=fe(e,t,r);if(i&&n===`backward`)return pe(e,i,i.newText.slice(0,-1));if(!D(t))return ge(e,t,n);let a=n===`backward`?t.start-1:t.start;return he(e,a)?ge(e,{start:a,end:a+1},n):T(`nothing`)}function ve(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=`${y}${r}${b}`;return D(t)?ye(k(e,t,a,E(e).some(n=>n.end===t.start&&n.markKind!==`comment`&&!e.slice(n.start,n.end).endsWith(b))?`${y}${b}`:``)):ye(k(e,t,`{==${i}==}${a}`))}function ye(e){return e?A(e,e.markEnd,null):T(`swallowed`)}function be(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 xe(e,t,n){if(!be(e,t.selection))return T(`nested`);switch(t.kind){case`type`:return me(e,t.selection,t.text,n);case`delete`:return _e(e,t.selection,t.direction,n);case`paragraph`:return ve(e,{start:t.selection.end,end:t.selection.end},`para`);case`note`:return D(t.selection)?T(`nothing`):ve(e,t.selection,t.body)}}var Se=/^ {0,3}(`{3,}|~{3,})/,j=/^ {0,3}#{1,6}[ \t]+/,Ce=/^ {0,3}(?:>[ \t]?)+/,we=/^[ \t]*(?:[-*+]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/,Te=/^[ \t]*\|/,Ee=/^[ \t]*!\[([^\]\n]*)\]\(\s*<?([^\s)<>]+)>?(?:\s+"[^"\n]*")?\s*\)[ \t]*$/,De=/^[ \t]*\|?(?:[ \t]*:?-{3,}:?[ \t]*\|)*[ \t]*:?-{3,}:?[ \t]*\|?[ \t]*$/,Oe=/(`+)(?!`)(.+?)(?<!`)\1(?!`)|(\*\*|__)(?=\S)(.+?)(?<=\S)\3|(?<![\w*])([*_])(?=[^\s*_])(.+?)(?<=[^\s*_])\5(?![\w*])/g,ke=[`plain`,`h1`,`h2`,`h3`,`h3`,`h3`,`h3`],Ae={h1:j,h2:j,h3:j,quote:Ce,list:we};function je(e){let t=u(e,{overlongLine:`truncate`});return t?ke[t.level]??`h3`:Ce.test(e)?`quote`:we.test(e)?`list`:Te.test(e)?`table`:`plain`}function Me(e,t){let n=Se.exec(e)?.[1];return n!==void 0&&n[0]===t[0]&&n.length>=t.length&&e.trim()===n}function Ne(e){let t=null;return e.split(`
3
3
  `).map(e=>t===null?(t=Se.exec(e)?.[1]??null,t===null?je(e):`fence`):(Me(e,t)&&(t=null),`fence`))}function M(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 Pe(e,t,n){if(t===`fence`||t===`table`)return[];let r=[],i=n?Ae[t]?.exec(e)?.[0]:void 0;i&&r.push({start:0,end:i.length,style:`syntax`});for(let t of e.matchAll(Oe)){let e=t.index,n=e+t[0].length,[,i,,a,,o]=t;i&&r.push(...M(e,n,i.length,`code`)),a&&r.push(...M(e,n,a.length,`strong`)),o&&r.push(...M(e,n,o.length,`emphasis`))}return r}function Fe(e){let t=Ee.exec(e);return t?{alt:t[1]??``,src:t[2]??``}:null}function Ie(e,t){return e===`table`||e===`fence`?e:e===`plain`&&Ee.test(t)?`image`:null}function Le(e,t){return e===`image`?t.length===1:t.length<2?!1:e===`fence`||De.test(t[1]??``)}function Re(e){let t=e.split(`
4
4
  `),n=Ne(e),r=[],i=0;for(let e of t)r.push(i),i+=e.length+1;let a=[],o={table:0,fence:0,image:0},s=0;for(;s<t.length;){let e=Ie(n[s],t[s]??``),i=s;if(s+=1,e===null)continue;for(;e!==`image`&&n[s]===e;)s+=1;let c=s-1;if(!Le(e,t.slice(i,s)))continue;let l=r[i]??0,u=(r[c]??0)+(t[c]?.length??0);a.push({kind:e,key:`${e}-${o[e]}`,start:l,end:u}),o[e]+=1}return a}var ze=1e3,Be=Object.freeze({stacks:Object.freeze({undo:[],redo:[]}),openGroup:null}),Ve=new Set([`type`,`delete`]);function He(e){return Ve.has(e)}function Ue(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e[a]===t[a];)a+=1;let o=0,s=i-a;for(;o<s&&e[e.length-1-o]===t[t.length-1-o];)o+=1;return{start:a,removedText:e.slice(a,e.length-o),insertedText:t.slice(a,t.length-o),caretBefore:n,caretAfter:r}}function We(e,t){return e?e.kind===t.kind&&e.caretAfter===t.caretBefore&&t.atMs-e.lastEditAtMs<ze:!1}function Ge(e,t){let n=e.undo.at(-1);return n?{undo:[...e.undo.slice(0,-1),[...n,t]],redo:[]}:g(e,[t])}function Ke(e,t){if(t.before===t.after)return e;let n=Ue(t.before,t.after,t.caretBefore,t.caretAfter),r=He(t.kind)?{kind:t.kind,caretAfter:t.caretAfter,lastEditAtMs:t.atMs}:null;return{stacks:We(e.openGroup,t)?Ge(e.stacks,n):g(e.stacks,[n]),openGroup:r}}function qe(e,t){return e.slice(0,t.start)+t.removedText+e.slice(t.start+t.insertedText.length)}function Je(e,t){return e.slice(0,t.start)+t.insertedText+e.slice(t.start+t.removedText.length)}function Ye(e,t,n){return n===`undo`?{source:t.toReversed().reduce(qe,e),caret:t[0]?.caretBefore??0}:{source:t.reduce(Je,e),caret:t.at(-1)?.caretAfter??0}}function Xe(e,t,n){let r=h(e.stacks,t);if(!r)return null;let i=Ye(n,r.entry,t);return{history:{stacks:_(r.history,t,r.entry),openGroup:null},...i}}var Ze={unclear:`?`,para:`¶`},Qe={deletion:`Cut`,insertion:`Add`,substitution:`Change`,highlight:`Note`,comment:`Note`},$e={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:``},et=new Set([`deleteContentBackward`,`deleteByCut`]),tt=new Set([`insertText`,`insertReplacementText`,`insertFromPaste`,`insertFromYank`]),nt=new Set([`insertParagraph`,`insertLineBreak`]),rt=`http://www.w3.org/2000/svg`,it={table:`table`,fence:`code block`,image:`image`},at=/^https?:\/\//i;function N(e,t){let n=document.createElementNS(rt,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function ot(){let e=N(`svg`,{width:`0`,height:`0`,"aria-hidden":`true`,class:`doc-markup-defs`}),t=N(`filter`,{id:`doc-markup-ink`});return t.append(N(`feTurbulence`,{type:`fractalNoise`,baseFrequency:`0.05`,numOctaves:`2`,result:`grain`}),N(`feDisplacementMap`,{in:`SourceGraphic`,in2:`grain`,scale:`1.6`})),e.append(t),e}function st(){let e=N(`svg`,{viewBox:`0 0 16 16`,class:`doc-markup-check`,"aria-hidden":`true`});return e.append(N(`path`,{d:`M2 9 L6 13 L14 3`})),e}function ct(){let e=d({variant:`primary`,size:`small`,label:`Accept`,action:`accept-mark`}),t=d({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=d({variant:`secondary`,size:`small`,label:`Add note`,action:`add-note`}),s=d({variant:`secondary`,size:`small`,label:`Preview all`,action:`preview-all-blocks`,hidden:!0});s.setAttribute(`aria-pressed`,`false`),o.classList.add(`doc-markup-float`);let c=a(`input`,`plan-control doc-markup-input`);c.type=`text`,c.placeholder=`Note, or a code like wc: or awk:`,c.setAttribute(`aria-label`,`Note on the selected text`);let l=a(`div`,`doc-markup-float doc-markup-composer`);l.append(c);let u=a(`span`,`doc-markup-hint`);u.setAttribute(`role`,`status`);let f=a(`div`,`doc-markup-paper`);f.spellcheck=!1,f.setAttribute(`role`,`textbox`),f.setAttribute(`aria-multiline`,`true`),f.setAttribute(`aria-label`,`Doc in red pen; edits become marks`);let p=a(`div`,`doc-markup-end`),m=a(`div`,`doc-markup`);for(let e of[i,o,l])e.hidden=!0;m.append(ot(),f,p,i,o,l);let h={root:m,paper:f,endNotes:p,markCard:i,markCardText:n,btnAccept:e,btnReject:t,btnAddNote:o,btnPreviewAll:s,previewBlocks:[],previewedBlockKeys:new Set,imageUrlsBySource:new Map,missingImageSources:new Set,noteComposer:l,noteInput:c,hint:u,marginResizeObserver:new ResizeObserver(()=>At([...h.visibleRows])),rowObserver:null,listeners:new AbortController,rowsByElement:new Map,visibleRows:new Set,selection:null,noteSelection:null,compositionSelection:null,run:null,history:Be,tip:``,marks:[],elementsByMarkIndex:[],selectedMarkIndex:null};return h.marginResizeObserver.observe(f),h}function lt(e){for(let t of e.imageUrlsBySource.values())t.then(e=>{e&&URL.revokeObjectURL(e)});e.imageUrlsBySource.clear(),e.missingImageSources.clear()}function ut(e){lt(e),e.marginResizeObserver.disconnect(),e.rowObserver?.disconnect(),e.listeners.abort()}function dt(e){let t=[Qe[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 ft(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`,dt(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 pt(e){let t=a(`div`,`doc-markup-note`);return t.dataset.code=e.note?.code??``,e.note?.code===`good`&&t.append(st()),e.note?.code&&e.note.code!==`good`&&t.append(a(`span`,`doc-markup-code`,Ze[e.note.code]??e.note.code)),e.note?.body&&t.append(a(`span`,`doc-markup-note-body`,e.note.body)),t}function mt(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 P(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 ht(e,t,n,r,i){let a=[],o=0;for(let s of Pe(e,r,i))s.start>o&&a.push(P(e.slice(o,s.start),t+o,n)),a.push(P(e.slice(s.start,s.end),t+s.start,n,s.style)),o=s.end;return o<e.length&&a.push(P(e.slice(o),t+o,n)),a}function gt(e){let t=Ne(e),n=new Map,r=0;for(let[i,a]of e.split(`
@@ -1 +1 @@
1
- import{Vt as e,t}from"./button-CfhUK7Jn.js";import{n,r,t as i}from"./flying-animal-preview-C9Ds134f.js";import{d as a}from"./control-ws-DEfwcMni.js";import{s as o}from"./dom-helpers-1xKy7VX6.js";import{G as s,_i as c,qa as l,vi as u}from"./index-CwndYdst.js";import{Lt as d}from"./ui-prefs-D3kfa1nO.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 u(localStorage,c(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`),l(`https://github.com/${r}`)},onDismiss:()=>C(`dismiss`)}),C(`shown`))}export{b as isHintCardShown,S as showFeatureHint,x as showHintCard,w as showStarHint};
1
+ import{Vt as e,t}from"./button-CfhUK7Jn.js";import{n,r,t as i}from"./flying-animal-preview-C9Ds134f.js";import{d as a}from"./control-ws-DEfwcMni.js";import{s as o}from"./dom-helpers-1xKy7VX6.js";import{G as s,_i as c,qa as l,vi as u}from"./index-k6lh2SOM.js";import{Lt as d}from"./ui-prefs-D3kfa1nO.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 u(localStorage,c(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`),l(`https://github.com/${r}`)},onDismiss:()=>C(`dismiss`)}),C(`shown`))}export{b as isHintCardShown,S as showFeatureHint,x as showHintCard,w as showStarHint};