glimmervoid 0.52.3-next.821 → 0.52.3-next.822

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 (90) hide show
  1. package/dist/client/assets/{agent-core-CXzuinog.js → agent-core-V-1YNpK6.js} +2 -2
  2. package/dist/client/assets/agent-core-V-1YNpK6.js.br +0 -0
  3. package/dist/client/assets/{agent-mark-DUhBzwDw.js → agent-mark-DRB_6Q8i.js} +1 -1
  4. package/dist/client/assets/agent-mark-DRB_6Q8i.js.br +0 -0
  5. package/dist/client/assets/{arena-panel-CSHhinn0.js → arena-panel-BSbImp7u.js} +2 -2
  6. package/dist/client/assets/arena-panel-BSbImp7u.js.br +0 -0
  7. package/dist/client/assets/{benchmark-panel-DYfKxUVr.js → benchmark-panel-Dw8ft54E.js} +1 -1
  8. package/dist/client/assets/benchmark-panel-Dw8ft54E.js.br +0 -0
  9. package/dist/client/assets/{boards-view-D-_CScqe.js → boards-view-CLX5JZsl.js} +1 -1
  10. package/dist/client/assets/boards-view-CLX5JZsl.js.br +0 -0
  11. package/dist/client/assets/{community-panel-C9O4JPCX.js → community-panel-C3cbbFnJ.js} +1 -1
  12. package/dist/client/assets/community-panel-C3cbbFnJ.js.br +0 -0
  13. package/dist/client/assets/{dialogs-BkU7zFNQ.js → dialogs-DqjOrA44.js} +1 -1
  14. package/dist/client/assets/dialogs-DqjOrA44.js.br +0 -0
  15. package/dist/client/assets/{doc-editor-ui-BMd8WZmt.js → doc-editor-ui-BM4ZDt5z.js} +1 -1
  16. package/dist/client/assets/doc-editor-ui-BM4ZDt5z.js.br +0 -0
  17. package/dist/client/assets/{feature-hint-DwHKkhDc.js → feature-hint-bOF8tUHy.js} +1 -1
  18. package/dist/client/assets/feature-hint-bOF8tUHy.js.br +0 -0
  19. package/dist/client/assets/{first-run-checklist-CSvN50kN.js → first-run-checklist-BQlDDD9y.js} +1 -1
  20. package/dist/client/assets/first-run-checklist-BQlDDD9y.js.br +0 -0
  21. package/dist/client/assets/{hooks-panel-BVx429sM.js → hooks-panel-hS7-5mX2.js} +1 -1
  22. package/dist/client/assets/hooks-panel-hS7-5mX2.js.br +0 -0
  23. package/dist/client/assets/{index-DbtIz4EN.js → index-CByiCIuo.js} +5 -5
  24. package/dist/client/assets/index-CByiCIuo.js.br +0 -0
  25. package/dist/client/assets/{issues-panel-WYdIMgYD.js → issues-panel-axMwQiBh.js} +1 -1
  26. package/dist/client/assets/issues-panel-axMwQiBh.js.br +0 -0
  27. package/dist/client/assets/{lane-read-token-step-Dxc1tmXl.js → lane-read-token-step-n4JGDhwd.js} +1 -1
  28. package/dist/client/assets/lane-read-token-step-n4JGDhwd.js.br +0 -0
  29. package/dist/client/assets/{my-prs-panel-yQSNEfn3.js → my-prs-panel-BvibE3Rg.js} +1 -1
  30. package/dist/client/assets/my-prs-panel-BvibE3Rg.js.br +0 -0
  31. package/dist/client/assets/{nyan-cat-BxympIrg.js → nyan-cat-jV8EqD5V.js} +1 -1
  32. package/dist/client/assets/nyan-cat-jV8EqD5V.js.br +0 -0
  33. package/dist/client/assets/{phone-shell-C7iozxsv.js → phone-shell-CVFeSYj8.js} +1 -1
  34. package/dist/client/assets/phone-shell-CVFeSYj8.js.br +0 -0
  35. package/dist/client/assets/{plan-face-CDPOZVPd.js → plan-face-DhdWJW_9.js} +1 -1
  36. package/dist/client/assets/plan-face-DhdWJW_9.js.br +0 -0
  37. package/dist/client/assets/{plan-render-7PY_vAFR.js → plan-render-C8QQ7AaV.js} +1 -1
  38. package/dist/client/assets/plan-render-C8QQ7AaV.js.br +0 -0
  39. package/dist/client/assets/{pr-queue-columns-ULfSLQzl.js → pr-queue-columns-M-LJkZf1.js} +1 -1
  40. package/dist/client/assets/pr-queue-columns-M-LJkZf1.js.br +0 -0
  41. package/dist/client/assets/{radar-panel-PiejkiI8.js → radar-panel-BiO5fVfp.js} +1 -1
  42. package/dist/client/assets/radar-panel-BiO5fVfp.js.br +0 -0
  43. package/dist/client/assets/{repo-roots-adder-CY5Iq_-O.js → repo-roots-adder-DYYg40Om.js} +1 -1
  44. package/dist/client/assets/repo-roots-adder-DYYg40Om.js.br +0 -0
  45. package/dist/client/assets/{resume-dialog-Cskz0w--.js → resume-dialog-BKYsnZgT.js} +1 -1
  46. package/dist/client/assets/resume-dialog-BKYsnZgT.js.br +0 -0
  47. package/dist/client/assets/{review-queue-panel-7CViVoDA.js → review-queue-panel-DVFqwHv7.js} +1 -1
  48. package/dist/client/assets/review-queue-panel-DVFqwHv7.js.br +0 -0
  49. package/dist/client/assets/{session-row-CCQDp9zg.js → session-row-1RDXO34-.js} +1 -1
  50. package/dist/client/assets/session-row-1RDXO34-.js.br +0 -0
  51. package/dist/client/assets/{settings-panel-DqMuBqMl.js → settings-panel-CDfOE9u7.js} +2 -2
  52. package/dist/client/assets/settings-panel-CDfOE9u7.js.br +0 -0
  53. package/dist/client/assets/{trace-panel-CDaGtlbi.js → trace-panel-Dsxdc83U.js} +1 -1
  54. package/dist/client/assets/trace-panel-Dsxdc83U.js.br +0 -0
  55. package/dist/client/assets/{usage-panel-BusH_oaU.js → usage-panel-Baduzj5u.js} +1 -1
  56. package/dist/client/assets/usage-panel-Baduzj5u.js.br +0 -0
  57. package/dist/client/assets/{your-day-tip-P3ywC8Pc.js → your-day-tip-BFNaNmBt.js} +1 -1
  58. package/dist/client/assets/your-day-tip-BFNaNmBt.js.br +0 -0
  59. package/dist/client/index.html +4 -4
  60. package/dist/client/index.html.br +0 -0
  61. package/package.json +1 -1
  62. package/dist/client/assets/agent-core-CXzuinog.js.br +0 -0
  63. package/dist/client/assets/agent-mark-DUhBzwDw.js.br +0 -0
  64. package/dist/client/assets/arena-panel-CSHhinn0.js.br +0 -0
  65. package/dist/client/assets/benchmark-panel-DYfKxUVr.js.br +0 -0
  66. package/dist/client/assets/boards-view-D-_CScqe.js.br +0 -0
  67. package/dist/client/assets/community-panel-C9O4JPCX.js.br +0 -0
  68. package/dist/client/assets/dialogs-BkU7zFNQ.js.br +0 -0
  69. package/dist/client/assets/doc-editor-ui-BMd8WZmt.js.br +0 -0
  70. package/dist/client/assets/feature-hint-DwHKkhDc.js.br +0 -0
  71. package/dist/client/assets/first-run-checklist-CSvN50kN.js.br +0 -0
  72. package/dist/client/assets/hooks-panel-BVx429sM.js.br +0 -0
  73. package/dist/client/assets/index-DbtIz4EN.js.br +0 -0
  74. package/dist/client/assets/issues-panel-WYdIMgYD.js.br +0 -0
  75. package/dist/client/assets/lane-read-token-step-Dxc1tmXl.js.br +0 -0
  76. package/dist/client/assets/my-prs-panel-yQSNEfn3.js.br +0 -0
  77. package/dist/client/assets/nyan-cat-BxympIrg.js.br +0 -0
  78. package/dist/client/assets/phone-shell-C7iozxsv.js.br +0 -0
  79. package/dist/client/assets/plan-face-CDPOZVPd.js.br +0 -0
  80. package/dist/client/assets/plan-render-7PY_vAFR.js.br +0 -0
  81. package/dist/client/assets/pr-queue-columns-ULfSLQzl.js.br +0 -0
  82. package/dist/client/assets/radar-panel-PiejkiI8.js.br +0 -0
  83. package/dist/client/assets/repo-roots-adder-CY5Iq_-O.js.br +0 -0
  84. package/dist/client/assets/resume-dialog-Cskz0w--.js.br +0 -0
  85. package/dist/client/assets/review-queue-panel-7CViVoDA.js.br +0 -0
  86. package/dist/client/assets/session-row-CCQDp9zg.js.br +0 -0
  87. package/dist/client/assets/settings-panel-DqMuBqMl.js.br +0 -0
  88. package/dist/client/assets/trace-panel-CDaGtlbi.js.br +0 -0
  89. package/dist/client/assets/usage-panel-BusH_oaU.js.br +0 -0
  90. package/dist/client/assets/your-day-tip-P3ywC8Pc.js.br +0 -2
@@ -1,4 +1,4 @@
1
- import{s as e,t}from"./action-status-GwVm_xGS.js";import{f as n}from"./control-ws-CU_Jcrnd.js";import{Ka as r,si as i}from"./index-DbtIz4EN.js";import{b as a,s as o}from"./dom-helpers-n8_Z2cD6.js";import{i as s,t as c}from"./plan-render-7PY_vAFR.js";import{a as l,r as u,t as d}from"./modal-CLLdvDUd.js";import{t as f}from"./button-B-DDg9O0.js";var p=[`wc`,`awk`,`frag`,`tense`,`unclear`,`para`,`good`,`must`,`end`],m=`{>>`,h=`<<}`,g=`~>`,_=[{opener:`{--`,closer:`--}`,markKind:`deletion`},{opener:`{++`,closer:`++}`,markKind:`insertion`},{opener:`{~~`,closer:`~~}`,markKind:`substitution`},{opener:`{==`,closer:`==}`,markKind:`highlight`},{opener:m,closer:h,markKind:`comment`}],v=[..._.flatMap(({opener:e,closer:t})=>[e,t]),g],y=RegExp(`^(${p.join(`|`)}):\\s*`,`i`);function b(e){return p.includes(e)}function x(e){if(e===void 0||e.trim()===``)return null;let t=y.exec(e),n=t?.[1]?.toLowerCase()??``;return!t||!b(n)?{code:null,body:e.trim()}:{code:n,body:e.slice(t[0].length).trim()}}function S(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 C(e,t,n){if(!e.startsWith(m,n))return{rawNote:void 0,end:n};let r=t(h,n+3);return r===-1?{rawNote:void 0,end:n}:{rawNote:e.slice(n+3,r),end:r+3}}function w(e,t,n){let r=t(g,n);if(r===-1)return null;let i=t(`~~}`,r+2);return i===-1?null:{oldText:e.slice(n,r),newText:e.slice(r+2,i),closeAt:i}}function T(e,t,n){let r=_.find(({opener:t})=>e.startsWith(t,n));if(!r)return null;let i=n+r.opener.length;if(r.markKind===`substitution`){let a=w(e,t,i);if(!a)return null;let o=C(e,t,a.closeAt+r.closer.length);return{kind:`mark`,markKind:`substitution`,start:n,end:o.end,oldText:a.oldText,newText:a.newText,note:x(o.rawNote)}}let a=t(r.closer,i);if(a===-1)return null;let o=e.slice(i,a),s=a+r.closer.length;if(r.markKind===`comment`)return{kind:`mark`,markKind:`comment`,start:n,end:s,oldText:``,newText:``,note:x(o)};let c=C(e,t,s),l=r.markKind===`insertion`;return{kind:`mark`,markKind:r.markKind,start:n,end:c.end,oldText:l?``:o,newText:l?o:``,note:x(c.rawNote)}}function E(e){let t=[],n=S(e),r=0,i=e.indexOf(`{`);for(;i!==-1;){let a=T(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 ee(e){return e.markKind===`comment`&&e.note?.code===`end`}function te(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 ne(e,t,n){return e.slice(0,t.start)+te(t,n)+e.slice(t.end)}function D(e){return v.some(t=>e.includes(t))}function O(e){return{kind:`refused`,reason:e}}function k(e){return E(e).filter(e=>e.kind===`mark`)}function A(e){return e.start===e.end}function j(e,t,n){switch(e){case`insertion`:return`{++${n}++}`;case`deletion`:return`{--${t}--}`;case`substitution`:return`{~~${t}~>${n}~~}`}}function M(e,t,n,r=``){let i=!n.endsWith(h)&&e.startsWith(m,t.end),a=r+n+(i?`${m}${h}`:``),o=e.slice(0,t.start)+a+e.slice(t.end),s=t.start+r.length,c=t.start+a.length;return k(o).some(e=>e.start===s&&e.end===c)?{source:o,markEnd:c}:null}function N(e,t,n){return{kind:`applied`,source:e.source,caret:t,run:n}}function re(e,t,n){if(!n||!A(t)||t.start!==n.markEnd)return null;let r=k(e).find(e=>e.start===n.markStart&&e.end===n.markEnd);return!r||r.note||r.markKind!==`insertion`&&r.markKind!==`substitution`?null:r}function ie(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(D(n))return O(`delimiter`);let r=M(e,t,j(t.markKind===`insertion`?`insertion`:`substitution`,t.oldText,n));return r?N(r,r.markEnd,{markStart:t.start,markEnd:r.markEnd}):O(`swallowed`)}function ae(e,t,n,r){if(n===``)return O(`nothing`);let i=re(e,t,r);if(i)return ie(e,i,i.newText+n);let a=e.slice(t.start,t.end);if(D(n)||D(a))return O(`delimiter`);let o=M(e,t,A(t)?j(`insertion`,``,n):j(`substitution`,a,n));return o?N(o,o.markEnd,{markStart:t.start,markEnd:o.markEnd}):O(`swallowed`)}function oe(e,t){return t<0||t>=e.length||e[t]===`
1
+ import{s as e,t}from"./action-status-GwVm_xGS.js";import{f as n}from"./control-ws-CU_Jcrnd.js";import{Ka as r,si as i}from"./index-CByiCIuo.js";import{b as a,s as o}from"./dom-helpers-n8_Z2cD6.js";import{i as s,t as c}from"./plan-render-C8QQ7AaV.js";import{a as l,r as u,t as d}from"./modal-CLLdvDUd.js";import{t as f}from"./button-B-DDg9O0.js";var p=[`wc`,`awk`,`frag`,`tense`,`unclear`,`para`,`good`,`must`,`end`],m=`{>>`,h=`<<}`,g=`~>`,_=[{opener:`{--`,closer:`--}`,markKind:`deletion`},{opener:`{++`,closer:`++}`,markKind:`insertion`},{opener:`{~~`,closer:`~~}`,markKind:`substitution`},{opener:`{==`,closer:`==}`,markKind:`highlight`},{opener:m,closer:h,markKind:`comment`}],v=[..._.flatMap(({opener:e,closer:t})=>[e,t]),g],y=RegExp(`^(${p.join(`|`)}):\\s*`,`i`);function b(e){return p.includes(e)}function x(e){if(e===void 0||e.trim()===``)return null;let t=y.exec(e),n=t?.[1]?.toLowerCase()??``;return!t||!b(n)?{code:null,body:e.trim()}:{code:n,body:e.slice(t[0].length).trim()}}function S(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 C(e,t,n){if(!e.startsWith(m,n))return{rawNote:void 0,end:n};let r=t(h,n+3);return r===-1?{rawNote:void 0,end:n}:{rawNote:e.slice(n+3,r),end:r+3}}function w(e,t,n){let r=t(g,n);if(r===-1)return null;let i=t(`~~}`,r+2);return i===-1?null:{oldText:e.slice(n,r),newText:e.slice(r+2,i),closeAt:i}}function T(e,t,n){let r=_.find(({opener:t})=>e.startsWith(t,n));if(!r)return null;let i=n+r.opener.length;if(r.markKind===`substitution`){let a=w(e,t,i);if(!a)return null;let o=C(e,t,a.closeAt+r.closer.length);return{kind:`mark`,markKind:`substitution`,start:n,end:o.end,oldText:a.oldText,newText:a.newText,note:x(o.rawNote)}}let a=t(r.closer,i);if(a===-1)return null;let o=e.slice(i,a),s=a+r.closer.length;if(r.markKind===`comment`)return{kind:`mark`,markKind:`comment`,start:n,end:s,oldText:``,newText:``,note:x(o)};let c=C(e,t,s),l=r.markKind===`insertion`;return{kind:`mark`,markKind:r.markKind,start:n,end:c.end,oldText:l?``:o,newText:l?o:``,note:x(c.rawNote)}}function E(e){let t=[],n=S(e),r=0,i=e.indexOf(`{`);for(;i!==-1;){let a=T(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 ee(e){return e.markKind===`comment`&&e.note?.code===`end`}function te(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 ne(e,t,n){return e.slice(0,t.start)+te(t,n)+e.slice(t.end)}function D(e){return v.some(t=>e.includes(t))}function O(e){return{kind:`refused`,reason:e}}function k(e){return E(e).filter(e=>e.kind===`mark`)}function A(e){return e.start===e.end}function j(e,t,n){switch(e){case`insertion`:return`{++${n}++}`;case`deletion`:return`{--${t}--}`;case`substitution`:return`{~~${t}~>${n}~~}`}}function M(e,t,n,r=``){let i=!n.endsWith(h)&&e.startsWith(m,t.end),a=r+n+(i?`${m}${h}`:``),o=e.slice(0,t.start)+a+e.slice(t.end),s=t.start+r.length,c=t.start+a.length;return k(o).some(e=>e.start===s&&e.end===c)?{source:o,markEnd:c}:null}function N(e,t,n){return{kind:`applied`,source:e.source,caret:t,run:n}}function re(e,t,n){if(!n||!A(t)||t.start!==n.markEnd)return null;let r=k(e).find(e=>e.start===n.markStart&&e.end===n.markEnd);return!r||r.note||r.markKind!==`insertion`&&r.markKind!==`substitution`?null:r}function ie(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(D(n))return O(`delimiter`);let r=M(e,t,j(t.markKind===`insertion`?`insertion`:`substitution`,t.oldText,n));return r?N(r,r.markEnd,{markStart:t.start,markEnd:r.markEnd}):O(`swallowed`)}function ae(e,t,n,r){if(n===``)return O(`nothing`);let i=re(e,t,r);if(i)return ie(e,i,i.newText+n);let a=e.slice(t.start,t.end);if(D(n)||D(a))return O(`delimiter`);let o=M(e,t,A(t)?j(`insertion`,``,n):j(`substitution`,a,n));return o?N(o,o.markEnd,{markStart:t.start,markEnd:o.markEnd}):O(`swallowed`)}function oe(e,t){return t<0||t>=e.length||e[t]===`
2
2
  `?!1:E(e).some(e=>e.kind===`text`&&e.start<=t&&t<e.start+e.text.length)}function se(e,t,n){let r=e.slice(t.start,t.end);if(D(r))return O(`delimiter`);let i=k(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=M(e,s,j(`deletion`,(a?.oldText??``)+r+(o?.oldText??``),``));return c?N(c,n===`forward`?c.markEnd:s.start,null):O(`swallowed`)}function ce(e,t,n,r){let i=re(e,t,r);if(i&&n===`backward`)return ie(e,i,i.newText.slice(0,-1));if(!A(t))return se(e,t,n);let a=n===`backward`?t.start-1:t.start;return oe(e,a)?se(e,{start:a,end:a+1},n):O(`nothing`)}function le(e,t,n){let r=n.trim();if(r===``)return O(`nothing`);let i=e.slice(t.start,t.end);if(D(r)||D(i))return O(`delimiter`);let a=`${m}${r}${h}`;return A(t)?ue(M(e,t,a,k(e).some(n=>n.end===t.start&&n.markKind!==`comment`&&!e.slice(n.start,n.end).endsWith(h))?`${m}${h}`:``)):ue(M(e,t,`{==${i}==}${a}`))}function ue(e){return e?N(e,e.markEnd,null):O(`swallowed`)}function de(e,t){return A(t)?!k(e).some(e=>e.start<t.start&&t.start<e.end):E(e).some(e=>e.kind===`text`&&e.start<=t.start&&t.end<=e.start+e.text.length)}function fe(e,t,n){if(!de(e,t.selection))return O(`nested`);switch(t.kind){case`type`:return ae(e,t.selection,t.text,n);case`delete`:return ce(e,t.selection,t.direction,n);case`paragraph`:return le(e,{start:t.selection.end,end:t.selection.end},`para`);case`note`:return A(t.selection)?O(`nothing`):le(e,t.selection,t.body)}}function pe(e,t){return[`I marked up ${e} in red pen: ${t} open CriticMarkup marks.`,`Read the file. For each {--cut--}, {++add++} and {~~old~>new~~} apply it unless you disagree, {==text==}{>>note<<} is my note on that text.`,`A note may start with a margin code: wc word choice, awk awkward, frag fragment, tense, unclear, para new paragraph, must required, good keep this, end overall note.`,`Remove every mark once handled, then tell me which ones you pushed back on and why.`].join(`
3
3
  `)}var me={unclear:`?`,para:`¶`},he={deletion:`Cut`,insertion:`Add`,substitution:`Change`,highlight:`Note`,comment:`Note`},ge={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:``},_e=new Set([`deleteContentBackward`,`deleteByCut`]),ve=new Set([`insertText`,`insertReplacementText`,`insertFromPaste`,`insertFromYank`]),ye=new Set([`insertParagraph`,`insertLineBreak`]),be=`http://www.w3.org/2000/svg`;function P(e,t){let n=document.createElementNS(be,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function xe(){let e=P(`svg`,{width:`0`,height:`0`,"aria-hidden":`true`,class:`doc-markup-defs`}),t=P(`filter`,{id:`doc-markup-ink`});return t.append(P(`feTurbulence`,{type:`fractalNoise`,baseFrequency:`0.05`,numOctaves:`2`,result:`grain`}),P(`feDisplacementMap`,{in:`SourceGraphic`,in2:`grain`,scale:`1.6`})),e.append(t),e}function Se(){let e=P(`svg`,{viewBox:`0 0 16 16`,class:`doc-markup-check`,"aria-hidden":`true`});return e.append(P(`path`,{d:`M2 9 L6 13 L14 3`})),e}function Ce(){let e=f({variant:`primary`,size:`small`,label:`Accept`,action:`accept-mark`}),t=f({variant:`danger`,size:`small`,label:`Reject`,action:`reject-mark`}),n=o(`p`,`doc-markup-card-text`),r=o(`div`,`doc-markup-card-actions`);r.append(e,t);let i=o(`div`,`doc-markup-float doc-markup-card`);i.append(n,r);let a=f({variant:`secondary`,size:`small`,label:`Add note`,action:`add-note`});a.classList.add(`doc-markup-float`);let s=o(`input`,`plan-control doc-markup-input`);s.type=`text`,s.placeholder=`Note, or a code like wc: or awk:`,s.setAttribute(`aria-label`,`Note on the selected text`);let c=o(`div`,`doc-markup-float doc-markup-composer`);c.append(s);let l=f({variant:`secondary`,size:`small`,label:`Copy agent prompt`,action:`copy-agent-prompt`}),u=o(`span`,`doc-markup-hint`);u.setAttribute(`role`,`status`);let d=o(`div`,`doc-markup-tools`);d.append(u,l);let p=o(`div`,`doc-markup-paper`);p.spellcheck=!1,p.setAttribute(`role`,`textbox`),p.setAttribute(`aria-multiline`,`true`),p.setAttribute(`aria-label`,`Doc in red pen; edits become marks`);let m=o(`div`,`doc-markup-end`),h=o(`div`,`doc-markup`);h.hidden=!0;for(let e of[i,a,c])e.hidden=!0;h.append(xe(),d,p,m,i,a,c);let g={root:h,paper:p,endNotes:m,markCard:i,markCardText:n,btnAccept:e,btnReject:t,btnAddNote:a,noteComposer:c,noteInput:s,btnCopyPrompt:l,hint:u,marginResizeObserver:new ResizeObserver(()=>Fe([...g.visibleRows])),rowObserver:null,listeners:new AbortController,rowsByElement:new Map,visibleRows:new Set,selection:null,noteSelection:null,compositionSelection:null,run:null,tip:``,marks:[],elementsByMarkIndex:[],selectedMarkIndex:null};return g.marginResizeObserver.observe(p),g}function we(e){e.marginResizeObserver.disconnect(),e.rowObserver?.disconnect(),e.listeners.abort()}function Te(e){let t=[he[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 Ee(e,t){let n=o(`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`,Te(e)),e.oldText&&e.markKind!==`highlight`&&n.append(o(`del`,null,e.oldText)),e.markKind===`highlight`&&n.append(o(`span`,`doc-markup-underline`,e.oldText)),e.newText){let t=o(`ruby`,`doc-markup-caret`,`^`);t.append(o(`rt`,null,e.newText)),n.append(t)}return e.markKind===`comment`&&n.append(o(`sup`,`doc-markup-pin`,`*`)),n}function De(e){let t=o(`div`,`doc-markup-note`);return t.dataset.code=e.note?.code??``,e.note?.code===`good`&&t.append(Se()),e.note?.code&&e.note.code!==`good`&&t.append(o(`span`,`doc-markup-code`,me[e.note.code]??e.note.code)),e.note?.body&&t.append(o(`span`,`doc-markup-note-body`,e.note.body)),t}function Oe(e,t){let n=o(`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(o(`span`,`doc-markup-code`,`End note`),o(`p`,`doc-markup-note-body`,e.note?.body??``)),n}function ke(e,t,n){let r=o(`span`,`doc-markup-text`,e);return r.dataset.start=String(t),r.dataset.segmentStart=String(n),r}function Ae(e){let t=o(`div`,`doc-markup-line`);t.dataset.start=String(e);let n=o(`div`,`doc-markup-row-margin`);n.setAttribute(`aria-hidden`,`true`),n.contentEditable=`false`;let r=o(`div`,`doc-markup-row`);return r.append(t,n),{row:r,line:t,margin:n,notesWithAnchors:[]}}function je(e,t){let n=t.start;t.text.split(`
4
4
  `).forEach((r,i)=>{i>0&&e.push(Ae(n)),r&&e.at(-1)?.line.append(ke(r,n,t.start)),n+=r.length+1})}var Me=40;function Ne(e){let t=[];for(let n=0;n<e.length;n+=Me){let r=o(`div`,`doc-markup-chunk`);r.append(...e.slice(n,n+Me)),t.push(r)}return t}function Pe(e){return e.rowObserver??=new IntersectionObserver(t=>{let n=[];for(let r of t){let t=e.rowsByElement.get(r.target);t&&(r.isIntersecting?(e.visibleRows.add(t),n.push(t)):e.visibleRows.delete(t))}Fe(n)},{root:e.root.closest(`.doc-editor-body`),rootMargin:`600px 0px`}),e.rowObserver}function F(e){let t=e.markup,n=Pe(t);n.disconnect();let r=[Ae(0)],i=[];t.marks=[],t.elementsByMarkIndex=[],t.rowsByElement.clear(),t.visibleRows.clear();for(let n of E(e.textarea.value)){if(n.kind===`text`){je(r,n);continue}let e=t.marks.push(n)-1;if(ee(n)){let r=Oe(n,e);i.push(r),t.elementsByMarkIndex.push([r]);continue}let a=r[r.length-1],o=Ee(n,e);if(a?.line.append(o),t.elementsByMarkIndex.push([o]),!n.note||!a)continue;let s=De(n);t.elementsByMarkIndex[e]?.push(s),a.margin.append(s),a.notesWithAnchors.push({note:s,anchor:o})}t.paper.replaceChildren(...Ne(r.map(({row:e})=>e)));for(let e of r)e.notesWithAnchors.length!==0&&(t.rowsByElement.set(e.row,e),n.observe(e.row));t.endNotes.replaceChildren(...i),t.endNotes.hidden=i.length===0,t.selectedMarkIndex=null,t.selection=null,t.noteSelection=null}function I(e){e.markup.run=null,e.markup.tip=``,F(e),B(e)}function Fe(e){let t=e.map(e=>{let t=e.margin.getBoundingClientRect().top;return{row:e,measuredNotes:e.notesWithAnchors.map(({note:e,anchor:n})=>({note:e,anchorTop:n.getBoundingClientRect().top-t,height:e.offsetHeight}))}});for(let{row:e,measuredNotes:n}of t){let t=0;for(let{note:e,anchorTop:r,height:i}of n){let n=Math.max(r,t);e.style.top=`${n}px`,t=n+i+6}e.margin.style.minHeight=`${t}px`}}function Ie(e){return e.selectedMarkIndex===null?null:e.marks[e.selectedMarkIndex]??null}function Le(e,t){let n=e.selectedMarkIndex;for(let t of n===null?[]:e.elementsByMarkIndex[n]??[])t.classList.remove(`is-selected`);e.selectedMarkIndex=t;for(let n of t===null?[]:e.elementsByMarkIndex[t]??[])n.classList.add(`is-selected`)}function L(e){return e.isBusy||e.baseHash===null||e.textarea.readOnly}function R(e){return!L(e)&&!r()}function z(e,t,n){t.hidden=n===null,n&&(t.style.top=`${n.top-e.root.getBoundingClientRect().top}px`)}function Re(){let e=window.getSelection();return!e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function ze(e){let t=e.markup,n=Ie(t),r=t.selectedMarkIndex===null?null:t.elementsByMarkIndex[t.selectedMarkIndex]?.[0]??null;t.markCardText.textContent=n?Te(n):``,z(t,t.markCard,r?.getBoundingClientRect()??null);let i=t.noteSelection!==null,a=t.selection!==null&&t.selection.end>t.selection.start,o=!i&&!n&&a&&R(e);z(t,t.btnAddNote,o?Re():null),i||z(t,t.noteComposer,null)}function B(e){let t=e.markup,n=L(e);t.paper.contentEditable=R(e)?`true`:`false`,t.btnAccept.disabled=n,t.btnReject.disabled=n,t.btnCopyPrompt.disabled=n||e.hasUnsavedChanges||t.marks.length===0,t.hint.textContent=t.tip||Be(e),t.hint.dataset.tone=t.tip?`warn`:`quiet`,ze(e)}function Be(e){let t=e.markup.marks.length,n=`${t} open ${t===1?`mark`:`marks`}.`;return r()?`Editing marks is off in streamer mode. Accept and Reject still work. ${n}`:e.hasUnsavedChanges&&t>0?`Suggesting: edits become red pen. ${n} Save before copying the agent prompt.`:`Suggesting: edits become red pen. ${n}`}function V(e){let t=e?.closest(`.doc-markup-mark`);return t?Number(t.dataset.markIndex):null}function Ve(e,t,n){let r={sourceOffset:Number(n.dataset.start),segmentStart:void 0};if(!(t instanceof HTMLElement))return r;let i=V(t);return i===null?{sourceOffset:Number(t.dataset.start)+(t.textContent?.length??0),segmentStart:t.dataset.segmentStart}:{sourceOffset:e.marks[i]?.end??r.sourceOffset,segmentStart:void 0}}function H(e,t,n){if(!t)return null;if(n===`end`)return Ve(e,t.lastChild??void 0,t);let r=t.firstChild;return r instanceof HTMLElement&&r.classList.contains(`doc-markup-text`)?{sourceOffset:Number(r.dataset.start),segmentStart:r.dataset.segmentStart}:{sourceOffset:Number(t.dataset.start),segmentStart:void 0}}function He(e){return e instanceof HTMLElement?e.classList.contains(`doc-markup-line`)?[e]:[...e.querySelectorAll(`.doc-markup-line`)]:[]}function Ue(e,t,n){let r=t instanceof Element?t:t.parentElement,i=V(r);if(i!==null){let t=e.marks[i];return t?{sourceOffset:t.end,segmentStart:void 0}:null}let a=r?.closest(`.doc-markup-text`);if(a){let e=t.nodeType===Node.TEXT_NODE?n:n===0?0:a.textContent?.length??0;return{sourceOffset:Number(a.dataset.start)+e,segmentStart:a.dataset.segmentStart}}let o=r?.closest(`.doc-markup-line`);if(o&&t===o)return Ve(e,o.childNodes[n-1],o);if(o||!(t instanceof Element)||!e.paper.contains(t))return null;let s=[...t.childNodes],c=s.slice(0,n).flatMap(He);return c.length>0?H(e,c.at(-1),`end`):H(e,s.slice(n).flatMap(He)[0],`start`)}function U(e,t){if(!t||!e.paper.contains(t.startContainer)||!e.paper.contains(t.endContainer))return null;let n=Ue(e,t.startContainer,t.startOffset),r=Ue(e,t.endContainer,t.endOffset);return!n||!r?null:t.collapsed?{start:n.sourceOffset,end:n.sourceOffset}:n.segmentStart===void 0||n.segmentStart!==r.segmentStart?`crosses-mark`:{start:n.sourceOffset,end:r.sourceOffset}}function W(){let e=window.getSelection();return e&&e.rangeCount>0?e.getRangeAt(0):null}function We(e,t){for(let n of e.paper.querySelectorAll(`.doc-markup-text`)){let e=Number(n.dataset.start),r=n.firstChild;if(r&&e<=t&&t<=e+(n.textContent?.length??0))return{node:r,offset:t-e}}let n=e.marks.findIndex(e=>e.end===t),r=n===-1?null:e.elementsByMarkIndex[n]?.[0];if(r&&e.paper.contains(r))return{after:r};let i=[...e.paper.querySelectorAll(`.doc-markup-line`)].find(e=>Number(e.dataset.start)===t);return i?{node:i,offset:0}:null}function Ge(e,t){let n=We(e,t),r=window.getSelection();if(!n||!r)return;let i=document.createRange();`after`in n&&i.setStartAfter(n.after),`node`in n&&i.setStart(n.node,n.offset),i.collapse(!0),e.paper.focus({preventScroll:!0}),r.removeAllRanges(),r.addRange(i)}function Ke(e,t){e.textarea.value=t,e.textarea.dispatchEvent(new Event(`input`))}function qe(e,t){e.markup.tip=ge[t],B(e)}function G(e,t){let n=e.markup,r=fe(e.textarea.value,t,n.run);r.kind===`refused`?qe(e,r.reason):(Ke(e,r.source),n.tip=``,F(e),Ge(n,r.caret),n.run=r.run,n.selection={start:r.caret,end:r.caret},B(e))}function Je(e){return e.data??e.dataTransfer?.getData(`text/plain`)??``}function Ye(e,t){return ve.has(e.inputType)?{kind:`type`,selection:t,text:Je(e)}:ye.has(e.inputType)?{kind:`paragraph`,selection:t}:_e.has(e.inputType)?{kind:`delete`,selection:t,direction:`backward`}:e.inputType===`deleteContentForward`?{kind:`delete`,selection:t,direction:`forward`}:null}function Xe(e,t){return U(e,(t.inputType===`insertReplacementText`?t.getTargetRanges()[0]??null:null)??W())}function Ze(e,t){if(t.inputType===`insertCompositionText`||(t.preventDefault(),!R(e)))return;let n=Xe(e.markup,t);if(n===`crosses-mark`){qe(e,`nested`);return}let r=n?Ye(t,n):null;r&&G(e,r)}function Qe(e,t){let n=e.markup,r=n.compositionSelection;n.compositionSelection=null,F(e),!r||!R(e)?B(e):G(e,{kind:`type`,selection:r,text:t.data})}function $e(e){let t=e.markup,n=W();if(!n||!t.paper.contains(n.startContainer))return;let r=U(t,n);t.selection=r===`crosses-mark`?null:r,(t.selection===null||t.selection.start!==t.run?.markEnd||t.selection.end!==t.run.markEnd)&&(t.run=null),t.tip=``,document.activeElement===t.paper&&t.selection!==null&&Le(t,null),B(e)}function et(e,t){let n=Ie(e.markup);n&&!L(e)&&(Ke(e,ne(e.textarea.value,n,t)),I(e))}function tt(e){let t=e.markup;if(!t.selection||t.selection.end===t.selection.start)return;let n=Re();t.noteSelection=t.selection,t.noteInput.value=``,z(t,t.noteComposer,n),B(e),t.noteInput.focus()}function nt(e){e.markup.noteSelection=null,B(e)}function rt(e){let t=e.markup,n=t.noteSelection;t.noteSelection=null,!n||!R(e)?B(e):G(e,{kind:`note`,selection:n,body:t.noteInput.value})}async function it(e){let t=a(pe(e.docPath,e.markup.marks.length));if(!t)e.showStatus(`This browser blocks clipboard writes here.`,`warn`);else try{await t,e.showStatus(`Agent prompt copied`)}catch{e.showStatus(`Could not copy the agent prompt`,`warn`)}}function K(e,t){let n=V(t instanceof Element?t:null);return n!==null&&(Le(e.markup,e.markup.marks[n]?n:null),e.markup.selection=null,e.markup.noteSelection=null,B(e),!0)}function at(e){let t=e.markup,{signal:n}=t.listeners;for(let n of[t.paper,t.endNotes])n.addEventListener(`focusin`,t=>{K(e,t.target)}),n.addEventListener(`click`,t=>{K(e,t.target)}),n.addEventListener(`keydown`,n=>{n.key===`Enter`&&K(e,n.target)&&(n.preventDefault(),t.btnAccept.focus())});t.paper.addEventListener(`beforeinput`,t=>Ze(e,t)),t.paper.addEventListener(`compositionstart`,()=>{let e=U(t,W());t.compositionSelection=e===`crosses-mark`?null:e}),t.paper.addEventListener(`compositionend`,t=>Qe(e,t)),t.paper.addEventListener(`input`,t=>{t instanceof InputEvent&&t.isComposing||(F(e),B(e))}),t.paper.addEventListener(`drop`,e=>e.preventDefault()),document.addEventListener(`selectionchange`,()=>{t.root.hidden||t.compositionSelection||$e(e)},{signal:n});for(let e of[t.btnAddNote,t.markCard])e.addEventListener(`mousedown`,e=>e.preventDefault());t.btnAddNote.addEventListener(`click`,()=>tt(e)),t.noteInput.addEventListener(`keydown`,t=>{t.key===`Escape`?(t.stopPropagation(),nt(e)):t.key!==`Enter`||t.isComposing||(t.preventDefault(),rt(e))}),t.noteInput.addEventListener(`blur`,()=>{t.noteSelection&&nt(e)}),t.btnAccept.addEventListener(`click`,()=>et(e,`accept`)),t.btnReject.addEventListener(`click`,()=>et(e,`reject`)),t.btnCopyPrompt.addEventListener(`click`,()=>{it(e)})}var q=null;function ot(e){let t=e.source.docs();e.select.replaceChildren(...t.map(t=>{let n=o(`option`,null,t.name);return n.value=t.path,n.selected=t.path===e.docPath,n})),e.select.hidden=t.length<2,e.title.textContent=t.find(t=>t.path===e.docPath)?.name??e.title.textContent}function J(e){let t=e.source.isSaveable(e.docPath);e.btnEdit.setAttribute(`aria-pressed`,String(e.mode===`edit`)),e.btnPreview.setAttribute(`aria-pressed`,String(e.mode===`preview`)),e.btnMarkup.setAttribute(`aria-pressed`,String(e.mode===`markup`)),e.textarea.hidden=e.mode!==`edit`,e.preview.hidden=e.mode!==`preview`,e.markup.root.hidden=e.mode!==`markup`,e.select.disabled=e.isBusy,e.btnReload.disabled=e.isBusy||!t,e.btnSave.disabled=e.isBusy||!t||e.baseHash===null||!e.hasUnsavedChanges,B(e)}function Y(e,t,n=`quiet`){e.status.textContent=t,e.status.dataset.tone=n}function st(e){e.preview.replaceChildren(c(s(e.textarea.value)))}function ct(e,t){l({title:e,message:`Your unsaved edits will be lost.`,confirmLabel:`Discard`,danger:!0,onConfirm:t})}function X(e,t,n){e.hasUnsavedChanges?ct(t,n):n()}async function lt(r,i){try{return{reply:await n(r,i,{timeoutMs:t}),failureText:null}}catch(n){return{reply:null,failureText:e(n,t)}}}async function ut(e,t){let{reply:n,failureText:r}=await lt(`session-doc-read`,{id:e,path:t}),i=n?.type===`session-doc-response`?n:null;return!i?.ok||i.text===void 0||i.hash===void 0?{ok:!1,error:i?.error||r}:{ok:!0,text:i.text,hash:i.hash}}async function dt(e,t,n,r){let{reply:i,failureText:a}=await lt(`session-doc-save`,{id:e,path:t,text:n,baseHash:r}),o=i?.type===`session-doc-save-result`?i:null;return!o?.ok||o.hash===void 0?{ok:!1,isConflict:o?.conflict===!0,error:o?.error||a}:{ok:!0,hash:o.hash}}function ft(e){return{key:e,docs:()=>i(e),isSaveable:t=>i(e).some(e=>e.path===t),hasMarkup:!0,openingMode:r()?`preview`:`edit`,conflictText:`The agent changed this file since you opened it. Reload to see its version.`,unsaveableText:`This doc is no longer surfaced, so it cannot be saved.`,read:t=>ut(e,t),save:(t,n,r)=>dt(e,t,n,r)}}async function Z(e,t){e.docPath=t,e.isBusy=!0,e.baseHash=null,e.textarea.readOnly=!0,ot(e),Y(e,`Loading`),J(e);let n=await e.source.read(t);q===e&&e.docPath===t&&(e.isBusy=!1,e.textarea.readOnly=!1,n.ok?(e.textarea.value=n.text,e.baseHash=n.hash,e.hasUnsavedChanges=!1,e.mode===`preview`&&st(e),e.mode===`markup`&&I(e),Y(e,``),J(e)):(Y(e,n.error||`Could not open this doc`,`warn`),J(e)))}async function pt(e){if(e.btnSave.disabled||e.baseHash===null)return;e.isBusy=!0,Y(e,`Saving`),J(e);let t=e.docPath,n=e.textarea.value,r=await e.source.save(t,n,e.baseHash);q===e&&e.docPath===t&&(e.isBusy=!1,r.ok?(e.baseHash=r.hash,e.hasUnsavedChanges=e.textarea.value!==n,Y(e,e.hasUnsavedChanges?`Unsaved changes`:`Saved`),J(e)):(Y(e,r.isConflict?e.source.conflictText:r.error||`Save failed`,`warn`),J(e)))}function Q(e,t){e.mode=t,t===`preview`&&st(e),t===`markup`&&I(e),J(e),t===`edit`&&e.textarea.focus()}function mt(e){$(ft(e))}function $(e){let t=e.docs()[0];if(!t||q)return;let n=()=>X(T,`Close this doc?`,()=>T.close()),r=u({dialogClass:`doc-editor`,closeOnBackdrop:!1,onEscape:n}),i=`doc-editor-title`,a=o(`h3`,`doc-editor-title`,t.name);a.id=i;let s=o(`select`,`plan-control doc-editor-picker`);s.setAttribute(`aria-label`,`Doc`);let c=o(`span`,`doc-editor-status`);c.setAttribute(`role`,`status`);let l=f({variant:`quiet`,size:`small`,label:`Edit`}),p=f({variant:`quiet`,size:`small`,label:`Preview`}),m=f({variant:`quiet`,size:`small`,label:`Markup`});m.hidden=!e.hasMarkup;let h=f({variant:`secondary`,label:`Reload`,action:`reload-doc`}),g=f({variant:`primary`,label:`Save`,action:`save-doc`}),_=f({variant:`secondary`,label:`Close`,action:`close-doc-editor`}),v=o(`div`,`doc-editor-modes`);v.append(l,p,m);let y=o(`div`,`doc-editor-actions`);y.append(c,h,g,_);let b=o(`div`,`doc-editor-header`);b.append(a,s,v,y);let x=o(`textarea`,`plan-editor doc-editor-text`);x.spellcheck=!0,x.setAttribute(`aria-labelledby`,i);let S=o(`div`,`doc-editor-preview`),C=Ce(),w=o(`div`,`doc-editor-body`);w.append(x,S,C.root),r.dialog.append(b,w),d(r.dialog,i);let T={source:e,docPath:t.path,baseHash:null,hasUnsavedChanges:!1,isBusy:!1,mode:e.openingMode,title:a,select:s,textarea:x,preview:S,markup:C,status:c,btnEdit:l,btnPreview:p,btnMarkup:m,btnReload:h,btnSave:g,showStatus:(e,t)=>Y(T,e,t),close:()=>{q=null,we(C),r.close()}};q=T,x.addEventListener(`input`,()=>{T.hasUnsavedChanges||(T.hasUnsavedChanges=!0,Y(T,`Unsaved changes`),J(T))}),x.addEventListener(`keydown`,e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),pt(T))}),s.addEventListener(`change`,()=>{let e=s.value;s.value=T.docPath,X(T,`Open another doc?`,()=>{Z(T,e)})}),l.addEventListener(`click`,()=>Q(T,`edit`)),p.addEventListener(`click`,()=>Q(T,`preview`)),m.addEventListener(`click`,()=>Q(T,`markup`)),at(T),h.addEventListener(`click`,()=>{X(T,`Reload this doc?`,()=>{Z(T,T.docPath)})}),g.addEventListener(`click`,()=>{pt(T)}),_.addEventListener(`click`,n),Z(T,t.path),T.mode===`edit`&&x.focus()}function ht(e){q&&q.source.key===e&&(ot(q),J(q),q.source.isSaveable(q.docPath)||Y(q,q.source.unsaveableText,`warn`))}export{ht as applyDocsToOpenEditor,mt as openDocEditor,$ as openDocEditorOn};
@@ -1 +1 @@
1
- import{Bt as e,t}from"./button-B-DDg9O0.js";import{n,r,t as i}from"./flying-animal-preview-2JUBGLhu.js";import{d as a}from"./control-ws-CU_Jcrnd.js";import{s as o}from"./dom-helpers-n8_Z2cD6.js";import{E as s,Pa as c,ai as l,ii as u}from"./index-DbtIz4EN.js";import{xt as d}from"./ui-prefs-CvA86s8z.js";var f={teamReview:e=>`${e} pull requests reviewed this week. Reviews lines up every PR waiting on you, and it is off right now.`,issues:e=>`${e} issues touched this week. The Issues tab keeps them in one list and starts a session on any of them, and it is off right now.`,usage:()=>`Keeping an eye on tokens? Usage tracks spend per session and warns before a limit hits, and it is off right now.`,posthog:()=>`Hunting errors again? Radar watches PostHog error tracking and can investigate an issue for you, and it is off right now.`,benchmarks:()=>`Comparing agents by hand? Bench runs the same review cases across agent setups side by side, and it is off right now.`};function p(e){return`${f[e.feature](e.distinctTargetCount)} Show me takes you to its switch in Settings.`}function m(e){let t=s.find(t=>t.rule===e);return t?{sectionId:t.sectionId,settingId:t.settingId}:null}var h=null,g=!1;function _(e,t){a({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`hints`,action:t,feature:e}})}function v(e,t){try{return l(localStorage,u(e,t),Date.now())}catch{return!0}}function y(t,n){if(n.isFeatureEnabled(t)){n.openView(e[t]);return}let r=m(t);r&&n.openSetting(r.sectionId,r.settingId)}function b(){return h?.isConnected===!0}function x({text:e,ariaLabel:r,openLabel:a=`Show me`,onOpen:s,onDismiss:c}){let l=o(`aside`,`feature-hint`);l.setAttribute(`aria-live`,`polite`),l.setAttribute(`aria-label`,r);let u=o(`div`,`feature-hint-bubble`),f=t({variant:`primary`,label:a}),p=t({variant:`secondary`,label:`Dismiss`}),m=o(`div`,`feature-hint-actions`);m.append(p,f),u.append(o(`p`,`feature-hint-text`,e),m);let _=n()??d[0];l.append(u,i(_,`feature-hint-animal`));function v(){l.remove(),h=null,g&&(g=!1,w())}f.addEventListener(`click`,()=>{v(),s()}),p.addEventListener(`click`,()=>{v(),c()}),document.body.append(l),h=l}function S(e,t){b()||v(`feature-hint`,`${e.feature}-${e.raisedAt}`)&&(x({text:p(e),ariaLabel:`Feature tip`,onOpen:()=>{_(e.feature,`open`),y(e.feature,t)},onDismiss:()=>_(e.feature,`dismiss`)}),_(e.feature,`shown`))}function C(e){a({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`star`,action:e}})}function w(){b()?g=!0:v(`star-hint`,`card`)&&(x({text:`Enjoying Glimmervoid? A star on GitHub helps other people find it.`,ariaLabel:`Star Glimmervoid on GitHub`,openLabel:`Star on GitHub`,onOpen:()=>{C(`open`),c(`https://github.com/${r}`)},onDismiss:()=>C(`dismiss`)}),C(`shown`))}export{b as isHintCardShown,S as showFeatureHint,x as showHintCard,w as showStarHint};
1
+ import{Bt as e,t}from"./button-B-DDg9O0.js";import{n,r,t as i}from"./flying-animal-preview-2JUBGLhu.js";import{d as a}from"./control-ws-CU_Jcrnd.js";import{s as o}from"./dom-helpers-n8_Z2cD6.js";import{E as s,Pa as c,ai as l,ii as u}from"./index-CByiCIuo.js";import{xt as d}from"./ui-prefs-CvA86s8z.js";var f={teamReview:e=>`${e} pull requests reviewed this week. Reviews lines up every PR waiting on you, and it is off right now.`,issues:e=>`${e} issues touched this week. The Issues tab keeps them in one list and starts a session on any of them, and it is off right now.`,usage:()=>`Keeping an eye on tokens? Usage tracks spend per session and warns before a limit hits, and it is off right now.`,posthog:()=>`Hunting errors again? Radar watches PostHog error tracking and can investigate an issue for you, and it is off right now.`,benchmarks:()=>`Comparing agents by hand? Bench runs the same review cases across agent setups side by side, and it is off right now.`};function p(e){return`${f[e.feature](e.distinctTargetCount)} Show me takes you to its switch in Settings.`}function m(e){let t=s.find(t=>t.rule===e);return t?{sectionId:t.sectionId,settingId:t.settingId}:null}var h=null,g=!1;function _(e,t){a({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`hints`,action:t,feature:e}})}function v(e,t){try{return l(localStorage,u(e,t),Date.now())}catch{return!0}}function y(t,n){if(n.isFeatureEnabled(t)){n.openView(e[t]);return}let r=m(t);r&&n.openSetting(r.sectionId,r.settingId)}function b(){return h?.isConnected===!0}function x({text:e,ariaLabel:r,openLabel:a=`Show me`,onOpen:s,onDismiss:c}){let l=o(`aside`,`feature-hint`);l.setAttribute(`aria-live`,`polite`),l.setAttribute(`aria-label`,r);let u=o(`div`,`feature-hint-bubble`),f=t({variant:`primary`,label:a}),p=t({variant:`secondary`,label:`Dismiss`}),m=o(`div`,`feature-hint-actions`);m.append(p,f),u.append(o(`p`,`feature-hint-text`,e),m);let _=n()??d[0];l.append(u,i(_,`feature-hint-animal`));function v(){l.remove(),h=null,g&&(g=!1,w())}f.addEventListener(`click`,()=>{v(),s()}),p.addEventListener(`click`,()=>{v(),c()}),document.body.append(l),h=l}function S(e,t){b()||v(`feature-hint`,`${e.feature}-${e.raisedAt}`)&&(x({text:p(e),ariaLabel:`Feature tip`,onOpen:()=>{_(e.feature,`open`),y(e.feature,t)},onDismiss:()=>_(e.feature,`dismiss`)}),_(e.feature,`shown`))}function C(e){a({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`star`,action:e}})}function w(){b()?g=!0:v(`star-hint`,`card`)&&(x({text:`Enjoying Glimmervoid? A star on GitHub helps other people find it.`,ariaLabel:`Star Glimmervoid on GitHub`,openLabel:`Star on GitHub`,onOpen:()=>{C(`open`),c(`https://github.com/${r}`)},onDismiss:()=>C(`dismiss`)}),C(`shown`))}export{b as isHintCardShown,S as showFeatureHint,x as showHintCard,w as showStarHint};
@@ -1 +1 @@
1
- import{i as e,s as t,t as n}from"./action-status-GwVm_xGS.js";import{d as r,f as i}from"./control-ws-CU_Jcrnd.js";import{c as a,s as o}from"./dom-helpers-n8_Z2cD6.js";import{$a as s,Ga as c,Jr as l,Ua as u,Wa as d,ni as f,r as p,ti as m}from"./index-DbtIz4EN.js";import{K as h}from"./ui-prefs-CvA86s8z.js";import{a as g,c as ee,d as _,f as v,h as y,i as b,l as te,m as x,n as S,o as C,p as ne,r as re,s as ie,t as ae,u as w}from"./repo-roots-adder-CY5Iq_-O.js";import{P as oe,g as se,s as ce,t as le,u as ue}from"./agent-core-CXzuinog.js";import{a as T,t as E}from"./button-B-DDg9O0.js";import{n as D,t as de}from"./setup-step-CBZFosoO.js";function O(e,t,...n){let r=o(`div`,`first-run-start-field`),i=o(`label`,`first-run-eyebrow`,e);return i.htmlFor=t,r.append(i,...n),r}function fe(e){let t=o(`span`,`first-run-start-project-path`);return t.append(o(`bdi`,null,e)),t}function pe({onAction:r}){let a=[],s=null,c=le,u=!1,d=o(`input`,`first-run-start-filter`);d.id=`first-run-start-filter`,d.type=`search`,d.placeholder=`Filter`,d.autocomplete=`off`;let f=o(`ul`,`first-run-start-projects`);f.setAttribute(`role`,`listbox`),f.setAttribute(`aria-label`,`Project`);let p=o(`div`,`first-run-start-agents`);p.id=`first-run-start-agents`,p.setAttribute(`role`,`group`);let m=o(`textarea`,`first-run-start-task`);m.id=`first-run-start-task`,m.value=re,m.maxLength=4e3;let h=E({variant:`primary`,label:`Start session`}),g=E({variant:`quiet`,label:`Advanced`}),_=e(`first-run-start-status`),v=o(`div`,`first-run-start-foot`);v.append(h,_.element,g);let y=o(`div`,`first-run-start`);y.append(O(`Project`,`first-run-start-filter`,d,f),O(`Agent`,`first-run-start-agents`,p),O(`First task`,`first-run-start-task`,m),v);function b(){let e=te(a,d.value,s);s=e.selectedPath,f.replaceChildren(...e.visibleProjects.map(e=>{let t=o(`li`,`first-run-start-project`),n=T(`first-run-start-project-choice`);return n.append(o(`span`,`first-run-start-project-name`,e.name),fe(e.path)),e.lastActivityMs!==null&&n.append(o(`span`,`first-run-start-project-age`,l(e.lastActivityMs,Date.now()))),n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(e.path===s)),n.addEventListener(`click`,()=>{s=e.path,b()}),t.append(n),t})),h.disabled=u||s===null}function x(e){let t=ee(e);c=t.selectedId,p.replaceChildren(...t.options.map(e=>{let t=T(`dialog-mode-button`,e.label);return t.setAttribute(`aria-pressed`,String(e.id===c)),t.addEventListener(`click`,()=>{c=e.id;for(let e of p.children)e.setAttribute(`aria-pressed`,String(e===t))}),t}))}function S(){let e=a.find(e=>e.path===s);if(!e||u)return;u=!0,h.disabled=!0,_.show(`busy`,`Starting the session`),r(`start-session`);let o={name:oe(e.name),path:e.path,prompt:m.value};c!==`claude-code`&&(o.agent=c),i(`add-session`,o,{timeoutMs:n}).then(e=>{e.type===`add-session-result`&&e.ok?(_.clear(),se(e.sessionId)):_.show(`error`,ce(e))}).catch(e=>{_.show(`error`,`The session was not started: ${t(e,n)}`)}).finally(()=>{u=!1,h.disabled=s===null})}d.addEventListener(`input`,b),h.addEventListener(`click`,S),g.addEventListener(`click`,()=>{r(`open-advanced`),ue()});function C({agentListing:e,startableProjects:t}){a=t,b(),x(e)}return{element:y,update:C,focusTask:()=>m.focus()}}var me=`npm install -g @anthropic-ai/claude-code`,k=null,A=null,j=null,M=null,N=`unloaded`,P=null,F=null,I={steps:b,agentSummary:``,installableAgents:w(null),repoRoots:[],notificationChoice:`ask`,agentListing:null,startableProjects:[]},L=0,R=!1,z=!1,B=new Set,V=e(`first-run-load-status`),H=pe({onAction:U});function U(e){r({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`onboarding`,action:e}})}function he(e){for(let t of ie(B,e))r({type:`dashboard-telemetry`,event:`onboarding_step`,properties:t})&&B.add(ne(t))}function ge(){return s()?`No agent found on PATH of the machine running Glimmervoid.`:`No agent found on PATH.`}function _e(){let e=o(`div`,`first-run-step-actions`);P=E({variant:`primary`,label:`Rescan`}),P.addEventListener(`click`,()=>{U(`rescan`),X({rescanAgents:!0})}),e.append(P);let t=[o(`p`,`first-run-step-text`,ge()),de(me),e];return R?[...t,o(`p`,`first-run-step-hint`,`Still missing after a rescan? Restart Glimmervoid from a terminal where the command runs. Other terminal agents go under customAgents.`)]:t}function ve(){let e=F??ae({onAdded:e=>{U(e===`typed`?`add-root-typed`:`add-root-suggested`),X({rescanAgents:!1})}});return F=e,[e.element]}var ye=`auth-refactor needs attention`;function W(e){U(e===`allow`?`allow-notifications`:`skip-notifications`),e===`skip`?(h(!1),X({rescanAgents:!1})):f().then(()=>X({rescanAgents:!1}))}function be(){let e=o(`div`,`first-run-sample-notification`);e.setAttribute(`aria-hidden`,`true`),e.append(Z(`first-run-sample-mark`),o(`span`,null,ye));let t=E({variant:`primary`,label:`Allow notifications`}),n=E({variant:`quiet`,label:`Skip`});t.addEventListener(`click`,()=>{t.disabled=!0,W(`allow`)}),n.addEventListener(`click`,()=>W(`skip`));let r=o(`div`,`first-run-step-actions`);return r.append(t,n),[o(`p`,`first-run-step-text`,`Know when a session needs you.`),e,r]}function G(){let{steps:e,agentSummary:t,repoRoots:n,notificationChoice:r}=I;return[D({title:`1. Agent CLI`,state:e.agent,summary:t,badge:``,body:_e}),D({title:`2. Repository roots`,state:e.repoRoots,summary:n.join(`, `),badge:``,body:ve}),D({title:`3. Notifications`,state:e.notifications,summary:v(r),badge:``,body:be})]}function xe(){let{agentSummary:e,repoRoots:t,notificationChoice:n}=I,r=`notifications ${v(n).toLowerCase()}`,i=[e,t.join(`, `),r].filter(Boolean).join(` · `);return D({title:`Setup done`,state:`done`,summary:i,badge:``,body:()=>[]})}function Se(e){H.update({agentListing:I.agentListing,startableProjects:I.startableProjects}),e.contains(H.element)||e.append(H.element),e.hidden=!1}function K(){A&&j&&N!==`folding`&&(_(I.steps)?(A.replaceChildren(xe()),Se(j)):(A.replaceChildren(...G()),j.hidden=!0))}var Ce=200,q=250,J=480,Y=`cubic-bezier(0.22, 1, 0.36, 1)`,we=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);function Te(){return!we?.matches&&!document.hidden}function Ee(e){[...e.querySelectorAll(`.first-run-step-icon circle, .first-run-step-icon path`)].forEach((e,t)=>{e.setAttribute(`pathLength`,`1`),e.animate([{strokeDasharray:`1`,strokeDashoffset:`1`},{strokeDasharray:`1`,strokeDashoffset:`0`}],{duration:q,delay:t*q,easing:Y,fill:`backwards`})})}function De(){let e=M?.querySelector(`svg`),t=e?.querySelector(`.first-run-mark-dial`),n=e?.querySelector(`.first-run-mark-light`),r=e?.querySelector(`.first-run-mark-halo`);return!e||!t||!n||!r?Promise.resolve():p({mark:e,dial:t,light:n,halo:r})}function Oe(e){return new Promise(t=>{setTimeout(t,e)})}async function ke(e,t){N=`folding`,await e.querySelector(`[aria-current="step"] .first-run-step-body`)?.animate([{opacity:1},{opacity:0}],{duration:Ce,fill:`forwards`}).finished;let n=G();e.replaceChildren(...n);let[r,...i]=n,a=n.at(-1);a&&Ee(a),await De();for(let e of i)e.animate([{transform:`none`,opacity:1},{opacity:0,offset:.35},{transform:`translateY(${r.offsetTop-e.offsetTop}px)`,opacity:0}],{duration:J,easing:Y,fill:`forwards`});r.querySelector(`.first-run-step-head`)?.animate([{opacity:1},{opacity:0}],{duration:q,fill:`forwards`}),await Oe(J),N=`done`,K(),e.firstElementChild?.animate([{opacity:0},{opacity:1}],{duration:q,easing:Y}),t.animate([{transform:`translateY(12px)`,opacity:0},{transform:`none`,opacity:1}],{duration:J,easing:Y}),H.focusTask()}function Ae(){if(N===`folding`)return;let e=_(I.steps),t=N===`in-progress`&&e&&Te();N=e?`done`:`in-progress`,!t||!A||!j?K():ke(A,j)}async function X({rescanAgents:e}){L+=1;let r=L;P&&(P.disabled=!0);try{let[t,a]=await Promise.all([i(`list-agents`,e?{rescan:!0}:{},{timeoutMs:n}),i(`scan-repo-roots`,{includeSuggestions:!0,includeActivity:!0},{timeoutMs:n})]);if(r!==L)return;let o=a.type===`repo-roots-scanned`,s=o?a.directories.map(e=>e.root):[],c=o?a.suggestions??[]:[],l=x(s,c);if(l.length>0&&!z){z=!0;let e=await S(l).catch(e=>String(e));if(r!==L)return;if(!e){X({rescanAgents:!1});return}}let u=m(),d=C({agentListing:t,repoRoots:s,notificationChoice:u});e&&(R=d.agent===`current`),I={steps:d,agentSummary:g(t),installableAgents:w(t),repoRoots:s,notificationChoice:u,agentListing:t,startableProjects:o?y(a.directories):[]},V.clear(),Ae(),he(I.steps),F?.setSuggestions(c)}catch(e){if(P&&(P.disabled=!1),r!==L)return;V.show(`error`,`The checklist could not load: ${t(e,n)} It loads again once the server answers. If it stays like this, check the terminal running Glimmervoid, or run glimmervoid doctor.`)}}function Z(e){let t=u.map(({side:e,d:t})=>`<path class="first-run-mark-bracket" data-side="${e}" d="${t}"/>`).join(``);return a(`span`,e,`<svg viewBox="${c}" aria-hidden="true"><path class="first-run-mark-halo" d="${d}"/><g class="first-run-mark-dial">${t}</g><path class="first-run-mark-light" d="${d}"/></svg>`)}var je=5e3,Q=-1/0;function $(){document.visibilityState===`visible`&&I.steps.agent===`current`&&k&&!k.hidden&&k.isConnected&&(performance.now()-Q<je||(Q=performance.now(),X({rescanAgents:!0})))}function Me(){if(k)return k;let e=o(`section`,`first-run-checklist`);e.setAttribute(`aria-label`,`Glimmervoid setup`);let t=o(`div`,`first-run-lockup`);return M=t,t.append(Z(`first-run-mark`),o(`span`,`first-run-wordmark`,`GLIMMERVOID`)),A=o(`ol`,`first-run-steps`),j=o(`div`,`first-run-start-host`),e.append(t,A,V.element,j),k=e,document.addEventListener(`visibilitychange`,$),window.addEventListener(`focus`,$),K(),e}function Ne(e,t){if(!t){k?.parentElement===e&&!k.hidden&&(k.hidden=!0);return}let n=Me(),r=!n.hidden&&n.parentElement===e;n.parentElement!==e&&e.append(n),n.hidden=!1,r||X({rescanAgents:!1})}function Pe(){k&&!k.hidden&&k.isConnected&&X({rescanAgents:!1})}export{Pe as refreshFirstRunChecklist,Ne as showFirstRunChecklist};
1
+ import{i as e,s as t,t as n}from"./action-status-GwVm_xGS.js";import{d as r,f as i}from"./control-ws-CU_Jcrnd.js";import{c as a,s as o}from"./dom-helpers-n8_Z2cD6.js";import{$a as s,Ga as c,Jr as l,Ua as u,Wa as d,ni as f,r as p,ti as m}from"./index-CByiCIuo.js";import{K as h}from"./ui-prefs-CvA86s8z.js";import{a as g,c as ee,d as _,f as v,h as y,i as b,l as te,m as x,n as S,o as C,p as ne,r as re,s as ie,t as ae,u as w}from"./repo-roots-adder-DYYg40Om.js";import{P as oe,g as se,s as ce,t as le,u as ue}from"./agent-core-V-1YNpK6.js";import{a as T,t as E}from"./button-B-DDg9O0.js";import{n as D,t as de}from"./setup-step-CBZFosoO.js";function O(e,t,...n){let r=o(`div`,`first-run-start-field`),i=o(`label`,`first-run-eyebrow`,e);return i.htmlFor=t,r.append(i,...n),r}function fe(e){let t=o(`span`,`first-run-start-project-path`);return t.append(o(`bdi`,null,e)),t}function pe({onAction:r}){let a=[],s=null,c=le,u=!1,d=o(`input`,`first-run-start-filter`);d.id=`first-run-start-filter`,d.type=`search`,d.placeholder=`Filter`,d.autocomplete=`off`;let f=o(`ul`,`first-run-start-projects`);f.setAttribute(`role`,`listbox`),f.setAttribute(`aria-label`,`Project`);let p=o(`div`,`first-run-start-agents`);p.id=`first-run-start-agents`,p.setAttribute(`role`,`group`);let m=o(`textarea`,`first-run-start-task`);m.id=`first-run-start-task`,m.value=re,m.maxLength=4e3;let h=E({variant:`primary`,label:`Start session`}),g=E({variant:`quiet`,label:`Advanced`}),_=e(`first-run-start-status`),v=o(`div`,`first-run-start-foot`);v.append(h,_.element,g);let y=o(`div`,`first-run-start`);y.append(O(`Project`,`first-run-start-filter`,d,f),O(`Agent`,`first-run-start-agents`,p),O(`First task`,`first-run-start-task`,m),v);function b(){let e=te(a,d.value,s);s=e.selectedPath,f.replaceChildren(...e.visibleProjects.map(e=>{let t=o(`li`,`first-run-start-project`),n=T(`first-run-start-project-choice`);return n.append(o(`span`,`first-run-start-project-name`,e.name),fe(e.path)),e.lastActivityMs!==null&&n.append(o(`span`,`first-run-start-project-age`,l(e.lastActivityMs,Date.now()))),n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(e.path===s)),n.addEventListener(`click`,()=>{s=e.path,b()}),t.append(n),t})),h.disabled=u||s===null}function x(e){let t=ee(e);c=t.selectedId,p.replaceChildren(...t.options.map(e=>{let t=T(`dialog-mode-button`,e.label);return t.setAttribute(`aria-pressed`,String(e.id===c)),t.addEventListener(`click`,()=>{c=e.id;for(let e of p.children)e.setAttribute(`aria-pressed`,String(e===t))}),t}))}function S(){let e=a.find(e=>e.path===s);if(!e||u)return;u=!0,h.disabled=!0,_.show(`busy`,`Starting the session`),r(`start-session`);let o={name:oe(e.name),path:e.path,prompt:m.value};c!==`claude-code`&&(o.agent=c),i(`add-session`,o,{timeoutMs:n}).then(e=>{e.type===`add-session-result`&&e.ok?(_.clear(),se(e.sessionId)):_.show(`error`,ce(e))}).catch(e=>{_.show(`error`,`The session was not started: ${t(e,n)}`)}).finally(()=>{u=!1,h.disabled=s===null})}d.addEventListener(`input`,b),h.addEventListener(`click`,S),g.addEventListener(`click`,()=>{r(`open-advanced`),ue()});function C({agentListing:e,startableProjects:t}){a=t,b(),x(e)}return{element:y,update:C,focusTask:()=>m.focus()}}var me=`npm install -g @anthropic-ai/claude-code`,k=null,A=null,j=null,M=null,N=`unloaded`,P=null,F=null,I={steps:b,agentSummary:``,installableAgents:w(null),repoRoots:[],notificationChoice:`ask`,agentListing:null,startableProjects:[]},L=0,R=!1,z=!1,B=new Set,V=e(`first-run-load-status`),H=pe({onAction:U});function U(e){r({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`onboarding`,action:e}})}function he(e){for(let t of ie(B,e))r({type:`dashboard-telemetry`,event:`onboarding_step`,properties:t})&&B.add(ne(t))}function ge(){return s()?`No agent found on PATH of the machine running Glimmervoid.`:`No agent found on PATH.`}function _e(){let e=o(`div`,`first-run-step-actions`);P=E({variant:`primary`,label:`Rescan`}),P.addEventListener(`click`,()=>{U(`rescan`),X({rescanAgents:!0})}),e.append(P);let t=[o(`p`,`first-run-step-text`,ge()),de(me),e];return R?[...t,o(`p`,`first-run-step-hint`,`Still missing after a rescan? Restart Glimmervoid from a terminal where the command runs. Other terminal agents go under customAgents.`)]:t}function ve(){let e=F??ae({onAdded:e=>{U(e===`typed`?`add-root-typed`:`add-root-suggested`),X({rescanAgents:!1})}});return F=e,[e.element]}var ye=`auth-refactor needs attention`;function W(e){U(e===`allow`?`allow-notifications`:`skip-notifications`),e===`skip`?(h(!1),X({rescanAgents:!1})):f().then(()=>X({rescanAgents:!1}))}function be(){let e=o(`div`,`first-run-sample-notification`);e.setAttribute(`aria-hidden`,`true`),e.append(Z(`first-run-sample-mark`),o(`span`,null,ye));let t=E({variant:`primary`,label:`Allow notifications`}),n=E({variant:`quiet`,label:`Skip`});t.addEventListener(`click`,()=>{t.disabled=!0,W(`allow`)}),n.addEventListener(`click`,()=>W(`skip`));let r=o(`div`,`first-run-step-actions`);return r.append(t,n),[o(`p`,`first-run-step-text`,`Know when a session needs you.`),e,r]}function G(){let{steps:e,agentSummary:t,repoRoots:n,notificationChoice:r}=I;return[D({title:`1. Agent CLI`,state:e.agent,summary:t,badge:``,body:_e}),D({title:`2. Repository roots`,state:e.repoRoots,summary:n.join(`, `),badge:``,body:ve}),D({title:`3. Notifications`,state:e.notifications,summary:v(r),badge:``,body:be})]}function xe(){let{agentSummary:e,repoRoots:t,notificationChoice:n}=I,r=`notifications ${v(n).toLowerCase()}`,i=[e,t.join(`, `),r].filter(Boolean).join(` · `);return D({title:`Setup done`,state:`done`,summary:i,badge:``,body:()=>[]})}function Se(e){H.update({agentListing:I.agentListing,startableProjects:I.startableProjects}),e.contains(H.element)||e.append(H.element),e.hidden=!1}function K(){A&&j&&N!==`folding`&&(_(I.steps)?(A.replaceChildren(xe()),Se(j)):(A.replaceChildren(...G()),j.hidden=!0))}var Ce=200,q=250,J=480,Y=`cubic-bezier(0.22, 1, 0.36, 1)`,we=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);function Te(){return!we?.matches&&!document.hidden}function Ee(e){[...e.querySelectorAll(`.first-run-step-icon circle, .first-run-step-icon path`)].forEach((e,t)=>{e.setAttribute(`pathLength`,`1`),e.animate([{strokeDasharray:`1`,strokeDashoffset:`1`},{strokeDasharray:`1`,strokeDashoffset:`0`}],{duration:q,delay:t*q,easing:Y,fill:`backwards`})})}function De(){let e=M?.querySelector(`svg`),t=e?.querySelector(`.first-run-mark-dial`),n=e?.querySelector(`.first-run-mark-light`),r=e?.querySelector(`.first-run-mark-halo`);return!e||!t||!n||!r?Promise.resolve():p({mark:e,dial:t,light:n,halo:r})}function Oe(e){return new Promise(t=>{setTimeout(t,e)})}async function ke(e,t){N=`folding`,await e.querySelector(`[aria-current="step"] .first-run-step-body`)?.animate([{opacity:1},{opacity:0}],{duration:Ce,fill:`forwards`}).finished;let n=G();e.replaceChildren(...n);let[r,...i]=n,a=n.at(-1);a&&Ee(a),await De();for(let e of i)e.animate([{transform:`none`,opacity:1},{opacity:0,offset:.35},{transform:`translateY(${r.offsetTop-e.offsetTop}px)`,opacity:0}],{duration:J,easing:Y,fill:`forwards`});r.querySelector(`.first-run-step-head`)?.animate([{opacity:1},{opacity:0}],{duration:q,fill:`forwards`}),await Oe(J),N=`done`,K(),e.firstElementChild?.animate([{opacity:0},{opacity:1}],{duration:q,easing:Y}),t.animate([{transform:`translateY(12px)`,opacity:0},{transform:`none`,opacity:1}],{duration:J,easing:Y}),H.focusTask()}function Ae(){if(N===`folding`)return;let e=_(I.steps),t=N===`in-progress`&&e&&Te();N=e?`done`:`in-progress`,!t||!A||!j?K():ke(A,j)}async function X({rescanAgents:e}){L+=1;let r=L;P&&(P.disabled=!0);try{let[t,a]=await Promise.all([i(`list-agents`,e?{rescan:!0}:{},{timeoutMs:n}),i(`scan-repo-roots`,{includeSuggestions:!0,includeActivity:!0},{timeoutMs:n})]);if(r!==L)return;let o=a.type===`repo-roots-scanned`,s=o?a.directories.map(e=>e.root):[],c=o?a.suggestions??[]:[],l=x(s,c);if(l.length>0&&!z){z=!0;let e=await S(l).catch(e=>String(e));if(r!==L)return;if(!e){X({rescanAgents:!1});return}}let u=m(),d=C({agentListing:t,repoRoots:s,notificationChoice:u});e&&(R=d.agent===`current`),I={steps:d,agentSummary:g(t),installableAgents:w(t),repoRoots:s,notificationChoice:u,agentListing:t,startableProjects:o?y(a.directories):[]},V.clear(),Ae(),he(I.steps),F?.setSuggestions(c)}catch(e){if(P&&(P.disabled=!1),r!==L)return;V.show(`error`,`The checklist could not load: ${t(e,n)} It loads again once the server answers. If it stays like this, check the terminal running Glimmervoid, or run glimmervoid doctor.`)}}function Z(e){let t=u.map(({side:e,d:t})=>`<path class="first-run-mark-bracket" data-side="${e}" d="${t}"/>`).join(``);return a(`span`,e,`<svg viewBox="${c}" aria-hidden="true"><path class="first-run-mark-halo" d="${d}"/><g class="first-run-mark-dial">${t}</g><path class="first-run-mark-light" d="${d}"/></svg>`)}var je=5e3,Q=-1/0;function $(){document.visibilityState===`visible`&&I.steps.agent===`current`&&k&&!k.hidden&&k.isConnected&&(performance.now()-Q<je||(Q=performance.now(),X({rescanAgents:!0})))}function Me(){if(k)return k;let e=o(`section`,`first-run-checklist`);e.setAttribute(`aria-label`,`Glimmervoid setup`);let t=o(`div`,`first-run-lockup`);return M=t,t.append(Z(`first-run-mark`),o(`span`,`first-run-wordmark`,`GLIMMERVOID`)),A=o(`ol`,`first-run-steps`),j=o(`div`,`first-run-start-host`),e.append(t,A,V.element,j),k=e,document.addEventListener(`visibilitychange`,$),window.addEventListener(`focus`,$),K(),e}function Ne(e,t){if(!t){k?.parentElement===e&&!k.hidden&&(k.hidden=!0);return}let n=Me(),r=!n.hidden&&n.parentElement===e;n.parentElement!==e&&e.append(n),n.hidden=!1,r||X({rescanAgents:!1})}function Pe(){k&&!k.hidden&&k.isConnected&&X({rescanAgents:!1})}export{Pe as refreshFirstRunChecklist,Ne as showFirstRunChecklist};
@@ -1 +1 @@
1
- import{f as e}from"./control-ws-CU_Jcrnd.js";import{i as t,s as n,t as r}from"./action-status-GwVm_xGS.js";import{M as i,O as a,a as o,b as s,t as c}from"./button-B-DDg9O0.js";import{d as l,m as ee,n as u,r as d,s as f}from"./dom-helpers-n8_Z2cD6.js";import{a as p}from"./modal-CLLdvDUd.js";import{di as m,li as h,ui as g}from"./index-DbtIz4EN.js";var _=`Claude Code hooks injected into every session Glimmervoid spawns.`,v=`Loading hooks`,y=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,b=`Start from`,x=`Filter by name, event or command`,te=`Nothing matches that filter.`,S=`Preview`,ne=`The entry this becomes in the per-session settings file.`,re=`Duplicate`,ie=`Discard changes`,ae=`Close the editor and lose the unsaved changes?`,oe=`Esc cancels. Ctrl+Enter saves.`,se=4,ce=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,le=`Glimmervoid's own hooks`,ue=`Always present, read-only. Status detection depends on them.`,de=`What Glimmervoid adds to the agent`,fe=`Text sent to the agent through the hooks above; the start line and each hint go at most once per conversation. A row marked template is filled in per session.`;function pe(e){return`${e.carriedBy}, when ${e.firesWhen}${e.isTemplate?` (template)`:``}`}function me(e){let t=e.version===null?``:` ${e.version}`,n=e.isBestEffort?`, best effort`:``;return`${e.label}${t}${n} (${e.rows.length})`}var he=`Your hooks`,ge=`New hook`,_e=`Edit hook`,ve=`Saved to config.json.`,C=`All projects`,ye=`This event takes no matcher.`,be=`Blank uses Claude Code's default for the event.`,w=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),xe=Object.freeze([{id:`lint`,label:`Lint after edits`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),Se=Object.freeze({hooks:[],builtinByAgent:[],agentNotes:[],events:[]});function Ce(e){return!e||typeof e.error==`string`}function we(e){return!e||typeof e.error!=`string`?``:e.error}function T(e,t){let n=e?.[t];return Array.isArray(n)?n:Se[t]}var E=e=>T(e,`hooks`),Te=e=>T(e,`agentNotes`),Ee=e=>T(e,`builtinByAgent`),De=e=>Ee(e).reduce((e,t)=>e+t.rows.length,0),D=e=>T(e,`events`);function Oe(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function ke(e){let t=E(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String(De(e)),tone:null}]}function Ae(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function je(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function Me(e){return e.length>=se}function Ne(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.event===n.event?e.hooks.push(n):t.push({event:n.event,hooks:[n]})}return t}function Pe(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function Fe(e){return`${e} copy`}function O(e,t){return e.find(e=>e.name===t)||null}function Ie(e,t){let n=O(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:ye:``}function Le(e){return e.type===`http`?e.url||``:e.command||``}function Re(e){let t=w.find(t=>t.value===e);return t?t.label:String(e||``)}function ze(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function Be(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?C:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function Ve(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function He(e){return Ve(e)}function Ue(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function k(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function A(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function We(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=O(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function j(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function Ge(e,t){let n={...k(t),...e.draft};return O(t,n.event)||(n.event=k(t).event),n}function Ke(e,t){return JSON.stringify(j(e))!==JSON.stringify(t)}function qe(e){return{...e,enabled:e.enabled===!1}}function Je(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var M=h(),N=null,P=null,F=null,I=null,L=null,R=null,z=!1,B=``,V=new Set,H=new Set,U=new Map,W=!1,G=(e,t)=>u(`hooks`,e,t);function K(e,t,n){let r=f(`p`,e,t);return n&&(r.dataset.tone=n),r}function q(e,t,n,r,i){let a=c({variant:e,size:`small`,label:t,action:n,onClick:i});return a.setAttribute(`aria-label`,r),a}async function Ye(t,i){try{let n=await e(t,i,{timeoutMs:r});if((n.type===`save-hook-result`||n.type===`delete-hook-result`)&&n.ok)return null;let a=t===`save-hook`?`Could not save the hook.`:`Could not delete the hook.`;return`error`in n&&typeof n.error==`string`&&n.error?n.error:a}catch(e){return n(e,r)}}async function Xe(e,t,n,r){H.add(e),U.set(e,{tone:`busy`,text:r}),$({force:!0});let i=await Ye(t,n);H.delete(e),i&&U.set(e,{tone:`error`,text:i}),i||U.delete(e),$({force:!0}),g()}function J(e,t,n){let r=f(`label`,`hooks-field`);return r.append(f(`span`,`hooks-field-label`,e),t),n&&r.append(f(`span`,`hooks-field-hint`,n)),r}function Y(e,t,n){let r=f(`input`,`settings-view-input`);return r.type=`text`,r.value=e,r.autocomplete=`off`,r.spellcheck=!1,t&&(r.placeholder=t),r.addEventListener(`input`,()=>n(r.value)),r}function Ze(e,t){let n=f(`textarea`,`settings-view-input hooks-command`);return n.rows=3,n.value=e,n.spellcheck=!1,n.addEventListener(`input`,()=>t(n.value)),n}function Qe(e,t){return e.find(e=>e.name===t)?.description??``}function $e(e,t,n){let r=f(`select`,`settings-view-input hooks-select`);for(let n of t){let t=f(`option`,null,n.name);t.value=n.name,n.name===e.event&&(t.selected=!0),r.append(t)}return r.addEventListener(`change`,()=>n(r.value)),r}function et(e,t){let n=f(`div`,`hooks-type-row`);n.setAttribute(`role`,`radiogroup`);for(let r of w){let i=f(`label`,`settings-view-toggle hooks-choice`),a=f(`input`,`settings-view-checkbox`);a.type=`radio`,a.name=`hooks-type`,a.value=r.value,a.checked=e.type===r.value,a.addEventListener(`change`,()=>{a.checked&&t(r.value)}),i.append(a,f(`span`,null,r.label)),n.append(i)}return n}function tt(e,t){let n=f(`div`,`hooks-projects`);if(t.length===0)return n.append(f(`span`,`hooks-field-hint`,C)),n;let r=f(`label`,`settings-view-project-choice hooks-choice`),i=f(`input`,`settings-view-checkbox`);i.type=`checkbox`,i.checked=e.projects.length===0,r.append(i,f(`span`,null,C)),n.append(r);let a=[];for(let r of t){let t=f(`label`,`settings-view-project-choice hooks-choice`),o=f(`input`,`settings-view-checkbox`);o.type=`checkbox`,o.value=r.id,o.checked=e.projects.includes(r.id),o.addEventListener(`change`,()=>{e.projects=a.filter(e=>e.checked).map(e=>e.value),i.checked=e.projects.length===0}),a.push(o),t.append(o,f(`span`,null,r.name)),r.agent!==`claude-code`&&t.append(f(`span`,`hooks-choice-note`,`${r.agent}, hook never runs`)),n.append(t)}return i.addEventListener(`change`,()=>{if(!i.checked)i.checked=e.projects.length===0;else{for(let e of a)e.checked=!1;e.projects=[]}}),n}function nt(e){let t=f(`div`,`hooks-templates`);t.append(f(`span`,`hooks-templates-label`,b));for(let n of xe){let r=o(`hooks-chip`,n.label);r.addEventListener(`click`,()=>X(null,Ge(n,e))),t.append(r)}return t}function rt(e){L&&(e?L.show(`error`,e):L.clear())}function it(e){let n=D(M.report),r=ee(M.report),i=G(e.id?_e:ge,ve);i.classList.add(`hooks-editor`);let a=f(`form`,`hooks-form`);a.addEventListener(`submit`,e=>{e.preventDefault(),Q()}),a.addEventListener(`keydown`,e=>{e.key===`Escape`?(e.preventDefault(),at()):e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),Q())}),e.id||a.append(nt(n));let o=f(`span`,`hooks-field-hint`,Ie(n,e.event)),s=Y(e.matcher,``,t=>{e.matcher=t}),l=J(`Command`,Ze(e.command,t=>{e.command=t}),`Runs through the shell with the event JSON on stdin. Exit 2 blocks the action where the event allows it.`),u=J(`URL`,Y(e.url,`http://127.0.0.1:8080/hook`,t=>{e.url=t}),`Claude Code POSTs the event JSON to it.`),d=()=>{l.hidden=e.type!==`command`,u.hidden=e.type!==`http`};d();let p=J(`Matcher`,s,null);p.append(o);let m=()=>{let t=n.find(t=>t.name===e.event);o.textContent=Ie(n,e.event),s.disabled=!!t&&!t.matcher,s.disabled&&(s.value=``,e.matcher=``)};m();let h=f(`input`,`settings-view-input hooks-timeout`);h.type=`number`,h.inputMode=`numeric`,h.min=`1`,h.max=String(Oe(M.report)),h.value=e.timeout,h.addEventListener(`input`,()=>{e.timeout=h.value});let g=f(`span`,`hooks-field-hint`,Qe(n,e.event)),_=J(`Event`,$e(e,n,t=>{e.event=t,g.textContent=Qe(n,t),m()}),null);_.append(g);let v=f(`label`,`settings-view-toggle hooks-choice`),y=f(`input`,`settings-view-checkbox`);y.type=`checkbox`,y.checked=e.enabled,y.addEventListener(`change`,()=>{e.enabled=y.checked}),v.append(y,f(`span`,null,`Enabled`)),a.append(J(`Name`,Y(e.name,`Lint after edits`,t=>{e.name=t}),null),_,p,J(`Type`,et(e,t=>{e.type=t,d()}),w.map(e=>`${e.label}: ${e.hint}`).join(` `)),l,u,J(`Timeout (seconds)`,h,be),J(`Projects`,tt(e,r),null),J(``,v,null)),L=t(`hooks-editor-status`);let b=f(`div`,`hooks-editor-footer`),x=f(`span`,`hooks-editor-shortcut`,oe),te=c({variant:`secondary`,label:`Cancel`,action:`cancel-hook-edit`,onClick:at}),S=c({variant:`primary`,label:e.id?`Save changes`:`Add hook`,action:`save-hook`});return S.type=`submit`,R=S,b.append(L.element,x,te,S),a.append(b),i.append(a),i}function X(e,t=null){P=t||(e?A(e):k(D(M.report))),F=j(e?A(e):k(D(M.report))),I=it(P),$({force:!0}),I.scrollIntoView({block:`nearest`});let n=I.querySelector(`input[type=text]`);n instanceof HTMLInputElement&&n.focus()}function Z(){P=null,F=null,I=null,L=null,R=null,z=!1,W=!0,$({force:!0})}function at(){!P||!F||!Ke(P,F)?Z():p({title:ie,message:ae,confirmLabel:`Discard`,danger:!0,onConfirm:Z})}async function Q(){if(!P||z)return;let e=We(P,D(M.report),Oe(M.report));if(e){rt(e);return}let t=L,n=R;z=!0,t?.show(`busy`,`Saving the hook.`),n&&(n.disabled=!0);let r=await Ye(`save-hook`,{hook:j(P)});z=!1,n&&(n.disabled=!1),t===L&&(r?rt(r):(Z(),g()))}function ot(e){let t=f(`details`,`hooks-preview`);t.open=V.has(e.id),t.addEventListener(`toggle`,()=>{t.open?V.add(e.id):V.delete(e.id)});let n=f(`summary`,`hooks-preview-summary`,S),r=f(`pre`,`hooks-preview-code`,Pe(e));return t.append(n,f(`p`,`hooks-field-hint`,ne),r),t}function st(e,{grouped:n=!1}={}){let r=ee(M.report),i=f(`article`,`hooks-row`);i.setAttribute(`aria-label`,e.name),e.enabled===!1&&(i.dataset.state=`off`);let a=f(`div`,`hooks-row-main`),o=f(`div`,`hooks-row-head`);o.append(f(`span`,`hooks-row-name`,e.name));let s=n?e.matcher||``:Ve(e);s&&o.append(f(`span`,`hooks-row-event`,s));let c=f(`code`,`hooks-row-target`,Le(e)),l=f(`p`,`hooks-row-meta`,[Re(e.type),ze(e),Be(e,r)].filter(Boolean).join(` / `));a.append(o,c,l);let u=Ue(e,r);u.length>0&&a.append(K(`hooks-row-meta`,`Scoped to a project no longer in config: ${u.join(`, `)}`,`warn`)),a.append(ot(e));let d=U.get(e.id);if(d){let e=t(`hooks-row-status`);e.show(d.tone,d.text),a.append(e.element)}let m=f(`div`,`hooks-row-actions`),h=f(`label`,`settings-view-toggle hooks-choice`),g=f(`input`,`settings-view-checkbox`);g.type=`checkbox`,g.checked=e.enabled!==!1,g.disabled=H.has(e.id),g.setAttribute(`aria-label`,`${e.name} enabled`),g.addEventListener(`change`,()=>{Xe(e.id,`save-hook`,{hook:qe(e)},g.checked?`Turning the hook on.`:`Turning the hook off.`)}),h.append(g,f(`span`,null,`On`));let _=q(`secondary`,`Edit`,`edit-hook`,`Edit ${e.name}`,()=>X(e)),v=q(`secondary`,re,`duplicate-hook`,`Duplicate ${e.name}`,()=>{let t=A({...e,name:Fe(e.name)});t.id=null,X(null,t)}),y=q(`danger`,`Delete`,`delete-hook`,`Delete ${e.name}`,()=>{p({title:`Delete hook`,message:Je(e),confirmLabel:`Delete`,danger:!0,onConfirm:()=>{Xe(e.id,`delete-hook`,{id:e.id},`Deleting the hook.`)}})});return y.disabled=H.has(e.id),m.append(h,_,v,y),i.append(a,m),i}function ct(e){let t=f(`article`,`hooks-row hooks-row-builtin`),n=f(`div`,`hooks-row-main`);return n.append(f(`span`,`hooks-row-event`,He(e)),f(`p`,`hooks-row-meta`,e.purpose)),t.append(n),t}function lt(){let e=G(`Hooks`,_),t=f(`div`,`hooks-stats`);for(let e of ke(M.report))t.append(d(`hooks`,e.label,e.value,e.tone));return e.append(t,K(`hooks-meta`,ce)),e}function ut(){let e=f(`input`,`settings-view-input hooks-filter`);return e.type=`search`,e.value=B,e.placeholder=x,e.setAttribute(`aria-label`,x),e.addEventListener(`input`,()=>{B=e.value;let t=N?.querySelector(`.hooks-list-yours`);t&&t.replaceWith(ft())}),e}function dt(){let e=f(`div`,`hooks-empty-state`);return e.append(K(`hooks-empty`,y),nt(D(M.report))),e}function ft(){let e=f(`div`,`hooks-list-yours`),t=E(M.report);if(t.length===0)return e.append(dt()),e;let n=je(Ae(t,D(M.report)),B);if(n.length===0)return e.append(K(`hooks-empty`,te)),e;for(let t of Ne(n)){let n=f(`div`,`hooks-group`);n.append(f(`h3`,`hooks-group-title`,t.event));let r=f(`div`,`hooks-list`);for(let e of t.hooks)r.append(st(e,{grouped:!0}));n.append(r),e.append(n)}return e}function pt(){let e=G(he,null),t=c({variant:`primary`,size:`small`,label:ge,icon:a(s),action:`new-hook`,disabled:!!P,onClick:()=>X(null)}),n=e.querySelector(`.hooks-section-head`);return n&&n.append(t),Me(E(M.report))&&e.append(ut()),e.append(ft()),e}function mt(e){let t=f(`details`,`hooks-agent-group`);t.append(f(`summary`,`hooks-agent-group-summary`,me(e)));let n=f(`div`,`hooks-list`);e.unavailableReason!==null&&n.append(f(`p`,`hooks-row-meta`,e.unavailableReason));for(let t of e.rows)n.append(ct(t));return t.append(n),t}function ht(){let e=f(`details`,`hooks-builtin`),t=f(`summary`,`hooks-builtin-summary`);t.append(f(`span`,`hooks-section-title`,`${le} (${De(M.report)})`),f(`span`,`hooks-section-hint`,ue));let n=f(`div`,`hooks-agent-groups`);for(let e of Ee(M.report))n.append(mt(e));return e.append(t,n),e}function gt(e){let t=f(`article`,`hooks-row hooks-row-builtin`),n=f(`div`,`hooks-row-main`);return n.append(f(`span`,`hooks-row-event`,e.name),f(`p`,`hooks-row-meta`,pe(e)),f(`code`,`hooks-note-text`,e.text)),t.append(n),t}function _t(){let e=f(`details`,`hooks-builtin`),t=f(`summary`,`hooks-builtin-summary`),n=Te(M.report);t.append(f(`span`,`hooks-section-title`,`${de} (${n.length})`),f(`span`,`hooks-section-hint`,fe));let r=f(`div`,`hooks-list`);for(let e of n)r.append(gt(e));return e.append(t,r),e}function vt(){let e=f(`div`,`hooks-content`);return M.report?Ce(M.report)?(e.append(K(`hooks-warning`,we(M.report))),e):(e.append(lt()),I&&e.append(I),e.append(pt(),ht(),_t()),e):(e.append(M.hasReportSendFailed?K(`hooks-warning`,i):K(`hooks-empty`,v)),e)}function $({force:e=!1}={}){if(!N||!e&&l(N)||(M=h(),N.replaceChildren(vt()),!W))return;W=!1;let t=N.querySelector(`[data-action="new-hook"]`);t instanceof HTMLButtonElement&&t.focus()}function yt(e){N||(N=f(`div`,`hooks-panel`),e.append(N),m(()=>$()),$({force:!0}))}function bt(e){e===`shown`&&$({force:!0}),g()}var xt={mount:yt,refresh:bt};export{xt as view};
1
+ import{f as e}from"./control-ws-CU_Jcrnd.js";import{i as t,s as n,t as r}from"./action-status-GwVm_xGS.js";import{M as i,O as a,a as o,b as s,t as c}from"./button-B-DDg9O0.js";import{d as l,m as ee,n as u,r as d,s as f}from"./dom-helpers-n8_Z2cD6.js";import{a as p}from"./modal-CLLdvDUd.js";import{di as m,li as h,ui as g}from"./index-CByiCIuo.js";var _=`Claude Code hooks injected into every session Glimmervoid spawns.`,v=`Loading hooks`,y=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,b=`Start from`,x=`Filter by name, event or command`,te=`Nothing matches that filter.`,S=`Preview`,ne=`The entry this becomes in the per-session settings file.`,re=`Duplicate`,ie=`Discard changes`,ae=`Close the editor and lose the unsaved changes?`,oe=`Esc cancels. Ctrl+Enter saves.`,se=4,ce=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,le=`Glimmervoid's own hooks`,ue=`Always present, read-only. Status detection depends on them.`,de=`What Glimmervoid adds to the agent`,fe=`Text sent to the agent through the hooks above; the start line and each hint go at most once per conversation. A row marked template is filled in per session.`;function pe(e){return`${e.carriedBy}, when ${e.firesWhen}${e.isTemplate?` (template)`:``}`}function me(e){let t=e.version===null?``:` ${e.version}`,n=e.isBestEffort?`, best effort`:``;return`${e.label}${t}${n} (${e.rows.length})`}var he=`Your hooks`,ge=`New hook`,_e=`Edit hook`,ve=`Saved to config.json.`,C=`All projects`,ye=`This event takes no matcher.`,be=`Blank uses Claude Code's default for the event.`,w=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),xe=Object.freeze([{id:`lint`,label:`Lint after edits`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),Se=Object.freeze({hooks:[],builtinByAgent:[],agentNotes:[],events:[]});function Ce(e){return!e||typeof e.error==`string`}function we(e){return!e||typeof e.error!=`string`?``:e.error}function T(e,t){let n=e?.[t];return Array.isArray(n)?n:Se[t]}var E=e=>T(e,`hooks`),Te=e=>T(e,`agentNotes`),Ee=e=>T(e,`builtinByAgent`),De=e=>Ee(e).reduce((e,t)=>e+t.rows.length,0),D=e=>T(e,`events`);function Oe(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function ke(e){let t=E(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String(De(e)),tone:null}]}function Ae(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function je(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function Me(e){return e.length>=se}function Ne(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.event===n.event?e.hooks.push(n):t.push({event:n.event,hooks:[n]})}return t}function Pe(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function Fe(e){return`${e} copy`}function O(e,t){return e.find(e=>e.name===t)||null}function Ie(e,t){let n=O(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:ye:``}function Le(e){return e.type===`http`?e.url||``:e.command||``}function Re(e){let t=w.find(t=>t.value===e);return t?t.label:String(e||``)}function ze(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function Be(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?C:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function Ve(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function He(e){return Ve(e)}function Ue(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function k(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function A(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function We(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=O(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function j(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function Ge(e,t){let n={...k(t),...e.draft};return O(t,n.event)||(n.event=k(t).event),n}function Ke(e,t){return JSON.stringify(j(e))!==JSON.stringify(t)}function qe(e){return{...e,enabled:e.enabled===!1}}function Je(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var M=h(),N=null,P=null,F=null,I=null,L=null,R=null,z=!1,B=``,V=new Set,H=new Set,U=new Map,W=!1,G=(e,t)=>u(`hooks`,e,t);function K(e,t,n){let r=f(`p`,e,t);return n&&(r.dataset.tone=n),r}function q(e,t,n,r,i){let a=c({variant:e,size:`small`,label:t,action:n,onClick:i});return a.setAttribute(`aria-label`,r),a}async function Ye(t,i){try{let n=await e(t,i,{timeoutMs:r});if((n.type===`save-hook-result`||n.type===`delete-hook-result`)&&n.ok)return null;let a=t===`save-hook`?`Could not save the hook.`:`Could not delete the hook.`;return`error`in n&&typeof n.error==`string`&&n.error?n.error:a}catch(e){return n(e,r)}}async function Xe(e,t,n,r){H.add(e),U.set(e,{tone:`busy`,text:r}),$({force:!0});let i=await Ye(t,n);H.delete(e),i&&U.set(e,{tone:`error`,text:i}),i||U.delete(e),$({force:!0}),g()}function J(e,t,n){let r=f(`label`,`hooks-field`);return r.append(f(`span`,`hooks-field-label`,e),t),n&&r.append(f(`span`,`hooks-field-hint`,n)),r}function Y(e,t,n){let r=f(`input`,`settings-view-input`);return r.type=`text`,r.value=e,r.autocomplete=`off`,r.spellcheck=!1,t&&(r.placeholder=t),r.addEventListener(`input`,()=>n(r.value)),r}function Ze(e,t){let n=f(`textarea`,`settings-view-input hooks-command`);return n.rows=3,n.value=e,n.spellcheck=!1,n.addEventListener(`input`,()=>t(n.value)),n}function Qe(e,t){return e.find(e=>e.name===t)?.description??``}function $e(e,t,n){let r=f(`select`,`settings-view-input hooks-select`);for(let n of t){let t=f(`option`,null,n.name);t.value=n.name,n.name===e.event&&(t.selected=!0),r.append(t)}return r.addEventListener(`change`,()=>n(r.value)),r}function et(e,t){let n=f(`div`,`hooks-type-row`);n.setAttribute(`role`,`radiogroup`);for(let r of w){let i=f(`label`,`settings-view-toggle hooks-choice`),a=f(`input`,`settings-view-checkbox`);a.type=`radio`,a.name=`hooks-type`,a.value=r.value,a.checked=e.type===r.value,a.addEventListener(`change`,()=>{a.checked&&t(r.value)}),i.append(a,f(`span`,null,r.label)),n.append(i)}return n}function tt(e,t){let n=f(`div`,`hooks-projects`);if(t.length===0)return n.append(f(`span`,`hooks-field-hint`,C)),n;let r=f(`label`,`settings-view-project-choice hooks-choice`),i=f(`input`,`settings-view-checkbox`);i.type=`checkbox`,i.checked=e.projects.length===0,r.append(i,f(`span`,null,C)),n.append(r);let a=[];for(let r of t){let t=f(`label`,`settings-view-project-choice hooks-choice`),o=f(`input`,`settings-view-checkbox`);o.type=`checkbox`,o.value=r.id,o.checked=e.projects.includes(r.id),o.addEventListener(`change`,()=>{e.projects=a.filter(e=>e.checked).map(e=>e.value),i.checked=e.projects.length===0}),a.push(o),t.append(o,f(`span`,null,r.name)),r.agent!==`claude-code`&&t.append(f(`span`,`hooks-choice-note`,`${r.agent}, hook never runs`)),n.append(t)}return i.addEventListener(`change`,()=>{if(!i.checked)i.checked=e.projects.length===0;else{for(let e of a)e.checked=!1;e.projects=[]}}),n}function nt(e){let t=f(`div`,`hooks-templates`);t.append(f(`span`,`hooks-templates-label`,b));for(let n of xe){let r=o(`hooks-chip`,n.label);r.addEventListener(`click`,()=>X(null,Ge(n,e))),t.append(r)}return t}function rt(e){L&&(e?L.show(`error`,e):L.clear())}function it(e){let n=D(M.report),r=ee(M.report),i=G(e.id?_e:ge,ve);i.classList.add(`hooks-editor`);let a=f(`form`,`hooks-form`);a.addEventListener(`submit`,e=>{e.preventDefault(),Q()}),a.addEventListener(`keydown`,e=>{e.key===`Escape`?(e.preventDefault(),at()):e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),Q())}),e.id||a.append(nt(n));let o=f(`span`,`hooks-field-hint`,Ie(n,e.event)),s=Y(e.matcher,``,t=>{e.matcher=t}),l=J(`Command`,Ze(e.command,t=>{e.command=t}),`Runs through the shell with the event JSON on stdin. Exit 2 blocks the action where the event allows it.`),u=J(`URL`,Y(e.url,`http://127.0.0.1:8080/hook`,t=>{e.url=t}),`Claude Code POSTs the event JSON to it.`),d=()=>{l.hidden=e.type!==`command`,u.hidden=e.type!==`http`};d();let p=J(`Matcher`,s,null);p.append(o);let m=()=>{let t=n.find(t=>t.name===e.event);o.textContent=Ie(n,e.event),s.disabled=!!t&&!t.matcher,s.disabled&&(s.value=``,e.matcher=``)};m();let h=f(`input`,`settings-view-input hooks-timeout`);h.type=`number`,h.inputMode=`numeric`,h.min=`1`,h.max=String(Oe(M.report)),h.value=e.timeout,h.addEventListener(`input`,()=>{e.timeout=h.value});let g=f(`span`,`hooks-field-hint`,Qe(n,e.event)),_=J(`Event`,$e(e,n,t=>{e.event=t,g.textContent=Qe(n,t),m()}),null);_.append(g);let v=f(`label`,`settings-view-toggle hooks-choice`),y=f(`input`,`settings-view-checkbox`);y.type=`checkbox`,y.checked=e.enabled,y.addEventListener(`change`,()=>{e.enabled=y.checked}),v.append(y,f(`span`,null,`Enabled`)),a.append(J(`Name`,Y(e.name,`Lint after edits`,t=>{e.name=t}),null),_,p,J(`Type`,et(e,t=>{e.type=t,d()}),w.map(e=>`${e.label}: ${e.hint}`).join(` `)),l,u,J(`Timeout (seconds)`,h,be),J(`Projects`,tt(e,r),null),J(``,v,null)),L=t(`hooks-editor-status`);let b=f(`div`,`hooks-editor-footer`),x=f(`span`,`hooks-editor-shortcut`,oe),te=c({variant:`secondary`,label:`Cancel`,action:`cancel-hook-edit`,onClick:at}),S=c({variant:`primary`,label:e.id?`Save changes`:`Add hook`,action:`save-hook`});return S.type=`submit`,R=S,b.append(L.element,x,te,S),a.append(b),i.append(a),i}function X(e,t=null){P=t||(e?A(e):k(D(M.report))),F=j(e?A(e):k(D(M.report))),I=it(P),$({force:!0}),I.scrollIntoView({block:`nearest`});let n=I.querySelector(`input[type=text]`);n instanceof HTMLInputElement&&n.focus()}function Z(){P=null,F=null,I=null,L=null,R=null,z=!1,W=!0,$({force:!0})}function at(){!P||!F||!Ke(P,F)?Z():p({title:ie,message:ae,confirmLabel:`Discard`,danger:!0,onConfirm:Z})}async function Q(){if(!P||z)return;let e=We(P,D(M.report),Oe(M.report));if(e){rt(e);return}let t=L,n=R;z=!0,t?.show(`busy`,`Saving the hook.`),n&&(n.disabled=!0);let r=await Ye(`save-hook`,{hook:j(P)});z=!1,n&&(n.disabled=!1),t===L&&(r?rt(r):(Z(),g()))}function ot(e){let t=f(`details`,`hooks-preview`);t.open=V.has(e.id),t.addEventListener(`toggle`,()=>{t.open?V.add(e.id):V.delete(e.id)});let n=f(`summary`,`hooks-preview-summary`,S),r=f(`pre`,`hooks-preview-code`,Pe(e));return t.append(n,f(`p`,`hooks-field-hint`,ne),r),t}function st(e,{grouped:n=!1}={}){let r=ee(M.report),i=f(`article`,`hooks-row`);i.setAttribute(`aria-label`,e.name),e.enabled===!1&&(i.dataset.state=`off`);let a=f(`div`,`hooks-row-main`),o=f(`div`,`hooks-row-head`);o.append(f(`span`,`hooks-row-name`,e.name));let s=n?e.matcher||``:Ve(e);s&&o.append(f(`span`,`hooks-row-event`,s));let c=f(`code`,`hooks-row-target`,Le(e)),l=f(`p`,`hooks-row-meta`,[Re(e.type),ze(e),Be(e,r)].filter(Boolean).join(` / `));a.append(o,c,l);let u=Ue(e,r);u.length>0&&a.append(K(`hooks-row-meta`,`Scoped to a project no longer in config: ${u.join(`, `)}`,`warn`)),a.append(ot(e));let d=U.get(e.id);if(d){let e=t(`hooks-row-status`);e.show(d.tone,d.text),a.append(e.element)}let m=f(`div`,`hooks-row-actions`),h=f(`label`,`settings-view-toggle hooks-choice`),g=f(`input`,`settings-view-checkbox`);g.type=`checkbox`,g.checked=e.enabled!==!1,g.disabled=H.has(e.id),g.setAttribute(`aria-label`,`${e.name} enabled`),g.addEventListener(`change`,()=>{Xe(e.id,`save-hook`,{hook:qe(e)},g.checked?`Turning the hook on.`:`Turning the hook off.`)}),h.append(g,f(`span`,null,`On`));let _=q(`secondary`,`Edit`,`edit-hook`,`Edit ${e.name}`,()=>X(e)),v=q(`secondary`,re,`duplicate-hook`,`Duplicate ${e.name}`,()=>{let t=A({...e,name:Fe(e.name)});t.id=null,X(null,t)}),y=q(`danger`,`Delete`,`delete-hook`,`Delete ${e.name}`,()=>{p({title:`Delete hook`,message:Je(e),confirmLabel:`Delete`,danger:!0,onConfirm:()=>{Xe(e.id,`delete-hook`,{id:e.id},`Deleting the hook.`)}})});return y.disabled=H.has(e.id),m.append(h,_,v,y),i.append(a,m),i}function ct(e){let t=f(`article`,`hooks-row hooks-row-builtin`),n=f(`div`,`hooks-row-main`);return n.append(f(`span`,`hooks-row-event`,He(e)),f(`p`,`hooks-row-meta`,e.purpose)),t.append(n),t}function lt(){let e=G(`Hooks`,_),t=f(`div`,`hooks-stats`);for(let e of ke(M.report))t.append(d(`hooks`,e.label,e.value,e.tone));return e.append(t,K(`hooks-meta`,ce)),e}function ut(){let e=f(`input`,`settings-view-input hooks-filter`);return e.type=`search`,e.value=B,e.placeholder=x,e.setAttribute(`aria-label`,x),e.addEventListener(`input`,()=>{B=e.value;let t=N?.querySelector(`.hooks-list-yours`);t&&t.replaceWith(ft())}),e}function dt(){let e=f(`div`,`hooks-empty-state`);return e.append(K(`hooks-empty`,y),nt(D(M.report))),e}function ft(){let e=f(`div`,`hooks-list-yours`),t=E(M.report);if(t.length===0)return e.append(dt()),e;let n=je(Ae(t,D(M.report)),B);if(n.length===0)return e.append(K(`hooks-empty`,te)),e;for(let t of Ne(n)){let n=f(`div`,`hooks-group`);n.append(f(`h3`,`hooks-group-title`,t.event));let r=f(`div`,`hooks-list`);for(let e of t.hooks)r.append(st(e,{grouped:!0}));n.append(r),e.append(n)}return e}function pt(){let e=G(he,null),t=c({variant:`primary`,size:`small`,label:ge,icon:a(s),action:`new-hook`,disabled:!!P,onClick:()=>X(null)}),n=e.querySelector(`.hooks-section-head`);return n&&n.append(t),Me(E(M.report))&&e.append(ut()),e.append(ft()),e}function mt(e){let t=f(`details`,`hooks-agent-group`);t.append(f(`summary`,`hooks-agent-group-summary`,me(e)));let n=f(`div`,`hooks-list`);e.unavailableReason!==null&&n.append(f(`p`,`hooks-row-meta`,e.unavailableReason));for(let t of e.rows)n.append(ct(t));return t.append(n),t}function ht(){let e=f(`details`,`hooks-builtin`),t=f(`summary`,`hooks-builtin-summary`);t.append(f(`span`,`hooks-section-title`,`${le} (${De(M.report)})`),f(`span`,`hooks-section-hint`,ue));let n=f(`div`,`hooks-agent-groups`);for(let e of Ee(M.report))n.append(mt(e));return e.append(t,n),e}function gt(e){let t=f(`article`,`hooks-row hooks-row-builtin`),n=f(`div`,`hooks-row-main`);return n.append(f(`span`,`hooks-row-event`,e.name),f(`p`,`hooks-row-meta`,pe(e)),f(`code`,`hooks-note-text`,e.text)),t.append(n),t}function _t(){let e=f(`details`,`hooks-builtin`),t=f(`summary`,`hooks-builtin-summary`),n=Te(M.report);t.append(f(`span`,`hooks-section-title`,`${de} (${n.length})`),f(`span`,`hooks-section-hint`,fe));let r=f(`div`,`hooks-list`);for(let e of n)r.append(gt(e));return e.append(t,r),e}function vt(){let e=f(`div`,`hooks-content`);return M.report?Ce(M.report)?(e.append(K(`hooks-warning`,we(M.report))),e):(e.append(lt()),I&&e.append(I),e.append(pt(),ht(),_t()),e):(e.append(M.hasReportSendFailed?K(`hooks-warning`,i):K(`hooks-empty`,v)),e)}function $({force:e=!1}={}){if(!N||!e&&l(N)||(M=h(),N.replaceChildren(vt()),!W))return;W=!1;let t=N.querySelector(`[data-action="new-hook"]`);t instanceof HTMLButtonElement&&t.focus()}function yt(e){N||(N=f(`div`,`hooks-panel`),e.append(N),m(()=>$()),$({force:!0}))}function bt(e){e===`shown`&&$({force:!0}),g()}var xt={mount:yt,refresh:bt};export{xt as view};